1 /* $NetBSD: bbstart.s,v 1.11 2002/01/26 13:18:58 aymeric Exp $ */
4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Ignatios Souvatzis.
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>
35 #define LVOAllocMem -0x0c6
36 #define LVODoIO -0x1c8
37 #define LVOCacheClearU -0x27c
48 #if defined(_PRIMARY_BOOT) || defined(AUTOLOAD)
49 Lzero
: .asciz "DOS" | "DOS type"
51 Lzero
: .ascii "BOOT" | Secondary Boot
54 * We put the relocator version here, for aout2bb, which replaces
55 * it with the bootblock checksum.
57 Chksum
: .long RELVER_RELATIVE_BYTES_FORWARD
58 Filesz
: .long 8192 | dummy
61 * Entry point from Kickstart.
62 * A1 points to an IOrequest, A6 points to ExecBase, we have a stack.
63 * _must_ be at offset 12.
65 ENTRY_NOPROFILE
(start
)
73 .word 0 | aout2bb puts the reloc table address here
75 .globl _C_LABEL(default_command)
76 _C_LABEL
(default_command
):
78 .org (_C_LABEL(default_command)+32)
85 movl
%a6
,%sp@
- |SysBase
86 movl
%a1
,%sp@
- |IORequest
88 movl
#AUTOLOAD,%d0 |Howmuch
89 movl
%d0
,%a1@
(IOlen
) | for the actual read.
..
90 movl
#0x10001,%d1 |MEMF_CLEAR|MEMF_PUBLIC
92 movl
%sp@
+,%a1 |IORequest
93 movl
%sp@
+,%a6 |SysBase
100 movl
%d0
,%sp@
- |Address
101 movl
%a1@
(IOoff
),%sp@
- |Old offset
105 /* we've set IOlen above */
107 movw
#Cmd_Rd,%a1@(IOcmd)
112 movl
%sp@
+,%a1@
(IOoff
)
116 addl
#Lrelocate-Lzero,%sp@
119 jsr
%a6@
(LVOCacheClearU
)
129 * Relocate ourselves, at the same time clearing the relocation table
130 * (in case it overlaps with BSS).
133 * A2: points into the reloc table, located at our end.
134 * A0: pointer to the longword to relocate.
135 * D0: word offset of longword to relocate
136 * D1: points to our start.
138 * Table has relative byte offsets, if a byte offset is zero, it is
139 * followed by an absolute word offset. If this is zero, too, table
146 movw
%pc@
(Lreltab
),%a2
152 movl
%d1
,%a0 | for
a variant with relative words
, erase this line
159 clrb
%a2@
+ | bfclr
%a2@
+{0:8} is still two shorts
160 tstb
%d0 | we could save one short by using casb
%d0
,d0
,%a2@
+
168 jsr
%a6@
(LVOCacheClearU
)
171 /* We are relocated. Now it is safe to initialize _SysBase: */
173 movl
%a6
,_C_LABEL
(SysBase
)
175 #ifndef _PRIMARY_BOOT
176 movl
%a5
,%sp@
- | Console info
190 .comm _C_LABEL(SysBase),4