MP Implementation 1/2: Get the APIC code working again, sweetly integrate the
[dragonfly.git] / sys / platform / vkernel / i386 / genassym.c
CommitLineData
984263bc
MD
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 $
8a8d5d85 38 * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.21 2003/07/06 21:23:48 dillon Exp $
984263bc
MD
39 */
40
41#include "opt_user_ldt.h"
42
43#include <stddef.h>
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/assym.h>
48#include <sys/buf.h>
49#include <sys/proc.h>
50#include <sys/errno.h>
51#include <sys/mount.h>
52#include <sys/socket.h>
8a8d5d85 53#include <sys/lock.h>
984263bc
MD
54#include <sys/resourcevar.h>
55#include <machine/frame.h>
56#include <machine/bootinfo.h>
57#include <machine/tss.h>
58#include <sys/vmmeter.h>
59#include <vm/vm.h>
60#include <vm/vm_param.h>
61#include <vm/pmap.h>
62#include <vm/vm_map.h>
63#include <sys/user.h>
64#include <net/if.h>
65#include <netinet/in.h>
66#include <nfs/nfsv2.h>
67#include <nfs/rpcv2.h>
68#include <nfs/nfs.h>
69#include <nfs/nfsdiskless.h>
70#ifdef SMP
71#include <machine/apic.h>
72#endif
73#include <machine/segments.h>
74#include <machine/sigframe.h>
984263bc 75#include <machine/vm86.h>
85100692 76#include <machine/globaldata.h>
984263bc
MD
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_ADDR, offsetof(struct proc, p_addr));
82ASSYM(P_STAT, offsetof(struct proc, p_stat));
263e4574 83ASSYM(P_THREAD, offsetof(struct proc, p_thread));
84b592ba
MD
84
85ASSYM(TD_PROC, offsetof(struct thread, td_proc));
b7c628e4 86ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
8ad65e08 87ASSYM(TD_SP, offsetof(struct thread, td_sp));
f1d1c3fa
MD
88ASSYM(TD_PRI, offsetof(struct thread, td_pri));
89ASSYM(TD_MACH, offsetof(struct thread, td_mach));
0cfcada1 90ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan));
8a8d5d85
MD
91#ifdef SMP
92ASSYM(TD_MPCOUNT, offsetof(struct thread, td_mpcount));
93#endif
99df837e
MD
94ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
95ASSYM(TDF_EXITED, TDF_EXITED);
8a8d5d85
MD
96#ifdef SMP
97ASSYM(MP_FREE_LOCK, MP_FREE_LOCK);
98#endif
ae8050a4
MD
99
100ASSYM(RW_OWNER, offsetof(struct lwkt_rwlock, rw_owner));
f1d1c3fa 101
ef0fdad1 102ASSYM(TD_CPL, offsetof(struct thread, td_mach) + offsetof(struct md_thread, mtd_cpl));
f1d1c3fa
MD
103
104ASSYM(TDPRI_CRIT, TDPRI_CRIT);
984263bc 105
984263bc
MD
106ASSYM(SSLEEP, SSLEEP);
107ASSYM(SRUN, SRUN);
108ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap));
109ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
110ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
8a8d5d85
MD
111ASSYM(V_FORWARDED_HITS, offsetof(struct vmmeter, v_forwarded_hits));
112ASSYM(V_FORWARDED_MISSES, offsetof(struct vmmeter, v_forwarded_misses));
984263bc
MD
113ASSYM(UPAGES, UPAGES);
114ASSYM(PAGE_SIZE, PAGE_SIZE);
115ASSYM(NPTEPG, NPTEPG);
116ASSYM(NPDEPG, NPDEPG);
117ASSYM(PDESIZE, PDESIZE);
118ASSYM(PTESIZE, PTESIZE);
119ASSYM(PAGE_SHIFT, PAGE_SHIFT);
120ASSYM(PAGE_MASK, PAGE_MASK);
121ASSYM(PDRSHIFT, PDRSHIFT);
122ASSYM(USRSTACK, USRSTACK);
123ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS);
124ASSYM(KERNBASE, KERNBASE);
125ASSYM(MCLBYTES, MCLBYTES);
126ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3));
127ASSYM(PCB_EDI, offsetof(struct pcb, pcb_edi));
128ASSYM(PCB_ESI, offsetof(struct pcb, pcb_esi));
129ASSYM(PCB_EBP, offsetof(struct pcb, pcb_ebp));
130ASSYM(PCB_ESP, offsetof(struct pcb, pcb_esp));
131ASSYM(PCB_EBX, offsetof(struct pcb, pcb_ebx));
132ASSYM(PCB_EIP, offsetof(struct pcb, pcb_eip));
133ASSYM(TSS_ESP0, offsetof(struct i386tss, tss_esp0));
134
135#ifdef USER_LDT
136ASSYM(PCB_USERLDT, offsetof(struct pcb, pcb_ldt));
137#endif
138
139ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs));
140ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
141ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
142ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
143ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
144ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
145ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
146ASSYM(PCB_DBREGS, PCB_DBREGS);
147ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext));
148
984263bc
MD
149ASSYM(PCB_SPARE, offsetof(struct pcb, __pcb_spare));
150ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
151ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save));
152ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu));
153ASSYM(PCB_SAVE87_SIZE, sizeof(struct save87));
154ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
155
984263bc 156ASSYM(PCB_SIZE, sizeof(struct pcb));
984263bc
MD
157
158ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno));
159ASSYM(TF_ERR, offsetof(struct trapframe, tf_err));
160ASSYM(TF_CS, offsetof(struct trapframe, tf_cs));
161ASSYM(TF_EFLAGS, offsetof(struct trapframe, tf_eflags));
162ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler));
163ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc));
164ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
165ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps));
166ASSYM(SC_FS, offsetof(struct osigcontext, sc_fs));
167ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs));
168ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno));
169ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags));
170ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs));
171ASSYM(B_READ, B_READ);
172ASSYM(ENOENT, ENOENT);
173ASSYM(EFAULT, EFAULT);
174ASSYM(ENAMETOOLONG, ENAMETOOLONG);
175ASSYM(MAXPATHLEN, MAXPATHLEN);
176ASSYM(BOOTINFO_SIZE, sizeof(struct bootinfo));
177ASSYM(BI_VERSION, offsetof(struct bootinfo, bi_version));
178ASSYM(BI_KERNELNAME, offsetof(struct bootinfo, bi_kernelname));
179ASSYM(BI_NFS_DISKLESS, offsetof(struct bootinfo, bi_nfs_diskless));
180ASSYM(BI_ENDCOMMON, offsetof(struct bootinfo, bi_endcommon));
181ASSYM(NFSDISKLESS_SIZE, sizeof(struct nfs_diskless));
182ASSYM(BI_SIZE, offsetof(struct bootinfo, bi_size));
183ASSYM(BI_SYMTAB, offsetof(struct bootinfo, bi_symtab));
184ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab));
185ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend));
85100692
MD
186
187ASSYM(GD_CURTHREAD, offsetof(struct mdglobaldata, mi.gd_curthread));
188ASSYM(GD_REQPRI, offsetof(struct mdglobaldata, mi.gd_reqpri));
189ASSYM(GD_CPUID, offsetof(struct mdglobaldata, mi.gd_cpuid));
12e4aaff 190ASSYM(GD_CNT, offsetof(struct mdglobaldata, mi.gd_cnt));
ef0fdad1 191ASSYM(GD_INTR_NESTING_LEVEL, offsetof(struct mdglobaldata, mi.gd_intr_nesting_level));
85100692 192ASSYM(GD_ASTPENDING, offsetof(struct mdglobaldata, mi.gd_astpending));
984263bc
MD
193
194#ifdef USER_LDT
85100692 195ASSYM(GD_CURRENTLDT, offsetof(struct mdglobaldata, gd_currentldt));
984263bc
MD
196#endif
197
ef0fdad1
MD
198ASSYM(GD_FPENDING, offsetof(struct mdglobaldata, gd_fpending));
199ASSYM(GD_IPENDING, offsetof(struct mdglobaldata, gd_ipending));
200ASSYM(GD_IRUNNING, offsetof(struct mdglobaldata, gd_irunning));
85100692
MD
201ASSYM(GD_COMMON_TSS, offsetof(struct mdglobaldata, gd_common_tss));
202ASSYM(GD_COMMON_TSSD, offsetof(struct mdglobaldata, gd_common_tssd));
203ASSYM(GD_TSS_GDT, offsetof(struct mdglobaldata, gd_tss_gdt));
204ASSYM(GD_IDLETHREAD, offsetof(struct mdglobaldata, gd_idlethread));
205ASSYM(GD_NPXTHREAD, offsetof(struct mdglobaldata, gd_npxthread));
206ASSYM(GD_CPU_LOCKID, offsetof(struct mdglobaldata, gd_cpu_lockid));
207ASSYM(GD_OTHER_CPUS, offsetof(struct mdglobaldata, gd_other_cpus));
208ASSYM(GD_SS_EFLAGS, offsetof(struct mdglobaldata, gd_ss_eflags));
209ASSYM(GD_CMAP1, offsetof(struct mdglobaldata, gd_CMAP1));
210ASSYM(GD_CMAP2, offsetof(struct mdglobaldata, gd_CMAP2));
211ASSYM(GD_CMAP3, offsetof(struct mdglobaldata, gd_CMAP3));
212ASSYM(GD_PMAP1, offsetof(struct mdglobaldata, gd_PMAP1));
213ASSYM(GD_CADDR1, offsetof(struct mdglobaldata, gd_CADDR1));
214ASSYM(GD_CADDR2, offsetof(struct mdglobaldata, gd_CADDR2));
215ASSYM(GD_CADDR3, offsetof(struct mdglobaldata, gd_CADDR3));
216ASSYM(GD_PADDR1, offsetof(struct mdglobaldata, gd_PADDR1));
17a9f566 217
984263bc 218ASSYM(PS_IDLESTACK, offsetof(struct privatespace, idlestack));
17a9f566 219ASSYM(PS_IDLESTACK_PAGE, offsetof(struct privatespace, idlestack) / PAGE_SIZE);
984263bc 220ASSYM(PS_IDLESTACK_TOP, sizeof(struct privatespace));
8ad65e08 221ASSYM(PS_SIZEOF, sizeof(struct privatespace));
984263bc
MD
222
223ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL));
224ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL));
984263bc 225ASSYM(KPSEL, GSEL(GPRIV_SEL, SEL_KPL));
984263bc
MD
226
227ASSYM(BC32SEL, GSEL(GBIOSCODE32_SEL, SEL_KPL));
228ASSYM(GPROC0_SEL, GPROC0_SEL);
229ASSYM(VM86_FRAMESIZE, sizeof(struct vm86frame));
230
231#ifdef PC98
232#include <machine/bus.h>
233
234ASSYM(BUS_SPACE_HANDLE_BASE, offsetof(struct bus_space_handle, bsh_base));
235ASSYM(BUS_SPACE_HANDLE_IAT, offsetof(struct bus_space_handle, bsh_iat));
236#endif