diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2007-09-28 10:20:02 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2007-09-28 10:20:02 +0000 |
commit | 7914e90738ff37e6378b37632eb1f05bab7354d5 (patch) | |
tree | 6b3d6a6bac4c7a3f82fa212d5f3ed324d81dc8bb /firmware/rolo.c | |
parent | edbf5d81f5a635a0db68039554b086f942b3e005 (diff) | |
download | rockbox-7914e90738ff37e6378b37632eb1f05bab7354d5.tar.gz rockbox-7914e90738ff37e6378b37632eb1f05bab7354d5.zip |
Commit a subset of the dual core changes that have to do with cache handling, stacks, firmware startup and thread startup. Tested on e200, H10-20GB, iPod Color and 5.5G. Thread function return implemented for all targets. Some changes to plugins to follow shortly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14879 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/rolo.c')
-rw-r--r-- | firmware/rolo.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/firmware/rolo.c b/firmware/rolo.c index 7ff5195318..1e9fc45984 100644 --- a/firmware/rolo.c +++ b/firmware/rolo.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "config.h" | 20 | #include "config.h" |
21 | #include "lcd.h" | 21 | #include "lcd.h" |
22 | #include "lcd-remote.h" | 22 | #include "lcd-remote.h" |
23 | #include "thread.h" | ||
23 | #include "kernel.h" | 24 | #include "kernel.h" |
24 | #include "sprintf.h" | 25 | #include "sprintf.h" |
25 | #include "button.h" | 26 | #include "button.h" |
@@ -52,10 +53,24 @@ | |||
52 | 53 | ||
53 | volatile unsigned char IDATA_ATTR cpu_message = 0; | 54 | volatile unsigned char IDATA_ATTR cpu_message = 0; |
54 | volatile unsigned char IDATA_ATTR cpu_reply = 0; | 55 | volatile unsigned char IDATA_ATTR cpu_reply = 0; |
56 | #if NUM_CORES > 1 | ||
57 | extern int cop_idlestackbegin[]; | ||
58 | #endif | ||
55 | 59 | ||
56 | void rolo_restart_cop(void) ICODE_ATTR; | 60 | void rolo_restart_cop(void) ICODE_ATTR; |
57 | void rolo_restart_cop(void) | 61 | void rolo_restart_cop(void) |
58 | { | 62 | { |
63 | if (CURRENT_CORE == CPU) | ||
64 | { | ||
65 | /* There should be free thread slots aplenty */ | ||
66 | create_thread(rolo_restart_cop, cop_idlestackbegin, IDLE_STACK_SIZE, | ||
67 | "rolo COP" IF_PRIO(, PRIORITY_REALTIME) | ||
68 | IF_COP(, COP, false)); | ||
69 | return; | ||
70 | } | ||
71 | |||
72 | COP_INT_CLR = -1; | ||
73 | |||
59 | /* Invalidate cache */ | 74 | /* Invalidate cache */ |
60 | invalidate_icache(); | 75 | invalidate_icache(); |
61 | 76 | ||
@@ -63,14 +78,14 @@ void rolo_restart_cop(void) | |||
63 | CACHE_CTL = CACHE_DISABLE; | 78 | CACHE_CTL = CACHE_DISABLE; |
64 | 79 | ||
65 | /* Tell the main core that we're ready to reload */ | 80 | /* Tell the main core that we're ready to reload */ |
66 | cpu_reply = 2; | 81 | cpu_reply = 1; |
67 | 82 | ||
68 | /* Wait while RoLo loads the image into SDRAM */ | 83 | /* Wait while RoLo loads the image into SDRAM */ |
69 | /* TODO: Accept checksum failure gracefully */ | 84 | /* TODO: Accept checksum failure gracefully */ |
70 | while(cpu_message == 1) {} | 85 | while(cpu_message != 1); |
71 | 86 | ||
72 | /* Acknowledge the CPU and then reload */ | 87 | /* Acknowledge the CPU and then reload */ |
73 | cpu_reply = 1; | 88 | cpu_reply = 2; |
74 | 89 | ||
75 | asm volatile( | 90 | asm volatile( |
76 | "mov r0, #0x10000000 \n" | 91 | "mov r0, #0x10000000 \n" |
@@ -127,9 +142,7 @@ void rolo_restart(const unsigned char* source, unsigned char* dest, | |||
127 | : : "a"(dest) | 142 | : : "a"(dest) |
128 | ); | 143 | ); |
129 | #elif defined(CPU_PP502x) | 144 | #elif defined(CPU_PP502x) |
130 | 145 | CPU_INT_CLR = -1; | |
131 | /* Tell the COP that we've finished loading and started rebooting */ | ||
132 | cpu_message = 0; | ||
133 | 146 | ||
134 | /* Flush cache */ | 147 | /* Flush cache */ |
135 | flush_icache(); | 148 | flush_icache(); |
@@ -141,8 +154,11 @@ void rolo_restart(const unsigned char* source, unsigned char* dest, | |||
141 | for (i=0;i<8;i++) | 154 | for (i=0;i<8;i++) |
142 | memmapregs[i]=0; | 155 | memmapregs[i]=0; |
143 | 156 | ||
157 | /* Tell the COP it's safe to continue rebooting */ | ||
158 | cpu_message = 1; | ||
159 | |||
144 | /* Wait for the COP to tell us it is rebooting */ | 160 | /* Wait for the COP to tell us it is rebooting */ |
145 | while(cpu_reply != 1) {} | 161 | while(cpu_reply != 2); |
146 | 162 | ||
147 | asm volatile( | 163 | asm volatile( |
148 | "mov r0, #0x10000000 \n" | 164 | "mov r0, #0x10000000 \n" |
@@ -211,11 +227,11 @@ int rolo_load(const char* filename) | |||
211 | #endif | 227 | #endif |
212 | 228 | ||
213 | #ifdef CPU_PP | 229 | #ifdef CPU_PP |
214 | cpu_message = COP_REBOOT; | ||
215 | COP_CTL = PROC_WAKE; | ||
216 | lcd_puts(0, 2, "Waiting for coprocessor..."); | 230 | lcd_puts(0, 2, "Waiting for coprocessor..."); |
217 | lcd_update(); | 231 | lcd_update(); |
218 | while(cpu_reply != 2) {} | 232 | rolo_restart_cop(); |
233 | /* Wait for COP to be in safe code */ | ||
234 | while(cpu_reply != 1); | ||
219 | lcd_puts(0, 2, " "); | 235 | lcd_puts(0, 2, " "); |
220 | lcd_update(); | 236 | lcd_update(); |
221 | #endif | 237 | #endif |