* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: reset.s
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
* ========== Copyright Header End ============================================
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* OpenSPARC T1 reset sequence
#include <sys/asm_linkage.h>
#include "xilinx_t1_system_config.h"
#define IOBBASE 0x9800000000
#define INT_VEC_DIS 0x800
#define ASI_ERROR_STATUS 0x4c
#define ICACHE_MAX_WAYS 4
#define BIST_CTL_BISI_MODE (1 << 6)
#define BIST_DONE (1 << 10)
#define BISI_START (BIST_CTL_BISI_MODE + BIST_START)
#define STR_STATUS_REG %asr26
#define STR_STATUS_STRAND_ACTIVE 1
#define STR_STATUS_STRAND_ID_SHIFT 8
#define STR_STATUS_STRAND_ID_MASK 0x3
#define STR_STATUS_CORE_ID_SHIFT 10
#define STR_STATUS_CORE_ID_MASK 0x7
#define CPU_ID_STRAND_MASK 0x3
#define CPU_ID_STRAND_SHIFT 0x0
#define CPU_ID_CORE_MASK 0x7
#define CPU_ID_CORE_SHIFT 0x2
#define N_THREADS_PER_CORE 0x4
#define STR_STATUS_CPU_ID_SHIFT STR_STATUS_STRAND_ID_SHIFT
#define STR_STATUS_CPU_ID_MASK 0x1f
* 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
! tick needs to be initialized, this is a hack for SAS
wrpr %g0, PSTATE_PRIV, %pstate
set ((PSTATE_PRIV | PSTATE_MM_TSO) << TSTATE_PSTATE_SHIFT), %g2
wrpr %g2, %tstate ! gl=0 ccr=0 asi=0
#ifdef T1_FPGA_DISABLE_DCACHE
stxa %g1, [%g0]ASI_LSUCR ! enable Icache
set (LSUCR_DC | LSUCR_IC), %g1
stxa %g1, [%g0]ASI_LSUCR ! enable Icache and Dcache
call wakeup_slave_threads
setx T1_FPGA_HV_MEMBASE, %o5, %g1
setx T1_FPGA_HV_MEMSIZE, %o5, %g2
setx T1_FPGA_HV_MD_ADDR, %o5, %g3
set T1_FPGA_TOTAL_MEMSIZE, %g5
set T1_FPGA_PROM_HV_START_OFFSET, %o4 ! next stage start point.
#ifdef T1_FPGA_DISABLE_DCACHE
stxa %g1, [%g0]ASI_LSUCR ! enable Icache
set (LSUCR_DC | LSUCR_IC), %g1
stxa %g1, [%g0]ASI_LSUCR ! enable Icache and Dcache
setx T1_FPGA_HV_MEMBASE, %o5, %g1
setx T1_FPGA_HV_MEMSIZE, %o5, %g2
setx T1_FPGA_HV_MD_ADDR, %o5, %g3
set T1_FPGA_TOTAL_MEMSIZE, %g5
set T1_FPGA_PROM_HV_START_OFFSET, %o4 ! next stage start point.
! %g1 contains trap# to revector to
wrhpr %g0, (HPSTATE_HPRIV | HPSTATE_ENB), %hpstate
save %sp, -(MINFRAME64), %sp
stxa %g1, [%g0]ASI_ERROR_STATUS ! Clear SPARC Error Status
stxa %g0, [%g1] ASI_IMMU ! Clear IMMU_SFSR
stxa %g0, [%g1] ASI_DMMU ! Clear DMMU_SFSR
or %g1, 0x4, %g1 ! Enable speculative load
save %sp, -(MINFRAME64), %sp
srlx %l0, STR_STATUS_CPU_ID_SHIFT, %l0
and %l0, STR_STATUS_CPU_ID_MASK, %l0 ! cpu_id
mov CPU_ID_STRAND_MASK, %l7
andn %l0, %l7, %l1 ! id of the first cpu in the core
and %l2, CPU_ID_MASK, %l2
add %l1, N_THREADS_PER_CORE, %l3
save %sp, -(MINFRAME64), %sp
srlx %l0, STR_STATUS_CPU_ID_SHIFT, %l0
and %l0, STR_STATUS_CPU_ID_MASK, %l0 ! cpu_id
ENTRY_NP(wakeup_slave_threads)
save %sp, -(MINFRAME64), %sp
srlx %l0, STR_STATUS_CPU_ID_SHIFT, %l0
and %l0, STR_STATUS_CPU_ID_MASK, %l0 ! cpu_id
mov CPU_ID_STRAND_MASK, %l7
andn %l0, %l7, %l1 ! id of the first cpu in the core
and %l2, CPU_ID_MASK, %l2
add %l1, N_THREADS_PER_CORE, %l3
setx IOBBASE + INT_VEC_DIS, %g4, %g5
mov INT_VEC_DIS_TYPE_RESET, %g4
sllx %g4, INT_VEC_DIS_TYPE_SHIFT, %g4
or %g4, INT_VEC_DIS_VECTOR_RESET, %g4
sllx %l0, INT_VEC_DIS_VCID_SHIFT, %g3
SET_SIZE(wakeup_slave_threads)
save %sp, -(MINFRAME64), %sp
stxa %g0, [%g0]ASI_TLB_INVALIDATE ! ITLB
stxa %g0, [%o1]ASI_TLB_INVALIDATE ! DTLB
save %sp, -(MINFRAME64), %sp
stxa %l1, [%g0]ASI_NIAGARA
1: ldxa [%g0]ASI_NIAGARA, %l0
andcc %l0, BIST_DONE, %l0
save %sp, -(MINFRAME64), %sp
set (ICACHE_MAX_WAYS - 1), %l0 /* way */
set (1 << 13), %l1 /* index */
1: subcc %l1, (1 << 3), %l1
stxa %g0, [%l1+%l2] ASI_ICACHE_INSTR
set (1 << 13), %l1 /* index */
set (ICACHE_MAX_WAYS - 1), %l0 /* way */
set (1 << 13), %l1 /* index */
2: subcc %l1, (1 << 6), %l1
stxa %g0, [%l1+%l2] ASI_ICACHE_TAG
set (1 << 13), %l1 /* index */
* init_dcache - init D$ tag, data
save %sp, -(MINFRAME64), %sp
set (1 << 13), %l0 /* index */
1: subcc %l0, (1 << 3), %l0
stxa %g0, [%l0]ASI_DC_DATA
set (1 << 13), %l0 /* index */
2: subcc %l0, (1 << 4), %l0
stxa %g0, [%l0]ASI_DC_TAG