17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bdstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bdstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bdstevel@tonic-gate * with the License.
87c478bdstevel@tonic-gate *
97c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bdstevel@tonic-gate * See the License for the specific language governing permissions
127c478bdstevel@tonic-gate * and limitations under the License.
137c478bdstevel@tonic-gate *
147c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bdstevel@tonic-gate *
207c478bdstevel@tonic-gate * CDDL HEADER END
217c478bdstevel@tonic-gate */
227c478bdstevel@tonic-gate/*
237c478bdstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bdstevel@tonic-gate * Use is subject to license terms.
257c478bdstevel@tonic-gate */
267c478bdstevel@tonic-gate
277c478bdstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
287c478bdstevel@tonic-gate
297c478bdstevel@tonic-gate/*
307c478bdstevel@tonic-gate * genconst generates datamodel-independent constants.  Such constants
317c478bdstevel@tonic-gate * are enum values and constants defined via preprocessor macros.
327c478bdstevel@tonic-gate * Under no circumstances should this program generate structure size
337c478bdstevel@tonic-gate * or structure member offset information, those belong in offsets.in.
347c478bdstevel@tonic-gate */
357c478bdstevel@tonic-gate
367c478bdstevel@tonic-gate#ifndef	_GENASSYM
377c478bdstevel@tonic-gate#define	_GENASSYM
387c478bdstevel@tonic-gate#endif
397c478bdstevel@tonic-gate
407c478bdstevel@tonic-gate/*
417c478bdstevel@tonic-gate * This user program uses the kernel header files and the kernel prototype
427c478bdstevel@tonic-gate * for "exit" isn't appropriate for programs linked against libc so exit
437c478bdstevel@tonic-gate * is mapped to kern_exit by the preprocessor and an appropriate exit
447c478bdstevel@tonic-gate * prototype is provided after the header files are included.
457c478bdstevel@tonic-gate */
467c478bdstevel@tonic-gate#define	exit	kern_exit
477c478bdstevel@tonic-gate
487c478bdstevel@tonic-gate#include <sys/types.h>
497c478bdstevel@tonic-gate#include <sys/param.h>
507c478bdstevel@tonic-gate#include <sys/elf_notes.h>
517c478bdstevel@tonic-gate#include <sys/systm.h>
527c478bdstevel@tonic-gate#include <sys/stream.h>
537c478bdstevel@tonic-gate#include <sys/strsubr.h>
547c478bdstevel@tonic-gate#include <sys/sunddi.h>
557c478bdstevel@tonic-gate#include <sys/ddi_impldefs.h>
567c478bdstevel@tonic-gate#include <sys/file.h>
577c478bdstevel@tonic-gate#include <sys/msacct.h>
587c478bdstevel@tonic-gate
597c478bdstevel@tonic-gate#include <sys/cpu.h>
607c478bdstevel@tonic-gate#include <sys/cpuvar.h>
617c478bdstevel@tonic-gate#include <sys/psr_compat.h>
627c478bdstevel@tonic-gate#include <sys/avintr.h>
637c478bdstevel@tonic-gate#include <sys/dtrace.h>
647c478bdstevel@tonic-gate
657c478bdstevel@tonic-gate#include <vm/hat.h>
667c478bdstevel@tonic-gate#include <vm/as.h>
677c478bdstevel@tonic-gate#include <vm/seg.h>
687c478bdstevel@tonic-gate
697c478bdstevel@tonic-gate#undef	exit		/* unhide exit, see comment above */
707c478bdstevel@tonic-gateextern void exit(int);
717c478bdstevel@tonic-gate
727c478bdstevel@tonic-gate/*
737c478bdstevel@tonic-gate * Proactively discourage anyone from referring to structures or
747c478bdstevel@tonic-gate * member offsets in this program.
757c478bdstevel@tonic-gate */
767c478bdstevel@tonic-gate#define	struct	struct...
777c478bdstevel@tonic-gate#define	OFFSET	OFFSET...
787c478bdstevel@tonic-gate
797c478bdstevel@tonic-gateint
807c478bdstevel@tonic-gatemain(int argc, char *argv[])
817c478bdstevel@tonic-gate{
827c478bdstevel@tonic-gate	printf("#define\tSSLEEP 0x%x\n", SSLEEP);
837c478bdstevel@tonic-gate	printf("#define\tSRUN 0x%x\n", SRUN);
847c478bdstevel@tonic-gate	printf("#define\tSONPROC 0x%x\n", SONPROC);
857c478bdstevel@tonic-gate
867c478bdstevel@tonic-gate	printf("#define\tT_INTR_THREAD %d\n", T_INTR_THREAD);
877c478bdstevel@tonic-gate	printf("#define\tTP_MSACCT 0x%x\n", TP_MSACCT);
887c478bdstevel@tonic-gate	printf("#define\tTP_WATCHPT 0x%x\n", TP_WATCHPT);
897c478bdstevel@tonic-gate	printf("#define\tTS_FREE 0x%x\n", TS_FREE);
907c478bdstevel@tonic-gate	printf("#define\tTS_ZOMB 0x%x\n", TS_ZOMB);
917c478bdstevel@tonic-gate	printf("#define\tTS_ONPROC 0x%x\n", TS_ONPROC);
927c478bdstevel@tonic-gate	printf("#define\tNSYSCALL %d\n", NSYSCALL);
937c478bdstevel@tonic-gate
947c478bdstevel@tonic-gate	printf("#define\tSE_64RVAL 0x%x\n", SE_64RVAL);
957c478bdstevel@tonic-gate	printf("#define\tSE_32RVAL1 0x%x\n", SE_32RVAL1);
967c478bdstevel@tonic-gate	printf("#define\tSE_32RVAL2 0x%x\n", SE_32RVAL2);
977c478bdstevel@tonic-gate
987c478bdstevel@tonic-gate	printf("#define\tCACHE_PAC 0x%x\n", CACHE_PAC);
997c478bdstevel@tonic-gate	printf("#define\tCACHE_VAC 0x%x\n", CACHE_VAC);
1007c478bdstevel@tonic-gate	printf("#define\tCACHE_WRITEBACK 0x%x\n", CACHE_WRITEBACK);
1017c478bdstevel@tonic-gate
1027c478bdstevel@tonic-gate	printf("#define\tS_READ 0x%x\n", S_READ);
1037c478bdstevel@tonic-gate	printf("#define\tS_WRITE 0x%x\n", S_WRITE);
1047c478bdstevel@tonic-gate	printf("#define\tS_EXEC 0x%x\n", S_EXEC);
1057c478bdstevel@tonic-gate	printf("#define\tS_OTHER 0x%x\n", S_OTHER);
1067c478bdstevel@tonic-gate
1077c478bdstevel@tonic-gate	printf("#define\tLWP_USER 0x%x\n", LWP_USER);
1087c478bdstevel@tonic-gate	printf("#define\tLWP_SYS 0x%x\n", LWP_SYS);
1097c478bdstevel@tonic-gate
1107c478bdstevel@tonic-gate	printf("#define\tLMS_USER 0x%x\n", LMS_USER);
1117c478bdstevel@tonic-gate	printf("#define\tLMS_SYSTEM 0x%x\n", LMS_SYSTEM);
1127c478bdstevel@tonic-gate
1137c478bdstevel@tonic-gate	printf("#define\tPSR_PIL_BIT %d\n", bit(PSR_PIL));
1147c478bdstevel@tonic-gate
1157c478bdstevel@tonic-gate	printf("#define\tELF_NOTE_SOLARIS \"%s\"\n", ELF_NOTE_SOLARIS);
1167c478bdstevel@tonic-gate	printf("#define\tELF_NOTE_PAGESIZE_HINT %d\n", ELF_NOTE_PAGESIZE_HINT);
1177c478bdstevel@tonic-gate
1187c478bdstevel@tonic-gate	printf("#define\tAV_INT_SPURIOUS %d\n", AV_INT_SPURIOUS);
1197c478bdstevel@tonic-gate
1207c478bdstevel@tonic-gate	printf("#define\tCPU_ENABLE %d\n", CPU_ENABLE);
1217c478bdstevel@tonic-gate	printf("#define\tCPU_READY %d\n", CPU_READY);
1227c478bdstevel@tonic-gate	printf("#define\tCPU_QUIESCED %d\n", CPU_QUIESCED);
1237c478bdstevel@tonic-gate	printf("#define\tCPU_INTRSTAT_LOW_PIL_OFFSET %d\n", (LOCK_LEVEL + 1) *
1247c478bdstevel@tonic-gate	    sizeof (uint64_t) * 2);
1257c478bdstevel@tonic-gate
1267c478bdstevel@tonic-gate	printf("#define\tCPU_DTRACE_NOFAULT 0x%x\n", CPU_DTRACE_NOFAULT);
1277c478bdstevel@tonic-gate	printf("#define\tCPU_DTRACE_BADADDR 0x%x\n", CPU_DTRACE_BADADDR);
1287c478bdstevel@tonic-gate
1297c478bdstevel@tonic-gate	printf("#define\tDMP_NOSYNC\t0x%x\n", DMP_NOSYNC);
1307c478bdstevel@tonic-gate
1317c478bdstevel@tonic-gate	printf("#define\tRW_WRITER\t0x%x\n", RW_WRITER);
1327c478bdstevel@tonic-gate	printf("#define\tRW_READER\t0x%x\n", RW_READER);
1337c478bdstevel@tonic-gate
1347c478bdstevel@tonic-gate	printf("#define\tSQ_EXCL 0x%x\n", SQ_EXCL);
1357c478bdstevel@tonic-gate	printf("#define\tSQ_BLOCKED 0x%x\n", SQ_BLOCKED);
1367c478bdstevel@tonic-gate	printf("#define\tSQ_FROZEN 0x%x\n", SQ_FROZEN);
1377c478bdstevel@tonic-gate	printf("#define\tSQ_WRITER 0x%x\n", SQ_WRITER);
1387c478bdstevel@tonic-gate	printf("#define\tSQ_QUEUED 0x%x\n", SQ_QUEUED);
1397c478bdstevel@tonic-gate	printf("#define\tSQ_WANTWAKEUP 0x%x\n", SQ_WANTWAKEUP);
1407c478bdstevel@tonic-gate	printf("#define\tSQ_WANTEXWAKEUP 0x%x\n", SQ_WANTEXWAKEUP);
1417c478bdstevel@tonic-gate	printf("#define\tSQ_CIPUT 0x%x\n", SQ_CIPUT);
1427c478bdstevel@tonic-gate	printf("#define\tSQ_TYPEMASK 0x%x\n", SQ_TYPEMASK);
1437c478bdstevel@tonic-gate	printf("#define\tSQ_GOAWAY 0x%x\n", SQ_GOAWAY);
1447c478bdstevel@tonic-gate	printf("#define\tSQ_STAYAWAY 0x%x\n", SQ_STAYAWAY);
1457c478bdstevel@tonic-gate	printf("#define\tSQ_PERMOD 0x%x\n", SQ_PERMOD);
1467c478bdstevel@tonic-gate
1477c478bdstevel@tonic-gate	printf("#define\tFKIOCTL\t0x%x\n", FKIOCTL);
1487c478bdstevel@tonic-gate	printf("#define\tLOCK_MASK\t0xff000000\n");
1497c478bdstevel@tonic-gate
1507c478bdstevel@tonic-gate	printf("#define\tDDI_DEV_NO_AUTOINCR %d\n", DDI_DEV_NO_AUTOINCR);
1517c478bdstevel@tonic-gate	printf("#define\tDDI_DEV_AUTOINCR %d\n", DDI_DEV_AUTOINCR);
1527c478bdstevel@tonic-gate
1537c478bdstevel@tonic-gate	printf("#define\tDTRACE_IDSIZE %d\n", sizeof (dtrace_id_t));
1547c478bdstevel@tonic-gate
1557c478bdstevel@tonic-gate	printf("#define\tMODS_NOUNLOAD 0x%x\n", MODS_NOUNLOAD);
1567c478bdstevel@tonic-gate	printf("#define\tMODS_WEAK 0x%x\n", MODS_WEAK);
1577c478bdstevel@tonic-gate	printf("#define\tMODS_INSTALLED 0x%x\n", MODS_INSTALLED);
1587c478bdstevel@tonic-gate
1597c478bdstevel@tonic-gate	printf("#define\tKPREEMPT_SYNC %d\n", KPREEMPT_SYNC);
1607c478bdstevel@tonic-gate	exit(0);
1617c478bdstevel@tonic-gate}
1627c478bdstevel@tonic-gate
1637c478bdstevel@tonic-gateint
1647c478bdstevel@tonic-gatebit(long mask)
1657c478bdstevel@tonic-gate{
1667c478bdstevel@tonic-gate	int i;
1677c478bdstevel@tonic-gate
1687c478bdstevel@tonic-gate	for (i = 0; i < sizeof (mask) * NBBY; i++) {
1697c478bdstevel@tonic-gate		if (mask & 1)
1707c478bdstevel@tonic-gate			return (i);
1717c478bdstevel@tonic-gate		mask >>= 1;
1727c478bdstevel@tonic-gate	}
1737c478bdstevel@tonic-gate
1747c478bdstevel@tonic-gate	exit(1);
1757c478bdstevel@tonic-gate}
176