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.3 (Berkeley) 01/04/94 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 /* general constants */ 70 def("UPAGES", UPAGES); 71 def("NBPG", NBPG); 72 def("PGSHIFT", PGSHIFT); 73 def("USRSTACK", USRSTACK); 74 def("MAXADDR", MAXADDR); 75 76 /* proc fields and values */ 77 off("P_FORW", struct proc, p_forw); 78 off("P_BACK", struct proc, p_back); 79 off("P_VMSPACE", struct proc, p_vmspace); 80 off("P_ADDR", struct proc, p_addr); 81 off("P_PRIORITY", struct proc, p_priority); 82 off("P_STAT", struct proc, p_stat); 83 off("P_WCHAN", struct proc, p_wchan); 84 off("P_FLAG", struct proc, p_flag); 85 off("P_MDFLAG", struct proc, p_md.md_flags); 86 def("SSLEEP", SSLEEP); 87 def("SRUN", SRUN); 88 89 /* VM structure fields */ 90 off("VM_PMAP", struct vmspace, vm_pmap); 91 off("PM_STCHG", struct pmap, pm_stchanged); 92 93 /* interrupt/fault metering */ 94 off("V_SWTCH", struct vmmeter, v_swtch); 95 off("V_INTR", struct vmmeter, v_intr); 96 97 /* trap types (should just include trap.h?) */ 98 def("T_BUSERR", T_BUSERR); 99 def("T_ADDRERR", T_ADDRERR); 100 def("T_ILLINST", T_ILLINST); 101 def("T_ZERODIV", T_ZERODIV); 102 def("T_CHKINST", T_CHKINST); 103 def("T_TRAPVINST", T_TRAPVINST); 104 def("T_PRIVINST", T_PRIVINST); 105 def("T_TRACE", T_TRACE); 106 def("T_MMUFLT", T_MMUFLT); 107 def("T_SSIR", T_SSIR); 108 def("T_FMTERR", T_FMTERR); 109 def("T_COPERR", T_COPERR); 110 def("T_FPERR", T_FPERR); 111 def("T_ASTFLT", T_ASTFLT); 112 def("T_TRAP15", T_TRAP15); 113 def("T_FPEMULI", T_FPEMULI); 114 def("T_FPEMULD", T_FPEMULD); 115 116 /* PSL values (should just include psl.h?) */ 117 def("PSL_S", PSL_S); 118 def("PSL_IPL7", PSL_IPL7); 119 def("PSL_LOWIPL", PSL_LOWIPL); 120 def("PSL_HIGHIPL", PSL_HIGHIPL); 121 def("PSL_USER", PSL_USER); 122 def("SPL1", PSL_S | PSL_IPL1); 123 def("SPL2", PSL_S | PSL_IPL2); 124 def("SPL3", PSL_S | PSL_IPL3); 125 def("SPL4", PSL_S | PSL_IPL4); 126 def("SPL5", PSL_S | PSL_IPL5); 127 def("SPL6", PSL_S | PSL_IPL6); 128 129 /* magic */ 130 def("FC_USERD", FC_USERD); 131 def("FC_PURGE", FC_PURGE); 132 def("INTIOBASE", INTIOBASE); 133 def("MMUBASE", MMUBASE); 134 def("MMUSTAT", MMUSTAT); 135 def("MMUCMD", MMUCMD); 136 def("MMUSSTP", MMUSSTP); 137 def("MMUUSTP", MMUUSTP); 138 def("MMUTBINVAL", MMUTBINVAL); 139 def("MMU_BERR", MMU_BERR); 140 def("MMU_ENAB", MMU_ENAB); 141 def("MMU_FAULT", MMU_FAULT); 142 def("MMU_CEN", MMU_CEN); 143 def("MMU_IEN", MMU_IEN); 144 def("MMU_FPE", MMU_FPE); 145 def("CACHE_ON", CACHE_ON); 146 def("CACHE_OFF", CACHE_OFF); 147 def("CACHE_CLR", CACHE_CLR); 148 def("IC_CLEAR", IC_CLEAR); 149 def("DC_CLEAR", DC_CLEAR); 150 151 /* pte/ste bits */ 152 def("PG_V", PG_V); 153 def("PG_NV", PG_NV); 154 def("PG_RO", PG_RO); 155 def("PG_RW", PG_RW); 156 def("PG_CI", PG_CI); 157 def("PG_PROT", PG_PROT); 158 def("PG_FRAME", PG_FRAME); 159 def("SG_V", SG_V); 160 def("SG_NV", SG_NV); 161 def("SG_RW", SG_RW); 162 def("SG_FRAME", SG_FRAME); 163 def("SG_ISHIFT", SG_ISHIFT); 164 165 /* pcb fields */ 166 off("PCB_PS", struct pcb, pcb_ps); 167 off("PCB_USTP", struct pcb, pcb_ustp); 168 off("PCB_USP", struct pcb, pcb_usp); 169 off("PCB_REGS", struct pcb, pcb_regs); 170 off("PCB_ONFAULT", struct pcb, pcb_onfault); 171 off("PCB_FPCTX", struct pcb, pcb_fpregs); 172 def("SIZEOF_PCB", sizeof(struct pcb)); 173 174 /* exception frame offset/sizes */ 175 off("FR_SP", struct frame, f_regs[15]); 176 off("FR_HW", struct frame, f_sr); 177 off("FR_ADJ", struct frame, f_stackadj); 178 179 /* system calls */ 180 def("SYS_exit", SYS_exit); 181 def("SYS_execve", SYS_execve); 182 def("SYS_sigreturn", SYS_sigreturn); 183 184 /* errno */ 185 def("EFAULT", EFAULT); 186 def("ENAMETOOLONG", ENAMETOOLONG); 187 188 /* clock registers */ 189 def("CLKSR", CLKSR); 190 def("CLKMSB1", CLKMSB1); 191 def("CLKMSB3", CLKMSB3); 192 193 /* HP-UX trace bit */ 194 def("MDP_TRCB", ffs(MDP_HPUXTRACE) - 1); 195 196 #ifdef USELEDS 197 /* LEDs */ 198 def("LED_PULSE", LED_PULSE); 199 def("LED_DISK", LED_DISK); 200 def("LED_LANRCV", LED_LANRCV); 201 def("LED_LANXMT", LED_LANXMT); 202 #endif 203 204 exit(0); 205 } 206