Print this page
de-linting of .s files


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25  
  26 #if !defined(lint)
  27 #include "assym.h"
  28 #endif /* !lint */
  29 #include <sys/asm_linkage.h>
  30 #include <sys/privregs.h>
  31 #include <sys/sun4asi.h>
  32 #include <sys/spitregs.h>
  33 #include <sys/cheetahregs.h>
  34 #include <sys/machtrap.h>
  35 #include <sys/machthread.h>
  36 #include <sys/machbrand.h>
  37 #include <sys/pcb.h>
  38 #include <sys/pte.h>
  39 #include <sys/mmu.h>
  40 #include <sys/machpcb.h>
  41 #include <sys/async.h>
  42 #include <sys/intreg.h>
  43 #include <sys/scb.h>
  44 #include <sys/psr_compat.h>
  45 #include <sys/syscall.h>
  46 #include <sys/machparam.h>
  47 #include <sys/traptrace.h>
  48 #include <vm/hat_sfmmu.h>


 100 #define TT_TRACE_L_INS  3
 101 
 102 #else
 103 
 104 #define TT_TRACE(label)
 105 #define TT_TRACE_INS    0
 106 
 107 #define TT_TRACE_L(label)
 108 #define TT_TRACE_L_INS  0
 109 
 110 #endif
 111 
 112 /*
 113  * This first set are funneled to trap() with %tt as the type.
 114  * Trap will then either panic or send the user a signal.
 115  */
 116 /*
 117  * NOT is used for traps that just shouldn't happen.
 118  * It comes in both single and quadruple flavors.
 119  */
 120 #if !defined(lint)
 121         .global trap
 122 #endif /* !lint */
 123 #define NOT                     \
 124         TT_TRACE(trace_gen)     ;\
 125         set     trap, %g1       ;\
 126         rdpr    %tt, %g3        ;\
 127         ba,pt   %xcc, sys_trap  ;\
 128         sub     %g0, 1, %g4     ;\
 129         .align  32
 130 #define NOT4    NOT; NOT; NOT; NOT
 131 /*
 132  * RED is for traps that use the red mode handler.
 133  * We should never see these either.
 134  */
 135 #define RED     NOT
 136 /*
 137  * BAD is used for trap vectors we don't have a kernel
 138  * handler for.
 139  * It also comes in single and quadruple versions.
 140  */
 141 #define BAD     NOT
 142 #define BAD4    NOT4
 143 
 144 #define DONE                    \
 145         done;                   \
 146         .align  32
 147 
 148 /*
 149  * TRAP vectors to the trap() function.
 150  * It's main use is for user errors.
 151  */
 152 #if !defined(lint)
 153         .global trap
 154 #endif /* !lint */
 155 #define TRAP(arg)               \
 156         TT_TRACE(trace_gen)     ;\
 157         set     trap, %g1       ;\
 158         mov     arg, %g3        ;\
 159         ba,pt   %xcc, sys_trap  ;\
 160         sub     %g0, 1, %g4     ;\
 161         .align  32
 162 
 163 /*
 164  * SYSCALL is used for unsupported syscall interfaces (with 'which'
 165  * set to 'nosys') and legacy support of old SunOS 4.x syscalls (with
 166  * 'which' set to 'syscall_trap32').
 167  *
 168  * The SYSCALL_TRAP* macros are used for syscall entry points.
 169  * SYSCALL_TRAP is used to support LP64 syscalls and SYSCALL_TRAP32
 170  * is used to support ILP32.  Each macro can only be used once
 171  * since they each define a symbol.  The symbols are used as hot patch
 172  * points by the brand infrastructure to dynamically enable and disable
 173  * brand syscall interposition.  See the comments around BRAND_CALLBACK
 174  * and brand_plat_interposition_enable() for more information.


 263  * REGISTER WINDOW MANAGEMENT MACROS
 264  */
 265 
 266 /*
 267  * various convenient units of padding
 268  */
 269 #define SKIP(n) .skip 4*(n)
 270 
 271 /*
 272  * CLEAN_WINDOW is the simple handler for cleaning a register window.
 273  */
 274 #define CLEAN_WINDOW                                            \
 275         TT_TRACE_L(trace_win)                                   ;\
 276         rdpr %cleanwin, %l0; inc %l0; wrpr %l0, %cleanwin       ;\
 277         clr %l0; clr %l1; clr %l2; clr %l3                      ;\
 278         clr %l4; clr %l5; clr %l6; clr %l7                      ;\
 279         clr %o0; clr %o1; clr %o2; clr %o3                      ;\
 280         clr %o4; clr %o5; clr %o6; clr %o7                      ;\
 281         retry; .align 128
 282 
 283 #if !defined(lint)
 284 
 285 /*
 286  * If we get an unresolved tlb miss while in a window handler, the fault
 287  * handler will resume execution at the last instruction of the window
 288  * hander, instead of delivering the fault to the kernel.  Spill handlers
 289  * use this to spill windows into the wbuf.
 290  *
 291  * The mixed handler works by checking %sp, and branching to the correct
 292  * handler.  This is done by branching back to label 1: for 32b frames,
 293  * or label 2: for 64b frames; which implies the handler order is: 32b,
 294  * 64b, mixed.  The 1: and 2: labels are offset into the routines to
 295  * allow the branchs' delay slots to contain useful instructions.
 296  */
 297 
 298 /*
 299  * SPILL_32bit spills a 32-bit-wide kernel register window.  It
 300  * assumes that the kernel context and the nucleus context are the
 301  * same.  The stack pointer is required to be eight-byte aligned even
 302  * though this code only needs it to be four-byte aligned.
 303  */
 304 #define SPILL_32bit(tail)                                       \


 683         ldxa    [%sp + V9BIAS64 + 16]%asi, %l2                  ;\
 684         ldxa    [%sp + V9BIAS64 + 24]%asi, %l3                  ;\
 685         ldxa    [%sp + V9BIAS64 + 32]%asi, %l4                  ;\
 686         ldxa    [%sp + V9BIAS64 + 40]%asi, %l5                  ;\
 687         ldxa    [%sp + V9BIAS64 + 48]%asi, %l6                  ;\
 688         ldxa    [%sp + V9BIAS64 + 56]%asi, %l7                  ;\
 689         ldxa    [%sp + V9BIAS64 + 64]%asi, %i0                  ;\
 690         ldxa    [%sp + V9BIAS64 + 72]%asi, %i1                  ;\
 691         ldxa    [%sp + V9BIAS64 + 80]%asi, %i2                  ;\
 692         ldxa    [%sp + V9BIAS64 + 88]%asi, %i3                  ;\
 693         ldxa    [%sp + V9BIAS64 + 96]%asi, %i4                  ;\
 694         ldxa    [%sp + V9BIAS64 + 104]%asi, %i5                 ;\
 695         ldxa    [%sp + V9BIAS64 + 112]%asi, %i6                 ;\
 696         ldxa    [%sp + V9BIAS64 + 120]%asi, %i7                 ;\
 697         restored                                                ;\
 698         retry                                                   ;\
 699         SKIP(31-19-TT_TRACE_L_INS)                              ;\
 700         ba,a,pt %xcc, fault_64bit_/**/tail                      ;\
 701         .empty
 702 
 703 #endif /* !lint */
 704 
 705 /*
 706  * SPILL_mixed spills either size window, depending on
 707  * whether %sp is even or odd, to a 32-bit address space.
 708  * This may only be used in conjunction with SPILL_32bit/
 709  * SPILL_64bit. New versions of SPILL_mixed_{tt1,asi} would be
 710  * needed for use with SPILL_{32,64}bit_{tt1,asi}.  Particular
 711  * attention should be paid to the instructions that belong
 712  * in the delay slots of the branches depending on the type
 713  * of spill handler being branched to.
 714  * Clear upper 32 bits of %sp if it is odd.
 715  * We won't need to clear them in 64 bit kernel.
 716  */
 717 #define SPILL_mixed                                             \
 718         btst    1, %sp                                          ;\
 719         bz,a,pt %xcc, 1b                                        ;\
 720         srl     %sp, 0, %sp                                     ;\
 721         ba,pt   %xcc, 2b                                        ;\
 722         nop                                                     ;\
 723         .align  128
 724 


 828         TT_TRACE(trace_gen)             ;\
 829         ba,pt   %xcc,.fp_disabled       ;\
 830         nop                             ;\
 831         .align  32
 832 
 833 /*
 834  * Floating point exceptions.
 835  */
 836 #define FP_IEEE_TRAP                    \
 837         TT_TRACE(trace_gen)             ;\
 838         ba,pt   %xcc,.fp_ieee_exception ;\
 839         nop                             ;\
 840         .align  32
 841 
 842 #define FP_TRAP                         \
 843         TT_TRACE(trace_gen)             ;\
 844         ba,pt   %xcc,.fp_exception      ;\
 845         nop                             ;\
 846         .align  32
 847 
 848 #if !defined(lint)
 849 /*
 850  * asynchronous traps at level 0 and level 1
 851  *
 852  * The first instruction must be a membar for UltraSPARC-III
 853  * to stop RED state entry if the store queue has many
 854  * pending bad stores (PRM, Chapter 11).
 855  */
 856 #define ASYNC_TRAP(ttype, ttlabel, table_name)\
 857         .global table_name      ;\
 858 table_name:                     ;\
 859         membar  #Sync           ;\
 860         TT_TRACE(ttlabel)       ;\
 861         ba      async_err       ;\
 862         mov     ttype, %g5      ;\
 863         .align  32
 864 
 865 /*
 866  * Defaults to BAD entry, but establishes label to be used for
 867  * architecture-specific overwrite of trap table entry.
 868  */
 869 #define LABELED_BAD(table_name)         \
 870         .global table_name              ;\
 871 table_name:                             ;\
 872         BAD
 873 
 874 #endif /* !lint */
 875 
 876 /*
 877  * illegal instruction trap
 878  */
 879 #define ILLTRAP_INSTR                     \
 880         membar  #Sync                     ;\
 881         TT_TRACE(trace_gen)               ;\
 882         or      %g0, P_UTRAP4, %g2        ;\
 883         or      %g0, T_UNIMP_INSTR, %g3   ;\
 884         sethi   %hi(.check_v9utrap), %g4  ;\
 885         jmp     %g4 + %lo(.check_v9utrap) ;\
 886         nop                               ;\
 887         .align  32
 888 
 889 /*
 890  * tag overflow trap
 891  */
 892 #define TAG_OVERFLOW                      \
 893         TT_TRACE(trace_gen)               ;\
 894         or      %g0, P_UTRAP10, %g2       ;\
 895         or      %g0, T_TAG_OVERFLOW, %g3  ;\


