genassym.c revision 99887
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: head/sys/amd64/amd64/genassym.c 99887 2002-07-12 18:34:22Z jhb $ 38 */ 39 40#include "opt_kstack_pages.h" 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/assym.h> 45#include <sys/bio.h> 46#include <sys/buf.h> 47#include <sys/proc.h> 48#include <sys/errno.h> 49#include <sys/mount.h> 50#include <sys/mutex.h> 51#include <sys/socket.h> 52#include <sys/resourcevar.h> 53#include <sys/ucontext.h> 54#include <sys/user.h> 55#include <machine/bootinfo.h> 56#include <machine/tss.h> 57#include <sys/vmmeter.h> 58#include <vm/vm.h> 59#include <vm/vm_param.h> 60#include <vm/pmap.h> 61#include <vm/vm_map.h> 62#include <sys/user.h> 63#include <sys/proc.h> 64#include <net/if.h> 65#include <netinet/in.h> 66#include <nfs/nfsproto.h> 67#include <nfs/rpcv2.h> 68#include <nfsclient/nfs.h> 69#include <nfsclient/nfsdiskless.h> 70#ifdef SMP 71#include <machine/apic.h> 72#endif 73#include <machine/cpu.h> 74#include <machine/sigframe.h> 75#include <machine/vm86.h> 76#include <machine/proc.h> 77 78ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace)); 79ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap)); 80ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); 81ASSYM(P_SFLAG, offsetof(struct proc, p_sflag)); 82ASSYM(P_STATE, offsetof(struct proc, p_state)); 83ASSYM(P_UAREA, offsetof(struct proc, p_uarea)); 84 85ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); 86ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan)); 87ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); 88ASSYM(TD_KSE, offsetof(struct thread, td_kse)); 89ASSYM(TD_PROC, offsetof(struct thread, td_proc)); 90ASSYM(TD_INTR_NESTING_LEVEL, offsetof(struct thread, td_intr_nesting_level)); 91ASSYM(TD_CRITNEST, offsetof(struct thread, td_critnest)); 92ASSYM(TD_MD, offsetof(struct thread, td_md)); 93 94ASSYM(P_MD, offsetof(struct proc, p_md)); 95ASSYM(MD_LDT, offsetof(struct mdproc, md_ldt)); 96 97ASSYM(KE_FLAGS, offsetof(struct kse, ke_flags)); 98 99ASSYM(KEF_ASTPENDING, KEF_ASTPENDING); 100ASSYM(KEF_NEEDRESCHED, KEF_NEEDRESCHED); 101 102ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap)); 103ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall)); 104ASSYM(V_INTR, offsetof(struct vmmeter, v_intr)); 105/* ASSYM(UPAGES, UPAGES);*/ 106ASSYM(UAREA_PAGES, UAREA_PAGES); 107ASSYM(KSTACK_PAGES, KSTACK_PAGES); 108ASSYM(PAGE_SIZE, PAGE_SIZE); 109ASSYM(NPTEPG, NPTEPG); 110ASSYM(NPDEPG, NPDEPG); 111ASSYM(PDESIZE, PDESIZE); 112ASSYM(PTESIZE, PTESIZE); 113ASSYM(PAGE_SHIFT, PAGE_SHIFT); 114ASSYM(PAGE_MASK, PAGE_MASK); 115ASSYM(PDRSHIFT, PDRSHIFT); 116ASSYM(USRSTACK, USRSTACK); 117ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS); 118ASSYM(KERNBASE, KERNBASE); 119ASSYM(MCLBYTES, MCLBYTES); 120ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3)); 121ASSYM(PCB_EDI, offsetof(struct pcb, pcb_edi)); 122ASSYM(PCB_ESI, offsetof(struct pcb, pcb_esi)); 123ASSYM(PCB_EBP, offsetof(struct pcb, pcb_ebp)); 124ASSYM(PCB_ESP, offsetof(struct pcb, pcb_esp)); 125ASSYM(PCB_EBX, offsetof(struct pcb, pcb_ebx)); 126ASSYM(PCB_EIP, offsetof(struct pcb, pcb_eip)); 127ASSYM(TSS_ESP0, offsetof(struct i386tss, tss_esp0)); 128 129ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs)); 130ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0)); 131ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1)); 132ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2)); 133ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3)); 134ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6)); 135ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7)); 136ASSYM(PCB_PSL, offsetof(struct pcb, pcb_psl)); 137ASSYM(PCB_DBREGS, PCB_DBREGS); 138ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext)); 139 140ASSYM(PCB_SPARE, offsetof(struct pcb, __pcb_spare)); 141ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags)); 142ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save)); 143ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu)); 144ASSYM(PCB_SAVE87_SIZE, sizeof(struct save87)); 145ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); 146 147ASSYM(PCB_SIZE, sizeof(struct pcb)); 148 149ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno)); 150ASSYM(TF_ERR, offsetof(struct trapframe, tf_err)); 151ASSYM(TF_CS, offsetof(struct trapframe, tf_cs)); 152ASSYM(TF_EFLAGS, offsetof(struct trapframe, tf_eflags)); 153ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler)); 154ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc)); 155ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); 156ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps)); 157ASSYM(SC_FS, offsetof(struct osigcontext, sc_fs)); 158ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs)); 159ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno)); 160ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); 161ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); 162ASSYM(ENOENT, ENOENT); 163ASSYM(EFAULT, EFAULT); 164ASSYM(ENAMETOOLONG, ENAMETOOLONG); 165ASSYM(MAXPATHLEN, MAXPATHLEN); 166ASSYM(BOOTINFO_SIZE, sizeof(struct bootinfo)); 167ASSYM(BI_VERSION, offsetof(struct bootinfo, bi_version)); 168ASSYM(BI_KERNELNAME, offsetof(struct bootinfo, bi_kernelname)); 169ASSYM(BI_NFS_DISKLESS, offsetof(struct bootinfo, bi_nfs_diskless)); 170ASSYM(BI_ENDCOMMON, offsetof(struct bootinfo, bi_endcommon)); 171ASSYM(NFSDISKLESS_SIZE, sizeof(struct nfs_diskless)); 172ASSYM(BI_SIZE, offsetof(struct bootinfo, bi_size)); 173ASSYM(BI_SYMTAB, offsetof(struct bootinfo, bi_symtab)); 174ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab)); 175ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); 176ASSYM(PC_SIZEOF, sizeof(struct pcpu)); 177ASSYM(PC_PRVSPACE, offsetof(struct pcpu, pc_prvspace)); 178ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread)); 179ASSYM(PC_INT_PENDING, offsetof(struct pcpu, pc_int_pending)); 180ASSYM(PC_IPENDING, offsetof(struct pcpu, pc_ipending)); 181ASSYM(PC_FPENDING, offsetof(struct pcpu, pc_fpending)); 182ASSYM(PC_SPENDING, offsetof(struct pcpu, pc_spending)); 183ASSYM(PC_FPCURTHREAD, offsetof(struct pcpu, pc_fpcurthread)); 184ASSYM(PC_IDLETHREAD, offsetof(struct pcpu, pc_idlethread)); 185ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb)); 186ASSYM(PC_COMMON_TSS, offsetof(struct pcpu, pc_common_tss)); 187ASSYM(PC_COMMON_TSSD, offsetof(struct pcpu, pc_common_tssd)); 188ASSYM(PC_TSS_GDT, offsetof(struct pcpu, pc_tss_gdt)); 189ASSYM(PC_CURRENTLDT, offsetof(struct pcpu, pc_currentldt)); 190ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); 191 192#ifdef SMP 193ASSYM(LA_VER, offsetof(struct LAPIC, version)); 194ASSYM(LA_TPR, offsetof(struct LAPIC, tpr)); 195ASSYM(LA_EOI, offsetof(struct LAPIC, eoi)); 196ASSYM(LA_SVR, offsetof(struct LAPIC, svr)); 197ASSYM(LA_ICR_LO, offsetof(struct LAPIC, icr_lo)); 198ASSYM(LA_ICR_HI, offsetof(struct LAPIC, icr_hi)); 199#endif 200 201ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL)); 202ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL)); 203ASSYM(KPSEL, GSEL(GPRIV_SEL, SEL_KPL)); 204 205ASSYM(BC32SEL, GSEL(GBIOSCODE32_SEL, SEL_KPL)); 206ASSYM(GPROC0_SEL, GPROC0_SEL); 207ASSYM(VM86_FRAMESIZE, sizeof(struct vm86frame)); 208 209ASSYM(MTX_LOCK, offsetof(struct mtx, mtx_lock)); 210ASSYM(MTX_RECURSECNT, offsetof(struct mtx, mtx_recurse)); 211 212#ifdef PC98 213#include <machine/bus.h> 214 215ASSYM(BUS_SPACE_HANDLE_BASE, offsetof(struct bus_space_handle, bsh_base)); 216ASSYM(BUS_SPACE_HANDLE_IAT, offsetof(struct bus_space_handle, bsh_iat)); 217#endif 218