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