genassym.c revision 331722
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 * 4. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 33 */ 34 35#include <sys/cdefs.h> 36__FBSDID("$FreeBSD: stable/11/sys/i386/i386/genassym.c 331722 2018-03-29 02:50:57Z eadler $"); 37 38#include "opt_apic.h" 39#include "opt_compat.h" 40#include "opt_hwpmc_hooks.h" 41#include "opt_kstack_pages.h" 42 43#include <sys/param.h> 44#include <sys/systm.h> 45#include <sys/assym.h> 46#include <sys/bio.h> 47#include <sys/buf.h> 48#ifdef HWPMC_HOOKS 49#include <sys/pmckern.h> 50#endif 51#include <sys/proc.h> 52#include <sys/errno.h> 53#include <sys/mount.h> 54#include <sys/mutex.h> 55#include <sys/socket.h> 56#include <sys/resourcevar.h> 57#include <sys/signalvar.h> 58#include <sys/ucontext.h> 59#include <machine/bootinfo.h> 60#include <machine/tss.h> 61#include <sys/vmmeter.h> 62#include <vm/vm.h> 63#include <vm/vm_param.h> 64#include <vm/pmap.h> 65#include <vm/vm_map.h> 66#include <sys/proc.h> 67#include <net/if.h> 68#include <netinet/in.h> 69#include <nfs/nfsproto.h> 70#include <nfsclient/nfs.h> 71#include <nfs/nfsdiskless.h> 72#ifdef DEV_APIC 73#include <x86/apicreg.h> 74#endif 75#include <machine/cpu.h> 76#include <machine/pcb.h> 77#include <machine/sigframe.h> 78#include <machine/vm86.h> 79#include <machine/proc.h> 80 81ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace)); 82ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap)); 83ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); 84 85ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); 86ASSYM(TD_LOCK, offsetof(struct thread, td_lock)); 87ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); 88ASSYM(TD_PFLAGS, offsetof(struct thread, td_pflags)); 89ASSYM(TD_PROC, offsetof(struct thread, td_proc)); 90ASSYM(TD_MD, offsetof(struct thread, td_md)); 91 92ASSYM(TDP_CALLCHAIN, TDP_CALLCHAIN); 93 94ASSYM(P_MD, offsetof(struct proc, p_md)); 95ASSYM(MD_LDT, offsetof(struct mdproc, md_ldt)); 96 97ASSYM(TDF_ASTPENDING, TDF_ASTPENDING); 98ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED); 99 100ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap)); 101ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall)); 102ASSYM(V_INTR, offsetof(struct vmmeter, v_intr)); 103ASSYM(TD0_KSTACK_PAGES, TD0_KSTACK_PAGES); 104ASSYM(PAGE_SIZE, PAGE_SIZE); 105ASSYM(NPTEPG, NPTEPG); 106ASSYM(NPDEPG, NPDEPG); 107ASSYM(NPDEPTD, NPDEPTD); 108ASSYM(NPGPTD, NPGPTD); 109ASSYM(PDESIZE, sizeof(pd_entry_t)); 110ASSYM(PTESIZE, sizeof(pt_entry_t)); 111ASSYM(PDESHIFT, PDESHIFT); 112ASSYM(PTESHIFT, PTESHIFT); 113ASSYM(PAGE_SHIFT, PAGE_SHIFT); 114ASSYM(PAGE_MASK, PAGE_MASK); 115ASSYM(PDRSHIFT, PDRSHIFT); 116ASSYM(PDRMASK, PDRMASK); 117ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS); 118ASSYM(KERNBASE, KERNBASE); 119ASSYM(KERNLOAD, KERNLOAD); 120ASSYM(PCB_CR0, offsetof(struct pcb, pcb_cr0)); 121ASSYM(PCB_CR2, offsetof(struct pcb, pcb_cr2)); 122ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3)); 123ASSYM(PCB_CR4, offsetof(struct pcb, pcb_cr4)); 124ASSYM(PCB_EDI, offsetof(struct pcb, pcb_edi)); 125ASSYM(PCB_ESI, offsetof(struct pcb, pcb_esi)); 126ASSYM(PCB_EBP, offsetof(struct pcb, pcb_ebp)); 127ASSYM(PCB_ESP, offsetof(struct pcb, pcb_esp)); 128ASSYM(PCB_EBX, offsetof(struct pcb, pcb_ebx)); 129ASSYM(PCB_EIP, offsetof(struct pcb, pcb_eip)); 130ASSYM(TSS_ESP0, offsetof(struct i386tss, tss_esp0)); 131 132ASSYM(PCB_DS, offsetof(struct pcb, pcb_ds)); 133ASSYM(PCB_ES, offsetof(struct pcb, pcb_es)); 134ASSYM(PCB_FS, offsetof(struct pcb, pcb_fs)); 135ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs)); 136ASSYM(PCB_SS, offsetof(struct pcb, pcb_ss)); 137ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0)); 138ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1)); 139ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2)); 140ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3)); 141ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6)); 142ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7)); 143ASSYM(PCB_PSL, offsetof(struct pcb, pcb_psl)); 144ASSYM(PCB_DBREGS, PCB_DBREGS); 145ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext)); 146 147ASSYM(PCB_FSD, offsetof(struct pcb, pcb_fsd)); 148ASSYM(PCB_GSD, offsetof(struct pcb, pcb_gsd)); 149ASSYM(PCB_VM86, offsetof(struct pcb, pcb_vm86)); 150ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags)); 151ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save)); 152ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); 153 154ASSYM(PCB_SIZE, sizeof(struct pcb)); 155ASSYM(PCB_VM86CALL, PCB_VM86CALL); 156 157ASSYM(PCB_GDT, offsetof(struct pcb, pcb_gdt)); 158ASSYM(PCB_IDT, offsetof(struct pcb, pcb_idt)); 159ASSYM(PCB_LDT, offsetof(struct pcb, pcb_ldt)); 160ASSYM(PCB_TR, offsetof(struct pcb, pcb_tr)); 161 162ASSYM(TF_FS, offsetof(struct trapframe, tf_fs)); 163ASSYM(TF_ES, offsetof(struct trapframe, tf_es)); 164ASSYM(TF_DS, offsetof(struct trapframe, tf_ds)); 165ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno)); 166ASSYM(TF_ERR, offsetof(struct trapframe, tf_err)); 167ASSYM(TF_EIP, offsetof(struct trapframe, tf_eip)); 168ASSYM(TF_CS, offsetof(struct trapframe, tf_cs)); 169ASSYM(TF_EFLAGS, offsetof(struct trapframe, tf_eflags)); 170 171ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler)); 172#ifdef COMPAT_43 173ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc)); 174#endif 175ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); 176#ifdef COMPAT_FREEBSD4 177ASSYM(SIGF_UC4, offsetof(struct sigframe4, sf_uc)); 178#endif 179#ifdef COMPAT_43 180ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps)); 181ASSYM(SC_FS, offsetof(struct osigcontext, sc_fs)); 182ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs)); 183ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno)); 184#endif 185#ifdef COMPAT_FREEBSD4 186ASSYM(UC4_EFLAGS, offsetof(struct ucontext4, uc_mcontext.mc_eflags)); 187ASSYM(UC4_GS, offsetof(struct ucontext4, uc_mcontext.mc_gs)); 188#endif 189ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); 190ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); 191ASSYM(ENOENT, ENOENT); 192ASSYM(EFAULT, EFAULT); 193ASSYM(ENAMETOOLONG, ENAMETOOLONG); 194ASSYM(MAXCOMLEN, MAXCOMLEN); 195ASSYM(MAXPATHLEN, MAXPATHLEN); 196ASSYM(BOOTINFO_SIZE, sizeof(struct bootinfo)); 197ASSYM(BI_VERSION, offsetof(struct bootinfo, bi_version)); 198ASSYM(BI_KERNELNAME, offsetof(struct bootinfo, bi_kernelname)); 199ASSYM(BI_NFS_DISKLESS, offsetof(struct bootinfo, bi_nfs_diskless)); 200ASSYM(BI_ENDCOMMON, offsetof(struct bootinfo, bi_endcommon)); 201ASSYM(NFSDISKLESS_SIZE, sizeof(struct nfs_diskless)); 202ASSYM(BI_SIZE, offsetof(struct bootinfo, bi_size)); 203ASSYM(BI_SYMTAB, offsetof(struct bootinfo, bi_symtab)); 204ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab)); 205ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); 206ASSYM(PC_SIZEOF, sizeof(struct pcpu)); 207ASSYM(PC_PRVSPACE, offsetof(struct pcpu, pc_prvspace)); 208ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread)); 209ASSYM(PC_FPCURTHREAD, offsetof(struct pcpu, pc_fpcurthread)); 210ASSYM(PC_IDLETHREAD, offsetof(struct pcpu, pc_idlethread)); 211ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb)); 212ASSYM(PC_COMMON_TSS, offsetof(struct pcpu, pc_common_tss)); 213ASSYM(PC_COMMON_TSSD, offsetof(struct pcpu, pc_common_tssd)); 214ASSYM(PC_TSS_GDT, offsetof(struct pcpu, pc_tss_gdt)); 215ASSYM(PC_FSGS_GDT, offsetof(struct pcpu, pc_fsgs_gdt)); 216ASSYM(PC_CURRENTLDT, offsetof(struct pcpu, pc_currentldt)); 217ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); 218ASSYM(PC_CURPMAP, offsetof(struct pcpu, pc_curpmap)); 219ASSYM(PC_PRIVATE_TSS, offsetof(struct pcpu, pc_private_tss)); 220 221#ifdef DEV_APIC 222ASSYM(LA_EOI, LAPIC_EOI * LAPIC_MEM_MUL); 223ASSYM(LA_ISR, LAPIC_ISR0 * LAPIC_MEM_MUL); 224#endif 225 226ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL)); 227ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL)); 228ASSYM(KPSEL, GSEL(GPRIV_SEL, SEL_KPL)); 229 230ASSYM(BC32SEL, GSEL(GBIOSCODE32_SEL, SEL_KPL)); 231ASSYM(GPROC0_SEL, GPROC0_SEL); 232ASSYM(VM86_FRAMESIZE, sizeof(struct vm86frame)); 233 234#ifdef PC98 235#include <machine/bus.h> 236 237ASSYM(BUS_SPACE_HANDLE_BASE, offsetof(struct bus_space_handle, bsh_base)); 238ASSYM(BUS_SPACE_HANDLE_IAT, offsetof(struct bus_space_handle, bsh_iat)); 239#endif 240 241#ifdef HWPMC_HOOKS 242ASSYM(PMC_FN_USER_CALLCHAIN, PMC_FN_USER_CALLCHAIN); 243#endif 244