amd64: Fix a bug in cpu_prepare_lwp().
[dragonfly.git] / sys / platform / pc64 / amd64 / genassym.c
CommitLineData
d7f50089
YY
1/*-
2 * Copyright (c) 1982, 1990 The Regents of the University of California.
c8fe38ae 3 * Copyright (c) 2008 The DragonFly Project.
d7f50089
YY
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * William Jolitz.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91
38 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $
c8fe38ae 39 * $DragonFly: src/sys/platform/pc64/amd64/genassym.c,v 1.2 2008/08/29 17:07:10 dillon Exp $
d7f50089
YY
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/assym.h>
45#include <sys/interrupt.h>
46#include <sys/buf.h>
47#include <sys/proc.h>
48#include <sys/errno.h>
49#include <sys/mount.h>
50#include <sys/socket.h>
51#include <sys/lock.h>
52#include <sys/resourcevar.h>
53#include <machine/frame.h>
54#include <machine/bootinfo.h>
55#include <machine/tss.h>
56#include <sys/vmmeter.h>
57#include <sys/machintr.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 <net/if.h>
63#include <netinet/in.h>
64#include <vfs/nfs/nfsv2.h>
65#include <vfs/nfs/rpcv2.h>
66#include <vfs/nfs/nfs.h>
67#include <vfs/nfs/nfsdiskless.h>
68
69#include <machine/segments.h>
70#include <machine/sigframe.h>
71#include <machine/globaldata.h>
c8fe38ae 72#include <machine/specialreg.h>
d7f50089
YY
73#include <machine/pcb.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));
78
c8fe38ae 79ASSYM(LWP_VMSPACE, offsetof(struct lwp, lwp_vmspace));
d7f50089
YY
80ASSYM(UPAGES, UPAGES);
81ASSYM(PAGE_SIZE, PAGE_SIZE);
82ASSYM(NPTEPG, NPTEPG);
83ASSYM(NPDEPG, NPDEPG);
84ASSYM(PDESIZE, PDESIZE);
85ASSYM(PTESIZE, PTESIZE);
86ASSYM(PAGE_SHIFT, PAGE_SHIFT);
87ASSYM(PAGE_MASK, PAGE_MASK);
88ASSYM(PDRSHIFT, PDRSHIFT);
89ASSYM(USRSTACK, USRSTACK);
90ASSYM(KERNBASE, KERNBASE);
91
c8fe38ae
MD
92ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap));
93ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
94ASSYM(V_SENDSYS, offsetof(struct vmmeter, v_sendsys));
95ASSYM(V_WAITSYS, offsetof(struct vmmeter, v_waitsys));
96ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
97ASSYM(V_FORWARDED_INTS, offsetof(struct vmmeter, v_forwarded_ints));
98ASSYM(V_FORWARDED_HITS, offsetof(struct vmmeter, v_forwarded_hits));
99ASSYM(V_FORWARDED_MISSES, offsetof(struct vmmeter, v_forwarded_misses));
100
d7f50089
YY
101ASSYM(MAXCOMLEN, MAXCOMLEN);
102ASSYM(EFAULT, EFAULT);
103ASSYM(ENAMETOOLONG, ENAMETOOLONG);
48ffc236 104ASSYM(VM_MAX_USER_ADDRESS, VM_MAX_USER_ADDRESS);
c8fe38ae 105
d7f50089 106ASSYM(GD_CURTHREAD, offsetof(struct mdglobaldata, mi.gd_curthread));
c8fe38ae
MD
107ASSYM(GD_CNT, offsetof(struct mdglobaldata, mi.gd_cnt));
108ASSYM(GD_CPUID, offsetof(struct mdglobaldata, mi.gd_cpuid));
109
110ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3));
111ASSYM(PCB_R15, offsetof(struct pcb, pcb_r15));
112ASSYM(PCB_R14, offsetof(struct pcb, pcb_r14));
113ASSYM(PCB_R13, offsetof(struct pcb, pcb_r13));
114ASSYM(PCB_R12, offsetof(struct pcb, pcb_r12));
115ASSYM(PCB_RSI, offsetof(struct pcb, pcb_rsi));
116ASSYM(PCB_RBP, offsetof(struct pcb, pcb_rbp));
117ASSYM(PCB_RSP, offsetof(struct pcb, pcb_rsp));
118ASSYM(PCB_RBX, offsetof(struct pcb, pcb_rbx));
119ASSYM(PCB_RIP, offsetof(struct pcb, pcb_rip));
0855a2af
JG
120ASSYM(TSS_RSP0, offsetof(struct amd64tss, tss_rsp0));
121
122ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
123ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
124ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
125ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
126ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
127ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
128ASSYM(PCB_DBREGS, PCB_DBREGS);
c8fe38ae 129ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext));
c8fe38ae 130ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
d7f50089 131ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
c8fe38ae
MD
132ASSYM(PCB_FSBASE, offsetof(struct pcb, pcb_fsbase));
133ASSYM(PCB_GSBASE, offsetof(struct pcb, pcb_gsbase));
134
135ASSYM(TF_R15, offsetof(struct trapframe, tf_r15));
136ASSYM(TF_R14, offsetof(struct trapframe, tf_r14));
137ASSYM(TF_R13, offsetof(struct trapframe, tf_r13));
138ASSYM(TF_R12, offsetof(struct trapframe, tf_r12));
139ASSYM(TF_R11, offsetof(struct trapframe, tf_r11));
140ASSYM(TF_R10, offsetof(struct trapframe, tf_r10));
141ASSYM(TF_R9, offsetof(struct trapframe, tf_r9));
142ASSYM(TF_R8, offsetof(struct trapframe, tf_r8));
143ASSYM(TF_RDI, offsetof(struct trapframe, tf_rdi));
144ASSYM(TF_RSI, offsetof(struct trapframe, tf_rsi));
145ASSYM(TF_RBP, offsetof(struct trapframe, tf_rbp));
146ASSYM(TF_RBX, offsetof(struct trapframe, tf_rbx));
147ASSYM(TF_RDX, offsetof(struct trapframe, tf_rdx));
148ASSYM(TF_RCX, offsetof(struct trapframe, tf_rcx));
149ASSYM(TF_RAX, offsetof(struct trapframe, tf_rax));
150
151ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno));
5b9f6cc4 152ASSYM(TF_XFLAGS, offsetof(struct trapframe, tf_xflags));
c8fe38ae
MD
153ASSYM(TF_ADDR, offsetof(struct trapframe, tf_addr));
154ASSYM(TF_ERR, offsetof(struct trapframe, tf_err));
155ASSYM(TF_FLAGS, offsetof(struct trapframe, tf_flags));
156
157ASSYM(TF_RIP, offsetof(struct trapframe, tf_rip));
158ASSYM(TF_CS, offsetof(struct trapframe, tf_cs));
159ASSYM(TF_RFLAGS, offsetof(struct trapframe, tf_rflags));
160ASSYM(TF_RSP, offsetof(struct trapframe, tf_rsp));
161ASSYM(TF_SS, offsetof(struct trapframe, tf_ss));
162ASSYM(TF_SIZE, sizeof(struct trapframe));
d7f50089
YY
163
164ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler));
165ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
166
c8fe38ae
MD
167ASSYM(TD_PROC, offsetof(struct thread, td_proc));
168ASSYM(TD_LWP, offsetof(struct thread, td_lwp));
169ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
170ASSYM(TD_SP, offsetof(struct thread, td_sp));
171ASSYM(TD_PRI, offsetof(struct thread, td_pri));
172ASSYM(TD_MACH, offsetof(struct thread, td_mach));
173ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan));
174ASSYM(TD_NEST_COUNT, offsetof(struct thread, td_nest_count));
175#ifdef SMP
176ASSYM(TD_MPCOUNT, offsetof(struct thread, td_mpcount));
177#endif
178ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
179ASSYM(TDF_RUNNING, TDF_RUNNING);
180ASSYM(TDF_USINGFP, TDF_USINGFP);
181ASSYM(TDF_KERNELFP, TDF_KERNELFP);
182
183ASSYM(FIRST_SOFTINT, FIRST_SOFTINT);
184ASSYM(MDGLOBALDATA_BASEALLOC_PAGES, MDGLOBALDATA_BASEALLOC_PAGES);
185
186ASSYM(GD_PRIVATE_TSS, offsetof(struct mdglobaldata, gd_private_tss));
187ASSYM(GD_SCRATCH_RSP, offsetof(struct mdglobaldata, gd_scratch_rsp));
188ASSYM(GD_RSP0, offsetof(struct mdglobaldata, gd_rsp0));
189ASSYM(GD_USER_FS, offsetof(struct mdglobaldata, gd_user_fs));
190ASSYM(GD_USER_GS, offsetof(struct mdglobaldata, gd_user_gs));
191ASSYM(GD_INTR_NESTING_LEVEL, offsetof(struct mdglobaldata, mi.gd_intr_nesting_level));
192
193ASSYM(GD_FPENDING, offsetof(struct mdglobaldata, gd_fpending));
194ASSYM(GD_IPENDING, offsetof(struct mdglobaldata, gd_ipending));
195ASSYM(GD_SPENDING, offsetof(struct mdglobaldata, gd_spending));
196ASSYM(GD_COMMON_TSS, offsetof(struct mdglobaldata, gd_common_tss));
197ASSYM(GD_COMMON_TSSD, offsetof(struct mdglobaldata, gd_common_tssd));
198ASSYM(GD_TSS_GDT, offsetof(struct mdglobaldata, gd_tss_gdt));
199ASSYM(GD_NPXTHREAD, offsetof(struct mdglobaldata, gd_npxthread));
200ASSYM(GD_FPU_LOCK, offsetof(struct mdglobaldata, gd_fpu_lock));
201ASSYM(GD_SAVEFPU, offsetof(struct mdglobaldata, gd_savefpu));
202ASSYM(GD_OTHER_CPUS, offsetof(struct mdglobaldata, gd_other_cpus));
203ASSYM(GD_SS_EFLAGS, offsetof(struct mdglobaldata, gd_ss_eflags));
204ASSYM(GD_REQFLAGS, offsetof(struct mdglobaldata, mi.gd_reqflags));
205
206ASSYM(RQF_IPIQ, RQF_IPIQ);
207ASSYM(RQF_INTPEND, RQF_INTPEND);
208ASSYM(RQF_AST_OWEUPC, RQF_AST_OWEUPC);
209ASSYM(RQF_AST_SIGNAL, RQF_AST_SIGNAL);
210ASSYM(RQF_AST_USER_RESCHED, RQF_AST_USER_RESCHED);
211ASSYM(RQF_AST_LWKT_RESCHED, RQF_AST_LWKT_RESCHED);
212ASSYM(RQF_AST_UPCALL, RQF_AST_UPCALL);
213ASSYM(RQF_AST_MASK, RQF_AST_MASK);
214
d7f50089
YY
215ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL));
216ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL));
c8fe38ae
MD
217ASSYM(KUCSEL, GSEL(GUCODE_SEL, SEL_UPL));
218ASSYM(KUDSEL, GSEL(GUDATA_SEL, SEL_UPL));
219ASSYM(SEL_RPL_MASK, SEL_RPL_MASK);
d7f50089 220
c8fe38ae
MD
221ASSYM(MSR_GSBASE, MSR_GSBASE);
222ASSYM(MSR_KGSBASE, MSR_KGSBASE);
223ASSYM(MSR_FSBASE, MSR_FSBASE);
224
225ASSYM(MACHINTR_INTREN, offsetof(struct machintr_abi, intren));
d7f50089
YY
226
227ASSYM(TDPRI_CRIT, TDPRI_CRIT);
228ASSYM(TDPRI_INT_SUPPORT, TDPRI_INT_SUPPORT);