1/*-
2 * Copyright (c) 2001 Jake Burkholder.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 *	from: @(#)genassym.c	5.11 (Berkeley) 5/10/91
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD$");
31
32#include "opt_kstack_pages.h"
33
34#include <sys/param.h>
35#include <sys/assym.h>
36#include <sys/ktr.h>
37#include <sys/proc.h>
38#include <sys/smp.h>
39#include <sys/vmmeter.h>
40#include <sys/_cpuset.h>
41
42#include <machine/atomic.h>
43#include <vm/vm.h>
44#include <vm/vm_page.h>
45#include <vm/vm_map.h>
46
47#include <machine/cache.h>
48#include <machine/pcb.h>
49#include <machine/setjmp.h>
50#include <machine/smp.h>
51#include <machine/tlb.h>
52#include <machine/tte.h>
53#include <machine/vmparam.h>
54
55ASSYM(KERNBASE, KERNBASE);
56
57ASSYM(KSTACK_PAGES, KSTACK_PAGES);
58ASSYM(PCPU_PAGES, PCPU_PAGES);
59
60ASSYM(TAR_VPN_SHIFT, TAR_VPN_SHIFT);
61
62ASSYM(_NCPUBITS, _NCPUBITS);
63
64ASSYM(TLB_DEMAP_ALL, TLB_DEMAP_ALL);
65ASSYM(TLB_DEMAP_CONTEXT, TLB_DEMAP_CONTEXT);
66ASSYM(TLB_DEMAP_NUCLEUS, TLB_DEMAP_NUCLEUS);
67ASSYM(TLB_DEMAP_PAGE, TLB_DEMAP_PAGE);
68ASSYM(TLB_DEMAP_PRIMARY, TLB_DEMAP_PRIMARY);
69
70ASSYM(INT_SHIFT, INT_SHIFT);
71ASSYM(PTR_SHIFT, PTR_SHIFT);
72
73ASSYM(PAGE_SHIFT, PAGE_SHIFT);
74ASSYM(PAGE_SHIFT_8K, PAGE_SHIFT_8K);
75ASSYM(PAGE_SHIFT_4M, PAGE_SHIFT_4M);
76ASSYM(PAGE_SIZE, PAGE_SIZE);
77ASSYM(PAGE_SIZE_4M, PAGE_SIZE_4M);
78
79#ifdef SMP
80ASSYM(CSA_PCPU, offsetof(struct cpu_start_args, csa_pcpu));
81ASSYM(CSA_STATE, offsetof(struct cpu_start_args, csa_state));
82ASSYM(CSA_MID, offsetof(struct cpu_start_args, csa_mid));
83ASSYM(CSA_STICK, offsetof(struct cpu_start_args, csa_stick));
84ASSYM(CSA_TICK, offsetof(struct cpu_start_args, csa_tick));
85ASSYM(CSA_TTES, offsetof(struct cpu_start_args, csa_ttes));
86ASSYM(CSA_VER, offsetof(struct cpu_start_args, csa_ver));
87#endif
88
89ASSYM(DC_SIZE, offsetof(struct cacheinfo, dc_size));
90ASSYM(DC_LINESIZE, offsetof(struct cacheinfo, dc_linesize));
91ASSYM(IC_SIZE, offsetof(struct cacheinfo, ic_size));
92ASSYM(IC_LINESIZE, offsetof(struct cacheinfo, ic_linesize));
93
94ASSYM(KTR_SIZEOF, sizeof(struct ktr_entry));
95ASSYM(KTR_LINE, offsetof(struct ktr_entry, ktr_line));
96ASSYM(KTR_FILE, offsetof(struct ktr_entry, ktr_file));
97ASSYM(KTR_DESC, offsetof(struct ktr_entry, ktr_desc));
98ASSYM(KTR_CPU, offsetof(struct ktr_entry, ktr_cpu));
99ASSYM(KTR_TIMESTAMP, offsetof(struct ktr_entry, ktr_timestamp));
100ASSYM(KTR_PARM1, offsetof(struct ktr_entry, ktr_parms[0]));
101ASSYM(KTR_PARM2, offsetof(struct ktr_entry, ktr_parms[1]));
102ASSYM(KTR_PARM3, offsetof(struct ktr_entry, ktr_parms[2]));
103ASSYM(KTR_PARM4, offsetof(struct ktr_entry, ktr_parms[3]));
104ASSYM(KTR_PARM5, offsetof(struct ktr_entry, ktr_parms[4]));
105ASSYM(KTR_PARM6, offsetof(struct ktr_entry, ktr_parms[5]));
106
107ASSYM(TTE_SHIFT, TTE_SHIFT);
108ASSYM(TTE_VPN, offsetof(struct tte, tte_vpn));
109ASSYM(TTE_DATA, offsetof(struct tte, tte_data));
110
111ASSYM(TD_V, TD_V);
112ASSYM(TD_EXEC, TD_EXEC);
113ASSYM(TD_REF, TD_REF);
114ASSYM(TD_SW, TD_SW);
115ASSYM(TD_L, TD_L);
116ASSYM(TD_CP, TD_CP);
117ASSYM(TD_CV, TD_CV);
118ASSYM(TD_W, TD_W);
119
120ASSYM(TS_MIN, TS_MIN);
121ASSYM(TS_MAX, TS_MAX);
122ASSYM(TLB_DAR_SLOT_SHIFT, TLB_DAR_SLOT_SHIFT);
123ASSYM(TLB_CXR_PGSZ_MASK, TLB_CXR_PGSZ_MASK);
124ASSYM(TLB_DIRECT_ADDRESS_MASK, TLB_DIRECT_ADDRESS_MASK);
125ASSYM(TLB_DIRECT_TO_TTE_MASK, TLB_DIRECT_TO_TTE_MASK);
126ASSYM(TV_SIZE_BITS, TV_SIZE_BITS);
127
128ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
129
130ASSYM(MAXCOMLEN, MAXCOMLEN);
131ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread));
132ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb));
133ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid));
134ASSYM(PC_IRHEAD, offsetof(struct pcpu, pc_irhead));
135ASSYM(PC_IRTAIL, offsetof(struct pcpu, pc_irtail));
136ASSYM(PC_IRFREE, offsetof(struct pcpu, pc_irfree));
137ASSYM(PC_CNT, offsetof(struct pcpu, pc_cnt));
138ASSYM(PC_SIZEOF, sizeof(struct pcpu));
139
140ASSYM(PC_CACHE, offsetof(struct pcpu, pc_cache));
141ASSYM(PC_MID, offsetof(struct pcpu, pc_mid));
142ASSYM(PC_PMAP, offsetof(struct pcpu, pc_pmap));
143ASSYM(PC_TLB_CTX, offsetof(struct pcpu, pc_tlb_ctx));
144ASSYM(PC_TLB_CTX_MAX, offsetof(struct pcpu, pc_tlb_ctx_max));
145ASSYM(PC_TLB_CTX_MIN, offsetof(struct pcpu, pc_tlb_ctx_min));
146
147ASSYM(IR_NEXT, offsetof(struct intr_request, ir_next));
148ASSYM(IR_FUNC, offsetof(struct intr_request, ir_func));
149ASSYM(IR_ARG, offsetof(struct intr_request, ir_arg));
150ASSYM(IR_PRI, offsetof(struct intr_request, ir_pri));
151ASSYM(IR_VEC, offsetof(struct intr_request, ir_vec));
152
153#ifdef SMP
154ASSYM(ICA_PA, offsetof(struct ipi_cache_args, ica_pa));
155
156ASSYM(IRA_MASK, offsetof(struct ipi_rd_args, ira_mask));
157ASSYM(IRA_VAL, offsetof(struct ipi_rd_args, ira_val));
158
159ASSYM(ITA_MASK, offsetof(struct ipi_tlb_args, ita_mask));
160ASSYM(ITA_PMAP, offsetof(struct ipi_tlb_args, ita_pmap));
161ASSYM(ITA_START, offsetof(struct ipi_tlb_args, ita_start));
162ASSYM(ITA_END, offsetof(struct ipi_tlb_args, ita_end));
163ASSYM(ITA_VA, offsetof(struct ipi_tlb_args, ita_va));
164#endif
165
166ASSYM(IV_FUNC, offsetof(struct intr_vector, iv_func));
167ASSYM(IV_ARG, offsetof(struct intr_vector, iv_arg));
168ASSYM(IV_PRI, offsetof(struct intr_vector, iv_pri));
169
170ASSYM(TDF_ASTPENDING, TDF_ASTPENDING);
171ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED);
172
173ASSYM(MD_UTRAP, offsetof(struct mdproc, md_utrap));
174
175ASSYM(P_COMM, offsetof(struct proc, p_comm));
176ASSYM(P_MD, offsetof(struct proc, p_md));
177ASSYM(P_PID, offsetof(struct proc, p_pid));
178ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace));
179
180ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
181ASSYM(TD_FRAME, offsetof(struct thread, td_frame));
182ASSYM(TD_KSTACK, offsetof(struct thread, td_kstack));
183ASSYM(TD_LOCK, offsetof(struct thread, td_lock));
184ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
185ASSYM(TD_PROC, offsetof(struct thread, td_proc));
186ASSYM(TD_MD, offsetof(struct thread, td_md));
187ASSYM(MD_SAVED_PIL, offsetof(struct mdthread, md_saved_pil));
188
189ASSYM(PCB_SIZEOF, sizeof(struct pcb));
190ASSYM(PCB_RW, offsetof(struct pcb, pcb_rw));
191ASSYM(PCB_KFP, offsetof(struct pcb, pcb_kfp));
192ASSYM(PCB_UFP, offsetof(struct pcb, pcb_ufp));
193ASSYM(PCB_RWSP, offsetof(struct pcb, pcb_rwsp));
194ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
195ASSYM(PCB_NSAVED, offsetof(struct pcb, pcb_nsaved));
196ASSYM(PCB_PC, offsetof(struct pcb, pcb_pc));
197ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp));
198ASSYM(PCB_PAD, offsetof(struct pcb, pcb_pad));
199
200ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap));
201ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active));
202ASSYM(PM_CONTEXT, offsetof(struct pmap, pm_context));
203ASSYM(PM_TSB, offsetof(struct pmap, pm_tsb));
204
205ASSYM(_JB_FP, offsetof(struct _jmp_buf, _jb[_JB_FP]));
206ASSYM(_JB_PC, offsetof(struct _jmp_buf, _jb[_JB_PC]));
207ASSYM(_JB_SP, offsetof(struct _jmp_buf, _jb[_JB_SP]));
208ASSYM(_JB_SIGFLAG, offsetof(struct _jmp_buf, _jb[_JB_SIGFLAG]));
209ASSYM(_JB_SIGMASK, offsetof(struct _jmp_buf, _jb[_JB_SIGMASK]));
210
211ASSYM(TF_G0, offsetof(struct trapframe, tf_global[0]));
212ASSYM(TF_G1, offsetof(struct trapframe, tf_global[1]));
213ASSYM(TF_G2, offsetof(struct trapframe, tf_global[2]));
214ASSYM(TF_G3, offsetof(struct trapframe, tf_global[3]));
215ASSYM(TF_G4, offsetof(struct trapframe, tf_global[4]));
216ASSYM(TF_G5, offsetof(struct trapframe, tf_global[5]));
217ASSYM(TF_G6, offsetof(struct trapframe, tf_global[6]));
218ASSYM(TF_G7, offsetof(struct trapframe, tf_global[7]));
219ASSYM(TF_O0, offsetof(struct trapframe, tf_out[0]));
220ASSYM(TF_O1, offsetof(struct trapframe, tf_out[1]));
221ASSYM(TF_O2, offsetof(struct trapframe, tf_out[2]));
222ASSYM(TF_O3, offsetof(struct trapframe, tf_out[3]));
223ASSYM(TF_O4, offsetof(struct trapframe, tf_out[4]));
224ASSYM(TF_O5, offsetof(struct trapframe, tf_out[5]));
225ASSYM(TF_O6, offsetof(struct trapframe, tf_out[6]));
226ASSYM(TF_O7, offsetof(struct trapframe, tf_out[7]));
227ASSYM(TF_FPRS, offsetof(struct trapframe, tf_fprs));
228ASSYM(TF_FSR, offsetof(struct trapframe, tf_fsr));
229ASSYM(TF_GSR, offsetof(struct trapframe, tf_gsr));
230ASSYM(TF_PIL, offsetof(struct trapframe, tf_pil));
231ASSYM(TF_LEVEL, offsetof(struct trapframe, tf_level));
232ASSYM(TF_SFAR, offsetof(struct trapframe, tf_sfar));
233ASSYM(TF_SFSR, offsetof(struct trapframe, tf_sfsr));
234ASSYM(TF_TAR, offsetof(struct trapframe, tf_tar));
235ASSYM(TF_TYPE, offsetof(struct trapframe, tf_type));
236ASSYM(TF_Y, offsetof(struct trapframe, tf_y));
237ASSYM(TF_TNPC, offsetof(struct trapframe, tf_tnpc));
238ASSYM(TF_TPC, offsetof(struct trapframe, tf_tpc));
239ASSYM(TF_TSTATE, offsetof(struct trapframe, tf_tstate));
240ASSYM(TF_WSTATE, offsetof(struct trapframe, tf_wstate));
241ASSYM(TF_SIZEOF, sizeof(struct trapframe));
242
243ASSYM(VM_MIN_DIRECT_ADDRESS, VM_MIN_DIRECT_ADDRESS);
244ASSYM(VM_MIN_PROM_ADDRESS, VM_MIN_PROM_ADDRESS);
245ASSYM(VM_MAX_PROM_ADDRESS, VM_MAX_PROM_ADDRESS);
246