4 * Copyright (c) 2005 NONAKA Kimihiro
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <machine/asm.h>
30 #include <sys/bootblock.h>
34 mov r0, r11 /* r11: relocate address */
38 mov r0, r10 /* r10: loaded address */
40 mov.w stack_offset, r1
42 mov r0, r15 /* r15: stack pointer */
47 add r2, r13 /* calc jump address */
74 /* search bootable partition */
75 mov.w part_offset, r12
76 add r11, r12 /* r12: pointer to partition entry */
77 mov #MBR_PART_COUNT, r8 /* r8: partition loop counter */
80 cmp/eq #MBR_PTYPE_UNUSED, r0
83 /* check active partition */
88 /* found bootable partition */
89 mov.w @(8, r12), r0 /* load unaligned 32bit data */
107 /* Not found bootable partition */
139 /* read PBR sector */
140 mova found_sector, r0
151 /* check signature */
154 bt noos_error /* first byte non-zero */
155 mov.w magic_offset, r0
159 bf noos_error /* magic */
161 /* now jump to PBR */
168 mbr_size: .word mbr_end - _C_LABEL(start)
170 stack_offset: .word 0x1000
172 part_offset: .word MBR_PART_OFFSET
174 magic_offset: .word MBR_MAGIC_OFFSET
177 found_sector: .long 0
181 banner: .asciz "\r\nNetBSD MBR boot"
187 ERR_INVPART: .asciz "No active partition"
189 ERR_READ: .asciz "Disk read error"
191 ERR_NOOS: .asciz "No operating system"
194 /* space for mbr_dsn */
195 . = _C_LABEL(start) + MBR_DSN_OFFSET
198 /* mbr_bootsel_magic */
199 . = _C_LABEL(start) + MBR_BS_MAGIC_OFFSET
203 * MBR partition table
205 . = _C_LABEL(start) + MBR_PART_OFFSET
207 .byte 0, 0, 0, 0, 0, 0, 0, 0
208 .byte 0, 0, 0, 0, 0, 0, 0, 0
210 .byte 0, 0, 0, 0, 0, 0, 0, 0
211 .byte 0, 0, 0, 0, 0, 0, 0, 0
213 .byte 0, 0, 0, 0, 0, 0, 0, 0
214 .byte 0, 0, 0, 0, 0, 0, 0, 0
216 .byte 0, 0, 0, 0, 0, 0, 0, 0
217 .byte 0, 0, 0, 0, 0, 0, 0, 0
219 . = _C_LABEL(start) + MBR_MAGIC_OFFSET