1302         stxa    %g1, [%g3 + TRAP_ENT_F3]%asi    /* tsb pointer */       ;\
1303         stxa    %g0, [%g3 + TRAP_ENT_F4]%asi                            ;\
1304         rdpr    %tpc, %g6                                               ;\
1305         stxa    %g6, [%g3 + TRAP_ENT_TPC]%asi                           ;\
1306         rdpr    %tl, %g6                                                ;\
1307         stha    %g6, [%g3 + TRAP_ENT_TL]%asi                            ;\
1308         rdpr    %tt, %g6                                                ;\
1309         or      %g6, (ttextra), %g6                                     ;\
1310         stha    %g6, [%g3 + TRAP_ENT_TT]%asi                            ;\
1311         ldxa    [%g0]ASI_IMMU, %g1              /* tag target */        ;\
1312         ldxa    [%g0]ASI_DMMU, %g4                                      ;\
1313         cmp     %g6, FAST_IMMU_MISS_TT                                  ;\
1314         movne   %icc, %g4, %g1                                          ;\
1315         stxa    %g1, [%g3 + TRAP_ENT_TSTATE]%asi /* tsb tag */          ;\
1316         stxa    %g0, [%g3 + TRAP_ENT_TR]%asi                            ;\
1317         TRACE_NEXT(%g3, %g4, %g6)
1318 #else
1319 #define TRACE_TSBHIT(ttextra)
1320 #endif
1321 
1322 #if defined(lint)
1323 
1324 struct scb      trap_table;
1325 struct scb      scb;            /* trap_table/scb are the same object */
1326 
1327 #else /* lint */
1328 
1329 /*
1330  * =======================================================================
1331  *              SPARC V9 TRAP TABLE
1332  *
1333  * The trap table is divided into two halves: the first half is used when
1334  * taking traps when TL=0; the second half is used when taking traps from
1335  * TL>0. Note that handlers in the second half of the table might not be able
1336  * to make the same assumptions as handlers in the first half of the table.
1337  *
1338  * Worst case trap nesting so far:
1339  *
1340  *      at TL=0 client issues software trap requesting service
1341  *      at TL=1 nucleus wants a register window
1342  *      at TL=2 register window clean/spill/fill takes a TLB miss
1343  *      at TL=3 processing TLB miss
1344  *      at TL=4 handle asynchronous error
1345  *
1346  * Note that a trap from TL=4 to TL=5 places Spitfire in "RED mode".
1347  *
1348  * =======================================================================


3048          * %g1: return address (where the brand handler jumps back to)      \
3049          * %g2: address of CPU structure                                    \
3050          * %g3: address of brand handler (where we will jump to)            \
3051          */                                                                 \
3052         mov     %pc, %g1                                                   ;\
3053         add     %g1, 16, %g1                                               ;\
3054         jmp     %g3                                                        ;\
3055         nop                                                                ;\
3056 1:
3057 
3058         ENTRY_NP(syscall_wrapper32)
3059         BRAND_CALLBACK(BRAND_CB_SYSCALL32)
3060         SYSCALL_NOTT(syscall_trap32)
3061         SET_SIZE(syscall_wrapper32)
3062 
3063         ENTRY_NP(syscall_wrapper)
3064         BRAND_CALLBACK(BRAND_CB_SYSCALL)
3065         SYSCALL_NOTT(syscall_trap)
3066         SET_SIZE(syscall_wrapper)
3067 
3068 #endif  /* lint */


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25  

  26 #include "assym.h"

  27 #include <sys/asm_linkage.h>
  28 #include <sys/privregs.h>
  29 #include <sys/sun4asi.h>
  30 #include <sys/spitregs.h>
  31 #include <sys/cheetahregs.h>
  32 #include <sys/machtrap.h>
  33 #include <sys/machthread.h>
  34 #include <sys/machbrand.h>
  35 #include <sys/pcb.h>
  36 #include <sys/pte.h>
  37 #include <sys/mmu.h>
  38 #include <sys/machpcb.h>
  39 #include <sys/async.h>
  40 #include <sys/intreg.h>
  41 #include <sys/scb.h>
  42 #include <sys/psr_compat.h>
  43 #include <sys/syscall.h>
  44 #include <sys/machparam.h>
  45 #include <sys/traptrace.h>
  46 #include <vm/hat_sfmmu.h>


  98 #define TT_TRACE_L_INS  3
  99 
 100 #else
 101 
 102 #define TT_TRACE(label)
 103 #define TT_TRACE_INS    0
 104 
 105 #define TT_TRACE_L(label)
 106 #define TT_TRACE_L_INS  0
 107 
 108 #endif
 109 
 110 /*
 111  * This first set are funneled to trap() with %tt as the type.
 112  * Trap will then either panic or send the user a signal.
 113  */
 114 /*
 115  * NOT is used for traps that just shouldn't happen.
 116  * It comes in both single and quadruple flavors.
 117  */

 118         .global trap

 119 #define NOT                     \
 120         TT_TRACE(trace_gen)     ;\
 121         set     trap, %g1       ;\
 122         rdpr    %tt, %g3        ;\
 123         ba,pt   %xcc, sys_trap  ;\
 124         sub     %g0, 1, %g4     ;\
 125         .align  32
 126 #define NOT4    NOT; NOT; NOT; NOT
 127 /*
 128  * RED is for traps that use the red mode handler.
 129  * We should never see these either.
 130  */
 131 #define RED     NOT
 132 /*
 133  * BAD is used for trap vectors we don't have a kernel
 134  * handler for.
 135  * It also comes in single and quadruple versions.
 136  */
 137 #define BAD     NOT
 138 #define BAD4    NOT4
 139 
 140 #define DONE                    \
 141         done;                   \
 142         .align  32
 143 
 144 /*
 145  * TRAP vectors to the trap() function.
 146  * It's main use is for user errors.
 147  */

 148         .global trap

 149 #define TRAP(arg)               \
 150         TT_TRACE(trace_gen)     ;\
 151         set     trap, %g1       ;\
 152         mov     arg, %g3        ;\
 153         ba,pt   %xcc, sys_trap  ;\
 154         sub     %g0, 1, %g4     ;\
 155         .align  32
 156 
 157 /*
 158  * SYSCALL is used for unsupported syscall interfaces (with 'which'
 159  * set to 'nosys') and legacy support of old SunOS 4.x syscalls (with
 160  * 'which' set to 'syscall_trap32').
 161  *
 162  * The SYSCALL_TRAP* macros are used for syscall entry points.
 163  * SYSCALL_TRAP is used to support LP64 syscalls and SYSCALL_TRAP32
 164  * is used to support ILP32.  Each macro can only be used once
 165  * since they each define a symbol.  The symbols are used as hot patch
 166  * points by the brand infrastructure to dynamically enable and disable
 167  * brand syscall interposition.  See the comments around BRAND_CALLBACK
 168  * and brand_plat_interposition_enable() for more information.


 257  * REGISTER WINDOW MANAGEMENT MACROS
 258  */
 259 
 260 /*
 261  * various convenient units of padding
 262  */
 263 #define SKIP(n) .skip 4*(n)
 264 
 265 /*
 266  * CLEAN_WINDOW is the simple handler for cleaning a register window.
 267  */
 268 #define CLEAN_WINDOW                                            \
 269         TT_TRACE_L(trace_win)                                   ;\
 270         rdpr %cleanwin, %l0; inc %l0; wrpr %l0, %cleanwin       ;\
 271         clr %l0; clr %l1; clr %l2; clr %l3                      ;\
 272         clr %l4; clr %l5; clr %l6; clr %l7                      ;\
 273         clr %o0; clr %o1; clr %o2; clr %o3                      ;\
 274         clr %o4; clr %o5; clr %o6; clr %o7                      ;\
 275         retry; .align 128
 276 


 277 /*
 278  * If we get an unresolved tlb miss while in a window handler, the fault
 279  * handler will resume execution at the last instruction of the window
 280  * hander, instead of delivering the fault to the kernel.  Spill handlers
 281  * use this to spill windows into the wbuf.
 282  *
 283  * The mixed handler works by checking %sp, and branching to the correct
 284  * handler.  This is done by branching back to label 1: for 32b frames,
 285  * or label 2: for 64b frames; which implies the handler order is: 32b,
 286  * 64b, mixed.  The 1: and 2: labels are offset into the routines to
 287  * allow the branchs' delay slots to contain useful instructions.
 288  */
 289 
 290 /*
 291  * SPILL_32bit spills a 32-bit-wide kernel register window.  It
 292  * assumes that the kernel context and the nucleus context are the
 293  * same.  The stack pointer is required to be eight-byte aligned even
 294  * though this code only needs it to be four-byte aligned.
 295  */
 296 #define SPILL_32bit(tail)                                       \


 675         ldxa    [%sp + V9BIAS64 + 16]%asi, %l2                  ;\
 676         ldxa    [%sp + V9BIAS64 + 24]%asi, %l3                  ;\
 677         ldxa    [%sp + V9BIAS64 + 32]%asi, %l4                  ;\
 678         ldxa    [%sp + V9BIAS64 + 40]%asi, %l5                  ;\
 679         ldxa    [%sp + V9BIAS64 + 48]%asi, %l6                  ;\
 680         ldxa    [%sp + V9BIAS64 + 56]%asi, %l7                  ;\
 681         ldxa    [%sp + V9BIAS64 + 64]%asi, %i0                  ;\
 682         ldxa    [%sp + V9BIAS64 + 72]%asi, %i1                  ;\
 683         ldxa    [%sp + V9BIAS64 + 80]%asi, %i2                  ;\
 684         ldxa    [%sp + V9BIAS64 + 88]%asi, %i3                  ;\
 685         ldxa    [%sp + V9BIAS64 + 96]%asi, %i4                  ;\
 686         ldxa    [%sp + V9BIAS64 + 104]%asi, %i5                 ;\
 687         ldxa    [%sp + V9BIAS64 + 112]%asi, %i6                 ;\
 688         ldxa    [%sp + V9BIAS64 + 120]%asi, %i7                 ;\
 689         restored                                                ;\
 690         retry                                                   ;\
 691         SKIP(31-19-TT_TRACE_L_INS)                              ;\
 692         ba,a,pt %xcc, fault_64bit_/**/tail                      ;\
 693         .empty
 694 


 695 /*
 696  * SPILL_mixed spills either size window, depending on
 697  * whether %sp is even or odd, to a 32-bit address space.
 698  * This may only be used in conjunction with SPILL_32bit/
 699  * SPILL_64bit. New versions of SPILL_mixed_{tt1,asi} would be
 700  * needed for use with SPILL_{32,64}bit_{tt1,asi}.  Particular
 701  * attention should be paid to the instructions that belong
 702  * in the delay slots of the branches depending on the type
 703  * of spill handler being branched to.
 704  * Clear upper 32 bits of %sp if it is odd.
 705  * We won't need to clear them in 64 bit kernel.
 706  */
 707 #define SPILL_mixed                                             \
 708         btst    1, %sp                                          ;\
 709         bz,a,pt %xcc, 1b                                        ;\
 710         srl     %sp, 0, %sp                                     ;\
 711         ba,pt   %xcc, 2b                                        ;\
 712         nop                                                     ;\
 713         .align  128
 714 


 818         TT_TRACE(trace_gen)             ;\
 819         ba,pt   %xcc,.fp_disabled       ;\
 820         nop                             ;\
 821         .align  32
 822 
 823 /*
 824  * Floating point exceptions.
 825  */
 826 #define FP_IEEE_TRAP                    \
 827         TT_TRACE(trace_gen)             ;\
 828         ba,pt   %xcc,.fp_ieee_exception ;\
 829         nop                             ;\
 830         .align  32
 831 
 832 #define FP_TRAP                         \
 833         TT_TRACE(trace_gen)             ;\
 834         ba,pt   %xcc,.fp_exception      ;\
 835         nop                             ;\
 836         .align  32
 837 

 838 /*
 839  * asynchronous traps at level 0 and level 1
 840  *
 841  * The first instruction must be a membar for UltraSPARC-III
 842  * to stop RED state entry if the store queue has many
 843  * pending bad stores (PRM, Chapter 11).
 844  */
 845 #define ASYNC_TRAP(ttype, ttlabel, table_name)\
 846         .global table_name      ;\
 847 table_name:                     ;\
 848         membar  #Sync           ;\
 849         TT_TRACE(ttlabel)       ;\
 850         ba      async_err       ;\
 851         mov     ttype, %g5      ;\
 852         .align  32
 853 
 854 /*
 855  * Defaults to BAD entry, but establishes label to be used for
 856  * architecture-specific overwrite of trap table entry.
 857  */
 858 #define LABELED_BAD(table_name)         \
 859         .global table_name              ;\
 860 table_name:                             ;\
 861         BAD
 862 


 863 /*
 864  * illegal instruction trap
 865  */
 866 #define ILLTRAP_INSTR                     \
 867         membar  #Sync                     ;\
 868         TT_TRACE(trace_gen)               ;\
 869         or      %g0, P_UTRAP4, %g2        ;\
 870         or      %g0, T_UNIMP_INSTR, %g3   ;\
 871         sethi   %hi(.check_v9utrap), %g4  ;\
 872         jmp     %g4 + %lo(.check_v9utrap) ;\
 873         nop                               ;\
 874         .align  32
 875 
 876 /*
 877  * tag overflow trap
 878  */
 879 #define TAG_OVERFLOW                      \
 880         TT_TRACE(trace_gen)               ;\
 881         or      %g0, P_UTRAP10, %g2       ;\
 882         or      %g0, T_TAG_OVERFLOW, %g3  ;\


