genassym.c revision 129309
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: head/sys/amd64/amd64/genassym.c 129309 2004-05-16 22:43:57Z peter $");
37
38#include "opt_compat.h"
39#include "opt_kstack_pages.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/assym.h>
44#include <sys/bio.h>
45#include <sys/buf.h>
46#include <sys/proc.h>
47#include <sys/errno.h>
48#include <sys/mount.h>
49#include <sys/mutex.h>
50#include <sys/socket.h>
51#include <sys/resourcevar.h>
52#include <sys/ucontext.h>
53#include <sys/user.h>
54#include <machine/tss.h>
55#include <sys/vmmeter.h>
56#include <vm/vm.h>
57#include <vm/vm_param.h>
58#include <vm/pmap.h>
59#include <vm/vm_map.h>
60#include <sys/user.h>
61#include <sys/proc.h>
62#include <net/if.h>
63#include <netinet/in.h>
64#include <nfs/nfsproto.h>
65#include <nfs/rpcv2.h>
66#include <nfsclient/nfs.h>
67#include <nfsclient/nfsdiskless.h>
68#include <machine/apicreg.h>
69#include <machine/cpu.h>
70#include <machine/sigframe.h>
71#include <machine/proc.h>
72#include <machine/specialreg.h>
73#include <machine/segments.h>
74
75ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace));
76ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap));
77ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active));
78ASSYM(P_SFLAG, offsetof(struct proc, p_sflag));
79ASSYM(P_UAREA, offsetof(struct proc, p_uarea));
80
81ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
82ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
83ASSYM(TD_PROC, offsetof(struct thread, td_proc));
84
85ASSYM(TDF_ASTPENDING, TDF_ASTPENDING);
86ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED);
87
88ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap));
89ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
90ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
91ASSYM(UAREA_PAGES, UAREA_PAGES);
92ASSYM(KSTACK_PAGES, KSTACK_PAGES);
93ASSYM(PAGE_SIZE, PAGE_SIZE);
94ASSYM(NPTEPG, NPTEPG);
95ASSYM(NPDEPG, NPDEPG);
96ASSYM(addr_PTmap, addr_PTmap);
97ASSYM(addr_PDmap, addr_PDmap);
98ASSYM(addr_PDPmap, addr_PDPmap);
99ASSYM(addr_PML4map, addr_PML4map);
100ASSYM(addr_PML4pml4e, addr_PML4pml4e);
101ASSYM(PDESIZE, sizeof(pd_entry_t));
102ASSYM(PTESIZE, sizeof(pt_entry_t));
103ASSYM(PTESHIFT, PTESHIFT);
104ASSYM(PAGE_SHIFT, PAGE_SHIFT);
105ASSYM(PAGE_MASK, PAGE_MASK);
106ASSYM(PDRSHIFT, PDRSHIFT);
107ASSYM(PDPSHIFT, PDPSHIFT);
108ASSYM(PML4SHIFT, PML4SHIFT);
109ASSYM(val_KPDPI, KPDPI);
110ASSYM(val_KPML4I, KPML4I);
111ASSYM(val_PML4PML4I, PML4PML4I);
112ASSYM(USRSTACK, USRSTACK);
113ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS);
114ASSYM(KERNBASE, KERNBASE);
115ASSYM(DMAP_MIN_ADDRESS, DMAP_MIN_ADDRESS);
116ASSYM(DMAP_MAX_ADDRESS, DMAP_MAX_ADDRESS);
117ASSYM(MCLBYTES, MCLBYTES);
118ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3));
119ASSYM(PCB_R15, offsetof(struct pcb, pcb_r15));
120ASSYM(PCB_R14, offsetof(struct pcb, pcb_r14));
121ASSYM(PCB_R13, offsetof(struct pcb, pcb_r13));
122ASSYM(PCB_R12, offsetof(struct pcb, pcb_r12));
123ASSYM(PCB_RBP, offsetof(struct pcb, pcb_rbp));
124ASSYM(PCB_RSP, offsetof(struct pcb, pcb_rsp));
125ASSYM(PCB_RBX, offsetof(struct pcb, pcb_rbx));
126ASSYM(PCB_RIP, offsetof(struct pcb, pcb_rip));
127ASSYM(PCB_RFLAGS, offsetof(struct pcb, pcb_rflags));
128ASSYM(PCB_FSBASE, offsetof(struct pcb, pcb_fsbase));
129ASSYM(PCB_GSBASE, offsetof(struct pcb, pcb_gsbase));
130ASSYM(PCB_DS, offsetof(struct pcb, pcb_ds));
131ASSYM(PCB_ES, offsetof(struct pcb, pcb_es));
132ASSYM(PCB_FS, offsetof(struct pcb, pcb_fs));
133ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs));
134ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
135ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
136ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
137ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
138ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
139ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
140ASSYM(PCB_DBREGS, PCB_DBREGS);
141ASSYM(PCB_32BIT, PCB_32BIT);
142
143ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
144ASSYM(PCB_FULLCTX, PCB_FULLCTX);
145ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save));
146ASSYM(PCB_SAVEFPU_SIZE, sizeof(struct savefpu));
147ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
148
149ASSYM(PCB_SIZE, sizeof(struct pcb));
150
151ASSYM(COMMON_TSS_RSP0, offsetof(struct amd64tss, tss_rsp0));
152
153ASSYM(TF_R15, offsetof(struct trapframe, tf_r15));
154ASSYM(TF_R14, offsetof(struct trapframe, tf_r14));
155ASSYM(TF_R13, offsetof(struct trapframe, tf_r13));
156ASSYM(TF_R12, offsetof(struct trapframe, tf_r12));
157ASSYM(TF_R11, offsetof(struct trapframe, tf_r11));
158ASSYM(TF_R10, offsetof(struct trapframe, tf_r10));
159ASSYM(TF_R9, offsetof(struct trapframe, tf_r9));
160ASSYM(TF_R8, offsetof(struct trapframe, tf_r8));
161ASSYM(TF_RDI, offsetof(struct trapframe, tf_rdi));
162ASSYM(TF_RSI, offsetof(struct trapframe, tf_rsi));
163ASSYM(TF_RBP, offsetof(struct trapframe, tf_rbp));
164ASSYM(TF_RBX, offsetof(struct trapframe, tf_rbx));
165ASSYM(TF_RDX, offsetof(struct trapframe, tf_rdx));
166ASSYM(TF_RCX, offsetof(struct trapframe, tf_rcx));
167ASSYM(TF_RAX, offsetof(struct trapframe, tf_rax));
168ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno));
169ASSYM(TF_ADDR, offsetof(struct trapframe, tf_addr));
170ASSYM(TF_ERR, offsetof(struct trapframe, tf_err));
171ASSYM(TF_RIP, offsetof(struct trapframe, tf_rip));
172ASSYM(TF_CS, offsetof(struct trapframe, tf_cs));
173ASSYM(TF_RFLAGS, offsetof(struct trapframe, tf_rflags));
174ASSYM(TF_RSP, offsetof(struct trapframe, tf_rsp));
175ASSYM(TF_SS, offsetof(struct trapframe, tf_ss));
176ASSYM(TF_SIZE, sizeof(struct trapframe));
177
178ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler));
179ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
180ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_rflags));
181ASSYM(ENOENT, ENOENT);
182ASSYM(EFAULT, EFAULT);
183ASSYM(ENAMETOOLONG, ENAMETOOLONG);
184ASSYM(MAXCOMLEN, MAXCOMLEN);
185ASSYM(MAXPATHLEN, MAXPATHLEN);
186ASSYM(PC_SIZEOF, sizeof(struct pcpu));
187ASSYM(PC_PRVSPACE, offsetof(struct pcpu, pc_prvspace));
188ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread));
189ASSYM(PC_FPCURTHREAD, offsetof(struct pcpu, pc_fpcurthread));
190ASSYM(PC_IDLETHREAD, offsetof(struct pcpu, pc_idlethread));
191ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb));
192ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid));
193ASSYM(PC_SCRATCH_RSP, offsetof(struct pcpu, pc_scratch_rsp));
194ASSYM(PC_CURPMAP, offsetof(struct pcpu, pc_curpmap));
195ASSYM(PC_TSSP, offsetof(struct pcpu, pc_tssp));
196ASSYM(PC_RSP0, offsetof(struct pcpu, pc_rsp0));
197
198ASSYM(LA_VER, offsetof(struct LAPIC, version));
199ASSYM(LA_TPR, offsetof(struct LAPIC, tpr));
200ASSYM(LA_EOI, offsetof(struct LAPIC, eoi));
201ASSYM(LA_SVR, offsetof(struct LAPIC, svr));
202ASSYM(LA_ICR_LO, offsetof(struct LAPIC, icr_lo));
203ASSYM(LA_ICR_HI, offsetof(struct LAPIC, icr_hi));
204ASSYM(LA_ISR, offsetof(struct LAPIC, isr0));
205
206ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL));
207ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL));
208ASSYM(KUCSEL, GSEL(GUCODE_SEL, SEL_UPL));
209ASSYM(KUDSEL, GSEL(GUDATA_SEL, SEL_UPL));
210ASSYM(KUC32SEL, GSEL(GUCODE32_SEL, SEL_UPL));
211ASSYM(SEL_RPL_MASK, SEL_RPL_MASK);
212
213ASSYM(MTX_LOCK, offsetof(struct mtx, mtx_lock));
214ASSYM(MTX_RECURSECNT, offsetof(struct mtx, mtx_recurse));
215