summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/coldfire/system-coldfire.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/firmware/target/coldfire/system-coldfire.c b/firmware/target/coldfire/system-coldfire.c
index c615d51217..66e4feb154 100644
--- a/firmware/target/coldfire/system-coldfire.c
+++ b/firmware/target/coldfire/system-coldfire.c
@@ -136,17 +136,24 @@ default_interrupt (CDROMNOSYNC); /* CD-ROM No sync */
136default_interrupt (CDROMILSYNC); /* CD-ROM Illegal sync */ 136default_interrupt (CDROMILSYNC); /* CD-ROM Illegal sync */
137default_interrupt (CDROMNEWBLK); /* CD-ROM New block */ 137default_interrupt (CDROMNEWBLK); /* CD-ROM New block */
138 138
139static struct 139#ifdef IAUDIO_X5
140{ 140#define EXCP_BUTTON_GPIO_READ GPIO_READ
141 unsigned long format; 141#define EXCP_BUTTON_MASK 0x0c000000
142 unsigned long pc; 142#define EXCP_BUTTON_VALUE 0x08000000 /* On button and !hold */
143} __attribute__ ((packed)) system_exception_info; 143#define EXCP_PLLCR 0x10400000
144#else
145#define EXCP_BUTTON_GPIO_READ GPIO1_READ
146#define EXCP_BUTTON_MASK 0x00000022
147#define EXCP_BUTTON_VALUE 0x00000000
148#define EXCP_PLLCR 0x10800000
149#endif
144 150
145static void system_display_exception_info(void) __attribute__ ((noreturn)); 151static void system_display_exception_info(unsigned long format,
146static void system_display_exception_info(void) 152 unsigned long pc) __attribute__ ((noreturn));
153static void system_display_exception_info(unsigned long format,
154 unsigned long pc)
147{ 155{
148 int pc = system_exception_info.pc; 156 int vector = (format >> 18) & 0xff;
149 int vector = (system_exception_info.format >> 18) & 0xff;
150 char str[32]; 157 char str[32];
151 158
152 /* clear screen */ 159 /* clear screen */
@@ -160,25 +167,15 @@ static void system_display_exception_info(void)
160 lcd_update(); 167 lcd_update();
161 168
162 /* set cpu frequency to 11mhz (to prevent overheating) */ 169 /* set cpu frequency to 11mhz (to prevent overheating) */
163 DCR = (DCR & ~0x01ff) | 1; 170 DCR = (DCR & ~0x01ff) | 1;
164 171 PLLCR = EXCP_PLLCR;
165#ifdef IAUDIO_X5
166 PLLCR = 0x10400000;
167
168 /* on key for 1s will shut down */
169 asm("halt");
170 while (1); /* loop to silence 'noreturn' function does return */
171#else
172 PLLCR = 0x10800000;
173 172
174 while (1) 173 while (1)
175 { 174 {
176 /* check for the ON button (and !hold) */ 175 if ((EXCP_BUTTON_GPIO_READ & EXCP_BUTTON_MASK) == EXCP_BUTTON_VALUE)
177 if ((GPIO1_READ & 0x22) == 0)
178 SYPCR = 0xc0; 176 SYPCR = 0xc0;
179 /* Start watchdog timer with 512 cycles timeout. Don't service it. */ 177 /* Start watchdog timer with 512 cycles timeout. Don't service it. */
180 } 178 }
181#endif
182 179
183 /* We need a reset method that works in all cases. Calling system_reboot() 180 /* We need a reset method that works in all cases. Calling system_reboot()
184 doesn't work when we're called from the debug interrupt, because then 181 doesn't work when we're called from the debug interrupt, because then
@@ -191,15 +188,9 @@ static void system_display_exception_info(void)
191static void UIE(void) __attribute__ ((noreturn)); 188static void UIE(void) __attribute__ ((noreturn));
192static void UIE(void) 189static void UIE(void)
193{ 190{
194 asm volatile ( 191 asm volatile("subq.l #4,%sp"); /* phony return address - never used */
195 "movem.l (%%sp),%%d0-%%d1 \n" /* Copy exception frame */ 192 asm volatile("jmp system_display_exception_info");
196 "lea.l %[info],%%a0 \n" 193 while (1); /* loop to silence 'noreturn' function does return */
197 "movem.l %%d0-%%d1,(%%a0) \n"
198 :
199 : [info] "m" (system_exception_info)
200 );
201
202 system_display_exception_info();
203} 194}
204 195
205/* reset vectors are handled in crt0.S */ 196/* reset vectors are handled in crt0.S */