xref: /illumos-gate/usr/src/uts/sun4/sys/cpu_sgnblk_defs.h (revision ed093b41a93e8563e6e1e5dae0768dda2a7bcc27)
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  * Copyright 2019 Peter Tribble.
28  */
29 
30 #ifndef	_CPU_SGNBLK_DEFS_H
31 #define	_CPU_SGNBLK_DEFS_H
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #ifndef _ASM
38 
39 #include <sys/types.h>
40 #include <sys/cpuvar.h>
41 
42 #endif /* _ASM */
43 
44 /*
45  * Build a CPU signature given a signature, state and sub-state.
46  */
47 #define	CPU_SIG_BLD(sig, state, sub_state) \
48 	(((sig) << 16) | ((state) << 8) | (sub_state))
49 
50 /*
51  * Definition of a CPU signature.
52  */
53 typedef union {
54 	struct cpu_signature {
55 		ushort_t	sig;		/* see xxxx_SIG below. */
56 		uchar_t		state;		/* see SIGBST_xxxx below. */
57 		uchar_t		sub_state;	/* EXIT_xxx if SIGBST_EXIT. */
58 	} state_t;
59 	uint32_t	signature;
60 } sig_state_t;
61 
62 /*
63  * CPU Signatures - the signature defines the entity that the CPU is executing.
64  * This entity can be the OS, OPB or the debugger.  This signature consists of
65  * two ASCII characters.
66  */
67 #define	SIG_BLD(f, s)	(((f) << 8) | (s))
68 
69 #define	OBP_SIG		SIG_BLD('O', 'B')
70 #define	OS_SIG		SIG_BLD('O', 'S')
71 #define	DBG_SIG		SIG_BLD('D', 'B')
72 #define	POST_SIG	SIG_BLD('P', 'O')
73 
74 /*
75  * CPU State - the state identifies what the CPU is doing.
76  * The states should be defined in an increasing, linear
77  * manner.
78  */
79 #define	SIGST_NONE			0
80 #define	SIGST_RUN			1
81 #define	SIGST_EXIT			2
82 #define	SIGST_PRERUN			3
83 #define	SIGST_DOMAINSTOP		4
84 #define	SIGST_RESET			5
85 #define	SIGST_POWEROFF			6
86 #define	SIGST_DETACHED			7
87 #define	SIGST_CALLBACK			8
88 #define	SIGST_OFFLINE			9
89 #define	SIGST_BOOTING			10
90 #define	SIGST_UNKNOWN			11
91 #define	SIGST_ERROR_RESET		12
92 #define	SIGST_ERROR_RESET_SYNC		13
93 #define	SIGST_QUIESCED			14
94 #define	SIGST_QUIESCE_INPROGRESS	15
95 #define	SIGST_RESUME_INPROGRESS		16
96 #define	SIGST_INIT			17
97 #define	SIGST_LOADING			18
98 
99 /*
100  *  CPU sub-state - the sub-state is used to further qualify
101  *  the state.
102  */
103 #define	SIGSUBST_NULL			0
104 #define	SIGSUBST_HALT			1
105 #define	SIGSUBST_ENVIRON		2
106 #define	SIGSUBST_REBOOT			3
107 #define	SIGSUBST_PANIC			4
108 #define	SIGSUBST_PANIC_CONT		5
109 #define	SIGSUBST_HUNG			6
110 #define	SIGSUBST_WATCH			7
111 #define	SIGSUBST_PANIC_REBOOT		8
112 #define	SIGSUBST_ERROR_RESET_REBOOT	9
113 #define	SIGSUBST_OBP_RESET		10
114 #define	SIGSUBST_DEBUG			11
115 #define	SIGSUBST_DUMP			12
116 #define	SIGSUBST_FAILED			13
117 
118 #ifdef _KERNEL
119 
120 #define	CPU_SIGNATURE(sig, state, sub_state, cpuid)			\
121 {									\
122 	if (cpu_sgn_func)						\
123 		(*cpu_sgn_func)((sig), (state), (sub_state), (cpuid));	\
124 }
125 
126 extern void (*cpu_sgn_func)(ushort_t, uchar_t, uchar_t, int);
127 
128 #endif	/* _KERNEL */
129 
130 #ifdef	__cplusplus
131 }
132 #endif
133 
134 #endif	/* _CPU_SGNBLK_DEFS_H */
135