From a443614dd20ef0fe7ca7d723d6ea4428a4da522c Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 18 Oct 2007 01:26:50 +0000 Subject: PP502x: Get switch_thread back out of IRAM and devise a better core wakeup system that's not timing dependant. Hopefully something simpler will be found or devised eventually that meets all requirements. Rename mailbox-related registers. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15179 a1c6a512-1295-4272-9138-f99709370657 --- firmware/thread.c | 131 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 88 insertions(+), 43 deletions(-) (limited to 'firmware/thread.c') diff --git a/firmware/thread.c b/firmware/thread.c index f9d8e01..f7100a7 100644 --- a/firmware/thread.c +++ b/firmware/thread.c @@ -387,13 +387,6 @@ void corelock_unlock(struct corelock *cl) #endif /* CONFIG_CORELOCK == SW_CORELOCK */ -#ifdef CPU_PP502x -/* Some code relies on timing */ -void switch_thread(struct thread_entry *old) ICODE_ATTR; -void core_wake(IF_COP_VOID(unsigned int othercore)) ICODE_ATTR; -void core_idle(void) ICODE_ATTR; -#endif - /*--------------------------------------------------------------------------- * Put core in a power-saving state if waking list wasn't repopulated and if * no other core requested a wakeup for it to perform a task. @@ -403,34 +396,59 @@ static inline void core_sleep(IF_COP(unsigned int core,) struct thread_entry **w { #if NUM_CORES > 1 #ifdef CPU_PP502x +#if 1 /* Disabling IRQ and FIQ is important to making the fixed-time sequence * non-interruptable */ asm volatile ( "mrs r2, cpsr \n" /* Disable IRQ, FIQ */ "orr r2, r2, #0xc0 \n" "msr cpsr_c, r2 \n" - "ldr r0, [%[w]] \n" /* Check *waking */ - "cmp r0, #0 \n" /* != NULL -> exit */ - "bne 1f \n" - /* ------ fixed-time sequence ----- */ /* Can this be relied upon? */ - "ldr r0, [%[ms], %[oc], lsl #2] \n" /* Stay-awake requested? */ - "mov r1, #0x80000000 \n" - "tst r0, #1 \n" - "streq r1, [%[ct], %[c], lsl #2] \n" /* Sleep if not */ - "nop \n" - "mov r0, #0 \n" - "str r0, [%[ct], %[c], lsl #2] \n" /* Clear control reg */ - /* -------------------------------- */ - "1: \n" - "mov r0, #1 \n" - "add r1, %[ms], #8 \n" - "str r0, [r1, %[oc], lsl #2] \n" /* Clear mailbox */ + "mov r0, #4 \n" /* r0 = 0x4 << core */ + "mov r0, r0, lsl %[c] \n" + "str r0, [%[mbx], #4] \n" /* signal intent to sleep */ + "ldr r1, [%[waking]] \n" /* *waking == NULL ? */ + "cmp r1, #0 \n" + "ldreq r1, [%[mbx], #0] \n" /* && !(MBX_MSG_STAT & (0x10< 1 /* This code path will not be run on single core targets */ /* TODO: HAL interface for this */ /* Wake up coprocessor and let it initialize kernel and threads */ + MBX_MSG_CLR = 0x3f; COP_CTL = PROC_WAKE; /* Sleep until finished */ CPU_CTL = PROC_SLEEP; -- cgit v1.1