IO APIC: Get rid of apic_pin_trigger
[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. 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 $
39  */
40
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/assym.h>
44 #include <sys/interrupt.h>
45 #include <sys/buf.h>
46 #include <sys/proc.h>
47 #include <sys/errno.h>
48 #include <sys/mount.h>
49 #include <sys/socket.h>
50 #include <sys/lock.h>
51 #include <sys/resourcevar.h>
52 #include <machine/frame.h>
53 #include <machine/bootinfo.h>
54 #include <machine/tss.h>
55 #include <sys/vmmeter.h>
56 #include <sys/machintr.h>
57 #include <vm/vm.h>
58 #include <vm/vm_param.h>
59 #include <vm/pmap.h>
60 #include <vm/vm_map.h>
61 #include <net/if.h>
62 #include <netinet/in.h>
63 #include <vfs/nfs/nfsv2.h>
64 #include <vfs/nfs/rpcv2.h>
65 #include <vfs/nfs/nfs.h>
66 #include <vfs/nfs/nfsdiskless.h>
67
68 #include <machine_base/apic/apicreg.h>
69 #include <machine/segments.h>
70 #include <machine/sigframe.h>
71 #include <machine/globaldata.h>
72 #include <machine/specialreg.h>
73 #include <machine/pcb.h>
74 #include <machine/smp.h>
75 #include <machine/pmap.h>
76
77 ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace));
78 ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap));
79 ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active));
80
81 ASSYM(LWP_VMSPACE, offsetof(struct lwp, lwp_vmspace));
82 ASSYM(V_IPI, offsetof(struct vmmeter, v_ipi));
83 ASSYM(V_TIMER, offsetof(struct vmmeter, v_timer));
84 ASSYM(UPAGES, UPAGES);
85 ASSYM(PAGE_SIZE, PAGE_SIZE);
86 ASSYM(NPTEPG, NPTEPG);
87 ASSYM(NPDEPG, NPDEPG);
88 ASSYM(PDESIZE, PDESIZE);
89 ASSYM(PTESIZE, PTESIZE);
90 ASSYM(PAGE_SHIFT, PAGE_SHIFT);
91 ASSYM(PAGE_MASK, PAGE_MASK);
92 ASSYM(PDRSHIFT, PDRSHIFT);
93 ASSYM(USRSTACK, USRSTACK);
94 ASSYM(KERNBASE, KERNBASE);
95
96 ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap));
97 ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
98 ASSYM(V_SENDSYS, offsetof(struct vmmeter, v_sendsys));
99 ASSYM(V_WAITSYS, offsetof(struct vmmeter, v_waitsys));
100 ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
101 ASSYM(V_FORWARDED_INTS, offsetof(struct vmmeter, v_forwarded_ints));
102 ASSYM(V_FORWARDED_HITS, offsetof(struct vmmeter, v_forwarded_hits));
103 ASSYM(V_FORWARDED_MISSES, offsetof(struct vmmeter, v_forwarded_misses));
104
105 ASSYM(MAXCOMLEN, MAXCOMLEN);
106 ASSYM(EFAULT, EFAULT);
107 ASSYM(ENAMETOOLONG, ENAMETOOLONG);
108 ASSYM(VM_MAX_USER_ADDRESS, VM_MAX_USER_ADDRESS);
109
110 ASSYM(GD_CURTHREAD, offsetof(struct mdglobaldata, mi.gd_curthread));
111 ASSYM(GD_CNT, offsetof(struct mdglobaldata, mi.gd_cnt));
112 ASSYM(GD_CPUID, offsetof(struct mdglobaldata, mi.gd_cpuid));
113 ASSYM(GD_CPUMASK, offsetof(struct mdglobaldata, mi.gd_cpumask));
114
115 ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3));
116 ASSYM(PCB_R15, offsetof(struct pcb, pcb_r15));
117 ASSYM(PCB_R14, offsetof(struct pcb, pcb_r14));
118 ASSYM(PCB_R13, offsetof(struct pcb, pcb_r13));
119 ASSYM(PCB_R12, offsetof(struct pcb, pcb_r12));
120 ASSYM(PCB_RSI, offsetof(struct pcb, pcb_rsi));
121 ASSYM(PCB_RBP, offsetof(struct pcb, pcb_rbp));
122 ASSYM(PCB_RSP, offsetof(struct pcb, pcb_rsp));
123 ASSYM(PCB_RBX, offsetof(struct pcb, pcb_rbx));
124 ASSYM(PCB_RIP, offsetof(struct pcb, pcb_rip));
125 ASSYM(TSS_RSP0, offsetof(struct x86_64tss, tss_rsp0));
126
127 ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
128 ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
129 ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
130 ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
131 ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
132 ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
133 ASSYM(PCB_DBREGS, PCB_DBREGS);
134 ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext));
135 ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
136 ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
137 ASSYM(PCB_FSBASE, offsetof(struct pcb, pcb_fsbase));
138 ASSYM(PCB_GSBASE, offsetof(struct pcb, pcb_gsbase));
139 ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save));
140
141 ASSYM(PCB_SIZE, sizeof(struct pcb));
142 ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu));
143
144 ASSYM(TF_R15, offsetof(struct trapframe, tf_r15));
145 ASSYM(TF_R14, offsetof(struct trapframe, tf_r14));
146 ASSYM(TF_R13, offsetof(struct trapframe, tf_r13));
147 ASSYM(TF_R12, offsetof(struct trapframe, tf_r12));
148 ASSYM(TF_R11, offsetof(struct trapframe, tf_r11));
149 ASSYM(TF_R10, offsetof(struct trapframe, tf_r10));
150 ASSYM(TF_R9, offsetof(struct trapframe, tf_r9));
151 ASSYM(TF_R8, offsetof(struct trapframe, tf_r8));
152 ASSYM(TF_RDI, offsetof(struct trapframe, tf_rdi));
153 ASSYM(TF_RSI, offsetof(struct trapframe, tf_rsi));
154 ASSYM(TF_RBP, offsetof(struct trapframe, tf_rbp));
155 ASSYM(TF_RBX, offsetof(struct trapframe, tf_rbx));
156 ASSYM(TF_RDX, offsetof(struct trapframe, tf_rdx));
157 ASSYM(TF_RCX, offsetof(struct trapframe, tf_rcx));
158 ASSYM(TF_RAX, offsetof(struct trapframe, tf_rax));
159
160 ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno));
161 ASSYM(TF_XFLAGS, offsetof(struct trapframe, tf_xflags));
162 ASSYM(TF_ADDR, offsetof(struct trapframe, tf_addr));
163 ASSYM(TF_ERR, offsetof(struct trapframe, tf_err));
164 ASSYM(TF_FLAGS, offsetof(struct trapframe, tf_flags));
165
166 ASSYM(TF_RIP, offsetof(struct trapframe, tf_rip));
167 ASSYM(TF_CS, offsetof(struct trapframe, tf_cs));
168 ASSYM(TF_RFLAGS, offsetof(struct trapframe, tf_rflags));
169 ASSYM(TF_RSP, offsetof(struct trapframe, tf_rsp));
170 ASSYM(TF_SS, offsetof(struct trapframe, tf_ss));
171 ASSYM(TF_SIZE, sizeof(struct trapframe));
172
173 ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler));
174 ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
175
176 ASSYM(TD_PROC, offsetof(struct thread, td_proc));
177 ASSYM(TD_LWP, offsetof(struct thread, td_lwp));
178 ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
179 ASSYM(TD_SP, offsetof(struct thread, td_sp));
180 ASSYM(TD_PRI, offsetof(struct thread, td_pri));
181 ASSYM(TD_CRITCOUNT, offsetof(struct thread, td_critcount));
182 ASSYM(TD_MACH, offsetof(struct thread, td_mach));
183 ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan));
184 ASSYM(TD_NEST_COUNT, offsetof(struct thread, td_nest_count));
185 #ifdef SMP
186 ASSYM(TD_MPCOUNT, offsetof(struct thread, td_mpcount));
187 #endif
188 ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
189 ASSYM(TD_SAVEFPU, offsetof(struct thread, td_savefpu));
190 ASSYM(TDF_RUNNING, TDF_RUNNING);
191 ASSYM(TDF_USINGFP, TDF_USINGFP);
192 ASSYM(TDF_KERNELFP, TDF_KERNELFP);
193
194 ASSYM(FIRST_SOFTINT, FIRST_SOFTINT);
195 ASSYM(MDGLOBALDATA_BASEALLOC_PAGES, MDGLOBALDATA_BASEALLOC_PAGES);
196
197 ASSYM(GD_PRIVATE_TSS, offsetof(struct mdglobaldata, gd_private_tss));
198 ASSYM(GD_SCRATCH_RSP, offsetof(struct mdglobaldata, gd_scratch_rsp));
199 ASSYM(GD_RSP0, offsetof(struct mdglobaldata, gd_rsp0));
200 ASSYM(GD_USER_FS, offsetof(struct mdglobaldata, gd_user_fs));
201 ASSYM(GD_USER_GS, offsetof(struct mdglobaldata, gd_user_gs));
202 ASSYM(GD_INTR_NESTING_LEVEL, offsetof(struct mdglobaldata, mi.gd_intr_nesting_level));
203
204 ASSYM(GD_FPENDING, offsetof(struct mdglobaldata, gd_fpending));
205 ASSYM(GD_SPENDING, offsetof(struct mdglobaldata, gd_spending));
206 ASSYM(GD_COMMON_TSS, offsetof(struct mdglobaldata, gd_common_tss));
207 ASSYM(GD_COMMON_TSSD, offsetof(struct mdglobaldata, gd_common_tssd));
208 ASSYM(GD_TSS_GDT, offsetof(struct mdglobaldata, gd_tss_gdt));
209 ASSYM(GD_NPXTHREAD, offsetof(struct mdglobaldata, gd_npxthread));
210 ASSYM(GD_FPU_LOCK, offsetof(struct mdglobaldata, gd_fpu_lock));
211 ASSYM(GD_SAVEFPU, offsetof(struct mdglobaldata, gd_savefpu));
212 ASSYM(GD_OTHER_CPUS, offsetof(struct mdglobaldata, gd_other_cpus));
213 ASSYM(GD_SS_EFLAGS, offsetof(struct mdglobaldata, gd_ss_eflags));
214 ASSYM(GD_REQFLAGS, offsetof(struct mdglobaldata, mi.gd_reqflags));
215
216 ASSYM(RQF_IPIQ, RQF_IPIQ);
217 ASSYM(RQF_INTPEND, RQF_INTPEND);
218 ASSYM(RQF_AST_OWEUPC, RQF_AST_OWEUPC);
219 ASSYM(RQF_AST_SIGNAL, RQF_AST_SIGNAL);
220 ASSYM(RQF_AST_USER_RESCHED, RQF_AST_USER_RESCHED);
221 ASSYM(RQF_AST_LWKT_RESCHED, RQF_AST_LWKT_RESCHED);
222 ASSYM(RQF_AST_UPCALL, RQF_AST_UPCALL);
223 ASSYM(RQF_TIMER, RQF_TIMER);
224 ASSYM(RQF_AST_MASK, RQF_AST_MASK);
225
226 ASSYM(LA_EOI, offsetof(struct LAPIC, eoi));
227
228 ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL));
229 ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL));
230 ASSYM(KUCSEL, GSEL(GUCODE_SEL, SEL_UPL));
231 ASSYM(KUDSEL, GSEL(GUDATA_SEL, SEL_UPL));
232 /*ASSYM(SEL_RPL_MASK, SEL_RPL_MASK);*/
233
234 ASSYM(MSR_GSBASE, MSR_GSBASE);
235 ASSYM(MSR_KGSBASE, MSR_KGSBASE);
236 ASSYM(MSR_FSBASE, MSR_FSBASE);
237
238 ASSYM(MACHINTR_INTREN, offsetof(struct machintr_abi, intren));
239
240 ASSYM(TDPRI_INT_SUPPORT, TDPRI_INT_SUPPORT);
241 #ifdef SMP
242 ASSYM(CPUMASK_LOCK, CPUMASK_LOCK);
243 #endif
244
245 #ifdef SMP
246 ASSYM(AIMI_APIC_ADDRESS, offsetof(struct apic_intmapinfo, apic_address));
247 ASSYM(AIMI_REDIRINDEX, offsetof(struct apic_intmapinfo, redirindex));
248 ASSYM(AIMI_FLAGS, offsetof(struct apic_intmapinfo, flags));
249 ASSYM(AIMI_SIZE, sizeof(struct apic_intmapinfo));
250 ASSYM(AIMI_FLAG_LEVEL, AIMI_FLAG_LEVEL);
251 #endif