* ========== 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
* - 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
* ========== 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/privregs.h>
* The following variables are machine-dependent and are set in fiximp.
* Space is allocated there.
#define STACK_SIZE 0x14000
.ebootstack: ! end (top) of boot stack
* The following variables are more or less machine-independent
* (or are set outside of fiximp).
.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.
! 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.
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
sethi %hi(edata), %o0 ! Beginning of bss
sub %i2, %o0, %o1 ! end - edata = size of bss
! All booters end up here...
* Use our own 32 bit stack now. But, zero it first (do we have to?)
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, PSTATE_PEF+PSTATE_AM+PSTATE_PRIV+PSTATE_IE, %pstate
sethi %hi(_local_p1275cif), %o2
st %i4, [%o2 + %lo(_local_p1275cif)]
wrpr %g0, PSTATE_PEF+PSTATE_PRIV+PSTATE_IE, %pstate
sethi %hi(_local_p1275cif), %o2
stx %i4, [%o2 + %lo(_local_p1275cif)]
call prom_init ! prom-init(NULL, prom-cookie)
mov %i4, %o1 ! SPARCV9/CIF
call prom_exit_to_mon ! can't happen .. :-)
* The interface for a 32-bit client program
* calling the 64-bit romvec OBP.
client_handler(void *cif_handler, cell_t **)
save %sp, -SA64(MINFRAME64), %sp ! 32 bit frame, 64 bit sized
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
jmpl %i0, %o7 ! Call cif handler
restore %o0, %g0, %o0 ! delay; result in %o0
ENTRY_NP(set_intr) ! Set the interrupt level.
rdpr %pil, %o1 ! Save existing intr level.
wrpr %o0, 0, %pil ! Write new intr level.
mov %o1, %o0 ! Return old intr level.