xref: /titanic_54/usr/src/uts/sun4v/sys/machcpuvar.h (revision 70f54ead78cbbb40e97bd3ff9f175c5c71783c3c)
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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_MACHCPUVAR_H
287c478bd9Sstevel@tonic-gate #define	_SYS_MACHCPUVAR_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/intr.h>
337c478bd9Sstevel@tonic-gate #include <sys/clock.h>
347c478bd9Sstevel@tonic-gate #include <sys/machparam.h>
357c478bd9Sstevel@tonic-gate #include <sys/machpcb.h>
367c478bd9Sstevel@tonic-gate #include <sys/privregs.h>
377c478bd9Sstevel@tonic-gate #include <sys/machlock.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
407c478bd9Sstevel@tonic-gate extern "C" {
417c478bd9Sstevel@tonic-gate #endif
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #ifndef	_ASM
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h>
467c478bd9Sstevel@tonic-gate #include <sys/async.h>
477c478bd9Sstevel@tonic-gate #include <sys/fm/protocol.h>
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * CPU state ptl1_panic save.
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate typedef struct ptl1_trapregs {
537c478bd9Sstevel@tonic-gate 	uint32_t	ptl1_tl;
547c478bd9Sstevel@tonic-gate 	uint32_t	ptl1_tt;
557c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_tstate;
567c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_tpc;
577c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_tnpc;
587c478bd9Sstevel@tonic-gate } ptl1_trapregs_t;
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate typedef struct ptl1_regs {
617c478bd9Sstevel@tonic-gate 	ptl1_trapregs_t	ptl1_trap_regs[PTL1_MAXTL];
627c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g1;
637c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g2;
647c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g3;
657c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g4;
667c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g5;
677c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g6;
687c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_g7;
697c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_tick;
707c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_dmmu_sfar;
717c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_dmmu_sfsr;
727c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_dmmu_tag_access;
737c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_immu_sfsr;
747c478bd9Sstevel@tonic-gate 	uint64_t	ptl1_immu_tag_access;
757c478bd9Sstevel@tonic-gate 	struct rwindow	ptl1_rwindow[MAXWIN];
767c478bd9Sstevel@tonic-gate 	uint32_t	ptl1_softint;
777c478bd9Sstevel@tonic-gate 	uint16_t	ptl1_pstate;
787c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_pil;
797c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_cwp;
807c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_wstate;
817c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_otherwin;
827c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_cleanwin;
837c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_cansave;
847c478bd9Sstevel@tonic-gate 	uint8_t		ptl1_canrestore;
857c478bd9Sstevel@tonic-gate } ptl1_regs_t;
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate typedef struct ptl1_state {
887c478bd9Sstevel@tonic-gate 	ptl1_regs_t	ptl1_regs;
897c478bd9Sstevel@tonic-gate 	uint32_t	ptl1_entry_count;
907c478bd9Sstevel@tonic-gate 	uintptr_t	ptl1_stktop;
917c478bd9Sstevel@tonic-gate 	ulong_t		ptl1_stk[1];
927c478bd9Sstevel@tonic-gate } ptl1_state_t;
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * Machine specific fields of the cpu struct
967c478bd9Sstevel@tonic-gate  * defined in common/sys/cpuvar.h.
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate struct	machcpu {
997c478bd9Sstevel@tonic-gate 	struct machpcb	*mpcb;
1007c478bd9Sstevel@tonic-gate 	uint64_t	mpcb_pa;
1017c478bd9Sstevel@tonic-gate 	int		mutex_ready;
1027c478bd9Sstevel@tonic-gate 	int		in_prom;
1037c478bd9Sstevel@tonic-gate 	int		tl1_hdlr;
1047c478bd9Sstevel@tonic-gate 	char		cpu_tstat_flags;	/* tstat flags */
1057c478bd9Sstevel@tonic-gate 	uint16_t	divisor;	/* Estar %tick clock ratio */
1067c478bd9Sstevel@tonic-gate 	uint8_t		intrcnt;	/* number of back-to-back interrupts */
1077c478bd9Sstevel@tonic-gate 	u_longlong_t	tmp1;		/* per-cpu tmps */
1087c478bd9Sstevel@tonic-gate 	u_longlong_t	tmp2;		/*  used in trap processing */
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate 	struct intr_req intr_pool[INTR_PENDING_MAX];	/* intr pool */
1117c478bd9Sstevel@tonic-gate 	struct intr_req *intr_head[PIL_LEVELS];		/* intr que heads */
1127c478bd9Sstevel@tonic-gate 	struct intr_req *intr_tail[PIL_LEVELS];		/* intr que tails */
1137c478bd9Sstevel@tonic-gate 	int		intr_pool_added;		/* add'l intr pool */
1147c478bd9Sstevel@tonic-gate 	boolean_t	poke_cpu_outstanding;
1157c478bd9Sstevel@tonic-gate 	/*
1167c478bd9Sstevel@tonic-gate 	 * The cpu module allocates a private data structure for the
1177c478bd9Sstevel@tonic-gate 	 * E$ data, which is needed for the specific cpu type.
1187c478bd9Sstevel@tonic-gate 	 */
1197c478bd9Sstevel@tonic-gate 	void		*cpu_private;		/* ptr to cpu private data */
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate 	ptl1_state_t	ptl1_state;
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate 	uint64_t	pil_high_start[HIGH_LEVELS];	/* high-level intrs */
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate 	/*
1267c478bd9Sstevel@tonic-gate 	 * intrstat[][] is used to keep track of ticks used at a given pil
1277c478bd9Sstevel@tonic-gate 	 * level. intrstat[pil][0] is cumulative and exported via kstats.
1287c478bd9Sstevel@tonic-gate 	 * intrstat[pil][1] is used in intr_get_time() and is private.
1297c478bd9Sstevel@tonic-gate 	 * 2-dimensional array improves cache locality.
1307c478bd9Sstevel@tonic-gate 	 */
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate 	uint64_t	intrstat[PIL_MAX+1][2];
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate 	int		kwbuf_full;
1357c478bd9Sstevel@tonic-gate 	caddr_t		kwbuf_sp;
1367c478bd9Sstevel@tonic-gate 	struct rwindow	kwbuf;
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate 	caddr_t		cpu_q_va;	/* cpu intrq base VA */
1397c478bd9Sstevel@tonic-gate 	caddr_t		dev_q_va;	/* dev intrq base VA */
1407c478bd9Sstevel@tonic-gate 	uint64_t	cpu_q_base_pa;	/* cpu intrq base PA */
1417c478bd9Sstevel@tonic-gate 	uint64_t	cpu_q_size;
1427c478bd9Sstevel@tonic-gate 	uint64_t	dev_q_base_pa;	/* dev intrq base PA */
1437c478bd9Sstevel@tonic-gate 	uint64_t	dev_q_size;
1447c478bd9Sstevel@tonic-gate 	caddr_t		cpu_rq_va;	/* resumable Q base VA */
1457c478bd9Sstevel@tonic-gate 	caddr_t		cpu_nrq_va;	/* nonresumable Q base VA */
1467c478bd9Sstevel@tonic-gate 	uint64_t	cpu_rq_base_pa;	/* resumable Q base PA */
1477c478bd9Sstevel@tonic-gate 	uint64_t	cpu_rq_size;	/* resumable Q size */
1487c478bd9Sstevel@tonic-gate 	uint64_t	cpu_nrq_base_pa;	/* nonresumable Q base PA */
1497c478bd9Sstevel@tonic-gate 	uint64_t	cpu_nrq_size;		/* nonresumable Q size */
1507c478bd9Sstevel@tonic-gate 	caddr_t		mondo_data;		/* send mondo data */
1517c478bd9Sstevel@tonic-gate 	uint64_t	mondo_data_ra;		/* mono data pa */
1527c478bd9Sstevel@tonic-gate 	uint16_t	*cpu_list;		/* uint16_t [NCPU] */
1537c478bd9Sstevel@tonic-gate 	uint64_t	cpu_list_ra;		/* cpu list ra */
154*70f54eadSesaxe 	id_t		cpu_ipipe;		/* cpu exec unit id */
1557c478bd9Sstevel@tonic-gate };
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate typedef	struct machcpu	machcpu_t;
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate /*
1607c478bd9Sstevel@tonic-gate  * Macro to access the "cpu private" data structure.
1617c478bd9Sstevel@tonic-gate  */
1627c478bd9Sstevel@tonic-gate #define	CPU_PRIVATE(cp)		((cp)->cpu_m.cpu_private)
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate /*
1657c478bd9Sstevel@tonic-gate  * The OpenBoot Standalone Interface supplies the kernel with
1667c478bd9Sstevel@tonic-gate  * implementation dependent parameters through the devinfo/property mechanism
1677c478bd9Sstevel@tonic-gate  */
1687c478bd9Sstevel@tonic-gate #define	MAXSYSNAME	20
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate /*
1717c478bd9Sstevel@tonic-gate  * Used to indicate busy/idle state of a cpu.
1727c478bd9Sstevel@tonic-gate  * msram field will be set with ECACHE_CPU_MIRROR if we are on
1737c478bd9Sstevel@tonic-gate  * mirrored sram module.
1747c478bd9Sstevel@tonic-gate  */
1757c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_IDLE		0x0		/* CPU is idle */
1767c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_BUSY		0x1		/* CPU is busy */
1777c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_MIRROR 	0x2		/* E$ is mirrored */
1787c478bd9Sstevel@tonic-gate #define	ECACHE_CPU_NON_MIRROR	0x3		/* E$ is not mirrored */
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate /*
1817c478bd9Sstevel@tonic-gate  * A CPU FRU FMRI string minus the unum component.
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate #define	CPU_FRU_FMRI		FM_FMRI_SCHEME_HC":///" \
1847c478bd9Sstevel@tonic-gate     FM_FMRI_LEGACY_HC"="
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate struct cpu_node {
1877c478bd9Sstevel@tonic-gate 	char	name[MAXSYSNAME];
1887c478bd9Sstevel@tonic-gate 	char	fru_fmri[sizeof (CPU_FRU_FMRI) + UNUM_NAMLEN];
1897c478bd9Sstevel@tonic-gate 	int	cpuid;
1907c478bd9Sstevel@tonic-gate 	dnode_t	nodeid;
1917c478bd9Sstevel@tonic-gate 	uint64_t	clock_freq;
1927c478bd9Sstevel@tonic-gate 	uint_t	tick_nsec_scale;
1937c478bd9Sstevel@tonic-gate 	union {
1947c478bd9Sstevel@tonic-gate 		int	dummy;
1957c478bd9Sstevel@tonic-gate 	}	u_info;
1967c478bd9Sstevel@tonic-gate 	int	ecache_size;
1977c478bd9Sstevel@tonic-gate 	int	ecache_linesize;
1987c478bd9Sstevel@tonic-gate 	int	ecache_associativity;
1997c478bd9Sstevel@tonic-gate 	int	ecache_setsize;
2007c478bd9Sstevel@tonic-gate 	uint64_t	device_id;
2017c478bd9Sstevel@tonic-gate };
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate extern struct cpu_node cpunodes[];
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate #endif	/* _ASM */
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2087c478bd9Sstevel@tonic-gate }
2097c478bd9Sstevel@tonic-gate #endif
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate #endif	/* _SYS_MACHCPUVAR_H */
212