10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51455Sandrei * Common Development and Distribution License (the "License"). 61455Sandrei * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 223856Svb70745 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_MACHCPUVAR_H 270Sstevel@tonic-gate #define _SYS_MACHCPUVAR_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/intr.h> 320Sstevel@tonic-gate #include <sys/clock.h> 330Sstevel@tonic-gate #include <sys/machparam.h> 340Sstevel@tonic-gate #include <sys/machpcb.h> 350Sstevel@tonic-gate #include <sys/privregs.h> 360Sstevel@tonic-gate #include <sys/machlock.h> 370Sstevel@tonic-gate 380Sstevel@tonic-gate #ifdef __cplusplus 390Sstevel@tonic-gate extern "C" { 400Sstevel@tonic-gate #endif 410Sstevel@tonic-gate 420Sstevel@tonic-gate #ifndef _ASM 430Sstevel@tonic-gate 440Sstevel@tonic-gate #include <sys/obpdefs.h> 450Sstevel@tonic-gate #include <sys/async.h> 460Sstevel@tonic-gate #include <sys/fm/protocol.h> 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* 490Sstevel@tonic-gate * CPU state ptl1_panic save. 500Sstevel@tonic-gate */ 510Sstevel@tonic-gate typedef struct ptl1_trapregs { 520Sstevel@tonic-gate uint32_t ptl1_tl; 530Sstevel@tonic-gate uint32_t ptl1_tt; 540Sstevel@tonic-gate uint64_t ptl1_tstate; 550Sstevel@tonic-gate uint64_t ptl1_tpc; 560Sstevel@tonic-gate uint64_t ptl1_tnpc; 570Sstevel@tonic-gate } ptl1_trapregs_t; 580Sstevel@tonic-gate 590Sstevel@tonic-gate typedef struct ptl1_regs { 600Sstevel@tonic-gate ptl1_trapregs_t ptl1_trap_regs[PTL1_MAXTL]; 610Sstevel@tonic-gate uint64_t ptl1_g1; 620Sstevel@tonic-gate uint64_t ptl1_g2; 630Sstevel@tonic-gate uint64_t ptl1_g3; 640Sstevel@tonic-gate uint64_t ptl1_g4; 650Sstevel@tonic-gate uint64_t ptl1_g5; 660Sstevel@tonic-gate uint64_t ptl1_g6; 670Sstevel@tonic-gate uint64_t ptl1_g7; 680Sstevel@tonic-gate uint64_t ptl1_tick; 690Sstevel@tonic-gate uint64_t ptl1_dmmu_sfar; 700Sstevel@tonic-gate uint64_t ptl1_dmmu_sfsr; 710Sstevel@tonic-gate uint64_t ptl1_dmmu_tag_access; 720Sstevel@tonic-gate uint64_t ptl1_immu_sfsr; 730Sstevel@tonic-gate uint64_t ptl1_immu_tag_access; 740Sstevel@tonic-gate struct rwindow ptl1_rwindow[MAXWIN]; 750Sstevel@tonic-gate uint32_t ptl1_softint; 760Sstevel@tonic-gate uint16_t ptl1_pstate; 770Sstevel@tonic-gate uint8_t ptl1_pil; 780Sstevel@tonic-gate uint8_t ptl1_cwp; 790Sstevel@tonic-gate uint8_t ptl1_wstate; 800Sstevel@tonic-gate uint8_t ptl1_otherwin; 810Sstevel@tonic-gate uint8_t ptl1_cleanwin; 820Sstevel@tonic-gate uint8_t ptl1_cansave; 830Sstevel@tonic-gate uint8_t ptl1_canrestore; 840Sstevel@tonic-gate } ptl1_regs_t; 850Sstevel@tonic-gate 860Sstevel@tonic-gate typedef struct ptl1_state { 870Sstevel@tonic-gate ptl1_regs_t ptl1_regs; 880Sstevel@tonic-gate uint32_t ptl1_entry_count; 890Sstevel@tonic-gate uintptr_t ptl1_stktop; 900Sstevel@tonic-gate ulong_t ptl1_stk[1]; 910Sstevel@tonic-gate } ptl1_state_t; 920Sstevel@tonic-gate 930Sstevel@tonic-gate /* 940Sstevel@tonic-gate * Machine specific fields of the cpu struct 950Sstevel@tonic-gate * defined in common/sys/cpuvar.h. 960Sstevel@tonic-gate */ 970Sstevel@tonic-gate struct machcpu { 980Sstevel@tonic-gate struct machpcb *mpcb; 990Sstevel@tonic-gate uint64_t mpcb_pa; 1000Sstevel@tonic-gate int mutex_ready; 1010Sstevel@tonic-gate int in_prom; 1020Sstevel@tonic-gate int tl1_hdlr; 1030Sstevel@tonic-gate uint16_t divisor; /* Estar %tick clock ratio */ 1040Sstevel@tonic-gate uint8_t intrcnt; /* number of back-to-back interrupts */ 1050Sstevel@tonic-gate u_longlong_t tmp1; /* per-cpu tmps */ 1060Sstevel@tonic-gate u_longlong_t tmp2; /* used in trap processing */ 107*4127Sedp u_longlong_t tmp3; 108*4127Sedp u_longlong_t tmp4; 1090Sstevel@tonic-gate 1103856Svb70745 label_t *ofd[HIGH_LEVELS]; /* saved pil ofd */ 1113856Svb70745 uintptr_t lfd[HIGH_LEVELS]; /* saved ret PC */ 1123856Svb70745 struct on_trap_data *otd[HIGH_LEVELS]; /* saved pil otd */ 1133856Svb70745 1142973Sgovinda struct intr_vec *intr_head[PIL_LEVELS]; /* intr queue heads per pil */ 1152973Sgovinda struct intr_vec *intr_tail[PIL_LEVELS]; /* intr queue tails per pil */ 1160Sstevel@tonic-gate boolean_t poke_cpu_outstanding; 1170Sstevel@tonic-gate /* 1180Sstevel@tonic-gate * The cpu module allocates a private data structure for the 1190Sstevel@tonic-gate * E$ data, which is needed for the specific cpu type. 1200Sstevel@tonic-gate */ 1210Sstevel@tonic-gate void *cpu_private; /* ptr to cpu private data */ 1222241Shuah /* 1232241Shuah * per-MMU ctxdom CPU data. 1242241Shuah */ 1252241Shuah uint_t cpu_mmu_idx; 1262241Shuah struct mmu_ctx *cpu_mmu_ctxp; 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate ptl1_state_t ptl1_state; 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate uint64_t pil_high_start[HIGH_LEVELS]; /* high-level intrs */ 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate /* 1330Sstevel@tonic-gate * intrstat[][] is used to keep track of ticks used at a given pil 1340Sstevel@tonic-gate * level. intrstat[pil][0] is cumulative and exported via kstats. 1350Sstevel@tonic-gate * intrstat[pil][1] is used in intr_get_time() and is private. 1360Sstevel@tonic-gate * 2-dimensional array improves cache locality. 1370Sstevel@tonic-gate */ 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate uint64_t intrstat[PIL_MAX+1][2]; 140834Sandrei kthread_t *startup_thread; 1410Sstevel@tonic-gate }; 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate typedef struct machcpu machcpu_t; 1440Sstevel@tonic-gate 145834Sandrei #define cpu_startup_thread cpu_m.startup_thread 1462241Shuah #define CPU_MMU_IDX(cp) ((cp)->cpu_m.cpu_mmu_idx) 1472241Shuah #define CPU_MMU_CTXP(cp) ((cp)->cpu_m.cpu_mmu_ctxp) 1481455Sandrei #define NINTR_THREADS (LOCK_LEVEL) /* number of interrupt threads */ 149834Sandrei 1500Sstevel@tonic-gate /* 1510Sstevel@tonic-gate * Macro to access the "cpu private" data structure. 1520Sstevel@tonic-gate */ 1530Sstevel@tonic-gate #define CPU_PRIVATE(cp) ((cp)->cpu_m.cpu_private) 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate /* 1560Sstevel@tonic-gate * The OpenBoot Standalone Interface supplies the kernel with 1570Sstevel@tonic-gate * implementation dependent parameters through the devinfo/property mechanism 1580Sstevel@tonic-gate */ 1590Sstevel@tonic-gate #define MAXSYSNAME 20 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate /* 1620Sstevel@tonic-gate * Used to indicate busy/idle state of a cpu. 1630Sstevel@tonic-gate * msram field will be set with ECACHE_CPU_MIRROR if we are on 1640Sstevel@tonic-gate * mirrored sram module. 1650Sstevel@tonic-gate */ 1660Sstevel@tonic-gate #define ECACHE_CPU_IDLE 0x0 /* CPU is idle */ 1670Sstevel@tonic-gate #define ECACHE_CPU_BUSY 0x1 /* CPU is busy */ 1680Sstevel@tonic-gate #define ECACHE_CPU_MIRROR 0x2 /* E$ is mirrored */ 1690Sstevel@tonic-gate #define ECACHE_CPU_NON_MIRROR 0x3 /* E$ is not mirrored */ 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate /* 1720Sstevel@tonic-gate * A CPU FRU FMRI string minus the unum component. 1730Sstevel@tonic-gate */ 1740Sstevel@tonic-gate #define CPU_FRU_FMRI FM_FMRI_SCHEME_HC":///" \ 1750Sstevel@tonic-gate FM_FMRI_LEGACY_HC"=" 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate struct cpu_node { 1780Sstevel@tonic-gate char name[MAXSYSNAME]; 1790Sstevel@tonic-gate char fru_fmri[sizeof (CPU_FRU_FMRI) + UNUM_NAMLEN]; 1800Sstevel@tonic-gate int implementation; 1810Sstevel@tonic-gate int version; 1820Sstevel@tonic-gate int portid; 183789Sahrens pnode_t nodeid; 1840Sstevel@tonic-gate uint64_t clock_freq; 1850Sstevel@tonic-gate uint_t tick_nsec_scale; 1860Sstevel@tonic-gate union { 1870Sstevel@tonic-gate int dummy; 1880Sstevel@tonic-gate } u_info; 1890Sstevel@tonic-gate int ecache_size; 1900Sstevel@tonic-gate int ecache_linesize; 1910Sstevel@tonic-gate int ecache_associativity; 1920Sstevel@tonic-gate int ecache_setsize; 1930Sstevel@tonic-gate ushort_t itlb_size; 1940Sstevel@tonic-gate ushort_t dtlb_size; 1950Sstevel@tonic-gate int msram; 1960Sstevel@tonic-gate uint64_t device_id; 1970Sstevel@tonic-gate }; 1980Sstevel@tonic-gate 1990Sstevel@tonic-gate extern struct cpu_node cpunodes[]; 2000Sstevel@tonic-gate 2010Sstevel@tonic-gate #endif /* _ASM */ 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate #ifdef __cplusplus 2040Sstevel@tonic-gate } 2050Sstevel@tonic-gate #endif 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate #endif /* _SYS_MACHCPUVAR_H */ 208