1289         stxa    %g1, [%g3 + TRAP_ENT_F3]%asi    /* tsb pointer */       ;\
1290         stxa    %g0, [%g3 + TRAP_ENT_F4]%asi                            ;\
1291         rdpr    %tpc, %g6                                               ;\
1292         stxa    %g6, [%g3 + TRAP_ENT_TPC]%asi                           ;\
1293         rdpr    %tl, %g6                                                ;\
1294         stha    %g6, [%g3 + TRAP_ENT_TL]%asi                            ;\
1295         rdpr    %tt, %g6                                                ;\
1296         or      %g6, (ttextra), %g6                                     ;\
1297         stha    %g6, [%g3 + TRAP_ENT_TT]%asi                            ;\
1298         ldxa    [%g0]ASI_IMMU, %g1              /* tag target */        ;\
1299         ldxa    [%g0]ASI_DMMU, %g4                                      ;\
1300         cmp     %g6, FAST_IMMU_MISS_TT                                  ;\
1301         movne   %icc, %g4, %g1                                          ;\
1302         stxa    %g1, [%g3 + TRAP_ENT_TSTATE]%asi /* tsb tag */          ;\
1303         stxa    %g0, [%g3 + TRAP_ENT_TR]%asi                            ;\
1304         TRACE_NEXT(%g3, %g4, %g6)
1305 #else
1306 #define TRACE_TSBHIT(ttextra)
1307 #endif
1308 







