summaryrefslogtreecommitdiff
path: root/firmware/kernel.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-01-15 08:19:30 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-01-15 08:19:30 +0000
commit3a1127785b9f29e526b2ab845efe0a313699c459 (patch)
treec16f2071dcdd1f1388b0216643a8f4a979023b9f /firmware/kernel.c
parent53db95417dc919a50e55b6f6b1f9852e1bdf8816 (diff)
downloadrockbox-3a1127785b9f29e526b2ab845efe0a313699c459.zip
rockbox-3a1127785b9f29e526b2ab845efe0a313699c459.tar.gz
rockbox-3a1127785b9f29e526b2ab845efe0a313699c459.tar.bz2
rockbox-3a1127785b9f29e526b2ab845efe0a313699c459.tar.xz
Bootloader USB mode for PP502x. Enable only on GoGear SA9200 for the time being. Add HAVE_BOOTLOADER_USB_MODE to config if BOOTLOADER is defined to enable it. Clean up some kernel stuff a little to support it. Mess up a bunch of other stuff (hopefully not too badly).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29053 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/kernel.c')
-rw-r--r--firmware/kernel.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c
index 41d1d00..4e629c5 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -48,10 +48,19 @@
#define KERNEL_ASSERT(exp, msg...) ({})
#endif
-#if !defined(CPU_PP) || !defined(BOOTLOADER)
+#if !defined(CPU_PP) || !defined(BOOTLOADER) || \
+ defined(HAVE_BOOTLOADER_USB_MODE)
volatile long current_tick SHAREDDATA_ATTR = 0;
#endif
+/* Unless otherwise defined, do nothing */
+#ifndef YIELD_KERNEL_HOOK
+#define YIELD_KERNEL_HOOK() false
+#endif
+#ifndef SLEEP_KERNEL_HOOK
+#define SLEEP_KERNEL_HOOK(ticks) false
+#endif
+
/* List of tick tasks - final element always NULL for termination */
void (*tick_funcs[MAX_NUM_TICK_TASKS+1])(void);
@@ -215,30 +224,25 @@ void timeout_register(struct timeout *tmo, timeout_cb_type callback,
****************************************************************************/
unsigned sleep(unsigned ticks)
{
-#if defined(CPU_PP) && defined(BOOTLOADER)
- unsigned stop = USEC_TIMER + ticks * (1000000/HZ);
- while (TIME_BEFORE(USEC_TIMER, stop))
- switch_thread();
-#elif defined(CREATIVE_ZVx) && defined(BOOTLOADER)
- /* hacky.. */
- long sleep_ticks = current_tick + ticks + 1;
- while (TIME_BEFORE(current_tick, sleep_ticks))
- switch_thread();
-#else
+ /* In certain situations, certain bootloaders in particular, a normal
+ * threading call is inappropriate. */
+ if (SLEEP_KERNEL_HOOK(ticks))
+ return 0; /* Handled */
+
disable_irq();
sleep_thread(ticks);
switch_thread();
-#endif
return 0;
}
void yield(void)
{
-#if ((defined(TATUNG_TPJ1022)) && defined(BOOTLOADER))
- /* Some targets don't like yielding in the bootloader */
-#else
+ /* In certain situations, certain bootloaders in particular, a normal
+ * threading call is inappropriate. */
+ if (YIELD_KERNEL_HOOK())
+ return; /* handled */
+
switch_thread();
-#endif
}
/****************************************************************************