genassym.c 8.91 KB
Newer Older
1
/*-
2
3
 * SPDX-License-Identifier: BSD-3-Clause
 *
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 * Copyright (c) 1982, 1990 The Regents of the University of California.
 * All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * William Jolitz.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
Warner Losh's avatar
Warner Losh committed
18
 * 3. Neither the name of the University nor the names of its contributors
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
Rodney W. Grimes's avatar
All:    
Rodney W. Grimes committed
34
 *	from: @(#)genassym.c	5.11 (Berkeley) 5/10/91
35
36
 */

David E. O'Brien's avatar
David E. O'Brien committed
37
38
39
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

40
#include "opt_apic.h"
41
#include "opt_hwpmc_hooks.h"
Julian Elischer's avatar
Julian Elischer committed
42
#include "opt_kstack_pages.h"
43

44
#include <sys/param.h>
45
#include <sys/systm.h>
46
#include <sys/assym.h>
47
#include <sys/bio.h>
48
#include <sys/buf.h>
49
50
51
#ifdef	HWPMC_HOOKS
#include <sys/pmckern.h>
#endif
52
#include <sys/proc.h>
53
#include <sys/errno.h>
54
#include <sys/mount.h>
55
#include <sys/mutex.h>
56
#include <sys/socket.h>
57
#include <sys/resourcevar.h>
58
#include <sys/signalvar.h>
59
#include <sys/ucontext.h>
60
#include <machine/bootinfo.h>
61
#include <machine/tss.h>
62
#include <sys/vmmeter.h>
63
#include <vm/vm.h>
64
65
66
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
67
#include <sys/proc.h>
68
69
#include <net/if.h>
#include <netinet/in.h>
70
71
#include <nfs/nfsproto.h>
#include <nfsclient/nfs.h>
72
#include <nfs/nfsdiskless.h>
73
#ifdef DEV_APIC
74
#include <x86/apicreg.h>
75
#endif
76
#include <machine/cpu.h>
Konstantin Belousov's avatar
Konstantin Belousov committed
77
#include <machine/pcb_ext.h>
78
#include <machine/pcb.h>
79
#include <machine/sigframe.h>
80
#include <machine/vm86.h>
81
#include <machine/proc.h>
82

83
84
85
ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace));
ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap));
ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active));
Julian Elischer's avatar
Julian Elischer committed
86
87

ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
88
ASSYM(TD_LOCK, offsetof(struct thread, td_lock));
Julian Elischer's avatar
Julian Elischer committed
89
ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
90
ASSYM(TD_PFLAGS, offsetof(struct thread, td_pflags));
Julian Elischer's avatar
Julian Elischer committed
91
ASSYM(TD_PROC, offsetof(struct thread, td_proc));
92
ASSYM(TD_MD, offsetof(struct thread, td_md));
Julian Elischer's avatar
Julian Elischer committed
93

94
95
ASSYM(TDP_CALLCHAIN, TDP_CALLCHAIN);

96
97
98
ASSYM(P_MD, offsetof(struct proc, p_md));
ASSYM(MD_LDT, offsetof(struct mdproc, md_ldt));

99
100
ASSYM(TDF_ASTPENDING, TDF_ASTPENDING);
ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED);
101

102
ASSYM(TD0_KSTACK_PAGES, TD0_KSTACK_PAGES);
103
104
105
ASSYM(PAGE_SIZE, PAGE_SIZE);
ASSYM(PAGE_SHIFT, PAGE_SHIFT);
ASSYM(PAGE_MASK, PAGE_MASK);
106
107
ASSYM(PCB_CR0, offsetof(struct pcb, pcb_cr0));
ASSYM(PCB_CR2, offsetof(struct pcb, pcb_cr2));
108
ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3));
109
ASSYM(PCB_CR4, offsetof(struct pcb, pcb_cr4));
110
111
112
113
114
115
116
117
ASSYM(PCB_EDI, offsetof(struct pcb, pcb_edi));
ASSYM(PCB_ESI, offsetof(struct pcb, pcb_esi));
ASSYM(PCB_EBP, offsetof(struct pcb, pcb_ebp));
ASSYM(PCB_ESP, offsetof(struct pcb, pcb_esp));
ASSYM(PCB_EBX, offsetof(struct pcb, pcb_ebx));
ASSYM(PCB_EIP, offsetof(struct pcb, pcb_eip));
ASSYM(TSS_ESP0, offsetof(struct i386tss, tss_esp0));