1309 /*
1310  * =======================================================================
1311  *              SPARC V9 TRAP TABLE
1312  *
1313  * The trap table is divided into two halves: the first half is used when
1314  * taking traps when TL=0; the second half is used when taking traps from
1315  * TL>0. Note that handlers in the second half of the table might not be able
1316  * to make the same assumptions as handlers in the first half of the table.
1317  *
1318  * Worst case trap nesting so far:
1319  *
1320  *      at TL=0 client issues software trap requesting service
1321  *      at TL=1 nucleus wants a register window
1322  *      at TL=2 register window clean/spill/fill takes a TLB miss
1323  *      at TL=3 processing TLB miss
1324  *      at TL=4 handle asynchronous error
1325  *
1326  * Note that a trap from TL=4 to TL=5 places Spitfire in "RED mode".
1327  *
1328  * =======================================================================


3028          * %g1: return address (where the brand handler jumps back to)      \
3029          * %g2: address of CPU structure                                    \
3030          * %g3: address of brand handler (where we will jump to)            \
3031          */                                                                 \
3032         mov     %pc, %g1                                                   ;\
3033         add     %g1, 16, %g1                                               ;\
3034         jmp     %g3                                                        ;\
3035         nop                                                                ;\
3036 1:
3037 
3038         ENTRY_NP(syscall_wrapper32)
3039         BRAND_CALLBACK(BRAND_CB_SYSCALL32)
3040         SYSCALL_NOTT(syscall_trap32)
3041         SET_SIZE(syscall_wrapper32)
3042 
3043         ENTRY_NP(syscall_wrapper)
3044         BRAND_CALLBACK(BRAND_CB_SYSCALL)
3045         SYSCALL_NOTT(syscall_trap)
3046         SET_SIZE(syscall_wrapper)
3047