summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-05-16 13:25:02 +0000
committerJens Arnold <amiconn@rockbox.org>2005-05-16 13:25:02 +0000
commit15d7077c3ad2b7e3bcacf61a04428784b11e418c (patch)
tree4912c6fa1155073289160e122a948905b4799f25
parentf414fb1e22b33bd0f4d9692bcea3da337e6aff7a (diff)
downloadrockbox-15d7077c3ad2b7e3bcacf61a04428784b11e418c.tar.gz
rockbox-15d7077c3ad2b7e3bcacf61a04428784b11e418c.zip
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
-rw-r--r--apps/main.c3
-rw-r--r--firmware/drivers/ata_mmc.c52
-rw-r--r--firmware/export/ata_mmc.h3
-rw-r--r--firmware/usb.c6
4 files changed, 44 insertions, 20 deletions
diff --git a/apps/main.c b/apps/main.c
index 25bc9296e5..edcff92995 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -233,6 +233,9 @@ void init(void)
233 usb_screen(); 233 usb_screen();
234 system_reboot(); 234 system_reboot();
235 } 235 }
236#if defined(HAVE_MMC) && defined(HAVE_HOTSWAP)
237 mmc_enable_monitoring(true);
238#endif
236 239
237 settings_calc_config_sector(); 240 settings_calc_config_sector();
238 settings_load(SETTINGS_ALL); 241 settings_load(SETTINGS_ALL);
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c
index 5afb6ca8a1..aa333dba32 100644
--- a/firmware/drivers/ata_mmc.c
+++ b/firmware/drivers/ata_mmc.c
@@ -94,6 +94,7 @@ static struct mutex mmc_mutex;
94static long mmc_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; 94static long mmc_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)];
95static const char mmc_thread_name[] = "mmc"; 95static const char mmc_thread_name[] = "mmc";
96static struct event_queue mmc_queue; 96static struct event_queue mmc_queue;
97static bool mmc_monitor_enabled = false;
97#endif 98#endif
98static bool initialized = false; 99static bool initialized = false;
99static bool new_mmc_circuit; 100static bool new_mmc_circuit;
@@ -1033,6 +1034,11 @@ static void mmc_thread(void)
1033 } 1034 }
1034 } 1035 }
1035} 1036}
1037
1038void mmc_enable_monitoring(bool on)
1039{
1040 mmc_monitor_enabled = on;
1041}
1036#endif /* #ifdef HAVE_HOTSWAP */ 1042#endif /* #ifdef HAVE_HOTSWAP */
1037 1043
1038bool mmc_detect(void) 1044bool mmc_detect(void)
@@ -1050,6 +1056,9 @@ bool mmc_usb_active(int delayticks)
1050static void mmc_tick(void) 1056static void mmc_tick(void)
1051{ 1057{
1052 bool current_status; 1058 bool current_status;
1059#ifndef HAVE_HOTSWAP
1060 const bool mmc_monitor_enabled = true;
1061#endif
1053 1062
1054 if (new_mmc_circuit) 1063 if (new_mmc_circuit)
1055 /* USB bridge activity is 0 on idle, ~527 on active */ 1064 /* USB bridge activity is 0 on idle, ~527 on active */
@@ -1061,29 +1070,32 @@ static void mmc_tick(void)
1061 last_usb_activity = current_tick; 1070 last_usb_activity = current_tick;
1062 usb_activity = current_status; 1071 usb_activity = current_status;
1063 1072
1064 current_status = mmc_detect(); 1073 if (mmc_monitor_enabled)
1065 /* Only report when the status has changed */
1066 if (current_status != last_mmc_status)
1067 {
1068 last_mmc_status = current_status;
1069 countdown = 30;
1070 }
1071 else
1072 { 1074 {
1073 /* Count down until it gets negative */ 1075 current_status = mmc_detect();
1074 if (countdown >= 0) 1076 /* Only report when the status has changed */
1075 countdown--; 1077 if (current_status != last_mmc_status)
1076
1077 if (countdown == 0)
1078 { 1078 {
1079 if (current_status) 1079 last_mmc_status = current_status;
1080 { 1080 countdown = 30;
1081 queue_broadcast(SYS_MMC_INSERTED, NULL); 1081 }
1082 } 1082 else
1083 else 1083 {
1084 /* Count down until it gets negative */
1085 if (countdown >= 0)
1086 countdown--;
1087
1088 if (countdown == 0)
1084 { 1089 {
1085 queue_broadcast(SYS_MMC_EXTRACTED, NULL); 1090 if (current_status)
1086 card_info[1].initialized = false; 1091 {
1092 queue_broadcast(SYS_MMC_INSERTED, NULL);
1093 }
1094 else
1095 {
1096 queue_broadcast(SYS_MMC_EXTRACTED, NULL);
1097 card_info[1].initialized = false;
1098 }
1087 } 1099 }
1088 } 1100 }
1089 } 1101 }
diff --git a/firmware/export/ata_mmc.h b/firmware/export/ata_mmc.h
index 8b5056bbd8..6f7fb2bdb5 100644
--- a/firmware/export/ata_mmc.h
+++ b/firmware/export/ata_mmc.h
@@ -45,5 +45,8 @@ unsigned long mmc_extract_bits(const unsigned long *p, unsigned int start,
45 unsigned int size); 45 unsigned int size);
46tCardInfo *mmc_card_info(int card_no); 46tCardInfo *mmc_card_info(int card_no);
47bool mmc_usb_active(int delayticks); 47bool mmc_usb_active(int delayticks);
48#ifdef HAVE_HOTSWAP
49void mmc_enable_monitoring(bool on);
50#endif
48 51
49#endif 52#endif
diff --git a/firmware/usb.c b/firmware/usb.c
index 6095bcd65e..4b76fe60be 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -194,7 +194,13 @@ static void usb_slave_mode(bool on)
194 panicf("ata: %d",rc); 194 panicf("ata: %d",rc);
195 } 195 }
196 196
197#if defined(HAVE_MMC) && defined(HAVE_HOTSWAP)
198 mmc_enable_monitoring(false);
197 rc = disk_mount_all(); 199 rc = disk_mount_all();
200 mmc_enable_monitoring(true);
201#else
202 rc = disk_mount_all();
203#endif
198 if (rc <= 0) /* no partition */ 204 if (rc <= 0) /* no partition */
199 panicf("mount: %d",rc); 205 panicf("mount: %d",rc);
200 206