118
119
120
ASSYM(PCB_DS, offsetof(struct pcb, pcb_ds));
ASSYM(PCB_ES, offsetof(struct pcb, pcb_es));
ASSYM(PCB_FS, offsetof(struct pcb, pcb_fs));
121
ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs));
122
ASSYM(PCB_SS, offsetof(struct pcb, pcb_ss));
123
124
125
126
127
128
129
130
131
ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
ASSYM(PCB_DBREGS, PCB_DBREGS);
ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext));

Konstantin Belousov's avatar
Konstantin Belousov committed
132
133
ASSYM(PCB_EXT_TSS, offsetof(struct pcb_ext, ext_tss));

134
ASSYM(PCB_FSD, offsetof(struct pcb, pcb_fsd));
135
ASSYM(PCB_GSD, offsetof(struct pcb, pcb_gsd));
136
ASSYM(PCB_VM86, offsetof(struct pcb, pcb_vm86));
137
ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
138
ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save));
139
140
141
ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));

ASSYM(PCB_SIZE, sizeof(struct pcb));
142
ASSYM(PCB_VM86CALL, PCB_VM86CALL);
143

144
145
146
147
148
ASSYM(PCB_GDT, offsetof(struct pcb, pcb_gdt));
ASSYM(PCB_IDT, offsetof(struct pcb, pcb_idt));
ASSYM(PCB_LDT, offsetof(struct pcb, pcb_ldt));
ASSYM(PCB_TR, offsetof(struct pcb, pcb_tr));

149
150
151
ASSYM(TF_FS, offsetof(struct trapframe, tf_fs));
ASSYM(TF_ES, offsetof(struct trapframe, tf_es));
ASSYM(TF_DS, offsetof(struct trapframe, tf_ds));
152
153
ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno));
ASSYM(TF_ERR, offsetof(struct trapframe, tf_err));
154
ASSYM(TF_EIP, offsetof(struct trapframe, tf_eip));
155
156
ASSYM(TF_CS, offsetof(struct trapframe, tf_cs));
ASSYM(TF_EFLAGS, offsetof(struct trapframe, tf_eflags));
Konstantin Belousov's avatar
Konstantin Belousov committed
157
ASSYM(TF_SZ, sizeof(struct trapframe));
158

