xref: /illumos-gate/usr/src/cmd/mdb/common/mdb/mdb_param.h (revision 6a634c9d)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef	_MDB_PARAM_H
26 #define	_MDB_PARAM_H
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 /*
33  * mdb_param.h
34  *
35  * Support header file for mdb_ks module for module developers wishing
36  * to access macros in <sys/param.h> which expand to the current value
37  * of kernel global variables.  Developers should include <mdb/mdb_param.h>
38  * rather than <sys/param.h>.  This will arrange for the inclusion of
39  * <sys/param.h>, plus redefinition of all the macros therein to expand
40  * to the value of globals defined in mdb_ks.  The following cpp goop
41  * is necessary to get <sys/param.h> to *not* define those macros.
42  */
43 
44 #ifdef	_SYS_PARAM_H
45 #error "You should not include <sys/param.h> prior to <mdb/mdb_param.h>"
46 #endif
47 
48 #ifndef _MACHDEP
49 #define	_MACHDEP
50 
51 #ifndef _SYS_MACHPARAM_H
52 #define	_SYS_MACHPARAM_H
53 
54 /*
55  * Case 1: We defined both _MACHDEP and _SYS_MACHPARAM_H.  Undef both
56  * after we include <sys/param.h>.
57  */
58 #include <sys/param.h>
59 #undef _SYS_MACHPARAM_H
60 #undef _MACHDEP
61 
62 #else	/* _SYS_MACHPARAM_H */
63 
64 /*
65  * Case 2: We defined _MACHDEP only.
66  */
67 #include <sys/param.h>
68 #undef _MACHDEP
69 
70 #endif	/* _SYS_MACHPARAM_H */
71 #else	/* _MACHDEP */
72 
73 #ifndef _SYS_MACHPARAM_H
74 #define	_SYS_MACHPARAM_H
75 
76 /*
77  * Case 3: We defined _SYS_MACHPARAM_H.
78  */
79 #include <sys/param.h>
80 #undef _SYS_MACHPARAM_H
81 
82 #else	/* _SYS_MACHPARAM_H */
83 
84 /*
85  * Case 4: _MACHDEP and _SYS_MACHPARAM_H are both already defined.
86  */
87 #include <sys/param.h>
88 
89 #endif	/* _SYS_MACHPARAM_H */
90 #endif	/* _MACHDEP */
91 
92 /*
93  * Extern declarations for global variables defined in the mdb_ks module.
94  * All of these will be filled in during ks's _mdb_init routine.
95  */
96 extern unsigned long _mdb_ks_pagesize;
97 extern unsigned int _mdb_ks_pageshift;
98 extern unsigned long _mdb_ks_pageoffset;
99 extern unsigned long long _mdb_ks_pagemask;
100 extern unsigned long _mdb_ks_mmu_pagesize;
101 extern unsigned int _mdb_ks_mmu_pageshift;
102 extern unsigned long _mdb_ks_mmu_pageoffset;
103 extern unsigned long _mdb_ks_mmu_pagemask;
104 extern uintptr_t _mdb_ks_kernelbase;
105 extern uintptr_t _mdb_ks_userlimit;
106 extern uintptr_t _mdb_ks_userlimit32;
107 extern uintptr_t _mdb_ks_argsbase;
108 extern unsigned long _mdb_ks_msg_bsize;
109 extern unsigned long _mdb_ks_defaultstksz;
110 extern int _mdb_ks_ncpu;
111 extern int _mdb_ks_ncpu_log2;
112 extern int _mdb_ks_ncpu_p2;
113 
114 /*
115  * Now derive all the macros using the global variables defined in
116  * the support library.  These macros will in turn be referenced in
117  * other kernel macros.
118  */
119 #define	PAGESIZE	_mdb_ks_pagesize
120 #define	PAGESHIFT	_mdb_ks_pageshift
121 #define	PAGEOFFSET	_mdb_ks_pageoffset
122 #define	PAGEMASK	_mdb_ks_pagemask
123 #define	MMU_PAGESIZE	_mdb_ks_mmu_pagesize
124 #define	MMU_PAGESHIFT	_mdb_ks_mmu_pageshift
125 #define	MMU_PAGEOFFSET	_mdb_ks_mmu_pageoffset
126 #define	MMU_PAGEMASK	_mdb_ks_mmu_pagemask
127 
128 #define	KERNELBASE	_mdb_ks_kernelbase
129 #define	USERLIMIT	_mdb_ks_userlimit
130 #define	USERLIMIT32	_mdb_ks_userlimit32
131 #define	ARGSBASE	_mdb_ks_argsbase
132 #define	MSG_BSIZE	_mdb_ks_msg_bsize
133 #define	DEFAULTSTKSZ	_mdb_ks_defaultstksz
134 #define	NCPU		_mdb_ks_ncpu
135 #define	NCPU_LOG2	_mdb_ks_ncpu_log2
136 #define	NCPU_P2		_mdb_ks_ncpu_p2
137 
138 #define	_STRING_H	/* Do not re-include <string.h> */
139 
140 #ifdef	__cplusplus
141 }
142 #endif
143 
144 #endif	/* _MDB_PARAM_H */
145