genassym.c revision 67899
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 67899 2000-10-29 16:57:42Z phk $
38 */
39
40#include "opt_user_ldt.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/* XXX */
54#ifdef KTR_PERCPU
55#include <sys/ktr.h>
56#endif
57#include <machine/bootinfo.h>
58#include <machine/tss.h>
59#include <sys/vmmeter.h>
60#include <vm/vm.h>
61#include <vm/vm_param.h>
62#include <vm/pmap.h>
63#include <vm/vm_map.h>
64#include <sys/user.h>
65#include <net/if.h>
66#include <netinet/in.h>
67#include <nfs/nfsv2.h>
68#include <nfs/rpcv2.h>
69#include <nfs/nfs.h>
70#include <nfs/nfsdiskless.h>
71#ifdef SMP
72#include <machine/apic.h>
73#endif
74#include <machine/cpu.h>
75#include <machine/sigframe.h>
76#include <machine/globaldata.h>
77#include <machine/vm86.h>
78
79ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace));
80ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap));
81ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active));
82ASSYM(P_ADDR, offsetof(struct proc, p_addr));
83ASSYM(P_STAT, offsetof(struct proc, p_stat));
84ASSYM(P_WCHAN, offsetof(struct proc, p_wchan));
85
86#ifdef SMP
87ASSYM(P_ONCPU, offsetof(struct proc, p_oncpu));
88ASSYM(P_LASTCPU, offsetof(struct proc, p_lastcpu));
89#endif
90
91ASSYM(SSLEEP, SSLEEP);
92ASSYM(SRUN, SRUN);
93ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap));
94ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
95ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
96ASSYM(UPAGES, UPAGES);
97ASSYM(PAGE_SIZE, PAGE_SIZE);
98ASSYM(NPTEPG, NPTEPG);
99ASSYM(NPDEPG, NPDEPG);
100ASSYM(PDESIZE, PDESIZE);
101ASSYM(PTESIZE, PTESIZE);
102ASSYM(PAGE_SHIFT, PAGE_SHIFT);
103ASSYM(PAGE_MASK, PAGE_MASK);
104ASSYM(PDRSHIFT, PDRSHIFT);
105ASSYM(USRSTACK, USRSTACK);
106ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS);
107ASSYM(KERNBASE, KERNBASE);
108ASSYM(MCLBYTES, MCLBYTES);
109ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3));
110ASSYM(PCB_EDI, offsetof(struct pcb, pcb_edi));
111ASSYM(PCB_ESI, offsetof(struct pcb, pcb_esi));
112ASSYM(PCB_EBP, offsetof(struct pcb, pcb_ebp));
113ASSYM(PCB_ESP, offsetof(struct pcb, pcb_esp));
114ASSYM(PCB_EBX, offsetof(struct pcb, pcb_ebx));
115ASSYM(PCB_EIP, offsetof(struct pcb, pcb_eip));
116ASSYM(TSS_ESP0, offsetof(struct i386tss, tss_esp0));
117
118#ifdef USER_LDT
119ASSYM(PCB_USERLDT, offsetof(struct pcb, pcb_ldt));
120#endif
121
122ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs));
123ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
124ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
125ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
126ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
127ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
128ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
129ASSYM(PCB_DBREGS, PCB_DBREGS);
130ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext));
131
132ASSYM(PCB_SCHEDNEST, offsetof(struct pcb, pcb_schednest));
133
134ASSYM(PCB_SPARE, offsetof(struct pcb, __pcb_spare));
135ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
136ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_savefpu));
137ASSYM(PCB_SAVEFPU_SIZE, sizeof(struct save87));
138ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
139
140#ifdef SMP
141ASSYM(PCB_SIZE, sizeof(struct pcb));
142#endif
143
144ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno));
145ASSYM(TF_ERR, offsetof(struct trapframe, tf_err));
146ASSYM(TF_CS, offsetof(struct trapframe, tf_cs));
147ASSYM(TF_EFLAGS, offsetof(struct trapframe, tf_eflags));
148ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler));
149ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc));
150ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
151ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps));
152ASSYM(SC_FS, offsetof(struct osigcontext, sc_fs));
153ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs));
154ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno));
155ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags));
156ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs));
157ASSYM(ENOENT, ENOENT);
158ASSYM(EFAULT, EFAULT);
159ASSYM(ENAMETOOLONG, ENAMETOOLONG);
160ASSYM(MAXPATHLEN, MAXPATHLEN);
161ASSYM(BOOTINFO_SIZE, sizeof(struct bootinfo));
162ASSYM(BI_VERSION, offsetof(struct bootinfo, bi_version));
163ASSYM(BI_KERNELNAME, offsetof(struct bootinfo, bi_kernelname));
164ASSYM(BI_NFS_DISKLESS, offsetof(struct bootinfo, bi_nfs_diskless));
165ASSYM(BI_ENDCOMMON, offsetof(struct bootinfo, bi_endcommon));
166ASSYM(NFSDISKLESS_SIZE, sizeof(struct nfs_diskless));
167ASSYM(BI_SIZE, offsetof(struct bootinfo, bi_size));
168ASSYM(BI_SYMTAB, offsetof(struct bootinfo, bi_symtab));
169ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab));
170ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend));
171ASSYM(GD_SIZEOF, sizeof(struct globaldata));
172ASSYM(GD_CURPROC, offsetof(struct globaldata, gd_curproc));
173ASSYM(GD_NPXPROC, offsetof(struct globaldata, gd_npxproc));
174ASSYM(GD_IDLEPROC, offsetof(struct globaldata, gd_idleproc));
175ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb));
176ASSYM(GD_COMMON_TSS, offsetof(struct globaldata, gd_common_tss));
177ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime));
178ASSYM(GD_SWITCHTICKS, offsetof(struct globaldata, gd_switchticks));
179ASSYM(GD_COMMON_TSSD, offsetof(struct globaldata, gd_common_tssd));
180ASSYM(GD_TSS_GDT, offsetof(struct globaldata, gd_tss_gdt));
181ASSYM(GD_ASTPENDING, offsetof(struct globaldata, gd_astpending));
182ASSYM(AST_PENDING, AST_PENDING);
183ASSYM(AST_RESCHED, AST_RESCHED);
184ASSYM(GD_INTR_NESTING_LEVEL, offsetof(struct globaldata, gd_intr_nesting_level));
185
186#ifdef USER_LDT
187ASSYM(GD_CURRENTLDT, offsetof(struct globaldata, gd_currentldt));
188#endif
189
190ASSYM(GD_WITNESS_SPIN_CHECK, offsetof(struct globaldata, gd_witness_spin_check));
191
192/* XXX */
193#ifdef KTR_PERCPU
194ASSYM(GD_KTR_IDX, offsetof(struct globaldata, gd_ktr_idx));
195ASSYM(GD_KTR_BUF, offsetof(struct globaldata, gd_ktr_buf));
196ASSYM(GD_KTR_BUF_DATA, offsetof(struct globaldata, gd_ktr_buf_data));
197#endif
198
199#ifdef SMP
200ASSYM(GD_CPUID, offsetof(struct globaldata, gd_cpuid));
201ASSYM(GD_CPU_LOCKID, offsetof(struct globaldata, gd_cpu_lockid));
202ASSYM(GD_OTHER_CPUS, offsetof(struct globaldata, gd_other_cpus));
203ASSYM(GD_SS_EFLAGS, offsetof(struct globaldata, gd_ss_eflags));
204ASSYM(GD_INSIDE_INTR, offsetof(struct globaldata, gd_inside_intr));
205ASSYM(GD_PRV_CMAP1, offsetof(struct globaldata, gd_prv_CMAP1));
206ASSYM(GD_PRV_CMAP2, offsetof(struct globaldata, gd_prv_CMAP2));
207ASSYM(GD_PRV_CMAP3, offsetof(struct globaldata, gd_prv_CMAP3));
208ASSYM(GD_PRV_PMAP1, offsetof(struct globaldata, gd_prv_PMAP1));
209ASSYM(GD_PRV_CADDR1, offsetof(struct globaldata, gd_prv_CADDR1));
210ASSYM(GD_PRV_CADDR2, offsetof(struct globaldata, gd_prv_CADDR2));
211ASSYM(GD_PRV_CADDR3, offsetof(struct globaldata, gd_prv_CADDR3));
212ASSYM(GD_PRV_PADDR1, offsetof(struct globaldata, gd_prv_PADDR1));
213ASSYM(PS_IDLESTACK, offsetof(struct privatespace, idlestack));
214ASSYM(PS_IDLESTACK_TOP, sizeof(struct privatespace));
215#endif
216
217ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL));
218ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL));
219
220#ifdef SMP
221ASSYM(KPSEL, GSEL(GPRIV_SEL, SEL_KPL));
222#endif
223
224ASSYM(BC32SEL, GSEL(GBIOSCODE32_SEL, SEL_KPL));
225ASSYM(GPROC0_SEL, GPROC0_SEL);
226ASSYM(VM86_FRAMESIZE, sizeof(struct vm86frame));
227
228ASSYM(MTX_LOCK, offsetof(struct mtx, mtx_lock));
229ASSYM(MTX_RECURSE, offsetof(struct mtx, mtx_recurse));
230ASSYM(MTX_SAVEINTR, offsetof(struct mtx, mtx_saveintr));
231
232ASSYM(MTX_UNOWNED, MTX_UNOWNED);
233