17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5100b72f4Sandrei * Common Development and Distribution License (the "License"). 6100b72f4Sandrei * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22fb2f18f8Sesaxe * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_MACHCPUVAR_H 277c478bd9Sstevel@tonic-gate #define _SYS_MACHCPUVAR_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/intr.h> 327c478bd9Sstevel@tonic-gate #include <sys/clock.h> 337c478bd9Sstevel@tonic-gate #include <sys/machparam.h> 347c478bd9Sstevel@tonic-gate #include <sys/machpcb.h> 357c478bd9Sstevel@tonic-gate #include <sys/privregs.h> 367c478bd9Sstevel@tonic-gate #include <sys/machlock.h> 37a60fc142Srf157361 #include <sys/async.h> 38a60fc142Srf157361 #include <sys/error.h> 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef __cplusplus 417c478bd9Sstevel@tonic-gate extern "C" { 427c478bd9Sstevel@tonic-gate #endif 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #ifndef _ASM 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h> 477c478bd9Sstevel@tonic-gate #include <sys/async.h> 487c478bd9Sstevel@tonic-gate #include <sys/fm/protocol.h> 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 517c478bd9Sstevel@tonic-gate * CPU state ptl1_panic save. 527c478bd9Sstevel@tonic-gate */ 537c478bd9Sstevel@tonic-gate typedef struct ptl1_trapregs { 547c478bd9Sstevel@tonic-gate uint32_t ptl1_tl; 557c478bd9Sstevel@tonic-gate uint32_t ptl1_tt; 567c478bd9Sstevel@tonic-gate uint64_t ptl1_tstate; 577c478bd9Sstevel@tonic-gate uint64_t ptl1_tpc; 587c478bd9Sstevel@tonic-gate uint64_t ptl1_tnpc; 597c478bd9Sstevel@tonic-gate } ptl1_trapregs_t; 607c478bd9Sstevel@tonic-gate 6149a230e1Ssvemuri typedef struct ptl1_gregs { 6249a230e1Ssvemuri uint64_t ptl1_gl; 637c478bd9Sstevel@tonic-gate uint64_t ptl1_g1; 647c478bd9Sstevel@tonic-gate uint64_t ptl1_g2; 657c478bd9Sstevel@tonic-gate uint64_t ptl1_g3; 667c478bd9Sstevel@tonic-gate uint64_t ptl1_g4; 677c478bd9Sstevel@tonic-gate uint64_t ptl1_g5; 687c478bd9Sstevel@tonic-gate uint64_t ptl1_g6; 697c478bd9Sstevel@tonic-gate uint64_t ptl1_g7; 7049a230e1Ssvemuri } ptl1_gregs_t; 7149a230e1Ssvemuri 7249a230e1Ssvemuri typedef struct ptl1_regs { 7349a230e1Ssvemuri ptl1_trapregs_t ptl1_trap_regs[PTL1_MAXTL]; 7449a230e1Ssvemuri ptl1_gregs_t ptl1_gregs[PTL1_MAXGL + 1]; 757c478bd9Sstevel@tonic-gate uint64_t ptl1_tick; 7649a230e1Ssvemuri uint64_t ptl1_dmmu_type; 7749a230e1Ssvemuri uint64_t ptl1_dmmu_addr; 7849a230e1Ssvemuri uint64_t ptl1_dmmu_ctx; 7949a230e1Ssvemuri uint64_t ptl1_immu_type; 8049a230e1Ssvemuri uint64_t ptl1_immu_addr; 8149a230e1Ssvemuri uint64_t ptl1_immu_ctx; 827c478bd9Sstevel@tonic-gate struct rwindow ptl1_rwindow[MAXWIN]; 837c478bd9Sstevel@tonic-gate uint32_t ptl1_softint; 847c478bd9Sstevel@tonic-gate uint16_t ptl1_pstate; 857c478bd9Sstevel@tonic-gate uint8_t ptl1_pil; 867c478bd9Sstevel@tonic-gate uint8_t ptl1_cwp; 877c478bd9Sstevel@tonic-gate uint8_t ptl1_wstate; 887c478bd9Sstevel@tonic-gate uint8_t ptl1_otherwin; 897c478bd9Sstevel@tonic-gate uint8_t ptl1_cleanwin; 907c478bd9Sstevel@tonic-gate uint8_t ptl1_cansave; 917c478bd9Sstevel@tonic-gate uint8_t ptl1_canrestore; 927c478bd9Sstevel@tonic-gate } ptl1_regs_t; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate typedef struct ptl1_state { 957c478bd9Sstevel@tonic-gate ptl1_regs_t ptl1_regs; 967c478bd9Sstevel@tonic-gate uint32_t ptl1_entry_count; 977c478bd9Sstevel@tonic-gate uintptr_t ptl1_stktop; 987c478bd9Sstevel@tonic-gate ulong_t ptl1_stk[1]; 997c478bd9Sstevel@tonic-gate } ptl1_state_t; 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* 10259ac0c16Sdavemq * For cpu_chip and cpu_core in machcpu structure if we cannot get 10359ac0c16Sdavemq * any chip id or core id information from MD. 10459ac0c16Sdavemq */ 10559ac0c16Sdavemq #define CPU_CHIPID_INVALID -1 10659ac0c16Sdavemq #define CPU_COREID_INVALID -1 107*ce8eb11aSdp78419 #define CPU_L2_CACHEID_INVALID -1 10859ac0c16Sdavemq 10959ac0c16Sdavemq /* 1107c478bd9Sstevel@tonic-gate * Machine specific fields of the cpu struct 1117c478bd9Sstevel@tonic-gate * defined in common/sys/cpuvar.h. 1127c478bd9Sstevel@tonic-gate */ 1137c478bd9Sstevel@tonic-gate struct machcpu { 1147c478bd9Sstevel@tonic-gate struct machpcb *mpcb; 1157c478bd9Sstevel@tonic-gate uint64_t mpcb_pa; 1167c478bd9Sstevel@tonic-gate int mutex_ready; 1177c478bd9Sstevel@tonic-gate int in_prom; 1187c478bd9Sstevel@tonic-gate int tl1_hdlr; 1197c478bd9Sstevel@tonic-gate char cpu_tstat_flags; /* tstat flags */ 1207c478bd9Sstevel@tonic-gate uint16_t divisor; /* Estar %tick clock ratio */ 1217c478bd9Sstevel@tonic-gate uint8_t intrcnt; /* number of back-to-back interrupts */ 1227c478bd9Sstevel@tonic-gate u_longlong_t tmp1; /* per-cpu tmps */ 1237c478bd9Sstevel@tonic-gate u_longlong_t tmp2; /* used in trap processing */ 1244a75c0c1Sedp u_longlong_t tmp3; 1254a75c0c1Sedp u_longlong_t tmp4; 1267c478bd9Sstevel@tonic-gate 12726046578Svb70745 label_t *ofd[HIGH_LEVELS]; /* saved pil ofd */ 12826046578Svb70745 uintptr_t lfd[HIGH_LEVELS]; /* saved ret PC */ 12926046578Svb70745 struct on_trap_data *otd[HIGH_LEVELS]; /* saved pil otd */ 13026046578Svb70745 131b0fc0e77Sgovinda struct intr_vec *intr_head[PIL_LEVELS]; /* intr queue heads per pil */ 132b0fc0e77Sgovinda struct intr_vec *intr_tail[PIL_LEVELS]; /* intr queue tails per pil */ 1337c478bd9Sstevel@tonic-gate boolean_t poke_cpu_outstanding; 1347c478bd9Sstevel@tonic-gate /* 1357c478bd9Sstevel@tonic-gate * The cpu module allocates a private data structure for the 1367c478bd9Sstevel@tonic-gate * E$ data, which is needed for the specific cpu type. 1377c478bd9Sstevel@tonic-gate */ 1387c478bd9Sstevel@tonic-gate void *cpu_private; /* ptr to cpu private data */ 1391e2e7a75Shuah /* 1401e2e7a75Shuah * per-MMU ctxdom CPU data. 1411e2e7a75Shuah */ 1421e2e7a75Shuah uint_t cpu_mmu_idx; 1431e2e7a75Shuah struct mmu_ctx *cpu_mmu_ctxp; 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate ptl1_state_t ptl1_state; 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate uint64_t pil_high_start[HIGH_LEVELS]; /* high-level intrs */ 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate /* 1507c478bd9Sstevel@tonic-gate * intrstat[][] is used to keep track of ticks used at a given pil 1517c478bd9Sstevel@tonic-gate * level. intrstat[pil][0] is cumulative and exported via kstats. 1527c478bd9Sstevel@tonic-gate * intrstat[pil][1] is used in intr_get_time() and is private. 1537c478bd9Sstevel@tonic-gate * 2-dimensional array improves cache locality. 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate uint64_t intrstat[PIL_MAX+1][2]; 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate int kwbuf_full; 1597c478bd9Sstevel@tonic-gate caddr_t kwbuf_sp; 1607c478bd9Sstevel@tonic-gate struct rwindow kwbuf; 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate caddr_t cpu_q_va; /* cpu intrq base VA */ 1637c478bd9Sstevel@tonic-gate caddr_t dev_q_va; /* dev intrq base VA */ 1647c478bd9Sstevel@tonic-gate uint64_t cpu_q_base_pa; /* cpu intrq base PA */ 1657c478bd9Sstevel@tonic-gate uint64_t cpu_q_size; 1667c478bd9Sstevel@tonic-gate uint64_t dev_q_base_pa; /* dev intrq base PA */ 1677c478bd9Sstevel@tonic-gate uint64_t dev_q_size; 1687c478bd9Sstevel@tonic-gate caddr_t cpu_rq_va; /* resumable Q base VA */ 1697c478bd9Sstevel@tonic-gate caddr_t cpu_nrq_va; /* nonresumable Q base VA */ 1707c478bd9Sstevel@tonic-gate uint64_t cpu_rq_base_pa; /* resumable Q base PA */ 1717c478bd9Sstevel@tonic-gate uint64_t cpu_rq_size; /* resumable Q size */ 1727c478bd9Sstevel@tonic-gate uint64_t cpu_nrq_base_pa; /* nonresumable Q base PA */ 1737c478bd9Sstevel@tonic-gate uint64_t cpu_nrq_size; /* nonresumable Q size */ 174a60fc142Srf157361 errh_er_t *cpu_rq_lastre; /* most recent RE */ 175a60fc142Srf157361 errh_er_t *cpu_nrq_lastnre; /* most recent NRE */ 1767c478bd9Sstevel@tonic-gate caddr_t mondo_data; /* send mondo data */ 1777c478bd9Sstevel@tonic-gate uint64_t mondo_data_ra; /* mono data pa */ 1787c478bd9Sstevel@tonic-gate uint16_t *cpu_list; /* uint16_t [NCPU] */ 1797c478bd9Sstevel@tonic-gate uint64_t cpu_list_ra; /* cpu list ra */ 180fb2f18f8Sesaxe id_t cpu_ipipe; /* cpu int exec unit id */ 181*ce8eb11aSdp78419 id_t cpu_mpipe; /* cpu memory pipe id */ 182fb2f18f8Sesaxe id_t cpu_fpu; /* cpu fpu unit id */ 183fb2f18f8Sesaxe id_t cpu_core; /* cpu core id */ 18459ac0c16Sdavemq id_t cpu_chip; /* cpu chip id */ 1859d7041eeSandrei kthread_t *startup_thread; 1867c478bd9Sstevel@tonic-gate }; 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate typedef struct machcpu machcpu_t; 1897c478bd9Sstevel@tonic-gate 1909d7041eeSandrei #define cpu_startup_thread cpu_m.startup_thread 1911e2e7a75Shuah #define CPU_MMU_IDX(cp) ((cp)->cpu_m.cpu_mmu_idx) 1921e2e7a75Shuah #define CPU_MMU_CTXP(cp) ((cp)->cpu_m.cpu_mmu_ctxp) 193100b72f4Sandrei #define NINTR_THREADS (LOCK_LEVEL) /* number of interrupt threads */ 1949d7041eeSandrei 1957c478bd9Sstevel@tonic-gate /* 1967c478bd9Sstevel@tonic-gate * Macro to access the "cpu private" data structure. 1977c478bd9Sstevel@tonic-gate */ 1987c478bd9Sstevel@tonic-gate #define CPU_PRIVATE(cp) ((cp)->cpu_m.cpu_private) 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate /* 2017c478bd9Sstevel@tonic-gate * The OpenBoot Standalone Interface supplies the kernel with 2027c478bd9Sstevel@tonic-gate * implementation dependent parameters through the devinfo/property mechanism 2037c478bd9Sstevel@tonic-gate */ 2047c478bd9Sstevel@tonic-gate #define MAXSYSNAME 20 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate /* 2077c478bd9Sstevel@tonic-gate * Used to indicate busy/idle state of a cpu. 2087c478bd9Sstevel@tonic-gate * msram field will be set with ECACHE_CPU_MIRROR if we are on 2097c478bd9Sstevel@tonic-gate * mirrored sram module. 2107c478bd9Sstevel@tonic-gate */ 2117c478bd9Sstevel@tonic-gate #define ECACHE_CPU_IDLE 0x0 /* CPU is idle */ 2127c478bd9Sstevel@tonic-gate #define ECACHE_CPU_BUSY 0x1 /* CPU is busy */ 2137c478bd9Sstevel@tonic-gate #define ECACHE_CPU_MIRROR 0x2 /* E$ is mirrored */ 2147c478bd9Sstevel@tonic-gate #define ECACHE_CPU_NON_MIRROR 0x3 /* E$ is not mirrored */ 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate /* 2177c478bd9Sstevel@tonic-gate * A CPU FRU FMRI string minus the unum component. 2187c478bd9Sstevel@tonic-gate */ 2197c478bd9Sstevel@tonic-gate #define CPU_FRU_FMRI FM_FMRI_SCHEME_HC":///" \ 2207c478bd9Sstevel@tonic-gate FM_FMRI_LEGACY_HC"=" 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate struct cpu_node { 2237c478bd9Sstevel@tonic-gate char name[MAXSYSNAME]; 2247c478bd9Sstevel@tonic-gate char fru_fmri[sizeof (CPU_FRU_FMRI) + UNUM_NAMLEN]; 2257c478bd9Sstevel@tonic-gate int cpuid; 226fa9e4066Sahrens pnode_t nodeid; 2277c478bd9Sstevel@tonic-gate uint64_t clock_freq; 2287c478bd9Sstevel@tonic-gate uint_t tick_nsec_scale; 2297c478bd9Sstevel@tonic-gate union { 2307c478bd9Sstevel@tonic-gate int dummy; 2317c478bd9Sstevel@tonic-gate } u_info; 2327c478bd9Sstevel@tonic-gate int ecache_size; 2337c478bd9Sstevel@tonic-gate int ecache_linesize; 2347c478bd9Sstevel@tonic-gate int ecache_associativity; 2357c478bd9Sstevel@tonic-gate int ecache_setsize; 2367c478bd9Sstevel@tonic-gate uint64_t device_id; 2371ae08745Sheppo id_t exec_unit_mapping; 238fb2f18f8Sesaxe id_t fpu_mapping; 23959ac0c16Sdavemq id_t l2_cache_mapping; 24059ac0c16Sdavemq id_t core_mapping; 2417c478bd9Sstevel@tonic-gate }; 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate extern struct cpu_node cpunodes[]; 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate #endif /* _ASM */ 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2487c478bd9Sstevel@tonic-gate } 2497c478bd9Sstevel@tonic-gate #endif 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate #endif /* _SYS_MACHCPUVAR_H */ 252