Merge branch 'vendor/DHCPCD'
[dragonfly.git] / sys / platform / pc64 / x86_64 / genassym.c
1 /*-
2  * Copyright (c) 1982, 1990 The Regents of the University of California.
3  * Copyright (c) 2008 The DragonFly Project.
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. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *      from: @(#)genassym.c    5.11 (Berkeley) 5/10/91
34  * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $
35  */
36
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/assym.h>
40 #include <sys/interrupt.h>
41 #include <sys/buf.h>
42 #include <sys/proc.h>
43 #include <sys/errno.h>
44 #include <sys/mount.h>
45 #include <sys/socket.h>
46 #include <sys/lock.h>
47 #include <sys/resourcevar.h>
48 #include <machine/frame.h>
49 #include <machine/bootinfo.h>
50 #include <machine/tss.h>
51 #include <sys/vmmeter.h>
52 #include <sys/machintr.h>
53 #include <vm/vm.h>
54 #include <vm/vm_param.h>
55 #include <vm/pmap.h>
56 #include <vm/vm_map.h>
57 #include <net/if.h>
58 #include <netinet/in.h>
59 #include <vfs/nfs/nfsv2.h>
60 #include <vfs/nfs/rpcv2.h>
61 #include <vfs/nfs/nfs.h>
62 #include <vfs/nfs/nfsdiskless.h>
63
64 #include <machine_base/apic/apicreg.h>
65 #include <machine_base/apic/ioapic_abi.h>
66 #include <machine/segments.h>
67 #include <machine/sigframe.h>
68 #include <machine/globaldata.h>
69 #include <machine/specialreg.h>
70 #include <machine/pcb.h>
71 #include <machine/pmap.h>
72
73 ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap));
74 ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active));
75 ASSYM(PM_ACTIVE_LOCK, offsetof(struct pmap, pm_active_lock));
76
77 ASSYM(LWP_VMSPACE, offsetof(struct lwp, lwp_vmspace));
78 ASSYM(V_IPI, offsetof(struct vmmeter, v_ipi));
79 ASSYM(V_TIMER, offsetof(struct vmmeter, v_timer));
80 ASSYM(UPAGES, UPAGES);
81 ASSYM(PAGE_SIZE, PAGE_SIZE);
82 ASSYM(NPTEPG, NPTEPG);
83 ASSYM(NPDEPG, NPDEPG);
84 ASSYM(PAGE_SHIFT, PAGE_SHIFT);
85 ASSYM(PAGE_MASK, PAGE_MASK);
86 ASSYM(PDRSHIFT, PDRSHIFT);
87 ASSYM(USRSTACK, USRSTACK);
88 ASSYM(KERNBASE, KERNBASE);
89
90 ASSYM(MAXCOMLEN, MAXCOMLEN);
91 ASSYM(EFAULT, EFAULT);
92 ASSYM(ENAMETOOLONG, ENAMETOOLONG);
93 ASSYM(VM_MAX_USER_ADDRESS, VM_MAX_USER_ADDRESS);
94
95 ASSYM(GD_CURTHREAD, offsetof(struct mdglobaldata, mi.gd_curthread));
96 ASSYM(GD_CNT, offsetof(struct mdglobaldata, mi.gd_cnt));
97 ASSYM(GD_CPUID, offsetof(struct mdglobaldata, mi.gd_cpuid));
98 ASSYM(GD_CPUMASK, offsetof(struct mdglobaldata, mi.gd_cpumask));
99 ASSYM(GD_NPOLL, offsetof(struct mdglobaldata, mi.gd_npoll));
100 ASSYM(GD_SAMPLE_PC, offsetof(struct mdglobaldata, mi.gd_sample_pc));
101 ASSYM(GD_SAMPLE_SP, offsetof(struct mdglobaldata, mi.gd_sample_sp));
102 ASSYM(GD_CPUMASK_SIMPLE, offsetof(struct mdglobaldata, mi.gd_cpumask_simple));
103 ASSYM(GD_CPUMASK_OFFSET, offsetof(struct mdglobaldata, mi.gd_cpumask_offset));
104 ASSYM(GD_IRESERVED, offsetof(struct mdglobaldata, mi.gd_ireserved[0]));
105
106 ASSYM(PCB_CR3_ISO, offsetof(struct pcb, pcb_cr3_iso));
107 ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3));
108 ASSYM(PCB_R15, offsetof(struct pcb, pcb_r15));
109 ASSYM(PCB_R14, offsetof(struct pcb, pcb_r14));
110 ASSYM(PCB_R13, offsetof(struct pcb, pcb_r13));
111 ASSYM(PCB_R12, offsetof(struct pcb, pcb_r12));
112 ASSYM(PCB_RSI, offsetof(struct pcb, pcb_rsi));
113 ASSYM(PCB_RBP, offsetof(struct pcb, pcb_rbp));
114 ASSYM(PCB_RSP, offsetof(struct pcb, pcb_rsp));
115 ASSYM(PCB_RBX, offsetof(struct pcb, pcb_rbx));
116 ASSYM(PCB_RIP, offsetof(struct pcb, pcb_rip));
117 ASSYM(TSS_RSP0, offsetof(struct x86_64tss, tss_rsp0));
118
119 ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
120 ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
121 ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
122 ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
123 ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
124 ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
125
126 ASSYM(PCB_DBREGS, PCB_DBREGS);
127 ASSYM(PCB_ISOMMU, PCB_ISOMMU);
128
129 #if 0 /* we get this from specialreg.h */
130 ASSYM(SPEC_CTRL_IBRS, SPEC_CTRL_IBRS);
131 ASSYM(SPEC_CTRL_STIBP, SPEC_CTRL_STIBP);
132 #endif
133 ASSYM(SPEC_CTRL_DUMMY_IBPB, SPEC_CTRL_DUMMY_IBPB);
134 ASSYM(SPEC_CTRL_DUMMY_ENABLE, SPEC_CTRL_DUMMY_ENABLE);
135 ASSYM(SPEC_CTRL_MDS_ENABLE, SPEC_CTRL_MDS_ENABLE);
136
137 ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext));
138 ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
139 ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
140 ASSYM(PCB_ONFAULT_SP, offsetof(struct pcb, pcb_onfault_sp));
141 ASSYM(PCB_FSBASE, offsetof(struct pcb, pcb_fsbase));
142 ASSYM(PCB_GSBASE, offsetof(struct pcb, pcb_gsbase));
143 ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save));
144
145 ASSYM(PCB_SIZE, sizeof(struct pcb));
146 ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu));
147
148 ASSYM(TF_R15, offsetof(struct trapframe, tf_r15));
149 ASSYM(TF_R14, offsetof(struct trapframe, tf_r14));
150 ASSYM(TF_R13, offsetof(struct trapframe, tf_r13));
151 ASSYM(TF_R12, offsetof(struct trapframe, tf_r12));
152 ASSYM(TF_R11, offsetof(struct trapframe, tf_r11));
153 ASSYM(TF_R10, offsetof(struct trapframe, tf_r10));
154 ASSYM(TF_R9, offsetof(struct trapframe, tf_r9));
155 ASSYM(TF_R8, offsetof(struct trapframe, tf_r8));
156 ASSYM(TF_RDI, offsetof(struct trapframe, tf_rdi));
157 ASSYM(TF_RSI, offsetof(struct trapframe, tf_rsi));
158 ASSYM(TF_RBP, offsetof(struct trapframe, tf_rbp));
159 ASSYM(TF_RBX, offsetof(struct trapframe, tf_rbx));
160 ASSYM(TF_RDX, offsetof(struct trapframe, tf_rdx));
161 ASSYM(TF_RCX, offsetof(struct trapframe, tf_rcx));
162 ASSYM(TF_RAX, offsetof(struct trapframe, tf_rax));
163
164 ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno));
165 ASSYM(TF_XFLAGS, offsetof(struct trapframe, tf_xflags));
166 ASSYM(TF_ADDR, offsetof(struct trapframe, tf_addr));
167 ASSYM(TF_ERR, offsetof(struct trapframe, tf_err));
168 ASSYM(TF_FLAGS, offsetof(struct trapframe, tf_flags));
169
170 ASSYM(TF_RIP, offsetof(struct trapframe, tf_rip));
171 ASSYM(TF_CS, offsetof(struct trapframe, tf_cs));
172 ASSYM(TF_RFLAGS, offsetof(struct trapframe, tf_rflags));
173 ASSYM(TF_RSP, offsetof(struct trapframe, tf_rsp));
174 ASSYM(TF_SS, offsetof(struct trapframe, tf_ss));
175 ASSYM(TF_SIZE, sizeof(struct trapframe));
176
177 ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler));
178 ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
179
180 ASSYM(TD_PROC, offsetof(struct thread, td_proc));
181 ASSYM(TD_LWP, offsetof(struct thread, td_lwp));
182 ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
183 ASSYM(TD_SP, offsetof(struct thread, td_sp));
184 ASSYM(TD_PRI, offsetof(struct thread, td_pri));
185 ASSYM(TD_CRITCOUNT, offsetof(struct thread, td_critcount));
186 ASSYM(TD_MACH, offsetof(struct thread, td_mach));
187 ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan));
188 ASSYM(TD_NEST_COUNT, offsetof(struct thread, td_nest_count));
189 ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
190 ASSYM(TD_TYPE, offsetof(struct thread, td_type));
191 ASSYM(TD_PREEMPTED, offsetof(struct thread, td_preempted));
192
193 ASSYM(TD_SAVEFPU, offsetof(struct thread, td_savefpu));
194 ASSYM(TDF_RUNNING, TDF_RUNNING);
195 ASSYM(TDF_USINGFP, TDF_USINGFP);
196 ASSYM(TDF_KERNELFP, TDF_KERNELFP);
197 ASSYM(TDF_PREEMPT_DONE, TDF_PREEMPT_DONE);
198
199 ASSYM(FIRST_SOFTINT, FIRST_SOFTINT);
200 ASSYM(MDGLOBALDATA_BASEALLOC_PAGES, MDGLOBALDATA_BASEALLOC_PAGES);
201
202 ASSYM(GD_PRIVATE_TSS, offsetof(struct mdglobaldata, gd_private_tss));
203 ASSYM(GD_COMMON_TSS, offsetof(struct privatespace, common_tss));
204 ASSYM(GD_TRAMPOLINE, offsetof(struct privatespace, trampoline));
205 ASSYM(GD_DEBUG1, offsetof(struct mdglobaldata, mi.gd_debug1));
206 ASSYM(GD_DEBUG2, offsetof(struct mdglobaldata, mi.gd_debug2));
207 ASSYM(GD_USER_FS, offsetof(struct mdglobaldata, gd_user_fs));
208 ASSYM(GD_USER_GS, offsetof(struct mdglobaldata, gd_user_gs));
209 ASSYM(GD_INTR_NESTING_LEVEL, offsetof(struct mdglobaldata, mi.gd_intr_nesting_level));
210
211 ASSYM(TR_CR2, offsetof(struct trampframe, tr_cr2));
212 ASSYM(TR_RAX, offsetof(struct trampframe, tr_rax));
213 ASSYM(TR_RCX, offsetof(struct trampframe, tr_rcx));
214 ASSYM(TR_RDX, offsetof(struct trampframe, tr_rdx));
215 ASSYM(TR_ERR, offsetof(struct trampframe, tr_err));
216 ASSYM(TR_RIP, offsetof(struct trampframe, tr_rip));
217 ASSYM(TR_CS, offsetof(struct trampframe, tr_cs));
218 ASSYM(TR_RFLAGS, offsetof(struct trampframe, tr_rflags));
219 ASSYM(TR_RSP, offsetof(struct trampframe, tr_rsp));
220 ASSYM(TR_SS, offsetof(struct trampframe, tr_ss));
221 ASSYM(TR_PCB_RSP, offsetof(struct trampframe, tr_pcb_rsp));
222 ASSYM(TR_PCB_FLAGS, offsetof(struct trampframe, tr_pcb_flags));
223 ASSYM(TR_PCB_CR3_ISO, offsetof(struct trampframe, tr_pcb_cr3_iso));
224 ASSYM(TR_PCB_CR3, offsetof(struct trampframe, tr_pcb_cr3));
225 ASSYM(TR_PCB_SPEC_CTRL, offsetof(struct trampframe, tr_pcb_spec_ctrl[0]));
226 ASSYM(TR_PCB_GS_KERNEL, offsetof(struct trampframe, tr_pcb_gs_kernel));
227 ASSYM(TR_PCB_GS_SAVED, offsetof(struct trampframe, tr_pcb_gs_saved));
228 ASSYM(TR_PCB_CR3_SAVED, offsetof(struct trampframe, tr_pcb_cr3_saved));
229
230 ASSYM(GD_IPENDING, offsetof(struct mdglobaldata, gd_ipending));
231 ASSYM(GD_SPENDING, offsetof(struct mdglobaldata, gd_spending));
232 ASSYM(GD_COMMON_TSSD, offsetof(struct mdglobaldata, gd_common_tssd));
233 ASSYM(GD_TSS_GDT, offsetof(struct mdglobaldata, gd_tss_gdt));
234 ASSYM(GD_NPXTHREAD, offsetof(struct mdglobaldata, gd_npxthread));
235 ASSYM(GD_FPU_LOCK, offsetof(struct mdglobaldata, gd_fpu_lock));
236 ASSYM(GD_SAVEFPU, offsetof(struct mdglobaldata, gd_savefpu));
237 ASSYM(GD_OTHER_CPUS, offsetof(struct mdglobaldata, mi.gd_other_cpus));
238 ASSYM(GD_SS_EFLAGS, offsetof(struct mdglobaldata, gd_ss_eflags));
239 ASSYM(GD_REQFLAGS, offsetof(struct mdglobaldata, mi.gd_reqflags));
240
241 ASSYM(RQF_IPIQ, RQF_IPIQ);
242 ASSYM(RQF_INTPEND, RQF_INTPEND);
243 ASSYM(RQF_AST_OWEUPC, RQF_AST_OWEUPC);
244 ASSYM(RQF_AST_SIGNAL, RQF_AST_SIGNAL);
245 ASSYM(RQF_AST_USER_RESCHED, RQF_AST_USER_RESCHED);
246 ASSYM(RQF_AST_LWKT_RESCHED, RQF_AST_LWKT_RESCHED);
247 ASSYM(RQF_TIMER, RQF_TIMER);
248 ASSYM(RQF_AST_MASK, RQF_AST_MASK);
249 ASSYM(RQF_QUICKRET, RQF_QUICKRET);
250
251 ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL));
252 ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL));
253 ASSYM(KUCSEL, GSEL(GUCODE_SEL, SEL_UPL));
254 ASSYM(KUDSEL, GSEL(GUDATA_SEL, SEL_UPL));
255 /*ASSYM(SEL_RPL_MASK, SEL_RPL_MASK);*/
256
257 ASSYM(MSR_GSBASE, MSR_GSBASE);
258 ASSYM(MSR_KGSBASE, MSR_KGSBASE);
259 ASSYM(MSR_FSBASE, MSR_FSBASE);
260
261 ASSYM(MACHINTR_INTREN, offsetof(struct machintr_abi, intr_enable));
262
263 ASSYM(TDPRI_INT_SUPPORT, TDPRI_INT_SUPPORT);
264 ASSYM(CPULOCK_EXCLBIT, CPULOCK_EXCLBIT);
265 ASSYM(CPULOCK_EXCL, CPULOCK_EXCL);
266 ASSYM(CPULOCK_INCR, CPULOCK_INCR);
267 ASSYM(CPULOCK_CNTMASK, CPULOCK_CNTMASK);
268
269 ASSYM(CPUMASK_ELEMENTS, CPUMASK_ELEMENTS);
270
271 ASSYM(IOAPIC_IRQI_ADDR, offsetof(struct ioapic_irqinfo, io_addr));
272 ASSYM(IOAPIC_IRQI_IDX, offsetof(struct ioapic_irqinfo, io_idx));
273 ASSYM(IOAPIC_IRQI_FLAGS, offsetof(struct ioapic_irqinfo, io_flags));
274 ASSYM(IOAPIC_IRQI_SIZE, sizeof(struct ioapic_irqinfo));
275 ASSYM(IOAPIC_IRQI_SZSHIFT, IOAPIC_IRQI_SZSHIFT);
276 ASSYM(IOAPIC_IRQI_FLAG_LEVEL, IOAPIC_IRQI_FLAG_LEVEL);
277 ASSYM(IOAPIC_IRQI_FLAG_MASKED, IOAPIC_IRQI_FLAG_MASKED);