xref: /original-bsd/sys/hp300/hp300/genassym.c (revision 1e29b3fc)
1 /*
2  * Copyright (c) 1982, 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)genassym.c	7.11 (Berkeley) 07/08/92
8  */
9 
10 #define KERNEL
11 
12 #include "sys/param.h"
13 #include "sys/buf.h"
14 #include "sys/map.h"
15 #include "sys/proc.h"
16 #include "sys/mbuf.h"
17 #include "sys/msgbuf.h"
18 #include "../include/cpu.h"
19 #include "../include/trap.h"
20 #include "../include/psl.h"
21 #include "../include/reg.h"
22 #include "clockreg.h"
23 #include "sys/syscall.h"
24 #include "vm/vm.h"
25 #include "sys/user.h"
26 #include "pte.h"
27 
28 #include <errno.h>
29 #include <stdio.h>
30 #include <stddef.h>
31 #include <string.h>
32 #include <unistd.h>
33 
34 extern int errno;
35 
36 void
37 def(what, val)
38 	char *what;
39 	int val;
40 {
41 
42 	if (printf("#define\t%s\t%d\n", what, val) < 0) {
43 		(void)fprintf(stderr, "genassym: printf: %s\n",
44 		    strerror(errno));
45 		exit(1);
46 	}
47 }
48 
49 void
50 flush()
51 {
52 
53 	if (fflush(stdout) || fsync(fileno(stdout)) < 0) {
54 		(void)fprintf(stderr, "genassym: flush stdout: %s\n",
55 		    strerror(errno));
56 		exit(1);
57 	}
58 }
59 
60 #define	off(what, s, m)	def(what, (int)offsetof(s, m))
61 
62 main()
63 {
64 	register unsigned i;
65 
66 	/* general constants */
67 	def("UPAGES", UPAGES);
68 	def("NBPG", NBPG);
69 	def("PGSHIFT", PGSHIFT);
70 	def("USRSTACK", USRSTACK);
71 	def("MAXADDR", MAXADDR);
72 
73 	/* proc fields and values */
74 	off("P_LINK", struct proc, p_link);
75 	off("P_RLINK", struct proc, p_rlink);
76 	off("P_VMSPACE", struct proc, p_vmspace);
77 	off("P_ADDR", struct proc, p_addr);
78 	off("P_PRI", struct proc, p_pri);
79 	off("P_STAT", struct proc, p_stat);
80 	off("P_WCHAN", struct proc, p_wchan);
81 	off("P_FLAG", struct proc, p_flag);
82 	def("SSLEEP", SSLEEP);
83 	def("SRUN", SRUN);
84 
85 	/* VM structure fields */
86 	off("VM_PMAP", struct vmspace, vm_pmap);
87 	off("PM_STCHG", struct pmap, pm_stchanged);
88 
89 	/* interrupt/fault metering */
90 	off("V_SWTCH", struct vmmeter, v_swtch);
91 	off("V_INTR", struct vmmeter, v_intr);
92 
93 	/* trap types (should just include trap.h?) */
94 	def("T_BUSERR", T_BUSERR);
95 	def("T_ADDRERR", T_ADDRERR);
96 	def("T_ILLINST", T_ILLINST);
97 	def("T_ZERODIV", T_ZERODIV);
98 	def("T_CHKINST", T_CHKINST);
99 	def("T_TRAPVINST", T_TRAPVINST);
100 	def("T_PRIVINST", T_PRIVINST);
101 	def("T_TRACE", T_TRACE);
102 	def("T_MMUFLT", T_MMUFLT);
103 	def("T_SSIR", T_SSIR);
104 	def("T_FMTERR", T_FMTERR);
105 	def("T_COPERR", T_COPERR);
106 	def("T_FPERR", T_FPERR);
107 	def("T_ASTFLT", T_ASTFLT);
108 	def("T_TRAP15", T_TRAP15);
109 	def("T_FPEMULI", T_FPEMULI);
110 	def("T_FPEMULD", T_FPEMULD);
111 
112 	/* PSL values (should just include psl.h?) */
113 	def("PSL_S", PSL_S);
114 	def("PSL_IPL7", PSL_IPL7);
115 	def("PSL_LOWIPL", PSL_LOWIPL);
116 	def("PSL_HIGHIPL", PSL_HIGHIPL);
117 	def("PSL_USER", PSL_USER);
118 	def("SPL1", PSL_S | PSL_IPL1);
119 	def("SPL2", PSL_S | PSL_IPL2);
120 	def("SPL3", PSL_S | PSL_IPL3);
121 	def("SPL4", PSL_S | PSL_IPL4);
122 	def("SPL5", PSL_S | PSL_IPL5);
123 	def("SPL6", PSL_S | PSL_IPL6);
124 
125 	/* magic */
126 	def("FC_USERD", FC_USERD);
127 	def("FC_PURGE", FC_PURGE);
128 	def("INTIOBASE", INTIOBASE);
129 	def("MMUBASE", MMUBASE);
130 	def("MMUSTAT", MMUSTAT);
131 	def("MMUCMD", MMUCMD);
132 	def("MMUSSTP", MMUSSTP);
133 	def("MMUUSTP", MMUUSTP);
134 	def("MMUTBINVAL", MMUTBINVAL);
135 	def("MMU_BERR", MMU_BERR);
136 	def("MMU_ENAB", MMU_ENAB);
137 	def("MMU_FAULT", MMU_FAULT);
138 	def("MMU_CEN", MMU_CEN);
139 	def("MMU_IEN", MMU_IEN);
140 	def("MMU_FPE", MMU_FPE);
141 	def("CACHE_ON", CACHE_ON);
142 	def("CACHE_OFF", CACHE_OFF);
143 	def("CACHE_CLR", CACHE_CLR);
144 	def("IC_CLEAR", IC_CLEAR);
145 	def("DC_CLEAR", DC_CLEAR);
146 
147 	/* pte/ste bits */
148 	def("PG_V", PG_V);
149 	def("PG_NV", PG_NV);
150 	def("PG_RO", PG_RO);
151 	def("PG_RW", PG_RW);
152 	def("PG_CI", PG_CI);
153 	def("PG_PROT", PG_PROT);
154 	def("PG_FRAME", PG_FRAME);
155 	def("SG_V", SG_V);
156 	def("SG_NV", SG_NV);
157 	def("SG_RW", SG_RW);
158 	def("SG_FRAME", SG_FRAME);
159 	def("SG_ISHIFT", SG_ISHIFT);
160 
161 	/* pcb fields */
162 	off("PCB_FLAGS", struct pcb, pcb_flags);
163 	off("PCB_PS", struct pcb, pcb_ps);
164 	off("PCB_USTP", struct pcb, pcb_ustp);
165 	off("PCB_USP", struct pcb, pcb_usp);
166 	off("PCB_REGS", struct pcb, pcb_regs);
167 	off("PCB_ONFAULT", struct pcb, pcb_onfault);
168 	off("PCB_FPCTX", struct pcb, pcb_fpregs);
169 	def("SIZEOF_PCB", sizeof(struct pcb));
170 
171 	/* system calls */
172 	def("SYS_exit", SYS_exit);
173 	def("SYS_execve", SYS_execve);
174 	def("SYS_sigreturn", SYS_sigreturn);
175 
176 	/* errno */
177 	def("EFAULT", EFAULT);
178 	def("ENAMETOOLONG", ENAMETOOLONG);
179 
180 	/* clock registers */
181 	def("CLKSR", CLKSR);
182 	def("CLKMSB1", CLKMSB1);
183 	def("CLKMSB3", CLKMSB3);
184 
185 	/* HP-UX trace bit */
186 	def("PCB_TRCB", ffs(PCB_HPUXTRACE) - 1);
187 
188 	exit(0);
189 }
190