xref: /illumos-gate/usr/src/uts/i86pc/sys/prom_debug.h (revision fdcca78f421670bb8f04d68bc3f2762a4b5342be)
1*fdcca78fSJoshua M. Clulow /*
2*fdcca78fSJoshua M. Clulow  * This file and its contents are supplied under the terms of the
3*fdcca78fSJoshua M. Clulow  * Common Development and Distribution License ("CDDL"), version 1.0.
4*fdcca78fSJoshua M. Clulow  * You may only use this file in accordance with the terms of version
5*fdcca78fSJoshua M. Clulow  * 1.0 of the CDDL.
6*fdcca78fSJoshua M. Clulow  *
7*fdcca78fSJoshua M. Clulow  * A full copy of the text of the CDDL should have accompanied this
8*fdcca78fSJoshua M. Clulow  * source.  A copy of the CDDL is also available via the Internet at
9*fdcca78fSJoshua M. Clulow  * http://www.illumos.org/license/CDDL.
10*fdcca78fSJoshua M. Clulow  */
11*fdcca78fSJoshua M. Clulow 
12*fdcca78fSJoshua M. Clulow /*
13*fdcca78fSJoshua M. Clulow  * Copyright 2020 Oxide Computer Company
14*fdcca78fSJoshua M. Clulow  */
15*fdcca78fSJoshua M. Clulow 
16*fdcca78fSJoshua M. Clulow #ifndef _SYS_PROM_DEBUG_H
17*fdcca78fSJoshua M. Clulow #define	_SYS_PROM_DEBUG_H
18*fdcca78fSJoshua M. Clulow 
19*fdcca78fSJoshua M. Clulow #include <sys/promif.h>
20*fdcca78fSJoshua M. Clulow 
21*fdcca78fSJoshua M. Clulow /*
22*fdcca78fSJoshua M. Clulow  * These macros are used to emit coarse-grained early boot debugging
23*fdcca78fSJoshua M. Clulow  * information when the user sets "prom_debug" in the boot environment.  They
24*fdcca78fSJoshua M. Clulow  * should only be used for information that we cannot easily obtain through a
25*fdcca78fSJoshua M. Clulow  * richer mechanism because the machine hangs or crashes before other debugging
26*fdcca78fSJoshua M. Clulow  * tools are available.
27*fdcca78fSJoshua M. Clulow  */
28*fdcca78fSJoshua M. Clulow 
29*fdcca78fSJoshua M. Clulow #ifdef __cplusplus
30*fdcca78fSJoshua M. Clulow extern "C" {
31*fdcca78fSJoshua M. Clulow #endif
32*fdcca78fSJoshua M. Clulow 
33*fdcca78fSJoshua M. Clulow extern int prom_debug;
34*fdcca78fSJoshua M. Clulow 
35*fdcca78fSJoshua M. Clulow /*
36*fdcca78fSJoshua M. Clulow  * Print a string message, used to signal that we have at least reached a
37*fdcca78fSJoshua M. Clulow  * particular point in the code:
38*fdcca78fSJoshua M. Clulow  */
39*fdcca78fSJoshua M. Clulow #define	PRM_POINT(q)	do {						\
40*fdcca78fSJoshua M. Clulow 		if (prom_debug) {					\
41*fdcca78fSJoshua M. Clulow 			prom_printf("%s:%d: %s\n",			\
42*fdcca78fSJoshua M. Clulow 			    __FILE__, __LINE__, (q));			\
43*fdcca78fSJoshua M. Clulow 		}							\
44*fdcca78fSJoshua M. Clulow 	} while (0)
45*fdcca78fSJoshua M. Clulow 
46*fdcca78fSJoshua M. Clulow /*
47*fdcca78fSJoshua M. Clulow  * Print the name and value of an integer variable:
48*fdcca78fSJoshua M. Clulow  */
49*fdcca78fSJoshua M. Clulow #define	PRM_DEBUG(q)	do {						\
50*fdcca78fSJoshua M. Clulow 		if (prom_debug) {					\
51*fdcca78fSJoshua M. Clulow 			prom_printf("%s:%d: '%s' is 0x%llx\n",		\
52*fdcca78fSJoshua M. Clulow 			    __FILE__, __LINE__, #q, (long long)(q));	\
53*fdcca78fSJoshua M. Clulow 		}							\
54*fdcca78fSJoshua M. Clulow 	} while (0)
55*fdcca78fSJoshua M. Clulow 
56*fdcca78fSJoshua M. Clulow /*
57*fdcca78fSJoshua M. Clulow  * Print the name and value of a string (char *) variable (which may be NULL):
58*fdcca78fSJoshua M. Clulow  */
59*fdcca78fSJoshua M. Clulow #define	PRM_DEBUGS(q)	do {						\
60*fdcca78fSJoshua M. Clulow 		if (prom_debug) {					\
61*fdcca78fSJoshua M. Clulow 			const char *qq = q;				\
62*fdcca78fSJoshua M. Clulow 			prom_printf("%s:%d: '%s' is '%s'\n",		\
63*fdcca78fSJoshua M. Clulow 			    __FILE__, __LINE__, #q,			\
64*fdcca78fSJoshua M. Clulow 			    qq != NULL ? qq : "<NULL>");		\
65*fdcca78fSJoshua M. Clulow 		}							\
66*fdcca78fSJoshua M. Clulow 	} while (0)
67*fdcca78fSJoshua M. Clulow 
68*fdcca78fSJoshua M. Clulow #ifdef __cplusplus
69*fdcca78fSJoshua M. Clulow }
70*fdcca78fSJoshua M. Clulow #endif
71*fdcca78fSJoshua M. Clulow 
72*fdcca78fSJoshua M. Clulow #endif /* _SYS_PROM_DEBUG_H */
73