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