1 /* $NetBSD: bootxx.S,v 1.10 2011/01/06 01:08:48 jakllsch Exp $ */
4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <machine/asm.h>
33 #include <sys/bootblock.h>
36 * Code linked to 0xa00 and copied to sectors 2+ of the netbsd boot
37 * partition by MI /usr/sbin/installboot.
38 * Read into memory by code in pbr.S
41 * %dl BIOS drive number
42 * %edi:%esi Sector number of NetBSD partition
43 * %cs, %ds, %es, %ss All zero
52 .long X86_BOOT_MAGIC_1 /* checked by installboot & pbr code */
53 boot_params: /* space for patchable variables */
54 .long 1f - boot_params /* length of this data area */
55 #include <boot_params.S>
56 . = bootxx + 0x80 /* Space for patching unknown params */
64 movl $_end, %ecx /* zero bss */
65 movl $__bss_start, %edi
67 shr $2, %ecx /* _end and __bss_start are aligned */
74 push %edi /* save args for secondary bootstrap */
76 movl %esp, %esi /* address of sector number */
78 push %esi /* args for boot1 */
80 call _C_LABEL(boot1) /* C code to load /boot */
88 pop %edx /* bios disk number */
89 pop %ebx /* expected partition start sector */
91 movl $boot_params, %esi
92 orb $X86_BP_FLAGS_LBA64VALID, 4(%esi)
93 lcall $SECONDARY_LOAD_ADDRESS/16, $0
96 push %ax /* error string from boot1 */
98 aam /* largest errno is < 100 */
99 addw $('0' << 8) | '0', %ax /* to ascii */
101 cmpb $'0', %al /* supress leading zero */
106 call message /* output boot failed message */
108 call message /* and text from boot1 */
110 11: .ascii "Boot failed (errno "
118 movb 0x86, %ah /* delay for about a second */
121 int $0x18 /* might be a boot fail entry */
122 1: sti /* if not loopstop */
127 * Vector the fs calls through here so we can support multiple
128 * file system types with one copy of the library code and
129 * multiple copies of this file.
131 .global xxfs_open, xxfs_close, xxfs_read, xxfs_stat
133 xxfs_open: jmp XXfs_open
134 xxfs_close: jmp XXfs_close
135 xxfs_read: jmp XXfs_read
136 xxfs_stat: jmp XXfs_stat