xref: /onnv-gate/usr/src/uts/sun4v/sys/machcpuvar.h (revision 1455:b43f098fa50c)
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
5*1455Sandrei  * Common Development and Distribution License (the "License").
6*1455Sandrei  * 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*1455Sandrei  * Copyright 2006 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 
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 /*
1000Sstevel@tonic-gate  * Machine specific fields of the cpu struct
1010Sstevel@tonic-gate  * defined in common/sys/cpuvar.h.
1020Sstevel@tonic-gate  */
1030Sstevel@tonic-gate struct	machcpu {
1040Sstevel@tonic-gate 	struct machpcb	*mpcb;
1050Sstevel@tonic-gate 	uint64_t	mpcb_pa;
1060Sstevel@tonic-gate 	int		mutex_ready;
1070Sstevel@tonic-gate 	int		in_prom;
1080Sstevel@tonic-gate 	int		tl1_hdlr;
1090Sstevel@tonic-gate 	char		cpu_tstat_flags;	/* tstat flags */
1100Sstevel@tonic-gate 	uint16_t	divisor;	/* Estar %tick clock ratio */
1110Sstevel@tonic-gate 	uint8_t		intrcnt;	/* number of back-to-back interrupts */
1120Sstevel@tonic-gate 	u_longlong_t	tmp1;		/* per-cpu tmps */
1130Sstevel@tonic-gate 	u_longlong_t	tmp2;		/*  used in trap processing */
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate 	struct intr_req intr_pool[INTR_PENDING_MAX];	/* intr pool */
1160Sstevel@tonic-gate 	struct intr_req *intr_head[PIL_LEVELS];		/* intr que heads */
1170Sstevel@tonic-gate 	struct intr_req *intr_tail[PIL_LEVELS];		/* intr que tails */
1180Sstevel@tonic-gate 	int		intr_pool_added;		/* add'l intr pool */
1190Sstevel@tonic-gate 	boolean_t	poke_cpu_outstanding;
1200Sstevel@tonic-gate 	/*
1210Sstevel@tonic-gate 	 * The cpu module allocates a private data structure for the
1220Sstevel@tonic-gate 	 * E$ data, which is needed for the specific cpu type.
1230Sstevel@tonic-gate 	 */
1240Sstevel@tonic-gate 	void		*cpu_private;		/* ptr to cpu private data */
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate 	ptl1_state_t	ptl1_state;
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate 	uint64_t	pil_high_start[HIGH_LEVELS];	/* high-level intrs */
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate 	/*
1310Sstevel@tonic-gate 	 * intrstat[][] is used to keep track of ticks used at a given pil
1320Sstevel@tonic-gate 	 * level. intrstat[pil][0] is cumulative and exported via kstats.
1330Sstevel@tonic-gate 	 * intrstat[pil][1] is used in intr_get_time() and is private.
1340Sstevel@tonic-gate 	 * 2-dimensional array improves cache locality.
1350Sstevel@tonic-gate 	 */
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate 	uint64_t	intrstat[PIL_MAX+1][2];
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate 	int		kwbuf_full;
1400Sstevel@tonic-gate 	caddr_t		kwbuf_sp;
1410Sstevel@tonic-gate 	struct rwindow	kwbuf;
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate 	caddr_t		cpu_q_va;	/* cpu intrq base VA */
1440Sstevel@tonic-gate 	caddr_t		dev_q_va;	/* dev intrq base VA */
1450Sstevel@tonic-gate 	uint64_t	cpu_q_base_pa;	/* cpu intrq base PA */
1460Sstevel@tonic-gate 	uint64_t	cpu_q_size;
1470Sstevel@tonic-gate 	uint64_t	dev_q_base_pa;	/* dev intrq base PA */
1480Sstevel@tonic-gate 	uint64_t	dev_q_size;
1490Sstevel@tonic-gate 	caddr_t		cpu_rq_va;	/* resumable Q base VA */
1500Sstevel@tonic-gate 	caddr_t		cpu_nrq_va;	/* nonresumable Q base VA */
1510Sstevel@tonic-gate 	uint64_t	cpu_rq_base_pa;	/* resumable Q base PA */
1520Sstevel@tonic-gate 	uint64_t	cpu_rq_size;	/* resumable Q size */
1530Sstevel@tonic-gate 	uint64_t	cpu_nrq_base_pa;	/* nonresumable Q base PA */
1540Sstevel@tonic-gate 	uint64_t	cpu_nrq_size;		/* nonresumable Q size */
1550Sstevel@tonic-gate 	caddr_t		mondo_data;		/* send mondo data */
1560Sstevel@tonic-gate 	uint64_t	mondo_data_ra;		/* mono data pa */
1570Sstevel@tonic-gate 	uint16_t	*cpu_list;		/* uint16_t [NCPU] */
1580Sstevel@tonic-gate 	uint64_t	cpu_list_ra;		/* cpu list ra */
159220Sesaxe 	id_t		cpu_ipipe;		/* cpu exec unit id */
160834Sandrei 	kthread_t	*startup_thread;
1610Sstevel@tonic-gate };
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate typedef	struct machcpu	machcpu_t;
1640Sstevel@tonic-gate 
165834Sandrei #define	cpu_startup_thread	cpu_m.startup_thread
166*1455Sandrei #define	NINTR_THREADS	(LOCK_LEVEL)	/* number of interrupt threads */
167834Sandrei 
1680Sstevel@tonic-gate /*
1690Sstevel@tonic-gate  * Macro to access the "cpu private" data structure.
1700Sstevel@tonic-gate  */
1710Sstevel@tonic-gate #define	CPU_PRIVATE(cp)		((cp)->cpu_m.cpu_private)
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate /*
1740Sstevel@tonic-gate  * The OpenBoot Standalone Interface supplies the kernel with
1750Sstevel@tonic-gate  * implementation dependent parameters through the devinfo/property mechanism
1760Sstevel@tonic-gate  */
1770Sstevel@tonic-gate #define	MAXSYSNAME	20
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate /*
1800Sstevel@tonic-gate  * Used to indicate busy/idle state of a cpu.
1810Sstevel@tonic-gate  * msram field will be set with ECACHE_CPU_MIRROR if we are on
1820Sstevel@tonic-gate  * mirrored sram module.
1830Sstevel@tonic-gate  */
1840Sstevel@tonic-gate #define	ECACHE_CPU_IDLE		0x0		/* CPU is idle */
1850Sstevel@tonic-gate #define	ECACHE_CPU_BUSY		0x1		/* CPU is busy */
1860Sstevel@tonic-gate #define	ECACHE_CPU_MIRROR 	0x2		/* E$ is mirrored */
1870Sstevel@tonic-gate #define	ECACHE_CPU_NON_MIRROR	0x3		/* E$ is not mirrored */
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate /*
1900Sstevel@tonic-gate  * A CPU FRU FMRI string minus the unum component.
1910Sstevel@tonic-gate  */
1920Sstevel@tonic-gate #define	CPU_FRU_FMRI		FM_FMRI_SCHEME_HC":///" \
1930Sstevel@tonic-gate     FM_FMRI_LEGACY_HC"="
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate struct cpu_node {
1960Sstevel@tonic-gate 	char	name[MAXSYSNAME];
1970Sstevel@tonic-gate 	char	fru_fmri[sizeof (CPU_FRU_FMRI) + UNUM_NAMLEN];
1980Sstevel@tonic-gate 	int	cpuid;
199789Sahrens 	pnode_t	nodeid;
2000Sstevel@tonic-gate 	uint64_t	clock_freq;
2010Sstevel@tonic-gate 	uint_t	tick_nsec_scale;
2020Sstevel@tonic-gate 	union {
2030Sstevel@tonic-gate 		int	dummy;
2040Sstevel@tonic-gate 	}	u_info;
2050Sstevel@tonic-gate 	int	ecache_size;
2060Sstevel@tonic-gate 	int	ecache_linesize;
2070Sstevel@tonic-gate 	int	ecache_associativity;
2080Sstevel@tonic-gate 	int	ecache_setsize;
2090Sstevel@tonic-gate 	uint64_t	device_id;
2100Sstevel@tonic-gate };
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate extern struct cpu_node cpunodes[];
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate #endif	/* _ASM */
2150Sstevel@tonic-gate 
2160Sstevel@tonic-gate #ifdef	__cplusplus
2170Sstevel@tonic-gate }
2180Sstevel@tonic-gate #endif
2190Sstevel@tonic-gate 
2200Sstevel@tonic-gate #endif	/* _SYS_MACHCPUVAR_H */
221