* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: dmmu_miss_handler_ext.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 ============================================
! extended trapcheck returns traptype
mov ASI_DMMU_TAG_ACCESS_VAL, %g7
ldxa [%g7] ASI_DMMU_TAG_REG, %g6 ! get va/context from tag-access
#ifdef USE_SOFTWARE_PTR_CALC
! SW Implementation of PTR register calQlations
! Load TSB_CONFIG address in %g7
mov ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_0, %g7
!Uses g1-g5, Expects TSB_CONFIG address in %g7, va in %g6, REsults in %g1
#include <mmu_ptr_calc.s>
ldxa [%g7] ASI_DTSB_PTR, %g1
brnz %g0, HT0_Fast_Data_Access_MMU_Miss_0x68
ldda [%g1] ASI_NUCLEUS_QUAD_LDD, %g4 ! load tte from tsb
srlx %g5, 63, %g2 ! Check valid bit ..
brz,a %g2, dmmu_check_for_ptr_chase
cmp %g4, -1 ! if all 1's, follow link
ldxa [%g0] ASI_DMMU_TAG_REG, %g2 ! get va/context from tag-target
#ifdef DMMU_HAS_SHARED_CTXT
check_dmmu_has_shared_ctx:
! If this TSB has use_ctxt bits set, then mask context
! 1. Get TSB config (%g7 has TSB_CONFIG addr OR TSB_PTR addr)
#ifndef USE_SOFTWARE_PTR_CALC
brz,a %g3, compare_ttetag_d ! Ignore shared ctx for nucleus
stxa %g0, [%g0]ASI_SCRATCHPAD ! Save decision for later
sub %g7, 0x40, %g3 ! %g3 has TSB config ADDR
mov %g7, %g3 ! %g3 has TSB config ADDR
ldxa [%g3] ASI_MMU_ZERO_CONTEXT_TSB_CONFIG, %g3
and %g3, 3, %g3 ! %g3 has use_ctx bits ..
brz %g3, compare_ttetag_d
stxa %g3, [%g0]ASI_SCRATCHPAD ! Save decision for later
sethi %hi(0x1fff0000), %g1
sllx %g1, 32, %g1 ! Create mask for ctxt in tag target
andn %g2, %g1, %g2 ! Masked tag target (%g2)
andn %g4, %g1, %g4 ! Masked tte tag (%g4)
mov 0x80, %g1 ! offset (VA) for patrition id
andcc %g5, 0x4, %g1 ! Check TTE size for mask
bz,a dmmu_check_for_ptr_chase ! size <5 .. no masking reqd
cmp %g4, -1 ! if all 1's, follow link
andn %g2, 0x3f, %g2 ! mask out bits 22:27
cmp %g2, %g4 ! Now compare masked tag target
mov 0x80, %g1 ! offset (VA) for patrition id
dmmu_check_for_ptr_chase:
cmp %g4, -1 ! if all 1's, follow link
be,a %xcc, dmmu_ptr_chase
!! Look up all config registers (1-3)
#ifdef USE_SOFTWARE_PTR_CALC
!! Gotta do SW table walk through the 3 remaing configs ..
! Expect %g7 to stll have addr of last ctx0 config register
! and %g6 should have va/context from tag access register
sub %g7, 0x20, %g7 ! this executes only if branch taken
cmp %g7, ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_1
mov ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_1, %g7
cmp %g7, ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_2
mov ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_2, %g7
cmp %g7, ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_3
mov ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_3, %g7
! %g7 contains last pointer used ..
ldxa [%g7] ASI_DTSB_PTR, %g1
ldxa [%g7] ASI_DTSB_PTR, %g1
ldxa [%g7] ASI_DTSB_PTR, %g1
#ifdef DMMU_SKIP_IF_NO_TTE
#if defined(KAOS_SIMULATION)
ba check_for_dmmu_flush_and_sigsegv
or %g5, %g0, %g3 ! %g3 is link-reg
ldda [%g3] ASI_NUCLEUS_QUAD_LDD, %g4 ! load tte from tsb
ldxa [%g0] ASI_DMMU_TAG_REG, %g2 ! get va/context from tag-target
#ifdef DMMU_HAS_SHARED_CTXT
check_dmmu_has_shared_ctx_l:
! If this TSB has use_ctxt bits set, then mask context
! 1. Get TSB config (%g7 has TSB_CONFIG addr OR TSB_PTR addr)
#ifndef USE_SOFTWARE_PTR_CALC
brz,a %g1, compare_ttetag_dl ! Ignore shared ctx for nucleus
stxa %g0, [%g0]ASI_SCRATCHPAD ! Save decision for later
sub %g7, 0x40, %g1 ! %g1 has TSB config ADDR
mov %g7, %g1 ! %g1 has TSB config ADDR
ldxa [%g1] ASI_MMU_ZERO_CONTEXT_TSB_CONFIG, %g1
and %g1, 3, %g1 ! %g1 has use_ctx bits ..
brz %g1, compare_ttetag_dl
stxa %g1, [%g0]ASI_SCRATCHPAD ! Save decision for later
sethi %hi(0x1fff0000), %g1
sllx %g1, 32, %g1 ! Create mask for ctxt in tag target
andn %g2, %g1, %g2 ! Masked tag target (%g2)
andn %g4, %g1, %g4 ! Masked tte tag (%g4)
mov 0x80, %g1 ! offset (VA) for patrition id
andcc %g5, 0x4, %g1 ! Check TTE size for mask
bz dfollow_link ! size <5 .. no masking reqd
andn %g2, 0x3f, %g2 ! mask out bits 22:27
cmp %g2, %g4 ! Now compare masked tag target
mov 0x80, %g1 ! offset (VA) for patrition id
! DONT USE G1 until PA is done
bne %xcc, dmmu_ptr_chase_loop ! keep chasing pointer
! Look up the Next TSB, until done with all TSBs ?
#ifdef USE_SOFTWARE_PTR_CALC
! Compare with TSB_CONFIG_3 for ctx0 and TSB_CONFIG_3+0x20 for ctx!0
mov ASI_MMU_ZERO_CONTEXT_TSB_CONFIG_3, %g4
dpointer_chase_unsuccessful:
#ifdef DMMU_SKIP_IF_NO_TTE
#if defined(KAOS_SIMULATION)
ba check_for_dmmu_flush_and_sigsegv
#ifdef DMMU_HAS_SHARED_CTXT
! %g6 has the unmasked tag access
ldxa [%g0]ASI_SCRATCHPAD, %g3 ! Do we need to force ctxt ?
brz %g3, done_forcing_ctxt_d ! Nope
movne %xcc, 0x8, %g3 ! ctxt_0
move %xcc, 0x108, %g3 ! ctxt_1
ldxa [%g3]ASI_PRIMARY_CONTEXT_REG, %g3 ! Get ctxt value
sllx %g2, 13, %g2 ! Clear ctxt from tag-access
or %g3, %g2, %g2 ! Stuff in masked tag-access
mov ASI_DMMU_TAG_ACCESS_VAL, %g3
stxa %g2, [%g3]0x50 ! Save forced ctx in tag-access
! Figure out if Offset should be added.
! %g7 contains TSB VA if SW ptr calc, and PTR address if HW_PTR_CALC
! %g6 contains ASI_DMMU_TAG_REG value
#ifndef USE_SOFTWARE_PTR_CALC
sub %g7, 0x20, %g7 ! extra subtract for Z ctx
ldxa [%g7] ASI_MMU_ZERO_CONTEXT_TSB_CONFIG, %g3
and %g3, 0x100, %g3 ! Is RANOTPA 1 ?
stxa %g5, [ %g0 ] ASI_DTLB_DATA_IN ! data-in
! add partition base to data-in
setx partition_base_list, %g3, %g2 ! for partition base
ldxa [%g1] ASI_PARTITION_ID, %g3 ! partition id
sllx %g3, 3, %g3 ! offset - partition list
stxa %g5, [ %g0 ] ASI_DTLB_DATA_IN ! data-in
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Data_Real_Tran_Miss_0x3f code here
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ldxa [%g7] 0x58, %g2 ! get ra from tag-access
!! check to see if RA[39] is set.
!! RA[39] = 0 means accessing memory space
!! RA[39] = 1 means accessing I/O space
mov %g0, %g1 ! %g1 will contain partition base
#ifndef DISABLE_PART_LIMIT_CHECK
srlx %g2, 33, %g2 ! check to see if ra exceeds 8GB limit
! add partition base to data-in
setx partition_base_list, %g1, %g2 ! for partition base
mov ASI_PARTITION_ID_VAL, %g1 ! offset (VA) for patrition id
ldxa [%g1] ASI_PARTITION_ID, %g3 ! partition id
sllx %g3, 3, %g3 ! offset - partition list
dmmu_real_skip_part_base:
setx REAL_DATA_ATTR, %g2, %g5 ! user defined attributes
setx 0x8000000000000022, %g2, %g5 ! CP W
setx 0x8000000000000440, %g2, %g5 ! CP W
srlx %g4, 13, %g4 ! get rid of garbage in context field
mov ASI_DMMU_TAG_ACCESS_VAL, %g7
stxa %g4, [ %g7 ] ASI_DMMU_TAG_REG ! {tag-access, data-in}
stxa %g5, [ %g6 ] ASI_DTLB_DATA_IN
/* Code specific for KAOS */
#if defined(KAOS_SIMULATION)
check_for_dmmu_flush_and_sigsegv:
ldxa [%g0]ASI_DMMU_TAG_TARGET, %g5
setx ra2pa(LOCAL_SUPERVISOR_SECTION_DATA_PA_0 THR_0_PARTID,), %g3, %g1
setx ra2pa(LOCAL_SUPERVISOR_SECTION_DATA_PA_1, THR_1_PARTID), %g3, %g1
setx ra2pa(LOCAL_SUPERVISOR_SECTION_DATA_PA_2, THR_2_PARTID), %g3, %g1
setx ra2pa(LOCAL_SUPERVISOR_SECTION_DATA_PA_3, THR_3_PARTID), %g3, %g1
setx ra2pa(LOCAL_SUPERVISOR_SECTION_DATA_PA_4, THR_4_PARTID), %g3, %g1
setx ra2pa(LOCAL_SUPERVISOR_SECTION_DATA_PA_5, THR_5_PARTID), %g3, %g1
setx ra2pa(LOCAL_SUPERVISOR_SECTION_DATA_PA_6, THR_6_PARTID), %g3, %g1
setx ra2pa(LOCAL_SUPERVISOR_SECTION_DATA_PA_7,THR_7_PARTID), %g3, %g1
setx data_segv_check, %g1, %o5