]>
Commit | Line | Data |
---|---|---|
5ba3f43e A |
1 | /* |
2 | * Copyright (c) 2007 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
30 | */ | |
0a7de745 | 31 | /* |
5ba3f43e A |
32 | * Mach Operating System |
33 | * Copyright (c) 1991,1990 Carnegie Mellon University | |
34 | * All Rights Reserved. | |
0a7de745 | 35 | * |
5ba3f43e A |
36 | * Permission to use, copy, modify and distribute this software and its |
37 | * documentation is hereby granted, provided that both the copyright | |
38 | * notice and this permission notice appear in all copies of the | |
39 | * software, derivative works or modified versions, and any portions | |
40 | * thereof, and that both notices appear in supporting documentation. | |
0a7de745 | 41 | * |
5ba3f43e A |
42 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" |
43 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
44 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
0a7de745 | 45 | * |
5ba3f43e | 46 | * Carnegie Mellon requests users of this software to return to |
0a7de745 | 47 | * |
5ba3f43e A |
48 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU |
49 | * School of Computer Science | |
50 | * Carnegie Mellon University | |
51 | * Pittsburgh PA 15213-3890 | |
0a7de745 | 52 | * |
5ba3f43e A |
53 | * any improvements or extensions that they make and grant Carnegie Mellon |
54 | * the rights to redistribute these changes. | |
55 | */ | |
56 | ||
57 | #include <stddef.h> | |
58 | ||
59 | #include <mach_ldebug.h> | |
60 | ||
61 | /* | |
62 | * Pass field offsets to assembly code. | |
63 | */ | |
64 | #include <kern/ast.h> | |
65 | #include <kern/thread.h> | |
66 | #include <kern/task.h> | |
67 | #include <kern/locks.h> | |
68 | #include <ipc/ipc_space.h> | |
69 | #include <ipc/ipc_port.h> | |
70 | #include <ipc/ipc_pset.h> | |
71 | #include <kern/host.h> | |
72 | #include <kern/misc_protos.h> | |
73 | #include <kern/syscall_sw.h> | |
74 | #include <arm/thread.h> | |
75 | #include <mach/arm/vm_param.h> | |
76 | #include <arm/misc_protos.h> | |
77 | #include <arm/pmap.h> | |
78 | #include <arm/trap.h> | |
79 | #include <arm/cpu_data_internal.h> | |
80 | #include <arm/cpu_capabilities.h> | |
81 | #include <arm/cpu_internal.h> | |
82 | #include <arm/rtclock.h> | |
83 | #include <machine/commpage.h> | |
84 | #include <vm/vm_map.h> | |
85 | #include <pexpert/arm64/boot.h> | |
86 | #include <arm64/proc_reg.h> | |
87 | #include <prng/random.h> | |
88 | ||
5ba3f43e A |
89 | /* |
90 | * genassym.c is used to produce an | |
91 | * assembly file which, intermingled with unuseful assembly code, | |
92 | * has all the necessary definitions emitted. This assembly file is | |
93 | * then postprocessed with sed to extract only these definitions | |
94 | * and thus the final assyms.s is created. | |
95 | * | |
96 | * This convoluted means is necessary since the structure alignment | |
97 | * and packing may be different between the host machine and the | |
98 | * target so we are forced into using the cross compiler to generate | |
99 | * the values, but we cannot run anything on the target machine. | |
100 | */ | |
101 | ||
0a7de745 | 102 | #define DECLARE(SYM, VAL) \ |
cb323159 | 103 | __asm("DEFINITION__define__" SYM ":\t .ascii \"%0\"" : : "i" ((u_long)(VAL))) |
5ba3f43e A |
104 | |
105 | ||
cb323159 A |
106 | int main(int argc, |
107 | char ** argv); | |
5ba3f43e A |
108 | |
109 | int | |
cb323159 A |
110 | main(int argc, |
111 | char ** argv) | |
5ba3f43e | 112 | { |
0a7de745 | 113 | DECLARE("AST_URGENT", AST_URGENT); |
5ba3f43e | 114 | |
0a7de745 | 115 | DECLARE("TH_RECOVER", offsetof(struct thread, recover)); |
5ba3f43e | 116 | DECLARE("TH_KSTACKPTR", offsetof(struct thread, machine.kstackptr)); |
cb323159 A |
117 | #if defined(HAS_APPLE_PAC) |
118 | DECLARE("TH_ROP_PID", offsetof(struct thread, machine.rop_pid)); | |
119 | DECLARE("TH_DISABLE_USER_JOP", offsetof(struct thread, machine.disable_user_jop)); | |
120 | #endif /* defined(HAS_APPLE_PAC) */ | |
5ba3f43e A |
121 | |
122 | /* These fields are being added on demand */ | |
5ba3f43e | 123 | DECLARE("ACT_CONTEXT", offsetof(struct thread, machine.contextData)); |
0a7de745 | 124 | DECLARE("TH_CTH_SELF", offsetof(struct thread, machine.cthread_self)); |
0a7de745 A |
125 | DECLARE("ACT_PREEMPT_CNT", offsetof(struct thread, machine.preemption_count)); |
126 | DECLARE("ACT_CPUDATAP", offsetof(struct thread, machine.CpuDatap)); | |
0a7de745 A |
127 | DECLARE("ACT_DEBUGDATA", offsetof(struct thread, machine.DebugData)); |
128 | DECLARE("TH_IOTIER_OVERRIDE", offsetof(struct thread, iotier_override)); | |
129 | DECLARE("TH_RWLOCK_CNT", offsetof(struct thread, rwlock_count)); | |
5ba3f43e | 130 | |
cb323159 A |
131 | #if defined(HAS_APPLE_PAC) |
132 | DECLARE("TASK_ROP_PID", offsetof(struct task, rop_pid)); | |
133 | #endif /* defined(HAS_APPLE_PAC) */ | |
5ba3f43e A |
134 | |
135 | DECLARE("ARM_CONTEXT_SIZE", sizeof(arm_context_t)); | |
136 | ||
5ba3f43e | 137 | DECLARE("SS_FLAVOR", offsetof(arm_context_t, ss.ash.flavor)); |
5ba3f43e A |
138 | DECLARE("ARM_SAVED_STATE64", ARM_SAVED_STATE64); |
139 | DECLARE("ARM_SAVED_STATE64_COUNT", ARM_SAVED_STATE64_COUNT); | |
140 | ||
5ba3f43e A |
141 | DECLARE("SS64_X0", offsetof(arm_context_t, ss.ss_64.x[0])); |
142 | DECLARE("SS64_X2", offsetof(arm_context_t, ss.ss_64.x[2])); | |
143 | DECLARE("SS64_X4", offsetof(arm_context_t, ss.ss_64.x[4])); | |
144 | DECLARE("SS64_X6", offsetof(arm_context_t, ss.ss_64.x[6])); | |
145 | DECLARE("SS64_X8", offsetof(arm_context_t, ss.ss_64.x[8])); | |
146 | DECLARE("SS64_X10", offsetof(arm_context_t, ss.ss_64.x[10])); | |
147 | DECLARE("SS64_X12", offsetof(arm_context_t, ss.ss_64.x[12])); | |
148 | DECLARE("SS64_X14", offsetof(arm_context_t, ss.ss_64.x[14])); | |
149 | DECLARE("SS64_X16", offsetof(arm_context_t, ss.ss_64.x[16])); | |
150 | DECLARE("SS64_X18", offsetof(arm_context_t, ss.ss_64.x[18])); | |
151 | DECLARE("SS64_X19", offsetof(arm_context_t, ss.ss_64.x[19])); | |
152 | DECLARE("SS64_X20", offsetof(arm_context_t, ss.ss_64.x[20])); | |
153 | DECLARE("SS64_X21", offsetof(arm_context_t, ss.ss_64.x[21])); | |
154 | DECLARE("SS64_X22", offsetof(arm_context_t, ss.ss_64.x[22])); | |
155 | DECLARE("SS64_X23", offsetof(arm_context_t, ss.ss_64.x[23])); | |
156 | DECLARE("SS64_X24", offsetof(arm_context_t, ss.ss_64.x[24])); | |
157 | DECLARE("SS64_X25", offsetof(arm_context_t, ss.ss_64.x[25])); | |
158 | DECLARE("SS64_X26", offsetof(arm_context_t, ss.ss_64.x[26])); | |
159 | DECLARE("SS64_X27", offsetof(arm_context_t, ss.ss_64.x[27])); | |
160 | DECLARE("SS64_X28", offsetof(arm_context_t, ss.ss_64.x[28])); | |
161 | DECLARE("SS64_FP", offsetof(arm_context_t, ss.ss_64.fp)); | |
162 | DECLARE("SS64_LR", offsetof(arm_context_t, ss.ss_64.lr)); | |
163 | DECLARE("SS64_SP", offsetof(arm_context_t, ss.ss_64.sp)); | |
164 | DECLARE("SS64_PC", offsetof(arm_context_t, ss.ss_64.pc)); | |
165 | DECLARE("SS64_CPSR", offsetof(arm_context_t, ss.ss_64.cpsr)); | |
166 | DECLARE("SS64_FAR", offsetof(arm_context_t, ss.ss_64.far)); | |
167 | DECLARE("SS64_ESR", offsetof(arm_context_t, ss.ss_64.esr)); | |
cb323159 A |
168 | #if defined(HAS_APPLE_PAC) |
169 | DECLARE("SS64_JOPHASH", offsetof(arm_context_t, ss.ss_64.jophash)); | |
170 | #endif /* defined(HAS_APPLE_PAC) */ | |
5ba3f43e | 171 | |
5ba3f43e A |
172 | DECLARE("NS_FLAVOR", offsetof(arm_context_t, ns.nsh.flavor)); |
173 | DECLARE("NS_COUNT", offsetof(arm_context_t, ns.nsh.count)); | |
5ba3f43e A |
174 | DECLARE("ARM_NEON_SAVED_STATE64", ARM_NEON_SAVED_STATE64); |
175 | DECLARE("ARM_NEON_SAVED_STATE64_COUNT", ARM_NEON_SAVED_STATE64_COUNT); | |
176 | ||
5ba3f43e A |
177 | DECLARE("NS64_D8", offsetof(arm_context_t, ns.ns_64.v.d[8])); |
178 | DECLARE("NS64_D9", offsetof(arm_context_t, ns.ns_64.v.d[9])); | |
179 | DECLARE("NS64_D10", offsetof(arm_context_t, ns.ns_64.v.d[10])); | |
180 | DECLARE("NS64_D11", offsetof(arm_context_t, ns.ns_64.v.d[11])); | |
181 | DECLARE("NS64_D12", offsetof(arm_context_t, ns.ns_64.v.d[12])); | |
182 | DECLARE("NS64_D13", offsetof(arm_context_t, ns.ns_64.v.d[13])); | |
183 | DECLARE("NS64_D14", offsetof(arm_context_t, ns.ns_64.v.d[14])); | |
184 | DECLARE("NS64_D15", offsetof(arm_context_t, ns.ns_64.v.d[15])); | |
185 | ||
186 | DECLARE("NS64_Q0", offsetof(arm_context_t, ns.ns_64.v.q[0])); | |
187 | DECLARE("NS64_Q2", offsetof(arm_context_t, ns.ns_64.v.q[2])); | |
188 | DECLARE("NS64_Q4", offsetof(arm_context_t, ns.ns_64.v.q[4])); | |
189 | DECLARE("NS64_Q6", offsetof(arm_context_t, ns.ns_64.v.q[6])); | |
190 | DECLARE("NS64_Q8", offsetof(arm_context_t, ns.ns_64.v.q[8])); | |
191 | DECLARE("NS64_Q10", offsetof(arm_context_t, ns.ns_64.v.q[10])); | |
192 | DECLARE("NS64_Q12", offsetof(arm_context_t, ns.ns_64.v.q[12])); | |
193 | DECLARE("NS64_Q14", offsetof(arm_context_t, ns.ns_64.v.q[14])); | |
194 | DECLARE("NS64_Q16", offsetof(arm_context_t, ns.ns_64.v.q[16])); | |
195 | DECLARE("NS64_Q18", offsetof(arm_context_t, ns.ns_64.v.q[18])); | |
196 | DECLARE("NS64_Q20", offsetof(arm_context_t, ns.ns_64.v.q[20])); | |
197 | DECLARE("NS64_Q22", offsetof(arm_context_t, ns.ns_64.v.q[22])); | |
198 | DECLARE("NS64_Q24", offsetof(arm_context_t, ns.ns_64.v.q[24])); | |
199 | DECLARE("NS64_Q26", offsetof(arm_context_t, ns.ns_64.v.q[26])); | |
200 | DECLARE("NS64_Q28", offsetof(arm_context_t, ns.ns_64.v.q[28])); | |
201 | DECLARE("NS64_Q30", offsetof(arm_context_t, ns.ns_64.v.q[30])); | |
202 | DECLARE("NS64_FPSR", offsetof(arm_context_t, ns.ns_64.fpsr)); | |
203 | DECLARE("NS64_FPCR", offsetof(arm_context_t, ns.ns_64.fpcr)); | |
204 | ||
cb323159 | 205 | |
5ba3f43e A |
206 | DECLARE("PGBYTES", ARM_PGBYTES); |
207 | DECLARE("PGSHIFT", ARM_PGSHIFT); | |
5ba3f43e | 208 | |
0a7de745 | 209 | DECLARE("VM_MIN_KERNEL_ADDRESS", VM_MIN_KERNEL_ADDRESS); |
0a7de745 A |
210 | DECLARE("KERNEL_STACK_SIZE", KERNEL_STACK_SIZE); |
211 | DECLARE("TBI_MASK", TBI_MASK); | |
5ba3f43e | 212 | |
cb323159 | 213 | DECLARE("MAX_CPUS", MAX_CPUS); |
5ba3f43e | 214 | |
cb323159 | 215 | DECLARE("cdeSize", sizeof(struct cpu_data_entry)); |
5ba3f43e | 216 | |
cb323159 | 217 | DECLARE("cdSize", sizeof(struct cpu_data)); |
5ba3f43e | 218 | |
cb323159 A |
219 | DECLARE("CPU_ACTIVE_THREAD", offsetof(cpu_data_t, cpu_active_thread)); |
220 | DECLARE("CPU_ISTACKPTR", offsetof(cpu_data_t, istackptr)); | |
221 | DECLARE("CPU_INTSTACK_TOP", offsetof(cpu_data_t, intstack_top)); | |
222 | DECLARE("CPU_EXCEPSTACK_TOP", offsetof(cpu_data_t, excepstack_top)); | |
5c9f4661 | 223 | #if __ARM_KERNEL_PROTECT__ |
cb323159 | 224 | DECLARE("CPU_EXC_VECTORS", offsetof(cpu_data_t, cpu_exc_vectors)); |
5c9f4661 | 225 | #endif /* __ARM_KERNEL_PROTECT__ */ |
cb323159 A |
226 | DECLARE("CPU_NUMBER_GS", offsetof(cpu_data_t, cpu_number)); |
227 | DECLARE("CPU_PENDING_AST", offsetof(cpu_data_t, cpu_pending_ast)); | |
228 | DECLARE("CPU_INT_STATE", offsetof(cpu_data_t, cpu_int_state)); | |
229 | DECLARE("CPU_USER_DEBUG", offsetof(cpu_data_t, cpu_user_debug)); | |
230 | DECLARE("CPU_STAT_IRQ", offsetof(cpu_data_t, cpu_stat.irq_ex_cnt)); | |
231 | DECLARE("CPU_STAT_IRQ_WAKE", offsetof(cpu_data_t, cpu_stat.irq_ex_cnt_wake)); | |
232 | DECLARE("CPU_RESET_HANDLER", offsetof(cpu_data_t, cpu_reset_handler)); | |
233 | DECLARE("CPU_PHYS_ID", offsetof(cpu_data_t, cpu_phys_id)); | |
234 | DECLARE("CLUSTER_MASTER", offsetof(cpu_data_t, cluster_master)); | |
235 | ||
236 | DECLARE("RTCLOCKDataSize", sizeof(rtclock_data_t)); | |
237 | ||
238 | DECLARE("rhdSize", sizeof(struct reset_handler_data)); | |
5ba3f43e | 239 | #if WITH_CLASSIC_S2R || !__arm64__ |
cb323159 A |
240 | DECLARE("stSize", sizeof(SleepToken)); |
241 | #endif /* WITH_CLASSIC_S2R || !__arm64__ */ | |
5ba3f43e | 242 | |
0a7de745 | 243 | DECLARE("CPU_DATA_ENTRIES", offsetof(struct reset_handler_data, cpu_data_entries)); |
5ba3f43e | 244 | |
0a7de745 | 245 | DECLARE("CPU_DATA_PADDR", offsetof(struct cpu_data_entry, cpu_data_paddr)); |
5ba3f43e | 246 | |
0a7de745 A |
247 | DECLARE("INTSTACK_SIZE", INTSTACK_SIZE); |
248 | DECLARE("EXCEPSTACK_SIZE", EXCEPSTACK_SIZE); | |
d9a64523 | 249 | |
0a7de745 | 250 | DECLARE("PAGE_MAX_SIZE", PAGE_MAX_SIZE); |
5ba3f43e | 251 | |
cb323159 A |
252 | DECLARE("BA_VIRT_BASE", offsetof(struct boot_args, virtBase)); |
253 | DECLARE("BA_PHYS_BASE", offsetof(struct boot_args, physBase)); | |
254 | DECLARE("BA_MEM_SIZE", offsetof(struct boot_args, memSize)); | |
255 | DECLARE("BA_TOP_OF_KERNEL_DATA", offsetof(struct boot_args, topOfKernelData)); | |
256 | DECLARE("BA_BOOT_FLAGS", offsetof(struct boot_args, bootFlags)); | |
5ba3f43e A |
257 | |
258 | DECLARE("SR_RESTORE_TCR_EL1", offsetof(struct sysreg_restore, tcr_el1)); | |
259 | ||
260 | ||
d9a64523 | 261 | |
cb323159 A |
262 | #if defined(HAS_APPLE_PAC) |
263 | DECLARE("CPU_ROP_KEY", offsetof(cpu_data_t, rop_key)); | |
264 | #endif /* defined(HAS_APPLE_PAC) */ | |
265 | ||
0a7de745 | 266 | return 0; |
5ba3f43e | 267 | } |