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