start.S revision 1.2.2.2 1 1.2.2.2 kent /* $NetBSD: start.S,v 1.2.2.2 2005/04/29 11:28:02 kent Exp $ */
2 1.2.2.2 kent
3 1.2.2.2 kent /*-
4 1.2.2.2 kent * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 1.2.2.2 kent * All rights reserved.
6 1.2.2.2 kent *
7 1.2.2.2 kent * This code is derived from software contributed to The NetBSD Foundation
8 1.2.2.2 kent * by Jonathan Stone, Michael Hitch and Simon Burge.
9 1.2.2.2 kent *
10 1.2.2.2 kent * Redistribution and use in source and binary forms, with or without
11 1.2.2.2 kent * modification, are permitted provided that the following conditions
12 1.2.2.2 kent * are met:
13 1.2.2.2 kent * 1. Redistributions of source code must retain the above copyright
14 1.2.2.2 kent * notice, this list of conditions and the following disclaimer.
15 1.2.2.2 kent * 2. Redistributions in binary form must reproduce the above copyright
16 1.2.2.2 kent * notice, this list of conditions and the following disclaimer in the
17 1.2.2.2 kent * documentation and/or other materials provided with the distribution.
18 1.2.2.2 kent * 3. All advertising materials mentioning features or use of this software
19 1.2.2.2 kent * must display the following acknowledgement:
20 1.2.2.2 kent * This product includes software developed by the NetBSD
21 1.2.2.2 kent * Foundation, Inc. and its contributors.
22 1.2.2.2 kent * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.2.2.2 kent * contributors may be used to endorse or promote products derived
24 1.2.2.2 kent * from this software without specific prior written permission.
25 1.2.2.2 kent *
26 1.2.2.2 kent * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.2.2.2 kent * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.2.2.2 kent * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.2.2.2 kent * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.2.2.2 kent * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.2.2.2 kent * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.2.2.2 kent * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.2.2.2 kent * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.2.2.2 kent * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.2.2.2 kent * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.2.2.2 kent * POSSIBILITY OF SUCH DAMAGE.
37 1.2.2.2 kent */
38 1.2.2.2 kent
39 1.2.2.2 kent /*
40 1.2.2.2 kent * Copyright (c) 1992, 1993
41 1.2.2.2 kent * The Regents of the University of California. All rights reserved.
42 1.2.2.2 kent *
43 1.2.2.2 kent * This code is derived from software contributed to Berkeley by
44 1.2.2.2 kent * Ralph Campbell.
45 1.2.2.2 kent *
46 1.2.2.2 kent * Redistribution and use in source and binary forms, with or without
47 1.2.2.2 kent * modification, are permitted provided that the following conditions
48 1.2.2.2 kent * are met:
49 1.2.2.2 kent * 1. Redistributions of source code must retain the above copyright
50 1.2.2.2 kent * notice, this list of conditions and the following disclaimer.
51 1.2.2.2 kent * 2. Redistributions in binary form must reproduce the above copyright
52 1.2.2.2 kent * notice, this list of conditions and the following disclaimer in the
53 1.2.2.2 kent * documentation and/or other materials provided with the distribution.
54 1.2.2.2 kent * 3. Neither the name of the University nor the names of its contributors
55 1.2.2.2 kent * may be used to endorse or promote products derived from this software
56 1.2.2.2 kent * without specific prior written permission.
57 1.2.2.2 kent *
58 1.2.2.2 kent * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 1.2.2.2 kent * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 1.2.2.2 kent * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 1.2.2.2 kent * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 1.2.2.2 kent * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 1.2.2.2 kent * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 1.2.2.2 kent * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 1.2.2.2 kent * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 1.2.2.2 kent * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 1.2.2.2 kent * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 1.2.2.2 kent * SUCH DAMAGE.
69 1.2.2.2 kent *
70 1.2.2.2 kent * @(#)start.s 8.2 (Berkeley) 1/21/94
71 1.2.2.2 kent */
72 1.2.2.2 kent
73 1.2.2.2 kent /*
74 1.2.2.2 kent * start.s -
75 1.2.2.2 kent *
76 1.2.2.2 kent * Contains code that is the first executed at boot time.
77 1.2.2.2 kent *
78 1.2.2.2 kent * Copyright (C) 1989 Digital Equipment Corporation.
79 1.2.2.2 kent * Permission to use, copy, modify, and distribute this software and
80 1.2.2.2 kent * its documentation for any purpose and without fee is hereby granted,
81 1.2.2.2 kent * provided that the above copyright notice appears in all copies.
82 1.2.2.2 kent * Digital Equipment Corporation makes no representations about the
83 1.2.2.2 kent * suitability of this software for any purpose. It is provided "as is"
84 1.2.2.2 kent * without express or implied warranty.
85 1.2.2.2 kent *
86 1.2.2.2 kent * from: Header: /sprite/src/boot/decprom/ds3100.md/RCS/start.s,
87 1.2.2.2 kent * v 1.1 90/02/16 16:19:39 shirriff Exp SPRITE (DECWRL)
88 1.2.2.2 kent */
89 1.2.2.2 kent
90 1.2.2.2 kent #include <mips/asm.h>
91 1.2.2.2 kent #include <mips/cpuregs.h>
92 1.2.2.2 kent
93 1.2.2.2 kent .globl start
94 1.2.2.2 kent start:
95 1.2.2.2 kent .set noreorder
96 1.2.2.2 kent #ifdef __GP_SUPPORT__
97 1.2.2.2 kent la gp, _C_LABEL (_gp)
98 1.2.2.2 kent #endif
99 1.2.2.2 kent addi sp, -CALLFRAME_SIZ
100 1.2.2.2 kent sw ra, CALLFRAME_RA(sp) # save ra
101 1.2.2.2 kent sw a0, 0(sp) # save argc
102 1.2.2.2 kent sw a1, 4(sp) # save argv
103 1.2.2.2 kent sw a2, 8(sp) # save envp
104 1.2.2.2 kent
105 1.2.2.2 kent la v0, 0x80001000 # ARCBIOS_SPB
106 1.2.2.2 kent lw v0, 8 * 4(v0) # FirmwareVector
107 1.2.2.2 kent sw v0, _C_LABEL(ARCBIOS) # save ARCBIOS
108 1.2.2.2 kent lw v0, 136(v0) # (*ARCBIOS->FlushAllCache)()
109 1.2.2.2 kent jalr v0
110 1.2.2.2 kent nop
111 1.2.2.2 kent la a0, _C_LABEL (edata) # clear BSS
112 1.2.2.2 kent move a1, zero
113 1.2.2.2 kent la a2, _C_LABEL (end)
114 1.2.2.2 kent jal _C_LABEL(memset) # memset(edata, 0, end - edata)
115 1.2.2.2 kent subu a2, a2, a0
116 1.2.2.2 kent lw a0, 0(sp) # restore argc
117 1.2.2.2 kent lw a1, 4(sp) # restore argv
118 1.2.2.2 kent jal _C_LABEL(main) # main(argc, argv, envp)
119 1.2.2.2 kent lw a2, 8(sp) # restore envp
120 1.2.2.2 kent lw ra, CALLFRAME_RA(sp) # restore RA
121 1.2.2.2 kent j ra
122 1.2.2.2 kent addi sp, CALLFRAME_SIZ
123 1.2.2.2 kent
124 1.2.2.2 kent .data
125 1.2.2.2 kent .global ARCBIOS
126 1.2.2.2 kent ARCBIOS:
127 1.2.2.2 kent .data 0
128