xref: /illumos-gate/usr/src/uts/sun4/ml/genconst.c (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate /*
30*7c478bd9Sstevel@tonic-gate  * genconst generates datamodel-independent constants.  Such constants
31*7c478bd9Sstevel@tonic-gate  * are enum values and constants defined via preprocessor macros.
32*7c478bd9Sstevel@tonic-gate  * Under no circumstances should this program generate structure size
33*7c478bd9Sstevel@tonic-gate  * or structure member offset information, those belong in offsets.in.
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #ifndef	_GENASSYM
37*7c478bd9Sstevel@tonic-gate #define	_GENASSYM
38*7c478bd9Sstevel@tonic-gate #endif
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate /*
41*7c478bd9Sstevel@tonic-gate  * This user program uses the kernel header files and the kernel prototype
42*7c478bd9Sstevel@tonic-gate  * for "exit" isn't appropriate for programs linked against libc so exit
43*7c478bd9Sstevel@tonic-gate  * is mapped to kern_exit by the preprocessor and an appropriate exit
44*7c478bd9Sstevel@tonic-gate  * prototype is provided after the header files are included.
45*7c478bd9Sstevel@tonic-gate  */
46*7c478bd9Sstevel@tonic-gate #define	exit	kern_exit
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
49*7c478bd9Sstevel@tonic-gate #include <sys/param.h>
50*7c478bd9Sstevel@tonic-gate #include <sys/elf_notes.h>
51*7c478bd9Sstevel@tonic-gate #include <sys/systm.h>
52*7c478bd9Sstevel@tonic-gate #include <sys/stream.h>
53*7c478bd9Sstevel@tonic-gate #include <sys/strsubr.h>
54*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
55*7c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
56*7c478bd9Sstevel@tonic-gate #include <sys/file.h>
57*7c478bd9Sstevel@tonic-gate #include <sys/msacct.h>
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate #include <sys/cpu.h>
60*7c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h>
61*7c478bd9Sstevel@tonic-gate #include <sys/psr_compat.h>
62*7c478bd9Sstevel@tonic-gate #include <sys/avintr.h>
63*7c478bd9Sstevel@tonic-gate #include <sys/dtrace.h>
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate #include <vm/hat.h>
66*7c478bd9Sstevel@tonic-gate #include <vm/as.h>
67*7c478bd9Sstevel@tonic-gate #include <vm/seg.h>
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate #undef	exit		/* unhide exit, see comment above */
70*7c478bd9Sstevel@tonic-gate extern void exit(int);
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate /*
73*7c478bd9Sstevel@tonic-gate  * Proactively discourage anyone from referring to structures or
74*7c478bd9Sstevel@tonic-gate  * member offsets in this program.
75*7c478bd9Sstevel@tonic-gate  */
76*7c478bd9Sstevel@tonic-gate #define	struct	struct...
77*7c478bd9Sstevel@tonic-gate #define	OFFSET	OFFSET...
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate int
main(int argc,char * argv[])80*7c478bd9Sstevel@tonic-gate main(int argc, char *argv[])
81*7c478bd9Sstevel@tonic-gate {
82*7c478bd9Sstevel@tonic-gate 	printf("#define\tSSLEEP 0x%x\n", SSLEEP);
83*7c478bd9Sstevel@tonic-gate 	printf("#define\tSRUN 0x%x\n", SRUN);
84*7c478bd9Sstevel@tonic-gate 	printf("#define\tSONPROC 0x%x\n", SONPROC);
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate 	printf("#define\tT_INTR_THREAD %d\n", T_INTR_THREAD);
87*7c478bd9Sstevel@tonic-gate 	printf("#define\tTP_MSACCT 0x%x\n", TP_MSACCT);
88*7c478bd9Sstevel@tonic-gate 	printf("#define\tTP_WATCHPT 0x%x\n", TP_WATCHPT);
89*7c478bd9Sstevel@tonic-gate 	printf("#define\tTS_FREE 0x%x\n", TS_FREE);
90*7c478bd9Sstevel@tonic-gate 	printf("#define\tTS_ZOMB 0x%x\n", TS_ZOMB);
91*7c478bd9Sstevel@tonic-gate 	printf("#define\tTS_ONPROC 0x%x\n", TS_ONPROC);
92*7c478bd9Sstevel@tonic-gate 	printf("#define\tNSYSCALL %d\n", NSYSCALL);
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate 	printf("#define\tSE_64RVAL 0x%x\n", SE_64RVAL);
95*7c478bd9Sstevel@tonic-gate 	printf("#define\tSE_32RVAL1 0x%x\n", SE_32RVAL1);
96*7c478bd9Sstevel@tonic-gate 	printf("#define\tSE_32RVAL2 0x%x\n", SE_32RVAL2);
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate 	printf("#define\tCACHE_PAC 0x%x\n", CACHE_PAC);
99*7c478bd9Sstevel@tonic-gate 	printf("#define\tCACHE_VAC 0x%x\n", CACHE_VAC);
100*7c478bd9Sstevel@tonic-gate 	printf("#define\tCACHE_WRITEBACK 0x%x\n", CACHE_WRITEBACK);
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate 	printf("#define\tS_READ 0x%x\n", S_READ);
103*7c478bd9Sstevel@tonic-gate 	printf("#define\tS_WRITE 0x%x\n", S_WRITE);
104*7c478bd9Sstevel@tonic-gate 	printf("#define\tS_EXEC 0x%x\n", S_EXEC);
105*7c478bd9Sstevel@tonic-gate 	printf("#define\tS_OTHER 0x%x\n", S_OTHER);
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate 	printf("#define\tLWP_USER 0x%x\n", LWP_USER);
108*7c478bd9Sstevel@tonic-gate 	printf("#define\tLWP_SYS 0x%x\n", LWP_SYS);
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate 	printf("#define\tLMS_USER 0x%x\n", LMS_USER);
111*7c478bd9Sstevel@tonic-gate 	printf("#define\tLMS_SYSTEM 0x%x\n", LMS_SYSTEM);
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate 	printf("#define\tPSR_PIL_BIT %d\n", bit(PSR_PIL));
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate 	printf("#define\tELF_NOTE_SOLARIS \"%s\"\n", ELF_NOTE_SOLARIS);
116*7c478bd9Sstevel@tonic-gate 	printf("#define\tELF_NOTE_PAGESIZE_HINT %d\n", ELF_NOTE_PAGESIZE_HINT);
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate 	printf("#define\tAV_INT_SPURIOUS %d\n", AV_INT_SPURIOUS);
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate 	printf("#define\tCPU_ENABLE %d\n", CPU_ENABLE);
121*7c478bd9Sstevel@tonic-gate 	printf("#define\tCPU_READY %d\n", CPU_READY);
122*7c478bd9Sstevel@tonic-gate 	printf("#define\tCPU_QUIESCED %d\n", CPU_QUIESCED);
123*7c478bd9Sstevel@tonic-gate 	printf("#define\tCPU_INTRSTAT_LOW_PIL_OFFSET %d\n", (LOCK_LEVEL + 1) *
124*7c478bd9Sstevel@tonic-gate 	    sizeof (uint64_t) * 2);
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate 	printf("#define\tCPU_DTRACE_NOFAULT 0x%x\n", CPU_DTRACE_NOFAULT);
127*7c478bd9Sstevel@tonic-gate 	printf("#define\tCPU_DTRACE_BADADDR 0x%x\n", CPU_DTRACE_BADADDR);
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate 	printf("#define\tDMP_NOSYNC\t0x%x\n", DMP_NOSYNC);
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate 	printf("#define\tRW_WRITER\t0x%x\n", RW_WRITER);
132*7c478bd9Sstevel@tonic-gate 	printf("#define\tRW_READER\t0x%x\n", RW_READER);
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_EXCL 0x%x\n", SQ_EXCL);
135*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_BLOCKED 0x%x\n", SQ_BLOCKED);
136*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_FROZEN 0x%x\n", SQ_FROZEN);
137*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_WRITER 0x%x\n", SQ_WRITER);
138*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_QUEUED 0x%x\n", SQ_QUEUED);
139*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_WANTWAKEUP 0x%x\n", SQ_WANTWAKEUP);
140*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_WANTEXWAKEUP 0x%x\n", SQ_WANTEXWAKEUP);
141*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_CIPUT 0x%x\n", SQ_CIPUT);
142*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_TYPEMASK 0x%x\n", SQ_TYPEMASK);
143*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_GOAWAY 0x%x\n", SQ_GOAWAY);
144*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_STAYAWAY 0x%x\n", SQ_STAYAWAY);
145*7c478bd9Sstevel@tonic-gate 	printf("#define\tSQ_PERMOD 0x%x\n", SQ_PERMOD);
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate 	printf("#define\tFKIOCTL\t0x%x\n", FKIOCTL);
148*7c478bd9Sstevel@tonic-gate 	printf("#define\tLOCK_MASK\t0xff000000\n");
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate 	printf("#define\tDDI_DEV_NO_AUTOINCR %d\n", DDI_DEV_NO_AUTOINCR);
151*7c478bd9Sstevel@tonic-gate 	printf("#define\tDDI_DEV_AUTOINCR %d\n", DDI_DEV_AUTOINCR);
152*7c478bd9Sstevel@tonic-gate 
153*7c478bd9Sstevel@tonic-gate 	printf("#define\tDTRACE_IDSIZE %d\n", sizeof (dtrace_id_t));
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate 	printf("#define\tMODS_NOUNLOAD 0x%x\n", MODS_NOUNLOAD);
156*7c478bd9Sstevel@tonic-gate 	printf("#define\tMODS_WEAK 0x%x\n", MODS_WEAK);
157*7c478bd9Sstevel@tonic-gate 	printf("#define\tMODS_INSTALLED 0x%x\n", MODS_INSTALLED);
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate 	printf("#define\tKPREEMPT_SYNC %d\n", KPREEMPT_SYNC);
160*7c478bd9Sstevel@tonic-gate 	exit(0);
161*7c478bd9Sstevel@tonic-gate }
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate int
bit(long mask)164*7c478bd9Sstevel@tonic-gate bit(long mask)
165*7c478bd9Sstevel@tonic-gate {
166*7c478bd9Sstevel@tonic-gate 	int i;
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (mask) * NBBY; i++) {
169*7c478bd9Sstevel@tonic-gate 		if (mask & 1)
170*7c478bd9Sstevel@tonic-gate 			return (i);
171*7c478bd9Sstevel@tonic-gate 		mask >>= 1;
172*7c478bd9Sstevel@tonic-gate 	}
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate 	exit(1);
175*7c478bd9Sstevel@tonic-gate }
176