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