1 /* $NetBSD: srt0.S,v 1.2 2009/05/08 09:33:59 skrll Exp $ */
3 /* $OpenBSD: srt0.S,v 1.7 2001/05/16 23:57:35 mickey Exp $ */
6 * Copyright (c) 1998-2004 Michael Shalayeff
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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.
31 * Copyright 1996 1995 by Open Software Foundation, Inc.
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.
40 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
41 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
42 * FOR A PARTICULAR PURPOSE.
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.
52 ; Copyright (c) 1990 mt Xinu, Inc. All rights reserved.
53 ; Copyright (c) 1990 University of Utah. All rights reserved.
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.
61 ; Utah $Hdr: srt0.c 1.3 94/12/13$
65 #include <machine/iomod.h>
66 #include <machine/asm.h>
69 * This is the ending of the begin
73 blr %r0,%r5 ; Get address of 'boff' into 'r5',
74 ldo begin-boff(%r5),%r5 ; and subtract to get 'begin'.
78 ldo start-begin(%r4),%rp
80 ldo R%edata(%r3),%r3 ; Get address of edata.
82 ldo R%begin(%r1),%r1 ; Get address of begin
83 sub %r3,%r1,%r3 ; Subtract to get # of bytes to copy
85 ldwm 4(%r5),%r1 ; *r4++ = *r5++;
86 addib,>= -4,%r3,copyloop ; while (--r3 >= 0);
89 ; here we zero the .bss
90 ldil L%__bss_start, %r4
91 ldo R%__bss_start(%r4), %r4
93 ldo R%__bss_end(%r3), %r3
95 combf,<,n %r3,%r4, zeroloop ; while (r4 < r3);
96 stwm %r0,4(%r4) ; *r4++ = 0;
99 ldo R%$global$(%dp),%dp
102 sub %dp,%r1,%dp ; Subtract to get difference
103 add %rp,%dp,%dp ; and relocate it.
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.
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
116 sub %r21,%r1,%r21 ; Subtract to get length
117 mtsp %r0,%sr0 ; Set sr0 to kernel space.
120 loop: addib,>,n -16,%r21,loop ; Decrement by cache line size (16).
122 fdc 0(%sr0,%r22) ; Flush first word at addr to handle
123 sync ; arbitrary cache line boundary.
124 nop ; Prevent prefetching.
133 EXIT(begin) /* jump to relocated code */
136 ldil L%HEAP_LIMIT, %sp
137 ldo R%HEAP_LIMIT(%sp), %sp
139 b boot ; Call boot(),
140 copy %r0, %arg0 ; use default boot device
144 * rtt - restart the box
147 ldil L%LBCAST_ADDR, %r25
149 stw %r26,R%iomod_command(%r25)
150 forever: ; Loop until bus reset takes effect.