* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: hred_reset_handler.s
* Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
* 4150 Network Circle, Santa Clara, California 95054, U.S.A.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
* This 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 program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* For the avoidance of doubt, and except that if any non-GPL license
* choice is available it will apply instead, Sun elects to use only
* the General Public License version 2 (GPLv2) at this time for any
* software where a choice of GPL license versions is made
* available with the language indicating that GPLv2 or any later version
* may be used, or where a choice of which version of the GPL is applied is
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* ========== Copyright Header End ============================================
.global nc_check_core_master_thread
.global check_core_master_thread
.global nc_chip_master_thread
.global chip_master_thread
#include "spc_por_rdchk.s"
! Clear %cwp before doing SAVE or using %i/%l/%o, to work around bug
hred_reset_handler_clear_cwp:
#endif /* RESET_STAT_CHECK */
hred_reset_handler_clear_red_state:
! Setup for normal operations
wrhpr %l1, 0x820, %hpstate
! set hyper trap base addr
best_set_reg(HV_TRAP_BASE_PA, %g2, %l7)
! Doing this in delay slot of jump from boot prom ...
ldxa [%g0] ASI_INTR_ID, %g1 ! USING this on N2 as a shortcut
!! CAUTION !! Don't modify G1 until PORTABLE_CORE
hred_reset_handler_non_cmp_check_master_tid:
! Non-cmp thread startup.
brz %g1, nc_chip_master_thread ! T0 is chip master
wr %g0, ASI_CMP_CORE, %asi
! Else figure out if lowest running
ldxa [0x50]%asi, %g2 ! Who is running ?
popc %l1, %l1 ! Get lowest bit set ..
bne,a %xcc, nc_check_core_master_thread
srlx %g1, 3, %l1 ! Get core-id
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!! System Level Inits in system_inits.s !!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!! Core - Level Inits in core_init.s !!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
nc_check_core_master_thread:
mov (CREGS_LSU_CTL_REG_DC << 1 | CREGS_LSU_CTL_REG_IC), %g2
stxa %g2, [%g0] 0x45 ! Enable L1
and %g1, 0x7, %l2 ! Portable core ..
brz %l2, nc_core_master_thread ! T0 is core master
ldxa [0x50]%asi, %g2 ! Who is running ?
popc %l1, %l1 ! Get lowest bit set ..
be %xcc, nc_core_master_thread
! CMP thread startup ! DO NOT MODIFY %G1 until CMP IS Done
! Find out if current thread is chip master thread
! Use CMP THREAD START and M4 macros for efficiency.
! When SIXGUNS is defined, cannot use CMP THREAD START for portability
check_chip_master_thread:
changequote([, ])dnl ! The M4_* variables need this
changequote(`,')dnl ! [] are not quotes anymore
! Determine master thread by querying CORE_RUNNING
ldxa [%g3]ASI_CMP_CORE, %g2 ! Who is running ?
popc %l1, %l1 ! Get lowest bit set ..
bne %xcc, check_core_master_thread
wr %g0, ASI_CMP_CORE, %asi
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!! System Level Inits in system_inits.s !!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
start_core_master_threads:
changequote([, ])dnl ! The M4_* variables need this
best_set_reg2( M4_core_lsb_mask, %g3, %g4)
changequote(`,')dnl ! [] are not quotes anymore
stxa %g4, [ASI_CMP_CORE_RUNNING_RW]%asi ! Start core_master_threads
check_core_master_thread:
! Find out if current thread is core master thread
! by comparing current TID mask with M4-core-lsb-mask.
changequote([, ])dnl ! The M4_* variables need this
best_set_reg2(M4_core_lsb_mask, %g2, %g3)
changequote(`,')dnl ! [] are not quotes anymore
mov (CREGS_LSU_CTL_REG_DC << 1 | CREGS_LSU_CTL_REG_IC), %g2
mov (CREGS_LSU_CTL_REG_DC << 1 | CREGS_LSU_CTL_REG_IC), %g2
stxa %g2, [%g0] 0x45 ! Enable L1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!! Core - Level Inits in core_init.s !!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ldxa [%g0] ASI_INTR_ID, %g1 ! USING this on N2 as a shortcut
changequote([, ])dnl ! The M4_* variables need this
best_set_reg2(M4_thread_mask, %g2, %g3)
changequote(`,')dnl ! Change quote back so all [] are not quoted ..
stxa %g4, [ASI_CMP_CORE_RUNNING_W1S]%asi ! Start all threads in core
hred_reset_handler_setup_partition_id:
! load partition id to %l7
and %g1, %g2, %l7 ! %l7 has TID
or %g1, %g0, %l7 ! %l7 has TID
setx part_id_list, %g1, %g2
sllx %l7, 3, %l7 ! offset - partition list
ldx [%g2 + %l7], %g2 ! %g2 contains partition ID
! WARNING DO NOT USE %g2 !!!
mov ASI_PARTITION_ID_VAL, %g1
stxa %g2, [%g1] ASI_PARTITION_ID
! HWTW setup for real_tange and physical offsets ..
! Set mode for TSB search. The default mode is Sequential
mov ASI_TSB_SEARCH_MODE_ADDR, %l2
or TSB_SEARCH_BURST, %g0, %l1
stxa %l1, [%l2] ASI_TSB_SEARCH_MODE_REG
#ifdef TSB_SEARCH_PREDICTION
mov ASI_TSB_SEARCH_MODE_ADDR, %l2
or TSB_SEARCH_PREDICTION, %g0, %l1
stxa %l1, [%l2] ASI_TSB_SEARCH_MODE_REG
wr %g0, ASI_MMU_PHYSICAL_OFFSET, %asi
setx partition_phys_offset_list, %g1, %g3
! %g3 -> [partition_phys_offset_list]
! %g4 -> [partition_phys_offset_list + PID*32]
stxa %l1, [ASI_MMU_PHYSICAL_OFFSET_0] %asi
stxa %l1, [ASI_MMU_PHYSICAL_OFFSET_1] %asi
stxa %l1, [ASI_MMU_PHYSICAL_OFFSET_2] %asi
stxa %l1, [ASI_MMU_PHYSICAL_OFFSET_3] %asi
! Set the ranges as follows
wr %g0, ASI_MMU_REAL_RANGE, %asi
!!! setx 0x8000048000000800, %g1, %l1
!!! setx 0x807ffffff8000000, %g1, %l1 ! MAX REAL RANGE !!!
setx 0x800007fff8000000, %g1, %l1
best_set_reg( MMU_REAL_RANGE_0 , %g1, %l1)
stxa %l1, [ASI_MMU_REAL_RANGE_0] %asi
setx 0x80007ffff8004000, %g1, %l1
best_set_reg(MMU_REAL_RANGE_1 , %g1, %l1)
stxa %l1, [ASI_MMU_REAL_RANGE_1] %asi
setx 0x8007fffff8040000, %g1, %l1
best_set_reg(MMU_REAL_RANGE_2 , %g1, %l1)
stxa %l1, [ASI_MMU_REAL_RANGE_2] %asi
setx 0x807ffffff8400000, %g1, %l1
best_set_reg(MMU_REAL_RANGE_3 , %g1, %l1)
stxa %l1, [ASI_MMU_REAL_RANGE_3] %asi
! Load tsb config/base from memory
! and write to corresponding ASI's
! set tsb-config-regs for one partition
setx tsb_config_base_list, %l0, %g1
umul %g2, 80, %g2 ! %g2 contains offset to tsb_config_base_list
add %g1, %g2, %g1 ! %g1 contains pointer to tsb_config_base_list
wr %g0, ASI_MMU_ZERO_CONTEXT_TSB_CONFIG, %asi
!!! Write CONTEXT ZERO, TSB_CONFIG_0 !!!
ldx [%g1], %g4 ! part_N_z_tsb_config_0
stxa %g4, [ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_0] %asi
!!! Write CONTEXT NON-ZERO, TSB_CONFIG_0 !!!
ldx [%g1+8], %g4 ! part_N_nz_tsb_config_0
stxa %g4, [ASI_MMU_NONZERO_CONTEXT_TSB_CONFIG_0] %asi
!!! Write CONTEXT ZERO, TSB_CONFIG_1 !!!
ldx [%g1+16], %g4 ! part_N_z_tsb_config_1
stxa %g4, [ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_1] %asi
!!! Write CONTEXT NON-ZERO, TSB_CONFIG_1 !!!
ldx [%g1+24], %g4 ! part_N_nz_tsb_config_1
stxa %g4, [ASI_MMU_NONZERO_CONTEXT_TSB_CONFIG_1] %asi
!!! Write CONTEXT ZERO, TSB_CONFIG_2 !!!
ldx [%g1+32], %g4 ! part_N_z_tsb_config_2
stxa %g4, [ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_2] %asi
!!! Write CONTEXT NON-ZERO, TSB_CONFIG_2 !!!
ldx [%g1+40], %g4 ! part_N_nz_tsb_config_2
stxa %g4, [ASI_MMU_NONZERO_CONTEXT_TSB_CONFIG_2] %asi
!!! Write CONTEXT ZERO, TSB_CONFIG_3 !!!
ldx [%g1+48], %g4 ! part_N_z_tsb_config_2
stxa %g4, [ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_3] %asi
!!! Write CONTEXT NON-ZERO, TSB_CONFIG_3 !!!
ldx [%g1+56], %g4 ! part_N_nz_tsb_config_3
stxa %g4, [ASI_MMU_NONZERO_CONTEXT_TSB_CONFIG_3] %asi
hred_reset_handler_enable_pmu:
! Enable PMU for counting instruction types
! Initialize control registers per defines
! Added conditionals, assuming that these values init at 0x0..
wr %g0, cregs_fprs_imm, %fprs
wr %g0, cregs_ccr_imm, %ccr
wr %g0, cregs_asi_imm, %asi
best_set_reg(cregs_tick_r64, %g1, %g2)
#if (NO_SLAM_INIT || CREGS_CANSAVE > 0 || CREGS_CANSAVE > 0x0)
wrpr cregs_cansave_imm, %cansave
#if (NO_SLAM_INIT || CREGS_CANRESTORE > 0 || CREGS_CANRESTORE > 0x0)
wrpr cregs_canrestore_imm, %canrestore
#if (NO_SLAM_INIT || CREGS_OTHERWIN > 0 || CREGS_OTHERWIN > 0x0)
wrpr cregs_otherwin_imm, %otherwin
#if (NO_SLAM_INIT || CREGS_CLEANWIN > 0 || CREGS_CLEANWIN > 0x0)
wrpr cregs_cleanwin_imm, %cleanwin
#if (NO_SLAM_INIT || CREGS_WSTATE > 0 || CREGS_WSTATE > 0x0)
wrpr cregs_wstate_imm, %wstate
! Set lsu control reg. enable dcache, icache, immu, dmmu
best_set_reg(cregs_lsu_ctl_reg_r64, %g1, %l7)
stxa %l7, [%g0] ASI_LSU_CTL_REG
stxa %g1, [%g4]0x4c !! CETER
hred_reset_handler_check_reset_stat:
setx RESET_STAT, %g1, %g2
and %g1, 2, %g1 !! nonzero if WMR
brz %g1, done_reset_stat_check
stxa %g0, [%g1]ASI_PRIMARY_CONTEXT_REG
#include "interrupt0x60_thread_init.s"
#endif /* ENABLE_INTR0x60 */
#if defined(ENABLE_PCIE_LINK_TRAINING) || defined(FC_NO_PEU_VERA)
! ***************************************************************
! PCI Express Link Training included here for the master thread
! ***************************************************************
ldxa [%g0] ASI_INTR_ID, %g1
bne %xcc, skip_wait_for_link
#include "system_init_pcie_wait.s"
#include "system_init_pcie_wait.s"
#endif /* CMP_THREAD_START */
#endif /* (ENABLE_PCIE_LINK_TRAINING) || defined(FC_NO_PEU_VERA) */
#endif /* not DTM_ENABLED */
#ifdef ENABLE_NIU_BACKGROUND_PACKETS_IN_BOOT
#include "niu_start_bg_pkts.s"
#endif /* ENABLE_NIU_BACKGROUND_PACKETS_IN_BOOT */
hred_reset_handler_jump_to_priv_reset:
best_set_reg(PRIV_RESET_VA, %g1, %g2)
wrhpr cregs_htstate_r64, %htstate
mov 0x0, %o0 /* please don't delete this , used in customized */
!! jump directly to user code - in hpriv mode ..
setx start_label_list, %g1, %g2
ldx [%g2], %o5 ! %o5 contains start_label