| 1 | /*- |
| 2 | * Copyright (c) 1982, 1990 The Regents of the University of California. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * This code is derived from software contributed to Berkeley by |
| 6 | * William Jolitz. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. All advertising materials mentioning features or use of this software |
| 17 | * must display the following acknowledgement: |
| 18 | * This product includes software developed by the University of |
| 19 | * California, Berkeley and its contributors. |
| 20 | * 4. Neither the name of the University nor the names of its contributors |
| 21 | * may be used to endorse or promote products derived from this software |
| 22 | * without specific prior written permission. |
| 23 | * |
| 24 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 34 | * SUCH DAMAGE. |
| 35 | * |
| 36 | * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 |
| 37 | * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ |
| 38 | * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.30 2003/10/02 22:26:56 dillon Exp $ |
| 39 | */ |
| 40 | |
| 41 | #include "opt_user_ldt.h" |
| 42 | |
| 43 | #include <sys/param.h> |
| 44 | #include <sys/systm.h> |
| 45 | #include <sys/assym.h> |
| 46 | #include <sys/buf.h> |
| 47 | #include <sys/proc.h> |
| 48 | #include <sys/errno.h> |
| 49 | #include <sys/mount.h> |
| 50 | #include <sys/socket.h> |
| 51 | #include <sys/lock.h> |
| 52 | #include <sys/resourcevar.h> |
| 53 | #include <machine/frame.h> |
| 54 | #include <machine/bootinfo.h> |
| 55 | #include <machine/tss.h> |
| 56 | #include <sys/vmmeter.h> |
| 57 | #include <vm/vm.h> |
| 58 | #include <vm/vm_param.h> |
| 59 | #include <vm/pmap.h> |
| 60 | #include <vm/vm_map.h> |
| 61 | #include <sys/user.h> |
| 62 | #include <net/if.h> |
| 63 | #include <netinet/in.h> |
| 64 | #include <vfs/nfs/nfsv2.h> |
| 65 | #include <vfs/nfs/rpcv2.h> |
| 66 | #include <vfs/nfs/nfs.h> |
| 67 | #include <vfs/nfs/nfsdiskless.h> |
| 68 | #ifdef SMP |
| 69 | #include <machine/apic.h> |
| 70 | #endif |
| 71 | #include <machine/segments.h> |
| 72 | #include <machine/sigframe.h> |
| 73 | #include <machine/vm86.h> |
| 74 | #include <machine/globaldata.h> |
| 75 | |
| 76 | ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace)); |
| 77 | ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap)); |
| 78 | ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); |
| 79 | ASSYM(P_ADDR, offsetof(struct proc, p_addr)); |
| 80 | ASSYM(P_STAT, offsetof(struct proc, p_stat)); |
| 81 | ASSYM(P_THREAD, offsetof(struct proc, p_thread)); |
| 82 | |
| 83 | ASSYM(TD_PROC, offsetof(struct thread, td_proc)); |
| 84 | ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); |
| 85 | ASSYM(TD_SP, offsetof(struct thread, td_sp)); |
| 86 | ASSYM(TD_PRI, offsetof(struct thread, td_pri)); |
| 87 | ASSYM(TD_MACH, offsetof(struct thread, td_mach)); |
| 88 | ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan)); |
| 89 | ASSYM(TD_NEST_COUNT, offsetof(struct thread, td_nest_count)); |
| 90 | #ifdef SMP |
| 91 | ASSYM(TD_MPCOUNT, offsetof(struct thread, td_mpcount)); |
| 92 | #endif |
| 93 | ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); |
| 94 | ASSYM(TDF_RUNNING, TDF_RUNNING); |
| 95 | #ifdef SMP |
| 96 | ASSYM(MP_FREE_LOCK, MP_FREE_LOCK); |
| 97 | #endif |
| 98 | |
| 99 | ASSYM(RW_OWNER, offsetof(struct lwkt_rwlock, rw_owner)); |
| 100 | |
| 101 | ASSYM(TD_CPL, offsetof(struct thread, td_mach) + offsetof(struct md_thread, mtd_cpl)); |
| 102 | |
| 103 | ASSYM(TDPRI_CRIT, TDPRI_CRIT); |
| 104 | ASSYM(TDPRI_INT_SUPPORT, TDPRI_INT_SUPPORT); |
| 105 | |
| 106 | ASSYM(SSLEEP, SSLEEP); |
| 107 | ASSYM(SRUN, SRUN); |
| 108 | ASSYM(SZOMB, SZOMB); |
| 109 | ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap)); |
| 110 | ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall)); |
| 111 | ASSYM(V_SENDSYS, offsetof(struct vmmeter, v_sendsys)); |
| 112 | ASSYM(V_INTR, offsetof(struct vmmeter, v_intr)); |
| 113 | ASSYM(V_FORWARDED_INTS, offsetof(struct vmmeter, v_forwarded_ints)); |
| 114 | ASSYM(V_FORWARDED_HITS, offsetof(struct vmmeter, v_forwarded_hits)); |
| 115 | ASSYM(V_FORWARDED_MISSES, offsetof(struct vmmeter, v_forwarded_misses)); |
| 116 | ASSYM(UPAGES, UPAGES); |
| 117 | ASSYM(PAGE_SIZE, PAGE_SIZE); |
| 118 | ASSYM(NPTEPG, NPTEPG); |
| 119 | ASSYM(NPDEPG, NPDEPG); |
| 120 | ASSYM(PDESIZE, PDESIZE); |
| 121 | ASSYM(PTESIZE, PTESIZE); |
| 122 | ASSYM(PAGE_SHIFT, PAGE_SHIFT); |
| 123 | ASSYM(PAGE_MASK, PAGE_MASK); |
| 124 | ASSYM(PDRSHIFT, PDRSHIFT); |
| 125 | ASSYM(USRSTACK, USRSTACK); |
| 126 | ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS); |
| 127 | ASSYM(KERNBASE, KERNBASE); |
| 128 | ASSYM(MCLBYTES, MCLBYTES); |
| 129 | ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3)); |
| 130 | ASSYM(PCB_EDI, offsetof(struct pcb, pcb_edi)); |
| 131 | ASSYM(PCB_ESI, offsetof(struct pcb, pcb_esi)); |
| 132 | ASSYM(PCB_EBP, offsetof(struct pcb, pcb_ebp)); |
| 133 | ASSYM(PCB_ESP, offsetof(struct pcb, pcb_esp)); |
| 134 | ASSYM(PCB_EBX, offsetof(struct pcb, pcb_ebx)); |
| 135 | ASSYM(PCB_EIP, offsetof(struct pcb, pcb_eip)); |
| 136 | ASSYM(TSS_ESP0, offsetof(struct i386tss, tss_esp0)); |
| 137 | |
| 138 | #ifdef USER_LDT |
| 139 | ASSYM(PCB_USERLDT, offsetof(struct pcb, pcb_ldt)); |
| 140 | #endif |
| 141 | |
| 142 | ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs)); |
| 143 | ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0)); |
| 144 | ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1)); |
| 145 | ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2)); |
| 146 | ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3)); |
| 147 | ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6)); |
| 148 | ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7)); |
| 149 | ASSYM(PCB_DBREGS, PCB_DBREGS); |
| 150 | ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext)); |
| 151 | |
| 152 | ASSYM(PCB_SPARE, offsetof(struct pcb, __pcb_spare)); |
| 153 | ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags)); |
| 154 | ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save)); |
| 155 | ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu)); |
| 156 | ASSYM(PCB_SAVE87_SIZE, sizeof(struct save87)); |
| 157 | ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); |
| 158 | |
| 159 | ASSYM(PCB_SIZE, sizeof(struct pcb)); |
| 160 | |
| 161 | ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno)); |
| 162 | ASSYM(TF_ERR, offsetof(struct trapframe, tf_err)); |
| 163 | ASSYM(TF_CS, offsetof(struct trapframe, tf_cs)); |
| 164 | ASSYM(TF_EFLAGS, offsetof(struct trapframe, tf_eflags)); |
| 165 | ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler)); |
| 166 | ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc)); |
| 167 | ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); |
| 168 | ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps)); |
| 169 | ASSYM(SC_FS, offsetof(struct osigcontext, sc_fs)); |
| 170 | ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs)); |
| 171 | ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno)); |
| 172 | ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); |
| 173 | ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); |
| 174 | ASSYM(B_READ, B_READ); |
| 175 | ASSYM(ENOENT, ENOENT); |
| 176 | ASSYM(EFAULT, EFAULT); |
| 177 | ASSYM(ENAMETOOLONG, ENAMETOOLONG); |
| 178 | ASSYM(MAXPATHLEN, MAXPATHLEN); |
| 179 | ASSYM(BOOTINFO_SIZE, sizeof(struct bootinfo)); |
| 180 | ASSYM(BI_VERSION, offsetof(struct bootinfo, bi_version)); |
| 181 | ASSYM(BI_KERNELNAME, offsetof(struct bootinfo, bi_kernelname)); |
| 182 | ASSYM(BI_NFS_DISKLESS, offsetof(struct bootinfo, bi_nfs_diskless)); |
| 183 | ASSYM(BI_ENDCOMMON, offsetof(struct bootinfo, bi_endcommon)); |
| 184 | ASSYM(NFSDISKLESS_SIZE, sizeof(struct nfs_diskless)); |
| 185 | ASSYM(BI_SIZE, offsetof(struct bootinfo, bi_size)); |
| 186 | ASSYM(BI_SYMTAB, offsetof(struct bootinfo, bi_symtab)); |
| 187 | ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab)); |
| 188 | ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); |
| 189 | |
| 190 | ASSYM(GD_CURTHREAD, offsetof(struct mdglobaldata, mi.gd_curthread)); |
| 191 | ASSYM(GD_CPUID, offsetof(struct mdglobaldata, mi.gd_cpuid)); |
| 192 | ASSYM(GD_CNT, offsetof(struct mdglobaldata, mi.gd_cnt)); |
| 193 | ASSYM(GD_PRIVATE_TSS, offsetof(struct mdglobaldata, gd_private_tss)); |
| 194 | ASSYM(GD_INTR_NESTING_LEVEL, offsetof(struct mdglobaldata, mi.gd_intr_nesting_level)); |
| 195 | ASSYM(GD_REQFLAGS, offsetof(struct mdglobaldata, mi.gd_reqflags)); |
| 196 | |
| 197 | #ifdef USER_LDT |
| 198 | ASSYM(GD_CURRENTLDT, offsetof(struct mdglobaldata, gd_currentldt)); |
| 199 | #endif |
| 200 | |
| 201 | ASSYM(RQF_IPIQ, RQF_IPIQ); |
| 202 | ASSYM(RQF_INTPEND, RQF_INTPEND); |
| 203 | ASSYM(RQF_AST_OWEUPC, RQF_AST_OWEUPC); |
| 204 | ASSYM(RQF_AST_SIGNAL, RQF_AST_SIGNAL); |
| 205 | ASSYM(RQF_AST_RESCHED, RQF_AST_RESCHED); |
| 206 | ASSYM(RQF_AST_MASK, RQF_AST_MASK); |
| 207 | |
| 208 | ASSYM(GD_FPENDING, offsetof(struct mdglobaldata, gd_fpending)); |
| 209 | ASSYM(GD_IPENDING, offsetof(struct mdglobaldata, gd_ipending)); |
| 210 | ASSYM(GD_COMMON_TSS, offsetof(struct mdglobaldata, gd_common_tss)); |
| 211 | ASSYM(GD_COMMON_TSSD, offsetof(struct mdglobaldata, gd_common_tssd)); |
| 212 | ASSYM(GD_TSS_GDT, offsetof(struct mdglobaldata, gd_tss_gdt)); |
| 213 | ASSYM(GD_NPXTHREAD, offsetof(struct mdglobaldata, gd_npxthread)); |
| 214 | ASSYM(GD_CPU_LOCKID, offsetof(struct mdglobaldata, gd_cpu_lockid)); |
| 215 | ASSYM(GD_OTHER_CPUS, offsetof(struct mdglobaldata, gd_other_cpus)); |
| 216 | ASSYM(GD_SS_EFLAGS, offsetof(struct mdglobaldata, gd_ss_eflags)); |
| 217 | ASSYM(GD_CMAP1, offsetof(struct mdglobaldata, gd_CMAP1)); |
| 218 | ASSYM(GD_CMAP2, offsetof(struct mdglobaldata, gd_CMAP2)); |
| 219 | ASSYM(GD_CMAP3, offsetof(struct mdglobaldata, gd_CMAP3)); |
| 220 | ASSYM(GD_PMAP1, offsetof(struct mdglobaldata, gd_PMAP1)); |
| 221 | ASSYM(GD_CADDR1, offsetof(struct mdglobaldata, gd_CADDR1)); |
| 222 | ASSYM(GD_CADDR2, offsetof(struct mdglobaldata, gd_CADDR2)); |
| 223 | ASSYM(GD_CADDR3, offsetof(struct mdglobaldata, gd_CADDR3)); |
| 224 | ASSYM(GD_PADDR1, offsetof(struct mdglobaldata, gd_PADDR1)); |
| 225 | |
| 226 | ASSYM(PS_IDLESTACK, offsetof(struct privatespace, idlestack)); |
| 227 | ASSYM(PS_IDLESTACK_PAGE, offsetof(struct privatespace, idlestack) / PAGE_SIZE); |
| 228 | ASSYM(PS_IDLESTACK_TOP, sizeof(struct privatespace)); |
| 229 | ASSYM(PS_SIZEOF, sizeof(struct privatespace)); |
| 230 | |
| 231 | ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL)); |
| 232 | ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL)); |
| 233 | ASSYM(KPSEL, GSEL(GPRIV_SEL, SEL_KPL)); |
| 234 | |
| 235 | ASSYM(BC32SEL, GSEL(GBIOSCODE32_SEL, SEL_KPL)); |
| 236 | ASSYM(GPROC0_SEL, GPROC0_SEL); |
| 237 | ASSYM(VM86_FRAMESIZE, sizeof(struct vm86frame)); |
| 238 | |
| 239 | #ifdef PC98 |
| 240 | #include <machine/bus.h> |
| 241 | |
| 242 | ASSYM(BUS_SPACE_HANDLE_BASE, offsetof(struct bus_space_handle, bsh_base)); |
| 243 | ASSYM(BUS_SPACE_HANDLE_IAT, offsetof(struct bus_space_handle, bsh_iat)); |
| 244 | #endif |