* ========== Copyright Header Begin ==========================================
* Hypervisor Software File: reset.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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
.ident "@(#)reset.s 1.18 07/05/03 SMI"
* dumbreset - a minimal Niagara reset sequence with the same
* hypervisor invocation as the real reset/config. This is useful
* when running the hypervisor with Legion, Simics, RTL simulation,
#include <sys/asm_linkage.h>
#define MEMBASE (4 * 1024 * 1024)
#define MEMSIZE (60 * 1024 * 1024)
#define LOCK_ADDR (MEMBASE + MEMSIZE - 16)
#define HVPD 0x1f12080000
#define CPU_START_SET 0x3
* Niagara reset trap tables
#define TRAP_ALIGN_SIZE 32
#define TRAP_ALIGN .align TRAP_ALIGN_SIZE
#define TRAP_ALIGN_BIG .align (TRAP_ALIGN_SIZE * 4)
#define TT_TRACE_L(label)
#define TRAP(ttnum, action) \
#define BIGTRAP(ttnum, action) \
/* revector to hypervisor */
#define NOT_BIG NOT NOT NOT NOT
* The basic hypervisor trap table
.type rtraptable, #function
TRAP(tt0_000, NOT) /* reserved */
TRAP(tt0_001, GOTO(start_reset)) /* power-on reset */
TRAP(tt0_002, HREVEC(0x2)) /* watchdog reset */
TRAP(tt0_003, HREVEC(0x3)) /* externally initiated reset */
TRAP(tt0_004, NOT) /* software initiated reset */
TRAP(tt0_005, NOT) /* red mode exception */
TRAP(tt0_006, NOT) /* reserved */
TRAP(tt0_007, NOT) /* reserved */
.size rtraptable, (.-rtraptable)
.type rtraptable, #function
.xword 0 /* hv md addr */
.size hv_info, (.-hv_info)
! tick needs to be initialized, this is a hack for SAS
! Enable L2 cache prior to enabling L1 caches
setx L2_CONTROL_REG, %g2, %g1
set (LSUCR_DC | LSUCR_IC), %g1
set ((PSTATE_PRIV | PSTATE_MM_TSO) << TSTATE_PSTATE_SHIFT), %g2
wrpr %g2, %pstate ! gl=0 ccr=0 asi=0
! before exiting RED state, setup htba
setx 0xfff0000000, %g3, %g2 ! XXXQ correct value?
set (HPSTATE_HPRIV | HPSTATE_ENB), %g2
and %g1, 0x1f, %g5 ! %g5 - current cpu id
inc %g5 ! number from 1..32
add %g6, hv_info - local1, %g6
ldx [%g6], %g1 ! Mem base
ldx [%g6+8], %g2 ! Mem size
ldx [%g6+16], %g3 ! Machine description location
ldx [%g6+24], %g4 ! Hypervisor ROM location
setx MEMBASE, %g6, %g1 ! Mem base XXX
setx MEMSIZE, %g6, %g2 ! Mem size XXX
setx HVPD, %g6, %g3 ! Partition Description
sub %g2, LOCK_SIZE, %g2 ! Hide lock location from HV
add %g1, %g2, %g7 ! Addr of lock location
casxa [%g7]ASI_N, %g6, %g5
be,pt %xcc, .master_entry
bne,pn %xcc, 1b ! wait for copy to complete
add %g4, 0x30, %g4 ! Slave entry point
/* IDLE all of the other strands */
and %g6, 0x1f, %g6 ! %g6 - current strand id
setx 0x9800000800, %g4, %g5 ! int_vec_dis address
be,pn %xcc, 2f ! skip our strand
mov 2, %g2 ! IDLE command
sllx %g1, 8, %g3 ! target strand
or %g2, %g3, %g2 ! int_vec_dis value
/* Allow them to continue when they wake up */
add %g6, hv_info - local2, %g6
ldx [%g6], %g1 ! Mem base
ldx [%g6+8], %g2 ! Mem size
ldx [%g6+16], %g3 ! Machine description location
ldx [%g6+24], %g6 ! Hypervisor ROM location
setx MEMBASE, %g6, %g1 ! Mem base XXX
setx MEMSIZE, %g6, %g2 ! Mem size XXX
setx HVPD, %g6, %g3 ! Partition Description
srl %g4, 0, %g4 ! %g4 now contains 0xffff.ffff
! %g5 = phys mem - only used for scrubbing on real HW so we can use 0x0
sub %g2, LOCK_SIZE, %g2 ! Hide lock
! %g1 contains trap# to revector to
wrhpr %g0, (HPSTATE_HPRIV | HPSTATE_ENB), %hpstate