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 uint16_t divisor; /* Estar %tick clock ratio */ 105*7c478bd9Sstevel@tonic-gate uint8_t intrcnt; /* number of back-to-back interrupts */ 106*7c478bd9Sstevel@tonic-gate u_longlong_t tmp1; /* per-cpu tmps */ 107*7c478bd9Sstevel@tonic-gate u_longlong_t tmp2; /* used in trap processing */ 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate struct intr_req intr_pool[INTR_PENDING_MAX]; /* intr pool */ 110*7c478bd9Sstevel@tonic-gate struct intr_req *intr_head[PIL_LEVELS]; /* intr que heads */ 111*7c478bd9Sstevel@tonic-gate struct intr_req *intr_tail[PIL_LEVELS]; /* intr que tails */ 112*7c478bd9Sstevel@tonic-gate int intr_pool_added; /* add'l intr pool */ 113*7c478bd9Sstevel@tonic-gate boolean_t poke_cpu_outstanding; 114*7c478bd9Sstevel@tonic-gate /* 115*7c478bd9Sstevel@tonic-gate * The cpu module allocates a private data structure for the 116*7c478bd9Sstevel@tonic-gate * E$ data, which is needed for the specific cpu type. 117*7c478bd9Sstevel@tonic-gate */ 118*7c478bd9Sstevel@tonic-gate void *cpu_private; /* ptr to cpu private data */ 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate ptl1_state_t ptl1_state; 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate uint64_t pil_high_start[HIGH_LEVELS]; /* high-level intrs */ 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate /* 125*7c478bd9Sstevel@tonic-gate * intrstat[][] is used to keep track of ticks used at a given pil 126*7c478bd9Sstevel@tonic-gate * level. intrstat[pil][0] is cumulative and exported via kstats. 127*7c478bd9Sstevel@tonic-gate * intrstat[pil][1] is used in intr_get_time() and is private. 128*7c478bd9Sstevel@tonic-gate * 2-dimensional array improves cache locality. 129*7c478bd9Sstevel@tonic-gate */ 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate uint64_t intrstat[PIL_MAX+1][2]; 132*7c478bd9Sstevel@tonic-gate }; 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate typedef struct machcpu machcpu_t; 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate /* 137*7c478bd9Sstevel@tonic-gate * Macro to access the "cpu private" data structure. 138*7c478bd9Sstevel@tonic-gate */ 139*7c478bd9Sstevel@tonic-gate #define CPU_PRIVATE(cp) ((cp)->cpu_m.cpu_private) 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate /* 142*7c478bd9Sstevel@tonic-gate * The OpenBoot Standalone Interface supplies the kernel with 143*7c478bd9Sstevel@tonic-gate * implementation dependent parameters through the devinfo/property mechanism 144*7c478bd9Sstevel@tonic-gate */ 145*7c478bd9Sstevel@tonic-gate #define MAXSYSNAME 20 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate /* 148*7c478bd9Sstevel@tonic-gate * Used to indicate busy/idle state of a cpu. 149*7c478bd9Sstevel@tonic-gate * msram field will be set with ECACHE_CPU_MIRROR if we are on 150*7c478bd9Sstevel@tonic-gate * mirrored sram module. 151*7c478bd9Sstevel@tonic-gate */ 152*7c478bd9Sstevel@tonic-gate #define ECACHE_CPU_IDLE 0x0 /* CPU is idle */ 153*7c478bd9Sstevel@tonic-gate #define ECACHE_CPU_BUSY 0x1 /* CPU is busy */ 154*7c478bd9Sstevel@tonic-gate #define ECACHE_CPU_MIRROR 0x2 /* E$ is mirrored */ 155*7c478bd9Sstevel@tonic-gate #define ECACHE_CPU_NON_MIRROR 0x3 /* E$ is not mirrored */ 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate /* 158*7c478bd9Sstevel@tonic-gate * A CPU FRU FMRI string minus the unum component. 159*7c478bd9Sstevel@tonic-gate */ 160*7c478bd9Sstevel@tonic-gate #define CPU_FRU_FMRI FM_FMRI_SCHEME_HC":///" \ 161*7c478bd9Sstevel@tonic-gate FM_FMRI_LEGACY_HC"=" 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate struct cpu_node { 164*7c478bd9Sstevel@tonic-gate char name[MAXSYSNAME]; 165*7c478bd9Sstevel@tonic-gate char fru_fmri[sizeof (CPU_FRU_FMRI) + UNUM_NAMLEN]; 166*7c478bd9Sstevel@tonic-gate int implementation; 167*7c478bd9Sstevel@tonic-gate int version; 168*7c478bd9Sstevel@tonic-gate int portid; 169*7c478bd9Sstevel@tonic-gate dnode_t nodeid; 170*7c478bd9Sstevel@tonic-gate uint64_t clock_freq; 171*7c478bd9Sstevel@tonic-gate uint_t tick_nsec_scale; 172*7c478bd9Sstevel@tonic-gate union { 173*7c478bd9Sstevel@tonic-gate int dummy; 174*7c478bd9Sstevel@tonic-gate } u_info; 175*7c478bd9Sstevel@tonic-gate int ecache_size; 176*7c478bd9Sstevel@tonic-gate int ecache_linesize; 177*7c478bd9Sstevel@tonic-gate int ecache_associativity; 178*7c478bd9Sstevel@tonic-gate int ecache_setsize; 179*7c478bd9Sstevel@tonic-gate ushort_t itlb_size; 180*7c478bd9Sstevel@tonic-gate ushort_t dtlb_size; 181*7c478bd9Sstevel@tonic-gate int msram; 182*7c478bd9Sstevel@tonic-gate uint64_t device_id; 183*7c478bd9Sstevel@tonic-gate }; 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate extern struct cpu_node cpunodes[]; 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate #endif /* _ASM */ 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 190*7c478bd9Sstevel@tonic-gate } 191*7c478bd9Sstevel@tonic-gate #endif 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate #endif /* _SYS_MACHCPUVAR_H */ 194