srt0.S revision 1.1 1 /* $NetBSD: srt0.S,v 1.1 2014/02/24 07:23:43 skrll Exp $ */
2
3 /* $OpenBSD: srt0.S,v 1.7 2001/05/16 23:57:35 mickey Exp $ */
4
5 /*
6 * Copyright (c) 1998-2004 Michael Shalayeff
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 /*
31 * Copyright 1996 1995 by Open Software Foundation, Inc.
32 * All Rights Reserved
33 *
34 * Permission to use, copy, modify, and distribute this software and
35 * its documentation for any purpose and without fee is hereby granted,
36 * provided that the above copyright notice appears in all copies and
37 * that both the copyright notice and this permission notice appear in
38 * supporting documentation.
39 *
40 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
41 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
42 * FOR A PARTICULAR PURPOSE.
43 *
44 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
45 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
46 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
47 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
48 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
49 *
50 */
51 ;
52 ; Copyright (c) 1990 mt Xinu, Inc. All rights reserved.
53 ; Copyright (c) 1990 University of Utah. All rights reserved.
54 ;
55 ; This file may be freely distributed in any form as long as
56 ; this copyright notice is included.
57 ; THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
58 ; IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
59 ; WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
60 ;
61 ; Utah $Hdr: srt0.c 1.3 94/12/13$
62 ;
63
64 #define _LOCORE
65 #include <machine/iomod.h>
66 #include <machine/asm.h>
67
68 /*
69 * This is the ending of the begin
70 */
71 ENTRY(begin,0)
72
73 blr %r0,%r5 ; Get address of 'boff' into 'r5',
74 ldo begin-boff(%r5),%r5 ; and subtract to get 'begin'.
75 boff:
76 ldil L%RELOC,%r4
77 ldo R%RELOC(%r4),%r4
78 ldo start-begin(%r4),%rp
79 ldil L%edata,%r3
80 ldo R%edata(%r3),%r3 ; Get address of edata.
81 ldil L%begin,%r1
82 ldo R%begin(%r1),%r1 ; Get address of begin
83 sub %r3,%r1,%r3 ; Subtract to get # of bytes to copy
84 copyloop: ; do
85 ldwm 4(%r5),%r1 ; *r4++ = *r5++;
86 addib,>= -4,%r3,copyloop ; while (--r3 >= 0);
87 stwm %r1,4(%r4)
88
89 ; here we zero the .bss
90 ldil L%__bss_start, %r4
91 ldo R%__bss_start(%r4), %r4
92 ldil L%__bss_end, %r3
93 ldo R%__bss_end(%r3), %r3
94 zeroloop:
95 combf,<,n %r3,%r4, zeroloop ; while (r4 < r3);
96 stwm %r0,4(%r4) ; *r4++ = 0;
97
98 ldil L%$global$,%dp
99 ldo R%$global$(%dp),%dp
100 ldil L%start,%r1
101 ldo R%start(%r1),%r1
102 sub %dp,%r1,%dp ; Subtract to get difference
103 add %rp,%dp,%dp ; and relocate it.
104
105 ;
106 ; We have relocated ourself to RELOC. If we are running on a machine
107 ; with separate instruction and data caches, we must flush our data
108 ; cache before trying to execute the code starting at rp.
109 ;
110 ldil L%RELOC,%r22 ; Set %t1 to start of relocated code.
111 ldo R%RELOC(%r22),%r22
112 ldil L%edata,%r21 ; Set r21 to address of edata
113 ldo R%edata(%r21),%r21
114 ldil L%begin,%r1 ; set %r1 to address of begin
115 ldo R%begin(%r1),%r1
116 sub %r21,%r1,%r21 ; Subtract to get length
117 mtsp %r0,%sr0 ; Set sr0 to kernel space.
118 ldo -1(%r21),%r21
119 fdc %r21(0,%r22)
120 loop: addib,>,n -16,%r21,loop ; Decrement by cache line size (16).
121 fdc %r21(%sr0,%r22)
122 fdc 0(%sr0,%r22) ; Flush first word at addr to handle
123 sync ; arbitrary cache line boundary.
124 nop ; Prevent prefetching.
125 nop
126 nop
127 nop
128 nop
129 nop
130 nop
131 bv 0(%rp)
132 nop
133 EXIT(begin) /* jump to relocated code */
134
135 start:
136 ldil L%HEAP_LIMIT, %sp
137 ldo R%HEAP_LIMIT(%sp), %sp
138
139 b boot ; Call boot(),
140 copy %r0, %arg0 ; use default boot device
141 nop
142
143 /*
144 * rtt - restart the box
145 */
146 LEAF_ENTRY(_rtt)
147 ldil L%LBCAST_ADDR, %r25
148 ldi CMD_RESET, %r26
149 stw %r26,R%iomod_command(%r25)
150 forever: ; Loop until bus reset takes effect.
151 b,n forever
152
153 bv 0(%rp)
154 ldo -48(%sp),%sp
155 EXIT(_rtt)
156
157 .end
158