xref: /illumos-gate/usr/src/uts/sun4u/sys/machcpuvar.h (revision 4a75c0c1)
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 /*
2226046578Svb  * 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>
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 
597c478bd9Sstevel@tonic-gate typedef struct ptl1_regs {
607c478bd9Sstevel@tonic-gate 	ptl1_trapregs_t	ptl1_trap_regs[PTL1_MAXTL];
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;
687c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_tick;
697c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_dmmu_sfar;
707c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_dmmu_sfsr;
717c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_dmmu_tag_access;
727c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_immu_sfsr;
737c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_immu_tag_access;
747c478bd9Sstevel@tonic-gate 	struct rwindow	ptl1_rwindow[MAXWIN];
757c478bd9Sstevel@tonic-gate 	uint32_t	ptl1_softint;
767c478bd9Sstevel@tonic-gate 	uint16_t	ptl1_pstate;
777c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_pil;
787c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_cwp;
797c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_wstate;
807c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_otherwin;
817c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_cleanwin;
827c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_cansave;
837c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_canrestore;
847c478bd9Sstevel@tonic-gate } ptl1_regs_t;
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate typedef struct ptl1_state {
877c478bd9Sstevel@tonic-gate 	ptl1_regs_t	ptl1_regs;
887c478bd9Sstevel@tonic-gate 	uint32_t	ptl1_entry_count;
897c478bd9Sstevel@tonic-gate 	uintptr_t	ptl1_stktop;
907c478bd9Sstevel@tonic-gate 	ulong_t		ptl1_stk[1];
917c478bd9Sstevel@tonic-gate } ptl1_state_t;
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /*
947c478bd9Sstevel@tonic-gate  * Machine specific fields of the cpu struct
957c478bd9Sstevel@tonic-gate  * defined in common/sys/cpuvar.h.
967c478bd9Sstevel@tonic-gate  */
977c478bd9Sstevel@tonic-gate struct	machcpu {
987c478bd9Sstevel@tonic-gate 	struct machpcb	*mpcb;
997c478bd9Sstevel@tonic-gate 	uint64_t	mpcb_pa;
1007c478bd9Sstevel@tonic-gate 	int		mutex_ready;
1017c478bd9Sstevel@tonic-gate 	int		in_prom;
1027c478bd9Sstevel@tonic-gate 	int		tl1_hdlr;
1037c478bd9Sstevel@tonic-gate 	uint16_t	divisor;	/* Estar %tick clock ratio */
1047c478bd9Sstevel@tonic-gate 	uint8_t		intrcnt;	/* number of back-to-back interrupts */
1057c478bd9Sstevel@tonic-gate 	u_longlong_t	tmp1;		/* per-cpu tmps */
1067c478bd9Sstevel@tonic-gate 	u_longlong_t	tmp2;		/*  used in trap processing */
107*4a75c0c1Sedp 	u_longlong_t	tmp3;
108*4a75c0c1Sedp 	u_longlong_t	tmp4;
1097c478bd9Sstevel@tonic-gate 
11026046578Svb 	label_t		*ofd[HIGH_LEVELS];	/* saved pil ofd */
11126046578Svb 	uintptr_t	lfd[HIGH_LEVELS];	/* saved ret PC */
11226046578Svb 	struct on_trap_data *otd[HIGH_LEVELS];	/* saved pil otd */
11326046578Svb 
114b0fc0e77Sgovinda 	struct intr_vec	*intr_head[PIL_LEVELS];	/* intr queue heads per pil */
115b0fc0e77Sgovinda 	struct intr_vec	*intr_tail[PIL_LEVELS];	/* intr queue tails per pil */
1167c478bd9Sstevel@tonic-gate 	boolean_t	poke_cpu_outstanding;
1177c478bd9Sstevel@tonic-gate 	/*
1187c478bd9Sstevel@tonic-gate 	 * The cpu module allocates a private data structure for the
1197c478bd9Sstevel@tonic-gate 	 * E$ data, which is needed for the specific cpu type.
1207c478bd9Sstevel@tonic-gate 	 */
1217c478bd9Sstevel@tonic-gate 	void		*cpu_private;		/* ptr to cpu private data */
1221e2e7a75Shuah 	/*
1231e2e7a75Shuah 	 * per-MMU ctxdom CPU data.
1241e2e7a75Shuah 	 */
1251e2e7a75Shuah 	uint_t		cpu_mmu_idx;
1261e2e7a75Shuah 	struct mmu_ctx	*cpu_mmu_ctxp;
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate 	ptl1_state_t	ptl1_state;
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 	uint64_t	pil_high_start[HIGH_LEVELS];	/* high-level intrs */
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate 	/*
1337c478bd9Sstevel@tonic-gate 	 * intrstat[][] is used to keep track of ticks used at a given pil
1347c478bd9Sstevel@tonic-gate 	 * level. intrstat[pil][0] is cumulative and exported via kstats.
1357c478bd9Sstevel@tonic-gate 	 * intrstat[pil][1] is used in intr_get_time() and is private.
1367c478bd9Sstevel@tonic-gate 	 * 2-dimensional array improves cache locality.
1377c478bd9Sstevel@tonic-gate 	 */
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate 	uint64_t	intrstat[PIL_MAX+1][2];
1409d7041eeSandrei 	kthread_t	*startup_thread;
1417c478bd9Sstevel@tonic-gate };
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate typedef	struct machcpu	machcpu_t;
1447c478bd9Sstevel@tonic-gate 
1459d7041eeSandrei #define	cpu_startup_thread	cpu_m.startup_thread
1461e2e7a75Shuah #define	CPU_MMU_IDX(cp)		((cp)->cpu_m.cpu_mmu_idx)
1471e2e7a75Shuah #define	CPU_MMU_CTXP(cp)	((cp)->cpu_m.cpu_mmu_ctxp)
148100b72f4Sandrei #define	NINTR_THREADS	(LOCK_LEVEL)	/* number of interrupt threads */
1499d7041eeSandrei 
1507c478bd9Sstevel@tonic-gate /*
1517c478bd9Sstevel@tonic-gate  * Macro to access the "cpu private" data structure.
1527c478bd9Sstevel@tonic-gate  */
1537c478bd9Sstevel@tonic-gate #define	CPU_PRIVATE(cp)		((cp)->cpu_m.cpu_private)
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate /*
1567c478bd9Sstevel@tonic-gate  * The OpenBoot Standalone Interface supplies the kernel with
1577c478bd9Sstevel@tonic-gate  * implementation dependent parameters through the devinfo/property mechanism
1587c478bd9Sstevel@tonic-gate  */
1597c478bd9Sstevel@tonic-gate #define	MAXSYSNAME	20
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate /*
1627c478bd9Sstevel@tonic-gate  * Used to indicate busy/idle state of a cpu.
1637c478bd9Sstevel@tonic-gate  * msram field will be set with ECACHE_CPU_MIRROR if we are on
1647c478bd9Sstevel@tonic-gate  * mirrored sram module.
1657c478bd9Sstevel@tonic-gate  */
1667c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_IDLE		0x0		/* CPU is idle */
1677c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_BUSY		0x1		/* CPU is busy */
1687c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_MIRROR 	0x2		/* E$ is mirrored */
1697c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_NON_MIRROR	0x3		/* E$ is not mirrored */
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate /*
1727c478bd9Sstevel@tonic-gate  * A CPU FRU FMRI string minus the unum component.
1737c478bd9Sstevel@tonic-gate  */
1747c478bd9Sstevel@tonic-gate #define	CPU_FRU_FMRI		FM_FMRI_SCHEME_HC":///" \
1757c478bd9Sstevel@tonic-gate     FM_FMRI_LEGACY_HC"="
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate struct cpu_node {
1787c478bd9Sstevel@tonic-gate 	char	name[MAXSYSNAME];
1797c478bd9Sstevel@tonic-gate 	char	fru_fmri[sizeof (CPU_FRU_FMRI) + UNUM_NAMLEN];
1807c478bd9Sstevel@tonic-gate 	int	implementation;
1817c478bd9Sstevel@tonic-gate 	int	version;
1827c478bd9Sstevel@tonic-gate 	int	portid;
183fa9e4066Sahrens 	pnode_t	nodeid;
1847c478bd9Sstevel@tonic-gate 	uint64_t	clock_freq;
1857c478bd9Sstevel@tonic-gate 	uint_t	tick_nsec_scale;
1867c478bd9Sstevel@tonic-gate 	union {
1877c478bd9Sstevel@tonic-gate 		int	dummy;
1887c478bd9Sstevel@tonic-gate 	}	u_info;
1897c478bd9Sstevel@tonic-gate 	int	ecache_size;
1907c478bd9Sstevel@tonic-gate 	int	ecache_linesize;
1917c478bd9Sstevel@tonic-gate 	int	ecache_associativity;
1927c478bd9Sstevel@tonic-gate 	int	ecache_setsize;
1937c478bd9Sstevel@tonic-gate 	ushort_t	itlb_size;
1947c478bd9Sstevel@tonic-gate 	ushort_t	dtlb_size;
1957c478bd9Sstevel@tonic-gate 	int	msram;
1967c478bd9Sstevel@tonic-gate 	uint64_t	device_id;
1977c478bd9Sstevel@tonic-gate };
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate extern struct cpu_node cpunodes[];
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate #endif	/* _ASM */
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2047c478bd9Sstevel@tonic-gate }
2057c478bd9Sstevel@tonic-gate #endif
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate #endif	/* _SYS_MACHCPUVAR_H */
208