159
ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler));
160
#ifdef COMPAT_43
161
ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc));
162
#endif
163
ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
164
#ifdef COMPAT_FREEBSD4
165
ASSYM(SIGF_UC4, offsetof(struct freebsd4_sigframe, sf_uc));
166
#endif
167
#ifdef COMPAT_43
168
169
170
171
ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps));
ASSYM(SC_FS, offsetof(struct osigcontext, sc_fs));
ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs));
ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno));
172
173
#endif
#ifdef COMPAT_FREEBSD4
174
175
ASSYM(UC4_EFLAGS, offsetof(struct freebsd4_ucontext, uc_mcontext.mc_eflags));
ASSYM(UC4_GS, offsetof(struct freebsd4_ucontext, uc_mcontext.mc_gs));
176
#endif
177
178
179
180
181
ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags));
ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs));
ASSYM(ENOENT, ENOENT);
ASSYM(EFAULT, EFAULT);
ASSYM(ENAMETOOLONG, ENAMETOOLONG);
182
ASSYM(MAXCOMLEN, MAXCOMLEN);
183
184
185
186
187
188
189
190
191
192
193
ASSYM(MAXPATHLEN, MAXPATHLEN);
ASSYM(BOOTINFO_SIZE, sizeof(struct bootinfo));
ASSYM(BI_VERSION, offsetof(struct bootinfo, bi_version));
ASSYM(BI_KERNELNAME, offsetof(struct bootinfo, bi_kernelname));
ASSYM(BI_NFS_DISKLESS, offsetof(struct bootinfo, bi_nfs_diskless));
ASSYM(BI_ENDCOMMON, offsetof(struct bootinfo, bi_endcommon));
ASSYM(NFSDISKLESS_SIZE, sizeof(struct nfs_diskless));
ASSYM(BI_SIZE, offsetof(struct bootinfo, bi_size));
ASSYM(BI_SYMTAB, offsetof(struct bootinfo, bi_symtab));
ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab));
ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend));
194
195
196
197
198
199
ASSYM(PC_SIZEOF, sizeof(struct pcpu));
ASSYM(PC_PRVSPACE, offsetof(struct pcpu, pc_prvspace));
ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread));
ASSYM(PC_FPCURTHREAD, offsetof(struct pcpu, pc_fpcurthread));
ASSYM(PC_IDLETHREAD, offsetof(struct pcpu, pc_idlethread));
ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb));
Konstantin Belousov's avatar
Konstantin Belousov committed
200
ASSYM(PC_COMMON_TSSP, offsetof(struct pcpu, pc_common_tssp));
201
202
ASSYM(PC_COMMON_TSSD, offsetof(struct pcpu, pc_common_tssd));
ASSYM(PC_TSS_GDT, offsetof(struct pcpu, pc_tss_gdt));
203
ASSYM(PC_FSGS_GDT, offsetof(struct pcpu, pc_fsgs_gdt));
204
205
ASSYM(PC_CURRENTLDT, offsetof(struct pcpu, pc_currentldt));
ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid));
206
ASSYM(PC_CURPMAP, offsetof(struct pcpu, pc_curpmap));
207
ASSYM(PC_PRIVATE_TSS, offsetof(struct pcpu, pc_private_tss));
Konstantin Belousov's avatar
Konstantin Belousov committed
208
209
210
ASSYM(PC_KESP0, offsetof(struct pcpu, pc_kesp0));
ASSYM(PC_TRAMPSTK, offsetof(struct pcpu, pc_trampstk));
ASSYM(PC_COPYOUT_BUF, offsetof(struct pcpu, pc_copyout_buf));
Konstantin Belousov's avatar
Konstantin Belousov committed
211
ASSYM(PC_IBPB_SET, offsetof(struct pcpu, pc_ibpb_set));
212
213
214
ASSYM(PC_MDS_TMP, offsetof(struct pcpu, pc_mds_tmp));
ASSYM(PC_MDS_BUF, offsetof(struct pcpu, pc_mds_buf));
ASSYM(PC_MDS_BUF64, offsetof(struct pcpu, pc_mds_buf64));
215
216
217
ASSYM(PMAP_TRM_MIN_ADDRESS, PMAP_TRM_MIN_ADDRESS);
ASSYM(KERNLOAD, KERNLOAD);
ASSYM(KERNBASE, KERNBASE);
218

219
#ifdef DEV_APIC
220
221
ASSYM(LA_EOI, LAPIC_EOI * LAPIC_MEM_MUL);
ASSYM(LA_ISR, LAPIC_ISR0 * LAPIC_MEM_MUL);
222
223
#endif

224
225
226
ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL));
ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL));
ASSYM(KPSEL, GSEL(GPRIV_SEL, SEL_KPL));
227

228
229
230
ASSYM(BC32SEL, GSEL(GBIOSCODE32_SEL, SEL_KPL));
ASSYM(GPROC0_SEL, GPROC0_SEL);
ASSYM(VM86_FRAMESIZE, sizeof(struct vm86frame));
Konstantin Belousov's avatar
Konstantin Belousov committed
231
232
233
ASSYM(VM86_STACK_SPACE, VM86_STACK_SPACE);

ASSYM(TRAMP_COPYOUT_SZ, TRAMP_COPYOUT_SZ);
234

235
236
237
#ifdef	HWPMC_HOOKS
ASSYM(PMC_FN_USER_CALLCHAIN, PMC_FN_USER_CALLCHAIN);
#endif