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