4 * First stage BIOS loader 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 * Permission is hereby granted, free of charge, to any person obtaining a copy
13 * of this software and associated documentation files (the "Software"), to deal
14 * in the Software without restriction, including without limitation the rights
15 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 * copies of the Software, and to permit persons to whom the Software is
17 * furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included in
20 * all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 * setup one RAM bank then
32 * relocate the one page BIOS second stage into RAM.
34 * We consider that we know nothing about the CPU state
35 * at the time we enter this code.
47 /* r11 is _boot_start address */
49 addi r11, r11, (_boot_start - _start - 4) ;
50 /* Disable MMU and interruptions */
51 addi r12, r11, (_boot_no_mmu - _boot_start) ;
55 ori r13, r13, 0xEF71 ;
60 /* TODO: initialize physical RAM (we need at least one page)
61 * before doing anything else.
62 * This may be machine dependent code.
65 /* Copy the second stage bootloader into RAM
66 * We may need a tiny driver if we need to boot from special device
67 * (ie disc-on-chip, ...)
69 lis r12, (VECTORS_SIZE / 4)@h ;
70 ori r12, r12, (VECTORS_SIZE / 4)@l ;
72 clrrwi r12, r11, BIOS_IMAGE_BITS ;
73 addis r3, r12, VECTORS_SIZE@h ;
74 addi r3, r3, VECTORS_SIZE@l ;
76 lis r13, VECTORS_BASE@h ;
77 ori r13, r13, VECTORS_BASE@l ;
83 bdnz _boot_copy_loop ;
84 /* Synchronize the whole execution context */
85 addi r12, r11, (_boot_sync - _boot_start) ;
91 /* All done, jump into the loaded code */
93 /* If we ever return, reboot */
96 .space BOOT_SIZE - 4 - (. - _boot_start), 0xFF
97 /* Reset entry point */