xref: /illumos-gate/usr/src/cmd/mdb/common/mdb/mdb_param.h (revision 581cede61ac9c14d8d4ea452562a567189eead78)
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	_MDB_PARAM_H
28 #define	_MDB_PARAM_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * mdb_param.h
38  *
39  * Support header file for mdb_ks module for module developers wishing
40  * to access macros in <sys/param.h> which expand to the current value
41  * of kernel global variables.  Developers should include <mdb/mdb_param.h>
42  * rather than <sys/param.h>.  This will arrange for the inclusion of
43  * <sys/param.h>, plus redefinition of all the macros therein to expand
44  * to the value of globals defined in mdb_ks.  The following cpp goop
45  * is necessary to get <sys/param.h> to *not* define those macros.
46  */
47 
48 #ifdef	_SYS_PARAM_H
49 #error "You should not include <sys/param.h> prior to <mdb/mdb_param.h>"
50 #endif
51 
52 #ifndef _MACHDEP
53 #define	_MACHDEP
54 
55 #ifndef _SYS_MACHPARAM_H
56 #define	_SYS_MACHPARAM_H
57 
58 /*
59  * Case 1: We defined both _MACHDEP and _SYS_MACHPARAM_H.  Undef both
60  * after we include <sys/param.h>.
61  */
62 #include <sys/param.h>
63 #undef _SYS_MACHPARAM_H
64 #undef _MACHDEP
65 
66 #else	/* _SYS_MACHPARAM_H */
67 
68 /*
69  * Case 2: We defined _MACHDEP only.
70  */
71 #include <sys/param.h>
72 #undef _MACHDEP
73 
74 #endif	/* _SYS_MACHPARAM_H */
75 #else	/* _MACHDEP */
76 
77 #ifndef _SYS_MACHPARAM_H
78 #define	_SYS_MACHPARAM_H
79 
80 /*
81  * Case 3: We defined _SYS_MACHPARAM_H.
82  */
83 #include <sys/param.h>
84 #undef _SYS_MACHPARAM_H
85 
86 #else	/* _SYS_MACHPARAM_H */
87 
88 /*
89  * Case 4: _MACHDEP and _SYS_MACHPARAM_H are both already defined.
90  */
91 #include <sys/param.h>
92 
93 #endif	/* _SYS_MACHPARAM_H */
94 #endif	/* _MACHDEP */
95 
96 /*
97  * Extern declarations for global variables defined in the mdb_ks module.
98  * All of these will be filled in during ks's _mdb_init routine.
99  */
100 extern unsigned long _mdb_ks_pagesize;
101 extern unsigned int _mdb_ks_pageshift;
102 extern unsigned long _mdb_ks_pageoffset;
103 extern unsigned long long _mdb_ks_pagemask;
104 extern unsigned long _mdb_ks_mmu_pagesize;
105 extern unsigned int _mdb_ks_mmu_pageshift;
106 extern unsigned long _mdb_ks_mmu_pageoffset;
107 extern unsigned long _mdb_ks_mmu_pagemask;
108 extern uintptr_t _mdb_ks_kernelbase;
109 extern uintptr_t _mdb_ks_userlimit;
110 extern uintptr_t _mdb_ks_userlimit32;
111 extern uintptr_t _mdb_ks_argsbase;
112 extern unsigned long _mdb_ks_msg_bsize;
113 extern unsigned long _mdb_ks_defaultstksz;
114 extern int _mdb_ks_ncpu;
115 
116 /*
117  * Now derive all the macros using the global variables defined in
118  * the support library.  These macros will in turn be referenced in
119  * other kernel macros.
120  */
121 #define	PAGESIZE	_mdb_ks_pagesize
122 #define	PAGESHIFT	_mdb_ks_pageshift
123 #define	PAGEOFFSET	_mdb_ks_pageoffset
124 #define	PAGEMASK	_mdb_ks_pagemask
125 #define	MMU_PAGESIZE	_mdb_ks_mmu_pagesize
126 #define	MMU_PAGESHIFT	_mdb_ks_mmu_pageshift
127 #define	MMU_PAGEOFFSET	_mdb_ks_mmu_pageoffset
128 #define	MMU_PAGEMASK	_mdb_ks_mmu_pagemask
129 
130 #define	KERNELBASE	_mdb_ks_kernelbase
131 #define	USERLIMIT	_mdb_ks_userlimit
132 #define	USERLIMIT32	_mdb_ks_userlimit32
133 #define	ARGSBASE	_mdb_ks_argsbase
134 #define	MSG_BSIZE	_mdb_ks_msg_bsize
135 #define	DEFAULTSTKSZ	_mdb_ks_defaultstksz
136 #define	NCPU		_mdb_ks_ncpu
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