Hash :
1a08f436
Author :
Date :
2010-08-25T09:23:17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
/*
* ========== Copyright Header Begin ==========================================
*
* Hypervisor Software File: crt0.s
*
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
*
* - Do no alter or remove copyright notices
*
* - Redistribution and use of this software in source and binary forms, with
* or without modification, are permitted provided that the following
* conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed, licensed or
* intended for use in the design, construction, operation or maintenance of
* any nuclear facility.
*
* ========== Copyright Header End ============================================
*/
/*
* Copyright (c) 1986-1995, 2003 Sun Microsystems, Inc. All Rights Reserved
* Use is subject to license terms.
*/
#pragma ident "@(#)srt0.s 1.4 01/03/26 SMI"
/*
* srt0.s - standalone startup code
* Generate the code with a fake a.out header if INETBOOT is defined.
* inetboot is loaded directly by the PROM, other booters are loaded via
* a bootblk and don't need the fake a.out header.
*/
#include <sys/asm_linkage.h>
#include <sys/cpu.h>
#include <sys/privregs.h>
#include <sys/stack.h>
.seg ".text"
.align 8
.global end
.global edata
.global main
/*
* The following variables are machine-dependent and are set in fiximp.
* Space is allocated there.
*/
.seg ".data"
.align 8
_local_p1275cif:
.word 0
#define STACK_SIZE 0x14000
.skip STACK_SIZE
.ebootstack: ! end (top) of boot stack
/*
* The following variables are more or less machine-independent
* (or are set outside of fiximp).
*/
.seg ".text"
.align 8
.global prom_exit_to_mon
.type prom_exit_to_mon, #function
! Each standalone program is responsible for its own stack. Our strategy
! is that each program which uses this runtime code creates a stack just
! below its relocation address. Previous windows may (and probably do)
! have frames allocated on the prior stack; leave them alone. Starting with
! this window, allocate our own stack frames for our windows. (Overflows
! or a window flush would then pass seamlessly from our stack to the old.)
! RESTRICTION: A program running at some relocation address must not exec
! another which will run at the very same address: the stacks would collide.
!
! Careful: don't touch %o4 until the save, since it contains the
! address of the IEEE 1275 SPARC v9 CIF handler (linkage to the prom).
!
!
! We cannot write to any symbols until we are relocated.
! Note that with the advent of 5.x boot, we no longer have to
! relocate ourselves, but this code is kept around cuz we *know*
! someone would scream if we did the obvious.
!
#ifndef INETBOOT
!
! Enter here for all booters loaded by a bootblk program.
! Careful, do not lose value of the SPARC v9 P1275 CIF handler in %o4
! Setup temporary 32 bit stack at _start.
!
! NB: Until the common startup code, AM may not be set.
!
ENTRY_NP(_start)
set _start - 0x10000, %o1
! and %o1, ~(STACK_ALIGN64-1), %o1
! save %o1, -SA(MINFRAME64), %sp ! %i4: 1275 sparcv9 CIF handler
and %o6, (STACK_ALIGN64-1), %o2
add %o1, -SA(MINFRAME64), %o1
save %o1, %o2, %sp ! %i4: 1275 sparcv9 CIF handler
! ta 0x7f
!
! zero the bss
!
sethi %hi(edata), %o0 ! Beginning of bss
or %o0, %lo(edata), %o0
set end, %i2
call bzero
sub %i2, %o0, %o1 ! end - edata = size of bss
#endif !INETBOOT
!
! All booters end up here...
!
9:
#ifndef __sparcv9
/*
* Use our own 32 bit stack now. But, zero it first (do we have to?)
*/
set .ebootstack, %o0
set STACK_SIZE, %o1
sub %o0, %o1, %o1
1: dec 4, %o0
st %g0, [%o0]
cmp %o0, %o1
bne 1b
nop
set .ebootstack, %o0
and %o0, ~(STACK_ALIGN64-1), %o0
sub %o0, SA64(MINFRAME64), %sp
/*
* Set the psr into a known state:
* Set AM, supervisor mode, interrupt level >= 13, traps enabled
*/
wrpr %g0, 13, %pil
wr %g0, FPRS_FEF, %fprs
wrpr %g0, PSTATE_PEF+PSTATE_AM+PSTATE_PRIV+PSTATE_IE, %pstate
nop; nop; nop
sethi %hi(_local_p1275cif), %o2
st %i4, [%o2 + %lo(_local_p1275cif)]
#else
wrpr %g0, 13, %pil
wr %g0, FPRS_FEF, %fprs
wrpr %g0, PSTATE_PEF+PSTATE_PRIV+PSTATE_IE, %pstate
nop; nop; nop
sethi %hi(_local_p1275cif), %o2
stx %i4, [%o2 + %lo(_local_p1275cif)]
#endif
mov %g0, %o0
call prom_init ! prom-init(NULL, prom-cookie)
mov %i4, %o1 ! SPARCV9/CIF
mov %g0, %o0
call main ! main(0)
mov %g0, %o1 !
call prom_exit_to_mon ! can't happen .. :-)
nop
SET_SIZE(_start)
/*
* The interface for a 32-bit client program
* calling the 64-bit romvec OBP.
*/
#if defined(lint)
#include <sys/promif.h>
/* ARGSUSED */
int
client_handler(void *cif_handler, cell_t **)
{}
#else /* !lint */
ENTRY_NP(client_handler)
save %sp, -SA64(MINFRAME64), %sp ! 32 bit frame, 64 bit sized
#ifndef __sparcv9
mov %i1, %o0
rdpr %pstate, %l1 ! Get the present pstate value
wrpr %l1, PSTATE_AM, %pstate ! Set PSTATE_AM = 0
jmpl %i0, %o7 ! Call cif handler
sub %sp, V9BIAS64, %sp ! delay; Now a 64 bit frame
rdpr %pstate, %l1 ! Get the present pstate value
wrpr %l1, PSTATE_AM, %pstate ! Set PSTATE_AM = 1
#else
mov %i1, %o0
jmpl %i0, %o7 ! Call cif handler
nop
#endif
ret ! Return result ...
restore %o0, %g0, %o0 ! delay; result in %o0
SET_SIZE(client_handler)
ENTRY_NP(set_intr) ! Set the interrupt level.
rdpr %pil, %o1 ! Save existing intr level.
wrpr %o0, 0, %pil ! Write new intr level.
retl
mov %o1, %o0 ! Return old intr level.
SET_SIZE(set_intr)
#endif /* !lint */