diff options
| author | Jörg Hohensohn <hohensoh@rockbox.org> | 2005-01-28 22:35:20 +0000 |
|---|---|---|
| committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2005-01-28 22:35:20 +0000 |
| commit | 3c758c13af485c612a73f932bd905054026c4e72 (patch) | |
| tree | 3ab83e2f7924d2c92096303ec57f6646739a65f9 | |
| parent | dc7534bdb2a784ae9d5c9089237935ff405c3525 (diff) | |
| download | rockbox-3c758c13af485c612a73f932bd905054026c4e72.zip rockbox-3c758c13af485c612a73f932bd905054026c4e72.tar.gz rockbox-3c758c13af485c612a73f932bd905054026c4e72.tar.bz2 rockbox-3c758c13af485c612a73f932bd905054026c4e72.tar.xz | |
do the hotswap
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5702 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/drivers/ata_mmc.c | 39 | ||||
| -rw-r--r-- | firmware/export/kernel.h | 1 |
2 files changed, 40 insertions, 0 deletions
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index a62f778..293ccaf 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c @@ -32,6 +32,7 @@ #include "hwcompat.h" #include "adc.h" #include "bitswap.h" +#include "disk.h" /* for mount/unmount */ #define SECTOR_SIZE 512 @@ -89,6 +90,11 @@ long last_disk_activity = -1; static struct mutex mmc_mutex; +#ifdef HAVE_HOTSWAP +static char mmc_stack[DEFAULT_STACK_SIZE]; +static const char mmc_thread_name[] = "mmc"; +static struct event_queue mmc_queue; +#endif static bool initialized = false; static bool delayed_write = false; static unsigned char delayed_sector[SECTOR_SIZE]; @@ -786,6 +792,34 @@ void ata_spin(void) { } +#ifdef HAVE_HOTSWAP +static void mmc_thread(void) +{ + struct event ev; + + while (1) { + queue_wait(&mmc_queue, &ev); + switch ( ev.id ) { + case SYS_USB_CONNECTED: + usb_acknowledge(SYS_USB_CONNECTED_ACK); + /* Wait until the USB cable is extracted again */ + usb_wait_for_disconnect(&mmc_queue); + break; + + case SYS_MMC_INSERTED: + disk_mount(1); /* mount MMC */ + queue_broadcast(SYS_FS_CHANGED, NULL); + break; + + case SYS_MMC_EXTRACTED: + disk_unmount(1); /* release "by force" */ + queue_broadcast(SYS_FS_CHANGED, NULL); + break; + } + } +} +#endif /* #ifdef HAVE_HOTSWAP */ + bool mmc_detect(void) { return adc_read(ADC_MMC_SWITCH) < 0x200 ? true : false; @@ -880,6 +914,11 @@ int ata_init(void) if ( !initialized ) { +#ifdef HAVE_HOTSWAP + queue_init(&mmc_queue); + create_thread(mmc_thread, mmc_stack, + sizeof(mmc_stack), mmc_thread_name); +#endif tick_add_task(mmc_tick); initialized = true; } diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h index 1a238a6..3816d71 100644 --- a/firmware/export/kernel.h +++ b/firmware/export/kernel.h @@ -42,6 +42,7 @@ #define SYS_MMC_INSERTED ((SYS_EVENT | ((long)6 << 27))) #define SYS_MMC_EXTRACTED ((SYS_EVENT | ((long)7 << 27))) #define SYS_POWEROFF ((SYS_EVENT | ((long)8 << 27))) +#define SYS_FS_CHANGED ((SYS_EVENT | ((long)9 << 27))) struct event { |