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 */
128 /* Machine check exception */
137 /* External interrupt: skip it */
140 /* Alignment exception */
143 /* Program exception */
146 /* No floating point exception */
149 /* Decrementer exception: skip it */
152 /* Reserved A exception */
155 /* Reserved B exception */
158 /* System call exception */
161 /* Trace exception */
164 /* Floating point assist exception */
167 /* Performance monitor exception */
170 /* Instruction TLB miss exception */
173 /* Data TLB miss for store exception */
176 /* Data TLB miss for load exception */
179 /* Instruction address breakpoint exception */
182 /* System management interrupt exception */
185 /* Thermal management exception */
188 /* Unknown exceptions */
208 /* End of exception vectors list */
216 /* void outb (uint32_t port, uint32_t data);
217 * Writes a single character on an IO port.
218 * Used for serial console.
225 /* void outstr (uint32_t port, const unsigned char *str);
226 * Writes a string on an IO port.
242 /* void outdigit (uint32_t port, uint32_t digit);
243 * Dumps a single digit on serial port.
252 /* void outhex (uint32_t port, uint32_t value);
253 * Dumps a 32 bits hex number on serial port
260 rlwinm r11, r11, 4, 0, 31 ;
268 addi r4, r4, 'a' - 10 ;
275 /* void dump_exception (uint32_t lr, uint32_t srr0, uint32_t srr1,
276 * uint32_t dar, uint32_t dsisr);
277 * Dump a message when catching an exception
280 /* Save call parameters */
287 lis r11, registers_area@h ;
288 ori r11, r11, registers_area@l ;
290 /* Now, serial IO port is in r27,
291 * message table start is in r28,
292 * first exception message offset is in r29,
293 * and last known exception number is in r30
295 /* Print error prompt message */
299 /* Find message corresponding to the caught exception */
305 rlwinm r12, r12, 2, 0, 31 ;
306 /* Dump execption message */
310 /* Complete exception message */
342 /* All done, dump last message and return */
352 .string "ERROR: BUG caught...\n"
364 .string "\nStopping execution\n"
367 .string "BIOS execution"
371 .string "Machine check"
373 .string "Data memory access"
375 .string "Instruction fetch"
383 .string "No floating point"
385 .string "Decrementer"
391 .string "System call"
395 .string "Floating point assist"
397 .string "Performance monitor"
399 .string "Instruction TLB miss"
401 .string "Data TLB miss for store"
403 .string "Data TLB miss for load"
405 .string "Instruction address breakpoint"
407 .string "System management"
409 .string "Thermal management"
420 _excp_messages_table:
421 .long _excp_message_0x00
422 .long _excp_message_0x01
423 .long _excp_message_0x02
424 .long _excp_message_0x03
425 .long _excp_message_0x04
426 .long _excp_message_0x05
427 .long _excp_message_0x06
428 .long _excp_message_0x07
429 .long _excp_message_0x08
430 .long _excp_message_0x09
431 .long _excp_message_0x0a
432 .long _excp_message_0x0b
433 .long _excp_message_0x0c
434 .long _excp_message_0x0d
435 .long _excp_message_0x0e
436 .long _excp_message_0x0f
437 .long _excp_message_0x10
438 .long _excp_message_0x11
439 .long _excp_message_0x12
440 .long _excp_message_0x13
441 .long _excp_message_0x14
442 .long _excp_message_0x15
443 .long _excp_message_0x16
453 registers_area: /* To be loaded in register when an exception is caught */
454 _serial_IO: /* r27 */
456 _messages_start: /* r28 */
457 .long _messages_table - 4
458 _excp_messages: /* r29 */
459 .long _excp_messages_table
461 .long (_last_excp_message - _excp_messages_table) / 4
462 _dummy_1: /* r31: dummy */
467 save_area: /* Area for r11 save when an exception is skipped */