1
0
Fork 0
forked from len0rd/rockbox

Fix idle monitoring to not freeze the Ondio, and add it in a more elegant way. Fixed hotswap ifdefing.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11465 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2006-11-08 07:32:53 +00:00
parent 92eff9d293
commit af2d91f629

View file

@ -976,14 +976,39 @@ void ata_spin(void)
{
}
#ifdef HAVE_HOTSWAP
static void mmc_thread(void)
{
struct event ev;
static long last_seen_mtx_unlock = 0;
while (1) {
while ( queue_empty( &mmc_queue ) ) {
queue_wait_w_tmo(&mmc_queue, &ev, HZ);
switch ( ev.id )
{
case SYS_POWEROFF:
call_ata_idle_notifys(false);
break;
case SYS_USB_CONNECTED:
call_ata_idle_notifys(false);
usb_acknowledge(SYS_USB_CONNECTED_ACK);
/* Wait until the USB cable is extracted again */
usb_wait_for_disconnect(&mmc_queue);
break;
#ifdef HAVE_HOTSWAP
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
default:
if (!ata_disk_is_active())
{
if (!last_seen_mtx_unlock)
@ -994,38 +1019,17 @@ static void mmc_thread(void)
last_seen_mtx_unlock = 0;
}
}
}
queue_wait(&mmc_queue, &ev);
switch ( ev.id )
{
case SYS_POWEROFF:
call_ata_idle_notifys(false);
break;
case SYS_USB_CONNECTED:
call_ata_idle_notifys(false);
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;
}
}
}
#ifdef HAVE_HOTSWAP
void mmc_enable_monitoring(bool on)
{
mmc_monitor_enabled = on;
}
#endif /* #ifdef HAVE_HOTSWAP */
#endif
bool mmc_detect(void)
{
@ -1168,11 +1172,10 @@ int ata_init(void)
{
if (!last_mmc_status)
mmc_status = MMC_UNTOUCHED;
#ifdef HAVE_HOTSWAP
queue_init(&mmc_queue, true);
create_thread(mmc_thread, mmc_stack,
sizeof(mmc_stack), mmc_thread_name IF_PRIO(, PRIORITY_SYSTEM));
#endif
tick_add_task(mmc_tick);
initialized = true;
}