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_MACHCPUVAR_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_MACHCPUVAR_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/intr.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/clock.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/machparam.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/machpcb.h> 36*7c478bd9Sstevel@tonic-gate #include <sys/privregs.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/machlock.h> 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 40*7c478bd9Sstevel@tonic-gate extern "C" { 41*7c478bd9Sstevel@tonic-gate #endif 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #ifndef _ASM 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h> 46*7c478bd9Sstevel@tonic-gate #include <sys/async.h> 47*7c478bd9Sstevel@tonic-gate #include <sys/fm/protocol.h> 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate /* 50*7c478bd9Sstevel@tonic-gate * CPU state ptl1_panic save. 51*7c478bd9Sstevel@tonic-gate */ 52*7c478bd9Sstevel@tonic-gate typedef struct ptl1_trapregs { 53*7c478bd9Sstevel@tonic-gate uint32_t ptl1_tl; 54*7c478bd9Sstevel@tonic-gate uint32_t ptl1_tt; 55*7c478bd9Sstevel@tonic-gate uint64_t ptl1_tstate; 56*7c478bd9Sstevel@tonic-gate uint64_t ptl1_tpc; 57*7c478bd9Sstevel@tonic-gate uint64_t ptl1_tnpc; 58*7c478bd9Sstevel@tonic-gate } ptl1_trapregs_t; 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate typedef struct ptl1_regs { 61*7c478bd9Sstevel@tonic-gate ptl1_trapregs_t ptl1_trap_regs[PTL1_MAXTL]; 62*7c478bd9Sstevel@tonic-gate uint64_t ptl1_g1; 63*7c478bd9Sstevel@tonic-gate uint64_t ptl1_g2; 64*7c478bd9Sstevel@tonic-gate uint64_t ptl1_g3; 65*7c478bd9Sstevel@tonic-gate uint64_t ptl1_g4; 66*7c478bd9Sstevel@tonic-gate uint64_t ptl1_g5; 67*7c478bd9Sstevel@tonic-gate uint64_t ptl1_g6; 68*7c478bd9Sstevel@tonic-gate uint64_t ptl1_g7; 69*7c478bd9Sstevel@tonic-gate uint64_t ptl1_tick; 70*7c478bd9Sstevel@tonic-gate uint64_t ptl1_dmmu_sfar; 71*7c478bd9Sstevel@tonic-gate uint64_t ptl1_dmmu_sfsr; 72*7c478bd9Sstevel@tonic-gate uint64_t ptl1_dmmu_tag_access; 73*7c478bd9Sstevel@tonic-gate uint64_t ptl1_immu_sfsr; 74*7c478bd9Sstevel@tonic-gate uint64_t ptl1_immu_tag_access; 75*7c478bd9Sstevel@tonic-gate struct rwindow ptl1_rwindow[MAXWIN]; 76*7c478bd9Sstevel@tonic-gate uint32_t ptl1_softint; 77*7c478bd9Sstevel@tonic-gate uint16_t ptl1_pstate; 78*7c478bd9Sstevel@tonic-gate uint8_t ptl1_pil; 79*7c478bd9Sstevel@tonic-gate uint8_t ptl1_cwp; 80*7c478bd9Sstevel@tonic-gate uint8_t ptl1_wstate; 81*7c478bd9Sstevel@tonic-gate uint8_t ptl1_otherwin; 82*7c478bd9Sstevel@tonic-gate uint8_t ptl1_cleanwin; 83*7c478bd9Sstevel@tonic-gate uint8_t ptl1_cansave; 84*7c478bd9Sstevel@tonic-gate uint8_t ptl1_canrestore; 85*7c478bd9Sstevel@tonic-gate } ptl1_regs_t; 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate typedef struct ptl1_state { 88*7c478bd9Sstevel@tonic-gate ptl1_regs_t ptl1_regs; 89*7c478bd9Sstevel@tonic-gate uint32_t ptl1_entry_count; 90*7c478bd9Sstevel@tonic-gate uintptr_t ptl1_stktop; 91*7c478bd9Sstevel@tonic-gate ulong_t ptl1_stk[1]; 92*7c478bd9Sstevel@tonic-gate } ptl1_state_t; 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate /* 95*7c478bd9Sstevel@tonic-gate * Machine specific fields of the cpu struct 96*7c478bd9Sstevel@tonic-gate * defined in common/sys/cpuvar.h. 97*7c478bd9Sstevel@tonic-gate */ 98*7c478bd9Sstevel@tonic-gate struct machcpu { 99*7c478bd9Sstevel@tonic-gate struct machpcb *mpcb; 100*7c478bd9Sstevel@tonic-gate uint64_t mpcb_pa; 101*7c478bd9Sstevel@tonic-gate int mutex_ready; 102*7c478bd9Sstevel@tonic-gate int in_prom; 103*7c478bd9Sstevel@tonic-gate int tl1_hdlr; 104*7c478bd9Sstevel@tonic-gate char cpu_tstat_flags; /* tstat flags */ 105*7c478bd9Sstevel@tonic-gate uint16_t divisor; /* Estar %tick clock ratio */ 106*7c478bd9Sstevel@tonic-gate uint8_t intrcnt; /* number of back-to-back interrupts */ 107*7c478bd9Sstevel@tonic-gate u_longlong_t tmp1; /* per-cpu tmps */ 108*7c478bd9Sstevel@tonic-gate u_longlong_t tmp2; /* used in trap processing */ 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate struct intr_req intr_pool[INTR_PENDING_MAX]; /* intr pool */ 111*7c478bd9Sstevel@tonic-gate struct intr_req *intr_head[PIL_LEVELS]; /* intr que heads */ 112*7c478bd9Sstevel@tonic-gate struct intr_req *intr_tail[PIL_LEVELS]; /* intr que tails */ 113*7c478bd9Sstevel@tonic-gate int intr_pool_added; /* add'l intr pool */ 114*7c478bd9Sstevel@tonic-gate boolean_t poke_cpu_outstanding; 115*7c478bd9Sstevel@tonic-gate /* 116*7c478bd9Sstevel@tonic-gate * The cpu module allocates a private data structure for the 117*7c478bd9Sstevel@tonic-gate * E$ data, which is needed for the specific cpu type. 118*7c478bd9Sstevel@tonic-gate */ 119*7c478bd9Sstevel@tonic-gate void *cpu_private; /* ptr to cpu private data */ 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate ptl1_state_t ptl1_state; 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate uint64_t pil_high_start[HIGH_LEVELS]; /* high-level intrs */ 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate /* 126*7c478bd9Sstevel@tonic-gate * intrstat[][] is used to keep track of ticks used at a given pil 127*7c478bd9Sstevel@tonic-gate * level. intrstat[pil][0] is cumulative and exported via kstats. 128*7c478bd9Sstevel@tonic-gate * intrstat[pil][1] is used in intr_get_time() and is private. 129*7c478bd9Sstevel@tonic-gate * 2-dimensional array improves cache locality. 130*7c478bd9Sstevel@tonic-gate */ 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate uint64_t intrstat[PIL_MAX+1][2]; 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate int kwbuf_full; 135*7c478bd9Sstevel@tonic-gate caddr_t kwbuf_sp; 136*7c478bd9Sstevel@tonic-gate struct rwindow kwbuf; 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate caddr_t cpu_q_va; /* cpu intrq base VA */ 139*7c478bd9Sstevel@tonic-gate caddr_t dev_q_va; /* dev intrq base VA */ 140*7c478bd9Sstevel@tonic-gate uint64_t cpu_q_base_pa; /* cpu intrq base PA */ 141*7c478bd9Sstevel@tonic-gate uint64_t cpu_q_size; 142*7c478bd9Sstevel@tonic-gate uint64_t dev_q_base_pa; /* dev intrq base PA */ 143*7c478bd9Sstevel@tonic-gate uint64_t dev_q_size; 144*7c478bd9Sstevel@tonic-gate caddr_t cpu_rq_va; /* resumable Q base VA */ 145*7c478bd9Sstevel@tonic-gate caddr_t cpu_nrq_va; /* nonresumable Q base VA */ 146*7c478bd9Sstevel@tonic-gate uint64_t cpu_rq_base_pa; /* resumable Q base PA */ 147*7c478bd9Sstevel@tonic-gate uint64_t cpu_rq_size; /* resumable Q size */ 148*7c478bd9Sstevel@tonic-gate uint64_t cpu_nrq_base_pa; /* nonresumable Q base PA */ 149*7c478bd9Sstevel@tonic-gate uint64_t cpu_nrq_size; /* nonresumable Q size */ 150*7c478bd9Sstevel@tonic-gate caddr_t mondo_data; /* send mondo data */ 151*7c478bd9Sstevel@tonic-gate uint64_t mondo_data_ra; /* mono data pa */ 152*7c478bd9Sstevel@tonic-gate uint16_t *cpu_list; /* uint16_t [NCPU] */ 153*7c478bd9Sstevel@tonic-gate uint64_t cpu_list_ra; /* cpu list ra */ 154*7c478bd9Sstevel@tonic-gate }; 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate typedef struct machcpu machcpu_t; 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate /* 159*7c478bd9Sstevel@tonic-gate * Macro to access the "cpu private" data structure. 160*7c478bd9Sstevel@tonic-gate */ 161*7c478bd9Sstevel@tonic-gate #define CPU_PRIVATE(cp) ((cp)->cpu_m.cpu_private) 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate /* 164*7c478bd9Sstevel@tonic-gate * The OpenBoot Standalone Interface supplies the kernel with 165*7c478bd9Sstevel@tonic-gate * implementation dependent parameters through the devinfo/property mechanism 166*7c478bd9Sstevel@tonic-gate */ 167*7c478bd9Sstevel@tonic-gate #define MAXSYSNAME 20 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate /* 170*7c478bd9Sstevel@tonic-gate * Used to indicate busy/idle state of a cpu. 171*7c478bd9Sstevel@tonic-gate * msram field will be set with ECACHE_CPU_MIRROR if we are on 172*7c478bd9Sstevel@tonic-gate * mirrored sram module. 173*7c478bd9Sstevel@tonic-gate */ 174*7c478bd9Sstevel@tonic-gate #define ECACHE_CPU_IDLE 0x0 /* CPU is idle */ 175*7c478bd9Sstevel@tonic-gate #define ECACHE_CPU_BUSY 0x1 /* CPU is busy */ 176*7c478bd9Sstevel@tonic-gate #define ECACHE_CPU_MIRROR 0x2 /* E$ is mirrored */ 177*7c478bd9Sstevel@tonic-gate #define ECACHE_CPU_NON_MIRROR 0x3 /* E$ is not mirrored */ 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate /* 180*7c478bd9Sstevel@tonic-gate * A CPU FRU FMRI string minus the unum component. 181*7c478bd9Sstevel@tonic-gate */ 182*7c478bd9Sstevel@tonic-gate #define CPU_FRU_FMRI FM_FMRI_SCHEME_HC":///" \ 183*7c478bd9Sstevel@tonic-gate FM_FMRI_LEGACY_HC"=" 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate struct cpu_node { 186*7c478bd9Sstevel@tonic-gate char name[MAXSYSNAME]; 187*7c478bd9Sstevel@tonic-gate char fru_fmri[sizeof (CPU_FRU_FMRI) + UNUM_NAMLEN]; 188*7c478bd9Sstevel@tonic-gate int cpuid; 189*7c478bd9Sstevel@tonic-gate dnode_t nodeid; 190*7c478bd9Sstevel@tonic-gate uint64_t clock_freq; 191*7c478bd9Sstevel@tonic-gate uint_t tick_nsec_scale; 192*7c478bd9Sstevel@tonic-gate union { 193*7c478bd9Sstevel@tonic-gate int dummy; 194*7c478bd9Sstevel@tonic-gate } u_info; 195*7c478bd9Sstevel@tonic-gate int ecache_size; 196*7c478bd9Sstevel@tonic-gate int ecache_linesize; 197*7c478bd9Sstevel@tonic-gate int ecache_associativity; 198*7c478bd9Sstevel@tonic-gate int ecache_setsize; 199*7c478bd9Sstevel@tonic-gate uint64_t device_id; 200*7c478bd9Sstevel@tonic-gate }; 201*7c478bd9Sstevel@tonic-gate 202*7c478bd9Sstevel@tonic-gate extern struct cpu_node cpunodes[]; 203*7c478bd9Sstevel@tonic-gate 204*7c478bd9Sstevel@tonic-gate #endif /* _ASM */ 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 207*7c478bd9Sstevel@tonic-gate } 208*7c478bd9Sstevel@tonic-gate #endif 209*7c478bd9Sstevel@tonic-gate 210*7c478bd9Sstevel@tonic-gate #endif /* _SYS_MACHCPUVAR_H */ 211