xref: /illumos-gate/usr/src/uts/sun4/sys/cpu_sgnblk_defs.h (revision 5e989a96186a37eb528fb7bb4d28a150874ec799)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_CPU_SGNBLK_DEFS_H
28 #define	_CPU_SGNBLK_DEFS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #ifndef _ASM
37 
38 #include <sys/types.h>
39 #include <sys/cpuvar.h>
40 
41 #endif /* _ASM */
42 
43 /*
44  * Build a CPU signature given a signature, state and sub-state.
45  */
46 #define	CPU_SIG_BLD(sig, state, sub_state) \
47 	(((sig) << 16) | ((state) << 8) | (sub_state))
48 
49 /*
50  * Definition of a CPU signature.
51  */
52 typedef union {
53 	struct cpu_signature {
54 		ushort_t	sig;		/* see xxxx_SIG below. */
55 		uchar_t		state;		/* see SIGBST_xxxx below. */
56 		uchar_t		sub_state;	/* EXIT_xxx if SIGBST_EXIT. */
57 	} state_t;
58 	uint32_t	signature;
59 } sig_state_t;
60 
61 /*
62  * CPU Signatures - the signature defines the entity that the CPU is executing.
63  * This entity can be the OS, OPB or the debugger.  This signature consists of
64  * two ASCII characters.
65  */
66 #define	SIG_BLD(f, s)	(((f) << 8) | (s))
67 
68 #define	OBP_SIG		SIG_BLD('O', 'B')
69 #define	OS_SIG		SIG_BLD('O', 'S')
70 #define	DBG_SIG		SIG_BLD('D', 'B')
71 #define	POST_SIG	SIG_BLD('P', 'O')
72 
73 /*
74  * CPU State - the state identifies what the CPU is doing.
75  * The states should be defined in an increasing, linear
76  * manner.
77  */
78 #define	SIGST_NONE			0
79 #define	SIGST_RUN			1
80 #define	SIGST_EXIT			2
81 #define	SIGST_PRERUN			3
82 #define	SIGST_DOMAINSTOP		4
83 #define	SIGST_RESET			5
84 #define	SIGST_POWEROFF			6
85 #define	SIGST_DETACHED			7
86 #define	SIGST_CALLBACK			8
87 #define	SIGST_OFFLINE			9
88 #define	SIGST_BOOTING			10
89 #define	SIGST_UNKNOWN			11
90 #define	SIGST_ERROR_RESET		12
91 #define	SIGST_ERROR_RESET_SYNC		13
92 #define	SIGST_QUIESCED			14
93 #define	SIGST_QUIESCE_INPROGRESS	15
94 #define	SIGST_RESUME_INPROGRESS		16
95 #define	SIGST_INIT			17
96 #define	SIGST_LOADING			18
97 
98 /*
99  *  CPU sub-state - the sub-state is used to further qualify
100  *  the state.
101  */
102 #define	SIGSUBST_NULL			0
103 #define	SIGSUBST_HALT			1
104 #define	SIGSUBST_ENVIRON		2
105 #define	SIGSUBST_REBOOT			3
106 #define	SIGSUBST_PANIC			4
107 #define	SIGSUBST_PANIC_CONT		5
108 #define	SIGSUBST_HUNG			6
109 #define	SIGSUBST_WATCH			7
110 #define	SIGSUBST_PANIC_REBOOT		8
111 #define	SIGSUBST_ERROR_RESET_REBOOT	9
112 #define	SIGSUBST_OBP_RESET		10
113 #define	SIGSUBST_DEBUG			11
114 #define	SIGSUBST_DUMP			12
115 #define	SIGSUBST_FAILED			13
116 
117 #ifdef _KERNEL
118 
119 #define	CPU_SIGNATURE(sig, state, sub_state, cpuid)			\
120 {									\
121 	if (cpu_sgn_func)						\
122 		(*cpu_sgn_func)((sig), (state), (sub_state), (cpuid));	\
123 }
124 
125 extern void (*cpu_sgn_func)(ushort_t, uchar_t, uchar_t, int);
126 
127 
128 
129 #ifdef _STARFIRE
130 
131 extern void register_bbus_intr();
132 extern void cpu_sgn_mapin(int);
133 extern void cpu_sgn_mapout(int);
134 extern int cpu_sgn_exists(int);
135 extern ushort_t get_cpu_sgn(int);
136 extern uchar_t get_cpu_sgn_state(int);
137 
138 #define	REGISTER_BBUS_INTR()	register_bbus_intr()
139 #define	CPU_SGN_MAPIN(cpuid)	cpu_sgn_mapin(cpuid)
140 #define	CPU_SGN_MAPOUT(cpuid)	cpu_sgn_mapout(cpuid)
141 #define	CPU_SGN_EXISTS(cpuid)	cpu_sgn_exists(cpuid)
142 #define	SGN_CPU_IS_OS(cpuid)	(get_cpu_sgn(cpuid) == OS_SIG)
143 #define	SGN_CPU_IS_OBP(cpuid)	(get_cpu_sgn(cpuid) == OBP_SIG)
144 #define	SGN_CPU_STATE_IS_DETACHED(cpuid)	\
145 				(get_cpu_sgn_state(cpuid) == SIGST_DETACHED)
146 
147 #else
148 
149 #define	REGISTER_BBUS_INTR()
150 #define	CPU_SGN_MAPIN(cpuid)
151 #define	CPU_SGN_MAPOUT(cpuid)
152 #define	CPU_SGN_EXISTS(cpuid)	(0)
153 #define	SGN_CPU_IS_OS(cpuid)	(0)
154 #define	SGN_CPU_IS_OBP(cpuid)	(0)
155 #define	SGN_CPU_STATE_IS_DETACHED(cpuid)	(0)
156 
157 #endif	/* _STARFIRE */
158 
159 #endif	/* _KERNEL */
160 
161 #ifdef	__cplusplus
162 }
163 #endif
164 
165 #endif	/* _CPU_SGNBLK_DEFS_H */
166