xref: /titanic_44/usr/src/uts/sun4v/sys/machcpuvar.h (revision 9d0d62ad2e60e8f742a2e723d06e88352ee6a1f3)
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*9d0d62adSJason Beloro  * 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 #include <sys/intr.h>
307c478bd9Sstevel@tonic-gate #include <sys/clock.h>
317c478bd9Sstevel@tonic-gate #include <sys/machparam.h>
327c478bd9Sstevel@tonic-gate #include <sys/machpcb.h>
337c478bd9Sstevel@tonic-gate #include <sys/privregs.h>
347c478bd9Sstevel@tonic-gate #include <sys/machlock.h>
35a60fc142Srf157361 #include <sys/async.h>
36a60fc142Srf157361 #include <sys/error.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
397c478bd9Sstevel@tonic-gate extern "C" {
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifndef	_ASM
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h>
457c478bd9Sstevel@tonic-gate #include <sys/async.h>
467c478bd9Sstevel@tonic-gate #include <sys/fm/protocol.h>
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * CPU state ptl1_panic save.
507c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate typedef struct ptl1_trapregs {
527c478bd9Sstevel@tonic-gate 	uint32_t	ptl1_tl;
537c478bd9Sstevel@tonic-gate 	uint32_t	ptl1_tt;
547c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_tstate;
557c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_tpc;
567c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_tnpc;
577c478bd9Sstevel@tonic-gate } ptl1_trapregs_t;
587c478bd9Sstevel@tonic-gate 
5949a230e1Ssvemuri typedef struct ptl1_gregs {
6049a230e1Ssvemuri 	uint64_t	ptl1_gl;
617c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g1;
627c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g2;
637c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g3;
647c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g4;
657c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g5;
667c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g6;
677c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g7;
6849a230e1Ssvemuri } ptl1_gregs_t;
6949a230e1Ssvemuri 
7049a230e1Ssvemuri typedef struct ptl1_regs {
7149a230e1Ssvemuri 	ptl1_trapregs_t	ptl1_trap_regs[PTL1_MAXTL];
7249a230e1Ssvemuri 	ptl1_gregs_t	ptl1_gregs[PTL1_MAXGL + 1];
737c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_tick;
7449a230e1Ssvemuri 	uint64_t	ptl1_dmmu_type;
7549a230e1Ssvemuri 	uint64_t	ptl1_dmmu_addr;
7649a230e1Ssvemuri 	uint64_t	ptl1_dmmu_ctx;
7749a230e1Ssvemuri 	uint64_t	ptl1_immu_type;
7849a230e1Ssvemuri 	uint64_t	ptl1_immu_addr;
7949a230e1Ssvemuri 	uint64_t	ptl1_immu_ctx;
807c478bd9Sstevel@tonic-gate 	struct rwindow	ptl1_rwindow[MAXWIN];
817c478bd9Sstevel@tonic-gate 	uint32_t	ptl1_softint;
827c478bd9Sstevel@tonic-gate 	uint16_t	ptl1_pstate;
837c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_pil;
847c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_cwp;
857c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_wstate;
867c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_otherwin;
877c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_cleanwin;
887c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_cansave;
897c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_canrestore;
907c478bd9Sstevel@tonic-gate } ptl1_regs_t;
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate typedef struct ptl1_state {
937c478bd9Sstevel@tonic-gate 	ptl1_regs_t	ptl1_regs;
947c478bd9Sstevel@tonic-gate 	uint32_t	ptl1_entry_count;
957c478bd9Sstevel@tonic-gate 	uintptr_t	ptl1_stktop;
967c478bd9Sstevel@tonic-gate 	ulong_t		ptl1_stk[1];
977c478bd9Sstevel@tonic-gate } ptl1_state_t;
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate /*
10059ac0c16Sdavemq  * For cpu_chip and cpu_core in machcpu structure if we cannot get
10159ac0c16Sdavemq  * any chip id or core id information from MD.
10259ac0c16Sdavemq  */
10359ac0c16Sdavemq #define	CPU_CHIPID_INVALID	-1
10459ac0c16Sdavemq #define	CPU_COREID_INVALID	-1
105ce8eb11aSdp78419 #define	CPU_L2_CACHEID_INVALID	-1
10659ac0c16Sdavemq 
10759ac0c16Sdavemq /*
1087c478bd9Sstevel@tonic-gate  * Machine specific fields of the cpu struct
1097c478bd9Sstevel@tonic-gate  * defined in common/sys/cpuvar.h.
1107c478bd9Sstevel@tonic-gate  */
1117c478bd9Sstevel@tonic-gate struct	machcpu {
1127c478bd9Sstevel@tonic-gate 	struct machpcb	*mpcb;
1137c478bd9Sstevel@tonic-gate 	uint64_t	mpcb_pa;
1147c478bd9Sstevel@tonic-gate 	int		mutex_ready;
1157c478bd9Sstevel@tonic-gate 	int		in_prom;
1167c478bd9Sstevel@tonic-gate 	int		tl1_hdlr;
1177c478bd9Sstevel@tonic-gate 	char		cpu_tstat_flags;	/* tstat flags */
1187c478bd9Sstevel@tonic-gate 	uint16_t	divisor;	/* Estar %tick clock ratio */
1197c478bd9Sstevel@tonic-gate 	uint8_t		intrcnt;	/* number of back-to-back interrupts */
1207c478bd9Sstevel@tonic-gate 	u_longlong_t	tmp1;		/* per-cpu tmps */
1217c478bd9Sstevel@tonic-gate 	u_longlong_t	tmp2;		/*  used in trap processing */
1224a75c0c1Sedp 	u_longlong_t	tmp3;
1234a75c0c1Sedp 	u_longlong_t	tmp4;
1247c478bd9Sstevel@tonic-gate 
12526046578Svb70745 	label_t		*ofd[HIGH_LEVELS];	/* saved pil ofd */
12626046578Svb70745 	uintptr_t	lfd[HIGH_LEVELS];	/* saved ret PC */
12726046578Svb70745 	struct on_trap_data *otd[HIGH_LEVELS];	/* saved pil otd */
12826046578Svb70745 
129b0fc0e77Sgovinda 	struct intr_vec	*intr_head[PIL_LEVELS];	/* intr queue heads per pil */
130b0fc0e77Sgovinda 	struct intr_vec	*intr_tail[PIL_LEVELS];	/* intr queue tails per pil */
1317c478bd9Sstevel@tonic-gate 	boolean_t	poke_cpu_outstanding;
1327c478bd9Sstevel@tonic-gate 	/*
1337c478bd9Sstevel@tonic-gate 	 * The cpu module allocates a private data structure for the
1347c478bd9Sstevel@tonic-gate 	 * E$ data, which is needed for the specific cpu type.
1357c478bd9Sstevel@tonic-gate 	 */
1367c478bd9Sstevel@tonic-gate 	void		*cpu_private;		/* ptr to cpu private data */
1371e2e7a75Shuah 	/*
1381e2e7a75Shuah 	 * per-MMU ctxdom CPU data.
1391e2e7a75Shuah 	 */
1401e2e7a75Shuah 	uint_t		cpu_mmu_idx;
1411e2e7a75Shuah 	struct mmu_ctx	*cpu_mmu_ctxp;
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate 	ptl1_state_t	ptl1_state;
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate 	uint64_t	pil_high_start[HIGH_LEVELS];	/* high-level intrs */
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 	/*
1487c478bd9Sstevel@tonic-gate 	 * intrstat[][] is used to keep track of ticks used at a given pil
1497c478bd9Sstevel@tonic-gate 	 * level. intrstat[pil][0] is cumulative and exported via kstats.
1507c478bd9Sstevel@tonic-gate 	 * intrstat[pil][1] is used in intr_get_time() and is private.
1517c478bd9Sstevel@tonic-gate 	 * 2-dimensional array improves cache locality.
1527c478bd9Sstevel@tonic-gate 	 */
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate 	uint64_t	intrstat[PIL_MAX+1][2];
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate 	int		kwbuf_full;
1577c478bd9Sstevel@tonic-gate 	caddr_t		kwbuf_sp;
1587c478bd9Sstevel@tonic-gate 	struct rwindow	kwbuf;
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate 	caddr_t		cpu_q_va;	/* cpu intrq base VA */
1617c478bd9Sstevel@tonic-gate 	caddr_t		dev_q_va;	/* dev intrq base VA */
1627c478bd9Sstevel@tonic-gate 	uint64_t	cpu_q_base_pa;	/* cpu intrq base PA */
1637c478bd9Sstevel@tonic-gate 	uint64_t	cpu_q_size;
1647c478bd9Sstevel@tonic-gate 	uint64_t	dev_q_base_pa;	/* dev intrq base PA */
1657c478bd9Sstevel@tonic-gate 	uint64_t	dev_q_size;
1667c478bd9Sstevel@tonic-gate 	caddr_t		cpu_rq_va;	/* resumable Q base VA */
1677c478bd9Sstevel@tonic-gate 	caddr_t		cpu_nrq_va;	/* nonresumable Q base VA */
1687c478bd9Sstevel@tonic-gate 	uint64_t	cpu_rq_base_pa;	/* resumable Q base PA */
1697c478bd9Sstevel@tonic-gate 	uint64_t	cpu_rq_size;	/* resumable Q size */
1707c478bd9Sstevel@tonic-gate 	uint64_t	cpu_nrq_base_pa;	/* nonresumable Q base PA */
1717c478bd9Sstevel@tonic-gate 	uint64_t	cpu_nrq_size;		/* nonresumable Q size */
172a60fc142Srf157361 	errh_er_t	*cpu_rq_lastre;		/* most recent RE */
173a60fc142Srf157361 	errh_er_t	*cpu_nrq_lastnre;	/* most recent NRE */
1747c478bd9Sstevel@tonic-gate 	caddr_t		mondo_data;		/* send mondo data */
1757c478bd9Sstevel@tonic-gate 	uint64_t	mondo_data_ra;		/* mono data pa */
1767c478bd9Sstevel@tonic-gate 	uint16_t	*cpu_list;		/* uint16_t [NCPU] */
1777c478bd9Sstevel@tonic-gate 	uint64_t	cpu_list_ra;		/* cpu list ra */
178fb2f18f8Sesaxe 	id_t		cpu_ipipe;		/* cpu int exec unit id */
179ce8eb11aSdp78419 	id_t		cpu_mpipe;		/* cpu memory pipe id */
180fb2f18f8Sesaxe 	id_t		cpu_fpu;		/* cpu fpu unit id */
181fb2f18f8Sesaxe 	id_t		cpu_core;		/* cpu core id */
18259ac0c16Sdavemq 	id_t		cpu_chip;		/* cpu chip id */
1839d7041eeSandrei 	kthread_t	*startup_thread;
1847c478bd9Sstevel@tonic-gate };
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate typedef	struct machcpu	machcpu_t;
1877c478bd9Sstevel@tonic-gate 
1889d7041eeSandrei #define	cpu_startup_thread	cpu_m.startup_thread
1891e2e7a75Shuah #define	CPU_MMU_IDX(cp)		((cp)->cpu_m.cpu_mmu_idx)
1901e2e7a75Shuah #define	CPU_MMU_CTXP(cp)	((cp)->cpu_m.cpu_mmu_ctxp)
191100b72f4Sandrei #define	NINTR_THREADS	(LOCK_LEVEL)	/* number of interrupt threads */
1929d7041eeSandrei 
1937c478bd9Sstevel@tonic-gate /*
1947c478bd9Sstevel@tonic-gate  * Macro to access the "cpu private" data structure.
1957c478bd9Sstevel@tonic-gate  */
1967c478bd9Sstevel@tonic-gate #define	CPU_PRIVATE(cp)		((cp)->cpu_m.cpu_private)
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate /*
1997c478bd9Sstevel@tonic-gate  * The OpenBoot Standalone Interface supplies the kernel with
2007c478bd9Sstevel@tonic-gate  * implementation dependent parameters through the devinfo/property mechanism
2017c478bd9Sstevel@tonic-gate  */
2027c478bd9Sstevel@tonic-gate #define	MAXSYSNAME	20
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate /*
2057c478bd9Sstevel@tonic-gate  * Used to indicate busy/idle state of a cpu.
2067c478bd9Sstevel@tonic-gate  * msram field will be set with ECACHE_CPU_MIRROR if we are on
2077c478bd9Sstevel@tonic-gate  * mirrored sram module.
2087c478bd9Sstevel@tonic-gate  */
2097c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_IDLE		0x0		/* CPU is idle */
2107c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_BUSY		0x1		/* CPU is busy */
2117c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_MIRROR 	0x2		/* E$ is mirrored */
2127c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_NON_MIRROR	0x3		/* E$ is not mirrored */
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate /*
2157c478bd9Sstevel@tonic-gate  * A CPU FRU FMRI string minus the unum component.
2167c478bd9Sstevel@tonic-gate  */
2177c478bd9Sstevel@tonic-gate #define	CPU_FRU_FMRI		FM_FMRI_SCHEME_HC":///" \
2187c478bd9Sstevel@tonic-gate     FM_FMRI_LEGACY_HC"="
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate struct cpu_node {
2217c478bd9Sstevel@tonic-gate 	char	name[MAXSYSNAME];
2227c478bd9Sstevel@tonic-gate 	char	fru_fmri[sizeof (CPU_FRU_FMRI) + UNUM_NAMLEN];
2237c478bd9Sstevel@tonic-gate 	int	cpuid;
224fa9e4066Sahrens 	pnode_t	nodeid;
2257c478bd9Sstevel@tonic-gate 	uint64_t	clock_freq;
2267c478bd9Sstevel@tonic-gate 	uint_t	tick_nsec_scale;
2277c478bd9Sstevel@tonic-gate 	union {
2287c478bd9Sstevel@tonic-gate 		int	dummy;
2297c478bd9Sstevel@tonic-gate 	}	u_info;
2307c478bd9Sstevel@tonic-gate 	int	ecache_size;
2317c478bd9Sstevel@tonic-gate 	int	ecache_linesize;
2327c478bd9Sstevel@tonic-gate 	int	ecache_associativity;
2337c478bd9Sstevel@tonic-gate 	int	ecache_setsize;
2347c478bd9Sstevel@tonic-gate 	uint64_t	device_id;
2351ae08745Sheppo 	id_t	exec_unit_mapping;
236fb2f18f8Sesaxe 	id_t	fpu_mapping;
23759ac0c16Sdavemq 	id_t	l2_cache_mapping;
23859ac0c16Sdavemq 	id_t	core_mapping;
2397c478bd9Sstevel@tonic-gate };
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate extern struct cpu_node cpunodes[];
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate #endif	/* _ASM */
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2467c478bd9Sstevel@tonic-gate }
2477c478bd9Sstevel@tonic-gate #endif
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate #endif	/* _SYS_MACHCPUVAR_H */
250