1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_TRAPSTAT_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_TRAPSTAT_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifndef _ASM 33*7c478bd9Sstevel@tonic-gate #include <sys/processor.h> 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 37*7c478bd9Sstevel@tonic-gate extern "C" { 38*7c478bd9Sstevel@tonic-gate #endif 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #define TSTATIOC (('t' << 16) | ('s' << 8)) 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #define TSTATIOC_READ (TSTATIOC | 1) 43*7c478bd9Sstevel@tonic-gate #define TSTATIOC_GO (TSTATIOC | 2) 44*7c478bd9Sstevel@tonic-gate #define TSTATIOC_NOGO (TSTATIOC | 3) 45*7c478bd9Sstevel@tonic-gate #define TSTATIOC_STOP (TSTATIOC | 4) 46*7c478bd9Sstevel@tonic-gate #define TSTATIOC_CPU (TSTATIOC | 5) 47*7c478bd9Sstevel@tonic-gate #define TSTATIOC_NOCPU (TSTATIOC | 6) 48*7c478bd9Sstevel@tonic-gate #define TSTATIOC_ENTRY (TSTATIOC | 7) 49*7c478bd9Sstevel@tonic-gate #define TSTATIOC_NOENTRY (TSTATIOC | 8) 50*7c478bd9Sstevel@tonic-gate #define TSTATIOC_TLBDATA (TSTATIOC | 9) 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate #define TSTAT_NENT 512 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate #ifndef _ASM 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate /* 57*7c478bd9Sstevel@tonic-gate * tstat_missdata_t must be of size 2^n, for some value of n. This allows 58*7c478bd9Sstevel@tonic-gate * tstat_tlbdata_t to be of size 2^(n+2), and tstat_pgszdata_t to be of 59*7c478bd9Sstevel@tonic-gate * size 2^(n+3) -- a constraint which greatly simplifies the TLB return 60*7c478bd9Sstevel@tonic-gate * entry. 61*7c478bd9Sstevel@tonic-gate */ 62*7c478bd9Sstevel@tonic-gate typedef struct tstat_missdata { 63*7c478bd9Sstevel@tonic-gate uint64_t tmiss_count; 64*7c478bd9Sstevel@tonic-gate hrtime_t tmiss_time; 65*7c478bd9Sstevel@tonic-gate } tstat_missdata_t; 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate typedef struct tstat_tlbdata { 68*7c478bd9Sstevel@tonic-gate tstat_missdata_t ttlb_tlb; 69*7c478bd9Sstevel@tonic-gate tstat_missdata_t ttlb_tsb; 70*7c478bd9Sstevel@tonic-gate } tstat_tlbdata_t; 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate typedef struct tstat_modedata { 73*7c478bd9Sstevel@tonic-gate tstat_tlbdata_t tmode_itlb; 74*7c478bd9Sstevel@tonic-gate tstat_tlbdata_t tmode_dtlb; 75*7c478bd9Sstevel@tonic-gate } tstat_modedata_t; 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate typedef struct tstat_pgszdata { 78*7c478bd9Sstevel@tonic-gate tstat_modedata_t tpgsz_user; 79*7c478bd9Sstevel@tonic-gate tstat_modedata_t tpgsz_kernel; 80*7c478bd9Sstevel@tonic-gate } tstat_pgszdata_t; 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate typedef struct tstat_data { 83*7c478bd9Sstevel@tonic-gate processorid_t tdata_cpuid; 84*7c478bd9Sstevel@tonic-gate hrtime_t tdata_snapts; 85*7c478bd9Sstevel@tonic-gate hrtime_t tdata_snaptick; 86*7c478bd9Sstevel@tonic-gate hrtime_t tdata_tmptick; 87*7c478bd9Sstevel@tonic-gate hrtime_t tdata_peffect; 88*7c478bd9Sstevel@tonic-gate uint64_t tdata_traps[TSTAT_NENT]; 89*7c478bd9Sstevel@tonic-gate tstat_pgszdata_t tdata_pgsz[1]; 90*7c478bd9Sstevel@tonic-gate } tstat_data_t; 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gate #endif 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate #define TSTAT_TLGT0_NENT 256 97*7c478bd9Sstevel@tonic-gate #define TSTAT_TOTAL_NENT (TSTAT_NENT + TSTAT_TLGT0_NENT) 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate #define TSTAT_ENT_NINSTR 8 /* 8 instructions/entry */ 100*7c478bd9Sstevel@tonic-gate #define TSTAT_ENT_SHIFT 5 /* 32 bytes/entry */ 101*7c478bd9Sstevel@tonic-gate #define TSTAT_ENT_ITLBMISS 0x64 102*7c478bd9Sstevel@tonic-gate #define TSTAT_ENT_DTLBMISS 0x68 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate #define TSTAT_TLBRET_NINSTR 32 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate #define TSTAT_PROBE_NPAGES 2048 107*7c478bd9Sstevel@tonic-gate #define TSTAT_PROBE_SIZE (TSTAT_PROBE_NPAGES * MMU_PAGESIZE) 108*7c478bd9Sstevel@tonic-gate #define TSTAT_PROBE_NLAPS 10 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate #ifndef _ASM 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate typedef struct tstat_tlbretent { 113*7c478bd9Sstevel@tonic-gate uint32_t ttlbrent_instr[TSTAT_TLBRET_NINSTR]; 114*7c478bd9Sstevel@tonic-gate } tstat_tlbretent_t; 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate typedef struct tstat_tlbret { 117*7c478bd9Sstevel@tonic-gate tstat_tlbretent_t ttlbr_ktlb; 118*7c478bd9Sstevel@tonic-gate tstat_tlbretent_t ttlbr_ktsb; 119*7c478bd9Sstevel@tonic-gate tstat_tlbretent_t ttlbr_utlb; 120*7c478bd9Sstevel@tonic-gate tstat_tlbretent_t ttlbr_utsb; 121*7c478bd9Sstevel@tonic-gate } tstat_tlbret_t; 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate typedef struct tstat_instr { 124*7c478bd9Sstevel@tonic-gate uint32_t tinst_traptab[TSTAT_TOTAL_NENT * TSTAT_ENT_NINSTR]; 125*7c478bd9Sstevel@tonic-gate tstat_tlbret_t tinst_itlbret; 126*7c478bd9Sstevel@tonic-gate tstat_tlbret_t tinst_dtlbret; 127*7c478bd9Sstevel@tonic-gate } tstat_instr_t; 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate typedef struct tstat_tsbmiss_patch_entry { 130*7c478bd9Sstevel@tonic-gate uint32_t *tpe_addr; 131*7c478bd9Sstevel@tonic-gate uint32_t tpe_instr; 132*7c478bd9Sstevel@tonic-gate } tstat_tsbmiss_patch_entry_t; 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate #endif 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate #ifdef sun4v 137*7c478bd9Sstevel@tonic-gate #if (NCPU > 128) 138*7c478bd9Sstevel@tonic-gate #error "sun4v trapstat supports upto 128 cpus" 139*7c478bd9Sstevel@tonic-gate #endif 140*7c478bd9Sstevel@tonic-gate #define TSTAT_TLB_STATS 0x1 /* cpu_tstat_flags */ 141*7c478bd9Sstevel@tonic-gate #define TSTAT_INSTR_SIZE (sizeof (tstat_instr_t)) 142*7c478bd9Sstevel@tonic-gate #define TSTAT_TBA_MASK ~((1 << 15) - 1) /* 32K per cpu */ 143*7c478bd9Sstevel@tonic-gate #else /* sun4v */ 144*7c478bd9Sstevel@tonic-gate #define TSTAT_INSTR_PAGES ((sizeof (tstat_instr_t) >> MMU_PAGESHIFT) + 1) 145*7c478bd9Sstevel@tonic-gate #define TSTAT_INSTR_SIZE (TSTAT_INSTR_PAGES * MMU_PAGESIZE) 146*7c478bd9Sstevel@tonic-gate #define TSTAT_TBA_MASK ~((1 << 16) - 1) /* 64K per cpu */ 147*7c478bd9Sstevel@tonic-gate #endif /* sun4v */ 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate #define TSTAT_DATA_OFFS(tcpu, mem) \ 150*7c478bd9Sstevel@tonic-gate ((uintptr_t)(tcpu)->tcpu_dbase + offsetof(tstat_data_t, mem)) 151*7c478bd9Sstevel@tonic-gate #define TSTAT_INSTR_OFFS(tcpu, mem) \ 152*7c478bd9Sstevel@tonic-gate ((uintptr_t)(tcpu)->tcpu_ibase + offsetof(tstat_instr_t, mem)) 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate #define TSTAT_CPU_SELECTED 0x0001 155*7c478bd9Sstevel@tonic-gate #define TSTAT_CPU_ALLOCATED 0x0002 156*7c478bd9Sstevel@tonic-gate #define TSTAT_CPU_ENABLED 0x0004 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate #define TSTAT_OPT_CPU 0x0001 159*7c478bd9Sstevel@tonic-gate #define TSTAT_OPT_NOGO 0x0002 160*7c478bd9Sstevel@tonic-gate #define TSTAT_OPT_TLBDATA 0x0004 161*7c478bd9Sstevel@tonic-gate #define TSTAT_OPT_ENTRY 0x0008 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate #define TSTAT_TSBMISS_INSTR 0x8e01e000 /* add %g7, 0, %g7 */ 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gate #ifndef _ASM 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate typedef struct tstat_percpu { 168*7c478bd9Sstevel@tonic-gate uint32_t tcpu_flags; 169*7c478bd9Sstevel@tonic-gate caddr_t tcpu_tba; 170*7c478bd9Sstevel@tonic-gate caddr_t tcpu_vabase; 171*7c478bd9Sstevel@tonic-gate caddr_t tcpu_ibase; 172*7c478bd9Sstevel@tonic-gate caddr_t tcpu_dbase; 173*7c478bd9Sstevel@tonic-gate pfn_t *tcpu_pfn; 174*7c478bd9Sstevel@tonic-gate tstat_instr_t *tcpu_instr; 175*7c478bd9Sstevel@tonic-gate tstat_data_t *tcpu_data; 176*7c478bd9Sstevel@tonic-gate } tstat_percpu_t; 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate #endif 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate #endif 181*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 182*7c478bd9Sstevel@tonic-gate } 183*7c478bd9Sstevel@tonic-gate #endif 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate #endif /* _SYS_TRAPSTAT_H */ 186