Hotswap: Avoid mount race at startup and after returning from USB mode.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6479 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2005-05-16 13:25:02 +00:00
parent f414fb1e22
commit 15d7077c3a
4 changed files with 44 additions and 20 deletions

View file

@ -233,6 +233,9 @@ void init(void)
usb_screen(); usb_screen();
system_reboot(); system_reboot();
} }
#if defined(HAVE_MMC) && defined(HAVE_HOTSWAP)
mmc_enable_monitoring(true);
#endif
settings_calc_config_sector(); settings_calc_config_sector();
settings_load(SETTINGS_ALL); settings_load(SETTINGS_ALL);

View file

@ -94,6 +94,7 @@ static struct mutex mmc_mutex;
static long mmc_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; static long mmc_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)];
static const char mmc_thread_name[] = "mmc"; static const char mmc_thread_name[] = "mmc";
static struct event_queue mmc_queue; static struct event_queue mmc_queue;
static bool mmc_monitor_enabled = false;
#endif #endif
static bool initialized = false; static bool initialized = false;
static bool new_mmc_circuit; static bool new_mmc_circuit;
@ -1033,6 +1034,11 @@ static void mmc_thread(void)
} }
} }
} }
void mmc_enable_monitoring(bool on)
{
mmc_monitor_enabled = on;
}
#endif /* #ifdef HAVE_HOTSWAP */ #endif /* #ifdef HAVE_HOTSWAP */
bool mmc_detect(void) bool mmc_detect(void)
@ -1050,6 +1056,9 @@ bool mmc_usb_active(int delayticks)
static void mmc_tick(void) static void mmc_tick(void)
{ {
bool current_status; bool current_status;
#ifndef HAVE_HOTSWAP
const bool mmc_monitor_enabled = true;
#endif
if (new_mmc_circuit) if (new_mmc_circuit)
/* USB bridge activity is 0 on idle, ~527 on active */ /* USB bridge activity is 0 on idle, ~527 on active */
@ -1061,29 +1070,32 @@ static void mmc_tick(void)
last_usb_activity = current_tick; last_usb_activity = current_tick;
usb_activity = current_status; usb_activity = current_status;
current_status = mmc_detect(); if (mmc_monitor_enabled)
/* Only report when the status has changed */
if (current_status != last_mmc_status)
{ {
last_mmc_status = current_status; current_status = mmc_detect();
countdown = 30; /* Only report when the status has changed */
} if (current_status != last_mmc_status)
else
{
/* Count down until it gets negative */
if (countdown >= 0)
countdown--;
if (countdown == 0)
{ {
if (current_status) last_mmc_status = current_status;
countdown = 30;
}
else
{
/* Count down until it gets negative */
if (countdown >= 0)
countdown--;
if (countdown == 0)
{ {
queue_broadcast(SYS_MMC_INSERTED, NULL); if (current_status)
} {
else queue_broadcast(SYS_MMC_INSERTED, NULL);
{ }
queue_broadcast(SYS_MMC_EXTRACTED, NULL); else
card_info[1].initialized = false; {
queue_broadcast(SYS_MMC_EXTRACTED, NULL);
card_info[1].initialized = false;
}
} }
} }
} }

View file

@ -45,5 +45,8 @@ unsigned long mmc_extract_bits(const unsigned long *p, unsigned int start,
unsigned int size); unsigned int size);
tCardInfo *mmc_card_info(int card_no); tCardInfo *mmc_card_info(int card_no);
bool mmc_usb_active(int delayticks); bool mmc_usb_active(int delayticks);
#ifdef HAVE_HOTSWAP
void mmc_enable_monitoring(bool on);
#endif
#endif #endif

View file

@ -194,7 +194,13 @@ static void usb_slave_mode(bool on)
panicf("ata: %d",rc); panicf("ata: %d",rc);
} }
#if defined(HAVE_MMC) && defined(HAVE_HOTSWAP)
mmc_enable_monitoring(false);
rc = disk_mount_all(); rc = disk_mount_all();
mmc_enable_monitoring(true);
#else
rc = disk_mount_all();
#endif
if (rc <= 0) /* no partition */ if (rc <= 0) /* no partition */
panicf("mount: %d",rc); panicf("mount: %d",rc);