4 * Second stage boot-loader and exception vectors for Open Hack'Ware.
6 * Copyright (C) 2004-2005 Jocelyn Mayer (l_indien@magic.fr)
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License V2
10 * as published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 /* Be sure MMU is off and we are in 32 bits mode (for PPC64) */
35 ori r11, r11, _hw_init@l ;
40 /* May need more hw init here */
42 /* Load the full BIOS into RAM */
43 lis r12, bios_base@h ;
44 ori r12, r12, bios_base@l ;
46 /* Set up the C stack */
47 addis r1, r29, 0x0040 ;
54 /* Skip frame pointer */
65 bdnz _bios_copy_loop ;
66 /* Synchronize the whole execution context */
68 ori r0, r0, (1 << 13) ;
72 /* If we ever return, stop */
79 /* Dump the exception and its context */
86 lis r0, _bug_no_mmu@h ;
87 ori r0, r0, _bug_no_mmu@l ;
99 /* Skip external interrupts and decrementer exception */
100 /* BEWARE: be sure not to modify any register */
101 stw r11, save_area@l(0) ;
103 clrlwi r11, r11, 16 ;
105 lwz r11, save_area@l(0) ;
108 #define EXCP_BUG(entry) \
115 #define EXCP_SKIP(entry) \
122 /* Exception vectors */
123 /* Reset exception */
126 /* Machine check exception */
135 /* External interrupt: skip it */
138 /* Alignment exception */
141 /* Program exception */
144 /* No floating point exception */
147 /* Decrementer exception: skip it */
150 /* Reserved A exception */
153 /* Reserved B exception */
156 /* System call exception */
159 /* Trace exception */
162 /* Floating point assist exception */
165 /* Performance monitor exception */
168 /* Instruction TLB miss exception */
171 /* Data TLB miss for store exception */
174 /* Data TLB miss for load exception */
177 /* Instruction address breakpoint exception */
180 /* System management interrupt exception */
183 /* Thermal management exception */
186 /* Unknown exceptions */
206 /* End of exception vectors list */
214 /* void outb (uint32_t port, uint32_t data);
215 * Writes a single character on an IO port.
216 * Used for serial console.
223 /* void outstr (uint32_t port, const unsigned char *str);
224 * Writes a string on an IO port.
240 /* void outdigit (uint32_t port, uint32_t digit);
241 * Dumps a single digit on serial port.
250 /* void outhex (uint32_t port, uint32_t value);
251 * Dumps a 32 bits hex number on serial port
258 rlwinm r11, r11, 4, 0, 31 ;
266 addi r4, r4, 'a' - 10 ;
273 /* void dump_exception (uint32_t lr, uint32_t srr0, uint32_t srr1,
274 * uint32_t dar, uint32_t dsisr);
275 * Dump a message when catching an exception
278 /* Save call parameters */
285 lis r11, registers_area@h ;
286 ori r11, r11, registers_area@l ;
288 /* Now, serial IO port is in r27,
289 * message table start is in r28,
290 * first exception message offset is in r29,
291 * and last known exception number is in r30
293 /* Print error prompt message */
297 /* Find message corresponding to the caught exception */
303 rlwinm r12, r12, 2, 0, 31 ;
304 /* Dump execption message */
308 /* Complete exception message */
340 /* All done, dump last message and return */
350 .string "ERROR: BUG caught...\n"
362 .string "\nStopping execution\n"
365 .string "BIOS execution"
369 .string "Machine check"
371 .string "Data memory access"
373 .string "Instruction fetch"
381 .string "No floating point"
383 .string "Decrementer"
389 .string "System call"
393 .string "Floating point assist"
395 .string "Performance monitor"
397 .string "Instruction TLB miss"
399 .string "Data TLB miss for store"
401 .string "Data TLB miss for load"
403 .string "Instruction address breakpoint"
405 .string "System management"
407 .string "Thermal management"
418 _excp_messages_table:
419 .long _excp_message_0x00
420 .long _excp_message_0x01
421 .long _excp_message_0x02
422 .long _excp_message_0x03
423 .long _excp_message_0x04
424 .long _excp_message_0x05
425 .long _excp_message_0x06
426 .long _excp_message_0x07
427 .long _excp_message_0x08
428 .long _excp_message_0x09
429 .long _excp_message_0x0a
430 .long _excp_message_0x0b
431 .long _excp_message_0x0c
432 .long _excp_message_0x0d
433 .long _excp_message_0x0e
434 .long _excp_message_0x0f
435 .long _excp_message_0x10
436 .long _excp_message_0x11
437 .long _excp_message_0x12
438 .long _excp_message_0x13
439 .long _excp_message_0x14
440 .long _excp_message_0x15
441 .long _excp_message_0x16
451 registers_area: /* To be loaded in register when an exception is caught */
452 _serial_IO: /* r27 */
454 _messages_start: /* r28 */
455 .long _messages_table - 4
456 _excp_messages: /* r29 */
457 .long _excp_messages_table
459 .long (_last_excp_message - _excp_messages_table) / 4
460 _dummy_1: /* r31: dummy */
465 save_area: /* Area for r11 save when an exception is skipped */