start.S revision 1.19 1 1.19 simonb /* $NetBSD: start.S,v 1.19 2006/02/07 11:59:22 simonb Exp $ */
2 1.11 simonb
3 1.11 simonb /*-
4 1.11 simonb * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 1.11 simonb * All rights reserved.
6 1.11 simonb *
7 1.11 simonb * This code is derived from software contributed to The NetBSD Foundation
8 1.11 simonb * by Jonathan Stone, Michael Hitch and Simon Burge.
9 1.11 simonb *
10 1.11 simonb * Redistribution and use in source and binary forms, with or without
11 1.11 simonb * modification, are permitted provided that the following conditions
12 1.11 simonb * are met:
13 1.11 simonb * 1. Redistributions of source code must retain the above copyright
14 1.11 simonb * notice, this list of conditions and the following disclaimer.
15 1.11 simonb * 2. Redistributions in binary form must reproduce the above copyright
16 1.11 simonb * notice, this list of conditions and the following disclaimer in the
17 1.11 simonb * documentation and/or other materials provided with the distribution.
18 1.11 simonb * 3. All advertising materials mentioning features or use of this software
19 1.11 simonb * must display the following acknowledgement:
20 1.11 simonb * This product includes software developed by the NetBSD
21 1.11 simonb * Foundation, Inc. and its contributors.
22 1.11 simonb * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.11 simonb * contributors may be used to endorse or promote products derived
24 1.11 simonb * from this software without specific prior written permission.
25 1.11 simonb *
26 1.11 simonb * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.11 simonb * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.11 simonb * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.11 simonb * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.11 simonb * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.11 simonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.11 simonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.11 simonb * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.11 simonb * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.11 simonb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.11 simonb * POSSIBILITY OF SUCH DAMAGE.
37 1.11 simonb */
38 1.1 mellon
39 1.1 mellon /*
40 1.1 mellon * Copyright (c) 1992, 1993
41 1.1 mellon * The Regents of the University of California. All rights reserved.
42 1.1 mellon *
43 1.1 mellon * This code is derived from software contributed to Berkeley by
44 1.1 mellon * Ralph Campbell.
45 1.1 mellon *
46 1.1 mellon * Redistribution and use in source and binary forms, with or without
47 1.1 mellon * modification, are permitted provided that the following conditions
48 1.1 mellon * are met:
49 1.1 mellon * 1. Redistributions of source code must retain the above copyright
50 1.1 mellon * notice, this list of conditions and the following disclaimer.
51 1.1 mellon * 2. Redistributions in binary form must reproduce the above copyright
52 1.1 mellon * notice, this list of conditions and the following disclaimer in the
53 1.1 mellon * documentation and/or other materials provided with the distribution.
54 1.17 agc * 3. Neither the name of the University nor the names of its contributors
55 1.1 mellon * may be used to endorse or promote products derived from this software
56 1.1 mellon * without specific prior written permission.
57 1.1 mellon *
58 1.1 mellon * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 1.1 mellon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 1.1 mellon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 1.1 mellon * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 1.1 mellon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 1.1 mellon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 1.1 mellon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 1.1 mellon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 1.1 mellon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 1.1 mellon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 1.1 mellon * SUCH DAMAGE.
69 1.1 mellon *
70 1.1 mellon * @(#)start.s 8.2 (Berkeley) 1/21/94
71 1.1 mellon */
72 1.1 mellon
73 1.1 mellon /*
74 1.1 mellon * start.s -
75 1.1 mellon *
76 1.1 mellon * Contains code that is the first executed at boot time.
77 1.1 mellon *
78 1.1 mellon * Copyright (C) 1989 Digital Equipment Corporation.
79 1.1 mellon * Permission to use, copy, modify, and distribute this software and
80 1.1 mellon * its documentation for any purpose and without fee is hereby granted,
81 1.1 mellon * provided that the above copyright notice appears in all copies.
82 1.1 mellon * Digital Equipment Corporation makes no representations about the
83 1.1 mellon * suitability of this software for any purpose. It is provided "as is"
84 1.1 mellon * without express or implied warranty.
85 1.1 mellon *
86 1.1 mellon * from: Header: /sprite/src/boot/decprom/ds3100.md/RCS/start.s,
87 1.1 mellon * v 1.1 90/02/16 16:19:39 shirriff Exp SPRITE (DECWRL)
88 1.1 mellon */
89 1.1 mellon
90 1.2 jonathan #include <mips/asm.h>
91 1.2 jonathan #include <mips/cpuregs.h>
92 1.5 simonb #include <machine/dec_prom.h>
93 1.1 mellon
94 1.12 simonb .extern callv, 4
95 1.14 simonb
96 1.1 mellon .globl start
97 1.1 mellon start:
98 1.1 mellon .set noreorder
99 1.1 mellon #ifdef __GP_SUPPORT__
100 1.1 mellon la gp, _C_LABEL (_gp)
101 1.1 mellon #endif
102 1.14 simonb la sp, start - CALLFRAME_SIZ
103 1.14 simonb sw zero, CALLFRAME_RA(sp) # Zero out old ra for debugger
104 1.14 simonb sw zero, CALLFRAME_SP(sp) # Zero out old fp for debugger
105 1.1 mellon move s0, a0 # save argc
106 1.1 mellon move s1, a1 # save argv
107 1.6 simonb beq a2, DEC_REX_MAGIC, 1f # jump if boot from DS5000
108 1.3 simonb move s3, a3 # BDslot: save call vector
109 1.1 mellon la s3, _C_LABEL(callvec) # init call vector
110 1.1 mellon 1:
111 1.7 simonb la a0, _C_LABEL (edata) # clear BSS
112 1.7 simonb move a1, zero
113 1.7 simonb la a2, _C_LABEL (end)
114 1.7 simonb jal _C_LABEL(memset) # memset(edata, 0, end - edata)
115 1.7 simonb subu a2, a2, a0
116 1.1 mellon sw s3, _C_LABEL(callv) # save call vector
117 1.1 mellon move a0, s0 # restore argc
118 1.9 simonb jal _C_LABEL(main) # main(argc, argv)
119 1.1 mellon move a1, s1 # restore argv
120 1.1 mellon j _C_LABEL(prom_restart) # restart...
121 1.1 mellon nop
122 1.1 mellon
123 1.1 mellon LEAF(prom_restart)
124 1.16 simonb XLEAF(_rtt)
125 1.1 mellon lw v0, _C_LABEL (callv)
126 1.1 mellon lw v0, 0x9C(v0) /* halt */
127 1.1 mellon move a0, zero /* Don't print anything. */
128 1.1 mellon j v0
129 1.1 mellon move a1, zero
130 1.1 mellon END(prom_restart)
131 1.1 mellon
132 1.1 mellon LEAF(prom_open)
133 1.1 mellon li v0, DEC_PROM_OPEN
134 1.1 mellon j v0
135 1.1 mellon nop
136 1.1 mellon END(prom_open)
137 1.13 simonb
138 1.13 simonb #ifndef LIBSA_NO_DEV_CLOSE
139 1.13 simonb LEAF(prom_close)
140 1.13 simonb li v0, DEC_PROM_CLOSE
141 1.13 simonb j v0
142 1.13 simonb nop
143 1.13 simonb END(prom_close)
144 1.13 simonb #endif
145 1.1 mellon
146 1.1 mellon LEAF(prom_lseek)
147 1.1 mellon li v0, DEC_PROM_LSEEK
148 1.1 mellon j v0
149 1.1 mellon nop
150 1.1 mellon END(prom_lseek)
151 1.1 mellon
152 1.1 mellon LEAF(prom_read)
153 1.1 mellon li v0, DEC_PROM_READ
154 1.16 simonb j v0
155 1.16 simonb nop
156 1.16 simonb END(prom_read)
157 1.16 simonb
158 1.16 simonb LEAF(prom_write)
159 1.16 simonb li v0, DEC_PROM_WRITE
160 1.1 mellon j v0
161 1.1 mellon nop
162 1.19 simonb END(prom_write)
163