xref: /titanic_53/usr/src/uts/i86pc/sys/machcpuvar.h (revision 0e7515250c8395f368aa45fb9acae7c4f8f8b786)
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 /*
22*0e751525SEric Saxe  * Copyright 2009 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 #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/inttypes.h>
347c478bd9Sstevel@tonic-gate #include <sys/xc_levels.h>
357c478bd9Sstevel@tonic-gate #include <sys/tss.h>
367c478bd9Sstevel@tonic-gate #include <sys/segments.h>
377c478bd9Sstevel@tonic-gate #include <sys/rm_platter.h>
387c478bd9Sstevel@tonic-gate #include <sys/avintr.h>
397c478bd9Sstevel@tonic-gate #include <sys/pte.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #ifndef	_ASM
427c478bd9Sstevel@tonic-gate /*
43b9bc7f78Ssmaybe  * On a virtualized platform a virtual cpu may not be actually
44b9bc7f78Ssmaybe  * on a physical cpu, especially in situations where a configuration has
45b9bc7f78Ssmaybe  * more vcpus than pcpus.  This function tells us (if it's able) if the
46b9bc7f78Ssmaybe  * specified vcpu is currently running on a pcpu.  Note if it is not
47b9bc7f78Ssmaybe  * known or not able to determine, it will return the unknown state.
48b9bc7f78Ssmaybe  */
49b9bc7f78Ssmaybe #define	VCPU_STATE_UNKNOWN	0
50b9bc7f78Ssmaybe #define	VCPU_ON_PCPU		1
51b9bc7f78Ssmaybe #define	VCPU_NOT_ON_PCPU	2
52b9bc7f78Ssmaybe 
53b9bc7f78Ssmaybe extern int vcpu_on_pcpu(processorid_t);
54b9bc7f78Ssmaybe 
55b9bc7f78Ssmaybe /*
567c478bd9Sstevel@tonic-gate  * Machine specific fields of the cpu struct
577c478bd9Sstevel@tonic-gate  * defined in common/sys/cpuvar.h.
587c478bd9Sstevel@tonic-gate  *
597c478bd9Sstevel@tonic-gate  * Note:  This is kinda kludgy but seems to be the best
607c478bd9Sstevel@tonic-gate  * of our alternatives.
617c478bd9Sstevel@tonic-gate  */
627c478bd9Sstevel@tonic-gate typedef void *cpu_pri_lev_t;
637c478bd9Sstevel@tonic-gate 
647aec1d6eScindi struct cpuid_info;
652449e17fSsherrym struct cpu_ucode_info;
667c478bd9Sstevel@tonic-gate 
67843e1988Sjohnlev /*
68843e1988Sjohnlev  * A note about the hypervisor affinity bits: a one bit in the affinity mask
69843e1988Sjohnlev  * means the corresponding event channel is allowed to be serviced
70843e1988Sjohnlev  * by this cpu.
71843e1988Sjohnlev  */
72843e1988Sjohnlev struct xen_evt_data {
73843e1988Sjohnlev 	ulong_t		pending_sel[PIL_MAX + 1]; /* event array selectors */
74843e1988Sjohnlev 	ulong_t		pending_evts[PIL_MAX + 1][sizeof (ulong_t) * 8];
75843e1988Sjohnlev 	ulong_t		evt_affinity[sizeof (ulong_t) * 8]; /* service on cpu */
76843e1988Sjohnlev };
77843e1988Sjohnlev 
787c478bd9Sstevel@tonic-gate struct	machcpu {
797c478bd9Sstevel@tonic-gate 	/* define all the x_call stuff */
8027423228Ssherrym 	volatile int	xc_pend[X_CALL_LEVELS];
8127423228Ssherrym 	volatile int	xc_wait[X_CALL_LEVELS];
8227423228Ssherrym 	volatile int	xc_ack[X_CALL_LEVELS];
8327423228Ssherrym 	volatile int	xc_state[X_CALL_LEVELS];
8427423228Ssherrym 	volatile int	xc_retval[X_CALL_LEVELS];
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate 	int		mcpu_nodeid;		/* node-id */
877c478bd9Sstevel@tonic-gate 	int		mcpu_pri;		/* CPU priority */
887c478bd9Sstevel@tonic-gate 	cpu_pri_lev_t	mcpu_pri_data;		/* ptr to machine dependent */
897c478bd9Sstevel@tonic-gate 						/* data for setting priority */
907c478bd9Sstevel@tonic-gate 						/* level */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 	struct hat	*mcpu_current_hat; /* cpu's current hat */
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate 	struct hat_cpu_info	*mcpu_hat_info;
957c478bd9Sstevel@tonic-gate 
9695c0a3c8Sjosephb 	volatile ulong_t	mcpu_tlb_info;
9795c0a3c8Sjosephb 
987c478bd9Sstevel@tonic-gate 	/* i86 hardware table addresses that cannot be shared */
99ae115bc7Smrj 
1007c478bd9Sstevel@tonic-gate 	user_desc_t	*mcpu_gdt;	/* GDT */
101ae115bc7Smrj 	gate_desc_t	*mcpu_idt;	/* current IDT */
102ae115bc7Smrj 
1037c478bd9Sstevel@tonic-gate 	struct tss	*mcpu_tss;	/* TSS */
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate 	kmutex_t	mcpu_ppaddr_mutex;
1067c478bd9Sstevel@tonic-gate 	caddr_t		mcpu_caddr1;	/* per cpu CADDR1 */
1077c478bd9Sstevel@tonic-gate 	caddr_t		mcpu_caddr2;	/* per cpu CADDR2 */
108ae115bc7Smrj 	uint64_t	mcpu_caddr1pte;
109ae115bc7Smrj 	uint64_t	mcpu_caddr2pte;
110ae115bc7Smrj 
1117c478bd9Sstevel@tonic-gate 	struct softint	mcpu_softinfo;
1127c478bd9Sstevel@tonic-gate 	uint64_t	pil_high_start[HIGH_LEVELS];
1137a364d25Sschwartz 	uint64_t	intrstat[PIL_MAX + 1][2];
114ae115bc7Smrj 
1157c478bd9Sstevel@tonic-gate 	struct cpuid_info	 *mcpu_cpi;
116ae115bc7Smrj 
1177c478bd9Sstevel@tonic-gate #if defined(__amd64)
1187c478bd9Sstevel@tonic-gate 	greg_t	mcpu_rtmp_rsp;		/* syscall: temporary %rsp stash */
1197c478bd9Sstevel@tonic-gate 	greg_t	mcpu_rtmp_r15;		/* syscall: temporary %r15 stash */
1207c478bd9Sstevel@tonic-gate #endif
121ae115bc7Smrj 
122ae115bc7Smrj 	struct vcpu_info *mcpu_vcpu_info;
123843e1988Sjohnlev 	uint64_t	mcpu_gdtpa;	/* hypervisor: GDT physical address */
124ae115bc7Smrj 
125843e1988Sjohnlev 	uint16_t mcpu_intr_pending;	/* hypervisor: pending intrpt levels */
126843e1988Sjohnlev 	struct xen_evt_data *mcpu_evt_pend; /* hypervisor: pending events */
127f98fbcecSbholler 
128f98fbcecSbholler 	volatile uint32_t *mcpu_mwait;	/* MONITOR/MWAIT buffer */
129*0e751525SEric Saxe 	void (*mcpu_idle_cpu)(void);	/* idle function */
130*0e751525SEric Saxe 	uint16_t mcpu_idle_type;	/* CPU next idle type */
131*0e751525SEric Saxe 	uint16_t max_cstates;		/* supported max cstates */
132*0e751525SEric Saxe 	uint32_t curr_cstate;		/* current cstate */
1332449e17fSsherrym 
1342449e17fSsherrym 	struct cpu_ucode_info	*mcpu_ucode_info;
135*0e751525SEric Saxe 
136*0e751525SEric Saxe 	void		*mcpu_pm_mach_state;
1377c478bd9Sstevel@tonic-gate };
1387c478bd9Sstevel@tonic-gate 
139100b72f4Sandrei #define	NINTR_THREADS	(LOCK_LEVEL-1)	/* number of interrupt threads */
140f98fbcecSbholler #define	MWAIT_HALTED	(1)		/* mcpu_mwait set when halting */
141f98fbcecSbholler #define	MWAIT_RUNNING	(0)		/* mcpu_mwait set to wakeup */
142*0e751525SEric Saxe #define	MWAIT_WAKEUP_IPI	(2)	/* need IPI to wakeup */
143*0e751525SEric Saxe #define	MWAIT_WAKEUP(cpu)	(*((cpu)->cpu_m.mcpu_mwait) = MWAIT_RUNNING)
144100b72f4Sandrei 
1457c478bd9Sstevel@tonic-gate #endif	/* _ASM */
1467c478bd9Sstevel@tonic-gate 
147ae115bc7Smrj /* Please DON'T add any more of this namespace-poisoning sewage here */
148ae115bc7Smrj 
1497c478bd9Sstevel@tonic-gate #define	cpu_nodeid cpu_m.mcpu_nodeid
1507c478bd9Sstevel@tonic-gate #define	cpu_pri cpu_m.mcpu_pri
1517c478bd9Sstevel@tonic-gate #define	cpu_pri_data cpu_m.mcpu_pri_data
1527c478bd9Sstevel@tonic-gate #define	cpu_current_hat cpu_m.mcpu_current_hat
1537c478bd9Sstevel@tonic-gate #define	cpu_hat_info cpu_m.mcpu_hat_info
1547c478bd9Sstevel@tonic-gate #define	cpu_ppaddr_mutex cpu_m.mcpu_ppaddr_mutex
1557c478bd9Sstevel@tonic-gate #define	cpu_gdt cpu_m.mcpu_gdt
1567c478bd9Sstevel@tonic-gate #define	cpu_idt cpu_m.mcpu_idt
1577c478bd9Sstevel@tonic-gate #define	cpu_tss cpu_m.mcpu_tss
1587c478bd9Sstevel@tonic-gate #define	cpu_ldt cpu_m.mcpu_ldt
1597c478bd9Sstevel@tonic-gate #define	cpu_caddr1 cpu_m.mcpu_caddr1
1607c478bd9Sstevel@tonic-gate #define	cpu_caddr2 cpu_m.mcpu_caddr2
1617c478bd9Sstevel@tonic-gate #define	cpu_softinfo cpu_m.mcpu_softinfo
1627c478bd9Sstevel@tonic-gate #define	cpu_caddr1pte cpu_m.mcpu_caddr1pte
1637c478bd9Sstevel@tonic-gate #define	cpu_caddr2pte cpu_m.mcpu_caddr2pte
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1667c478bd9Sstevel@tonic-gate }
1677c478bd9Sstevel@tonic-gate #endif
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate #endif	/* _SYS_MACHCPUVAR_H */
170