xref: /onnv-gate/usr/src/uts/sun4v/sys/machcpuvar.h (revision 10271:7c80b70bb8de)
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 /*
22*10271SJason.Beloro@Sun.COM  * Copyright 2009 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 #include <sys/intr.h>
300Sstevel@tonic-gate #include <sys/clock.h>
310Sstevel@tonic-gate #include <sys/machparam.h>
320Sstevel@tonic-gate #include <sys/machpcb.h>
330Sstevel@tonic-gate #include <sys/privregs.h>
340Sstevel@tonic-gate #include <sys/machlock.h>
354612Srf157361 #include <sys/async.h>
364612Srf157361 #include <sys/error.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 
59357Ssvemuri typedef struct ptl1_gregs {
60357Ssvemuri 	uint64_t	ptl1_gl;
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;
68357Ssvemuri } ptl1_gregs_t;
69357Ssvemuri 
70357Ssvemuri typedef struct ptl1_regs {
71357Ssvemuri 	ptl1_trapregs_t	ptl1_trap_regs[PTL1_MAXTL];
72357Ssvemuri 	ptl1_gregs_t	ptl1_gregs[PTL1_MAXGL + 1];
730Sstevel@tonic-gate 	uint64_t	ptl1_tick;
74357Ssvemuri 	uint64_t	ptl1_dmmu_type;
75357Ssvemuri 	uint64_t	ptl1_dmmu_addr;
76357Ssvemuri 	uint64_t	ptl1_dmmu_ctx;
77357Ssvemuri 	uint64_t	ptl1_immu_type;
78357Ssvemuri 	uint64_t	ptl1_immu_addr;
79357Ssvemuri 	uint64_t	ptl1_immu_ctx;
800Sstevel@tonic-gate 	struct rwindow	ptl1_rwindow[MAXWIN];
810Sstevel@tonic-gate 	uint32_t	ptl1_softint;
820Sstevel@tonic-gate 	uint16_t	ptl1_pstate;
830Sstevel@tonic-gate 	uint8_t		ptl1_pil;
840Sstevel@tonic-gate 	uint8_t		ptl1_cwp;
850Sstevel@tonic-gate 	uint8_t		ptl1_wstate;
860Sstevel@tonic-gate 	uint8_t		ptl1_otherwin;
870Sstevel@tonic-gate 	uint8_t		ptl1_cleanwin;
880Sstevel@tonic-gate 	uint8_t		ptl1_cansave;
890Sstevel@tonic-gate 	uint8_t		ptl1_canrestore;
900Sstevel@tonic-gate } ptl1_regs_t;
910Sstevel@tonic-gate 
920Sstevel@tonic-gate typedef struct ptl1_state {
930Sstevel@tonic-gate 	ptl1_regs_t	ptl1_regs;
940Sstevel@tonic-gate 	uint32_t	ptl1_entry_count;
950Sstevel@tonic-gate 	uintptr_t	ptl1_stktop;
960Sstevel@tonic-gate 	ulong_t		ptl1_stk[1];
970Sstevel@tonic-gate } ptl1_state_t;
980Sstevel@tonic-gate 
990Sstevel@tonic-gate /*
1004732Sdavemq  * For cpu_chip and cpu_core in machcpu structure if we cannot get
1014732Sdavemq  * any chip id or core id information from MD.
1024732Sdavemq  */
1034732Sdavemq #define	CPU_CHIPID_INVALID	-1
1044732Sdavemq #define	CPU_COREID_INVALID	-1
1054769Sdp78419 #define	CPU_L2_CACHEID_INVALID	-1
1064732Sdavemq 
1074732Sdavemq /*
1080Sstevel@tonic-gate  * Machine specific fields of the cpu struct
1090Sstevel@tonic-gate  * defined in common/sys/cpuvar.h.
1100Sstevel@tonic-gate  */
1110Sstevel@tonic-gate struct	machcpu {
1120Sstevel@tonic-gate 	struct machpcb	*mpcb;
1130Sstevel@tonic-gate 	uint64_t	mpcb_pa;
1140Sstevel@tonic-gate 	int		mutex_ready;
1150Sstevel@tonic-gate 	int		in_prom;
1160Sstevel@tonic-gate 	int		tl1_hdlr;
1170Sstevel@tonic-gate 	char		cpu_tstat_flags;	/* tstat flags */
1180Sstevel@tonic-gate 	uint16_t	divisor;	/* Estar %tick clock ratio */
1190Sstevel@tonic-gate 	uint8_t		intrcnt;	/* number of back-to-back interrupts */
1200Sstevel@tonic-gate 	u_longlong_t	tmp1;		/* per-cpu tmps */
1210Sstevel@tonic-gate 	u_longlong_t	tmp2;		/*  used in trap processing */
1224127Sedp 	u_longlong_t	tmp3;
1234127Sedp 	u_longlong_t	tmp4;
1240Sstevel@tonic-gate 
1253856Svb70745 	label_t		*ofd[HIGH_LEVELS];	/* saved pil ofd */
1263856Svb70745 	uintptr_t	lfd[HIGH_LEVELS];	/* saved ret PC */
1273856Svb70745 	struct on_trap_data *otd[HIGH_LEVELS];	/* saved pil otd */
1283856Svb70745 
1292973Sgovinda 	struct intr_vec	*intr_head[PIL_LEVELS];	/* intr queue heads per pil */
1302973Sgovinda 	struct intr_vec	*intr_tail[PIL_LEVELS];	/* intr queue tails per pil */
1310Sstevel@tonic-gate 	boolean_t	poke_cpu_outstanding;
1320Sstevel@tonic-gate 	/*
1330Sstevel@tonic-gate 	 * The cpu module allocates a private data structure for the
1340Sstevel@tonic-gate 	 * E$ data, which is needed for the specific cpu type.
1350Sstevel@tonic-gate 	 */
1360Sstevel@tonic-gate 	void		*cpu_private;		/* ptr to cpu private data */
1372241Shuah 	/*
1382241Shuah 	 * per-MMU ctxdom CPU data.
1392241Shuah 	 */
1402241Shuah 	uint_t		cpu_mmu_idx;
1412241Shuah 	struct mmu_ctx	*cpu_mmu_ctxp;
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate 	ptl1_state_t	ptl1_state;
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate 	uint64_t	pil_high_start[HIGH_LEVELS];	/* high-level intrs */
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate 	/*
1480Sstevel@tonic-gate 	 * intrstat[][] is used to keep track of ticks used at a given pil
1490Sstevel@tonic-gate 	 * level. intrstat[pil][0] is cumulative and exported via kstats.
1500Sstevel@tonic-gate 	 * intrstat[pil][1] is used in intr_get_time() and is private.
1510Sstevel@tonic-gate 	 * 2-dimensional array improves cache locality.
1520Sstevel@tonic-gate 	 */
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate 	uint64_t	intrstat[PIL_MAX+1][2];
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate 	int		kwbuf_full;
1570Sstevel@tonic-gate 	caddr_t		kwbuf_sp;
1580Sstevel@tonic-gate 	struct rwindow	kwbuf;
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate 	caddr_t		cpu_q_va;	/* cpu intrq base VA */
1610Sstevel@tonic-gate 	caddr_t		dev_q_va;	/* dev intrq base VA */
1620Sstevel@tonic-gate 	uint64_t	cpu_q_base_pa;	/* cpu intrq base PA */
1630Sstevel@tonic-gate 	uint64_t	cpu_q_size;
1640Sstevel@tonic-gate 	uint64_t	dev_q_base_pa;	/* dev intrq base PA */
1650Sstevel@tonic-gate 	uint64_t	dev_q_size;
1660Sstevel@tonic-gate 	caddr_t		cpu_rq_va;	/* resumable Q base VA */
1670Sstevel@tonic-gate 	caddr_t		cpu_nrq_va;	/* nonresumable Q base VA */
1680Sstevel@tonic-gate 	uint64_t	cpu_rq_base_pa;	/* resumable Q base PA */
1690Sstevel@tonic-gate 	uint64_t	cpu_rq_size;	/* resumable Q size */
1700Sstevel@tonic-gate 	uint64_t	cpu_nrq_base_pa;	/* nonresumable Q base PA */
1710Sstevel@tonic-gate 	uint64_t	cpu_nrq_size;		/* nonresumable Q size */
1724612Srf157361 	errh_er_t	*cpu_rq_lastre;		/* most recent RE */
1734612Srf157361 	errh_er_t	*cpu_nrq_lastnre;	/* most recent NRE */
1740Sstevel@tonic-gate 	caddr_t		mondo_data;		/* send mondo data */
1750Sstevel@tonic-gate 	uint64_t	mondo_data_ra;		/* mono data pa */
1760Sstevel@tonic-gate 	uint16_t	*cpu_list;		/* uint16_t [NCPU] */
1770Sstevel@tonic-gate 	uint64_t	cpu_list_ra;		/* cpu list ra */
1783434Sesaxe 	id_t		cpu_ipipe;		/* cpu int exec unit id */
1794769Sdp78419 	id_t		cpu_mpipe;		/* cpu memory pipe id */
1803434Sesaxe 	id_t		cpu_fpu;		/* cpu fpu unit id */
1813434Sesaxe 	id_t		cpu_core;		/* cpu core id */
1824732Sdavemq 	id_t		cpu_chip;		/* cpu chip id */
183834Sandrei 	kthread_t	*startup_thread;
1840Sstevel@tonic-gate };
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate typedef	struct machcpu	machcpu_t;
1870Sstevel@tonic-gate 
188834Sandrei #define	cpu_startup_thread	cpu_m.startup_thread
1892241Shuah #define	CPU_MMU_IDX(cp)		((cp)->cpu_m.cpu_mmu_idx)
1902241Shuah #define	CPU_MMU_CTXP(cp)	((cp)->cpu_m.cpu_mmu_ctxp)
1911455Sandrei #define	NINTR_THREADS	(LOCK_LEVEL)	/* number of interrupt threads */
192834Sandrei 
1930Sstevel@tonic-gate /*
1940Sstevel@tonic-gate  * Macro to access the "cpu private" data structure.
1950Sstevel@tonic-gate  */
1960Sstevel@tonic-gate #define	CPU_PRIVATE(cp)		((cp)->cpu_m.cpu_private)
1970Sstevel@tonic-gate 
1980Sstevel@tonic-gate /*
1990Sstevel@tonic-gate  * The OpenBoot Standalone Interface supplies the kernel with
2000Sstevel@tonic-gate  * implementation dependent parameters through the devinfo/property mechanism
2010Sstevel@tonic-gate  */
2020Sstevel@tonic-gate #define	MAXSYSNAME	20
2030Sstevel@tonic-gate 
2040Sstevel@tonic-gate /*
2050Sstevel@tonic-gate  * Used to indicate busy/idle state of a cpu.
2060Sstevel@tonic-gate  * msram field will be set with ECACHE_CPU_MIRROR if we are on
2070Sstevel@tonic-gate  * mirrored sram module.
2080Sstevel@tonic-gate  */
2090Sstevel@tonic-gate #define	ECACHE_CPU_IDLE		0x0		/* CPU is idle */
2100Sstevel@tonic-gate #define	ECACHE_CPU_BUSY		0x1		/* CPU is busy */
2110Sstevel@tonic-gate #define	ECACHE_CPU_MIRROR 	0x2		/* E$ is mirrored */
2120Sstevel@tonic-gate #define	ECACHE_CPU_NON_MIRROR	0x3		/* E$ is not mirrored */
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate /*
2150Sstevel@tonic-gate  * A CPU FRU FMRI string minus the unum component.
2160Sstevel@tonic-gate  */
2170Sstevel@tonic-gate #define	CPU_FRU_FMRI		FM_FMRI_SCHEME_HC":///" \
2180Sstevel@tonic-gate     FM_FMRI_LEGACY_HC"="
2190Sstevel@tonic-gate 
2200Sstevel@tonic-gate struct cpu_node {
2210Sstevel@tonic-gate 	char	name[MAXSYSNAME];
2220Sstevel@tonic-gate 	char	fru_fmri[sizeof (CPU_FRU_FMRI) + UNUM_NAMLEN];
2230Sstevel@tonic-gate 	int	cpuid;
224789Sahrens 	pnode_t	nodeid;
2250Sstevel@tonic-gate 	uint64_t	clock_freq;
2260Sstevel@tonic-gate 	uint_t	tick_nsec_scale;
2270Sstevel@tonic-gate 	union {
2280Sstevel@tonic-gate 		int	dummy;
2290Sstevel@tonic-gate 	}	u_info;
2300Sstevel@tonic-gate 	int	ecache_size;
2310Sstevel@tonic-gate 	int	ecache_linesize;
2320Sstevel@tonic-gate 	int	ecache_associativity;
2330Sstevel@tonic-gate 	int	ecache_setsize;
2340Sstevel@tonic-gate 	uint64_t	device_id;
2351991Sheppo 	id_t	exec_unit_mapping;
2363434Sesaxe 	id_t	fpu_mapping;
2374732Sdavemq 	id_t	l2_cache_mapping;
2384732Sdavemq 	id_t	core_mapping;
2390Sstevel@tonic-gate };
2400Sstevel@tonic-gate 
2410Sstevel@tonic-gate extern struct cpu_node cpunodes[];
2420Sstevel@tonic-gate 
2430Sstevel@tonic-gate #endif	/* _ASM */
2440Sstevel@tonic-gate 
2450Sstevel@tonic-gate #ifdef	__cplusplus
2460Sstevel@tonic-gate }
2470Sstevel@tonic-gate #endif
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate #endif	/* _SYS_MACHCPUVAR_H */
250