Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / include / daccess_except_handler.s
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: daccess_except_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
* otherwise unspecified.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*
* ========== Copyright Header End ============================================
*/
daccess_except_handler:
#ifdef CHECK_SFSR_SFAR
mov 0x18, %g7
ldxa [%g7] 0x58, %g2 ! get sfsr
mov 0x20, %g7
ldxa [%g7] 0x58, %g3 ! get sfar
#endif
dacc_ex_ps0:
ldxa [%g0] 0x59, %g1 ! dmmu ps0 ptr
ldda [%g1] 0x24, %g4 ! load tte from ps0 tsb
cmp %g4, -1 ! if all 1's, follow link
be,a %xcc, dacc_ex_ptr_chase
mov 0, %g7 ! remember ptr chase from ps0
srlx %g5, 63, %g3 ! if not valid, check ps1
brz %g3, dacc_ex_ps1
#ifndef SUN4V
sllx %g5, 15, %g3 ! extract size[2]
srlx %g3, 61, %g3
sllx %g5, 1, %g1 ! extract size[1:0]
srlx %g1, 62, %g1
or %g3, %g1, %g1 ! %g1 = size[2:0]
#else
sllx %g5, 61, %g1
srlx %g1, 61, %g1 ! %g1 = size[2:0]
#endif
mulx %g1, 3, %g1
sub %g0, 1, %g3
sllx %g3, 13, %g3
sllx %g3, %g1, %g3
sethi %hi(0x00001fff), %g1
or %g1, 0xfff, %g1
or %g3, %g1, %g3 ! %g3 = va/ctxt mask based on size[2:0]
and %g2, %g3, %g3 ! apply mask
cmp %g3, %g4 ! check if va/ctxt match
be %xcc, dacc_ex_trap_done
nop
dacc_ex_ps1:
ldxa [%g0] 0x5a, %g1 ! dmmu ps1 ptr
ldda [%g1] 0x24, %g4 ! load tte from ps1 tsb
cmp %g4, -1 ! if all 1's, follow link
be,a %xcc, dacc_ex_ptr_chase
mov 1, %g7 ! remember ptr chase from ps1
srlx %g5, 63, %g3 ! if not valid, bad_trap
!brz %g3, bad_trap
cmp %g3, 0x0
tz T_BAD_TRAP
#ifndef SUN4V
sllx %g5, 15, %g3 ! extract size[2]
srlx %g3, 61, %g3
sllx %g5, 1, %g1 ! extract size[1:0]
srlx %g1, 62, %g1
or %g3, %g1, %g1 ! %g1 = size[2:0]
#else
sllx %g5, 61, %g1
srlx %g1, 61, %g1 ! %g1 = size[2:0]
#endif
mulx %g1, 3, %g1
sub %g0, 1, %g3
sllx %g3, 13, %g3
sllx %g3, %g1, %g3
sethi %hi(0x00001fff), %g1
or %g1, 0xfff, %g1
or %g3, %g1, %g3 ! %g3 = va/ctxt mask based on size[2:0]
and %g2, %g3, %g3 ! apply mask
cmp %g3, %g4 ! check if va/ctxt match
be %xcc, dacc_ex_trap_done
nop
ta T_BAD_TRAP
nop
dacc_ex_ptr_chase:
or %g5, %g0, %g6 ! %g6 is link-reg
dacc_ex_ptr_chase_loop:
ldda [%g6] 0x24, %g4 ! load tte from tsb
#ifndef SUN4V
sllx %g5, 15, %g3 ! extract size[2]
srlx %g3, 61, %g3
sllx %g5, 1, %g1 ! extract size[1:0]
srlx %g1, 62, %g1
or %g3, %g1, %g1 ! %g1 = size[2:0]
#else
sllx %g5, 61, %g1
srlx %g1, 61, %g1 ! %g1 = size[2:0]
#endif
mulx %g1, 3, %g1
sub %g0, 1, %g3
sllx %g3, 13, %g3
sllx %g3, %g1, %g3
sethi %hi(0x00001fff), %g1
or %g1, 0xfff, %g1
or %g3, %g1, %g3 ! %g3 = va/ctxt mask based on size[2:0]
and %g2, %g3, %g3 ! apply mask
cmp %g3, %g4 ! check if va/ctxt match
be %xcc, dacc_ex_trap_done
ldx [%g6+16], %g6
cmp %g6, -1
bne %xcc, dacc_ex_ptr_chase_loop ! keep chasing pointer
nop
brz %g7, dacc_ex_ps1 ! finished ps0 pointer chasing, go to ps1
nop
ta T_BAD_TRAP ! finished ps1 pointer chasing, go to bad_trap
nop
dacc_ex_trap_done:
! add partition base to data-in
setx partition_base_list, %g1, %g2 ! for partition base
mov 0x80, %g1 ! offset (VA) for patrition id
ldxa [%g1] 0x58, %g3 ! partition id
sllx %g3, 3, %g3 ! offset - partition list
ldx [%g2 + %g3], %g1
add %g5, %g1, %g5
mov 0x4, %g1 ! clear P-bit
not %g1
and %g1, %g5, %g5
mov 0x30, %g7
mov %g0, %g6
stxa %g4, [ %g7 ] 0x58 ! {tag-access, data-in}
stxa %g5, [ %g6 ] 0x5c
retry