]>
Commit | Line | Data |
---|---|---|
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 | */ | |
31 | /* | |
32 | * Mach Operating System | |
33 | * Copyright (c) 1991,1990 Carnegie Mellon University | |
34 | * All Rights Reserved. | |
35 | * | |
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. | |
41 | * | |
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. | |
45 | * | |
46 | * Carnegie Mellon requests users of this software to return to | |
47 | * | |
48 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
49 | * School of Computer Science | |
50 | * Carnegie Mellon University | |
51 | * Pittsburgh PA 15213-3890 | |
52 | * | |
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/lock_stat.h> | |
68 | #include <kern/locks.h> | |
69 | #include <ipc/ipc_space.h> | |
70 | #include <ipc/ipc_port.h> | |
71 | #include <ipc/ipc_pset.h> | |
72 | #include <kern/host.h> | |
73 | #include <kern/misc_protos.h> | |
74 | #include <kern/syscall_sw.h> | |
75 | #include <arm/thread.h> | |
76 | #include <mach/arm/vm_param.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 <machine/config.h> | |
85 | #include <vm/vm_map.h> | |
86 | #include <pexpert/arm/boot.h> | |
87 | #include <arm/proc_reg.h> | |
88 | #include <prng/entropy.h> | |
89 | ||
90 | /* | |
91 | * genassym.c is used to produce an | |
92 | * assembly file which, intermingled with unuseful assembly code, | |
93 | * has all the necessary definitions emitted. This assembly file is | |
94 | * then postprocessed with sed to extract only these definitions | |
95 | * and thus the final assyms.s is created. | |
96 | * | |
97 | * This convoluted means is necessary since the structure alignment | |
98 | * and packing may be different between the host machine and the | |
99 | * target so we are forced into using the cross compiler to generate | |
100 | * the values, but we cannot run anything on the target machine. | |
101 | */ | |
102 | ||
103 | #define DECLARE(SYM, VAL) \ | |
104 | __asm("DEFINITION__define__" SYM ":\t .ascii \"%0\"" : : "n" ((u_int)(VAL))) | |
105 | ||
106 | ||
107 | int main( | |
108 | int argc, | |
109 | char ** argv); | |
110 | ||
111 | int | |
112 | main( | |
113 | int argc, | |
114 | char **argv) | |
115 | { | |
116 | DECLARE("T_PREFETCH_ABT", T_PREFETCH_ABT); | |
117 | DECLARE("T_DATA_ABT", T_DATA_ABT); | |
118 | ||
119 | DECLARE("AST_URGENT", AST_URGENT); | |
120 | DECLARE("AST_PREEMPTION", AST_PREEMPTION); | |
121 | ||
122 | DECLARE("TH_RECOVER", offsetof(struct thread, recover)); | |
123 | DECLARE("TH_CONTINUATION", offsetof(struct thread, continuation)); | |
124 | DECLARE("TH_KERNEL_STACK", offsetof(struct thread, kernel_stack)); | |
125 | DECLARE("TH_KSTACKPTR", offsetof(struct thread, machine.kstackptr)); | |
126 | DECLARE("TH_UTHREAD", offsetof(struct thread, uthread)); | |
127 | ||
128 | DECLARE("TASK_MACH_EXC_PORT", | |
129 | offsetof(struct task, exc_actions[EXC_MACH_SYSCALL].port)); | |
130 | ||
131 | /* These fields are being added on demand */ | |
132 | DECLARE("ACT_TASK", offsetof(struct thread, task)); | |
133 | DECLARE("ACT_PCBDATA", offsetof(struct thread, machine.PcbData)); | |
134 | #if __ARM_VFP__ | |
135 | DECLARE("ACT_UVFP", offsetof(struct thread, machine.PcbData.VFPdata)); | |
136 | #endif | |
137 | DECLARE("TH_CTH_SELF", offsetof(struct thread, machine.cthread_self)); | |
138 | DECLARE("ACT_PCBDATA_PC", offsetof(struct thread, machine.PcbData.pc)); | |
139 | DECLARE("ACT_PCBDATA_R0", offsetof(struct thread, machine.PcbData.r[0])); | |
140 | DECLARE("ACT_PREEMPT_CNT", offsetof(struct thread, machine.preemption_count)); | |
141 | DECLARE("ACT_CPUDATAP", offsetof(struct thread, machine.CpuDatap)); | |
142 | DECLARE("ACT_MAP", offsetof(struct thread, map)); | |
143 | #if __ARM_USER_PROTECT__ | |
144 | DECLARE("ACT_UPTW_TTB", offsetof(struct thread, machine.uptw_ttb)); | |
145 | DECLARE("ACT_KPTW_TTB", offsetof(struct thread, machine.kptw_ttb)); | |
146 | DECLARE("ACT_ASID", offsetof(struct thread, machine.asid)); | |
147 | #endif | |
148 | DECLARE("ACT_DEBUGDATA", offsetof(struct thread, machine.DebugData)); | |
149 | DECLARE("TH_IOTIER_OVERRIDE", offsetof(struct thread, iotier_override)); | |
150 | DECLARE("TH_RWLOCK_CNT", offsetof(struct thread, rwlock_count)); | |
151 | DECLARE("TH_TMP_ALLOC_CNT", offsetof(struct thread, t_temp_alloc_count)); | |
152 | DECLARE("TH_SCHED_FLAGS", offsetof(struct thread, sched_flags)); | |
153 | DECLARE("TH_SFLAG_RW_PROMOTED", TH_SFLAG_RW_PROMOTED); | |
154 | ||
155 | DECLARE("TH_MACH_SYSCALLS", offsetof(struct thread, syscalls_mach)); | |
156 | DECLARE("TH_UNIX_SYSCALLS", offsetof(struct thread, syscalls_unix)); | |
157 | DECLARE("TASK_BSD_INFO", offsetof(struct task, bsd_info)); | |
158 | ||
159 | DECLARE("MACH_TRAP_TABLE_COUNT", MACH_TRAP_TABLE_COUNT); | |
160 | DECLARE("MACH_TRAP_TABLE_ENTRY_SIZE", sizeof(mach_trap_t)); | |
161 | ||
162 | DECLARE("MAP_PMAP", offsetof(struct _vm_map, pmap)); | |
163 | ||
164 | DECLARE("SS_SIZE", sizeof(struct arm_saved_state)); | |
165 | DECLARE("SS_LR", offsetof(struct arm_saved_state, lr)); | |
166 | DECLARE("SS_CPSR", offsetof(struct arm_saved_state, cpsr)); | |
167 | DECLARE("SS_PC", offsetof(struct arm_saved_state, pc)); | |
168 | DECLARE("SS_R0", offsetof(struct arm_saved_state, r[0])); | |
169 | DECLARE("SS_R4", offsetof(struct arm_saved_state, r[4])); | |
170 | DECLARE("SS_R9", offsetof(struct arm_saved_state, r[9])); | |
171 | DECLARE("SS_R12", offsetof(struct arm_saved_state, r[12])); | |
172 | DECLARE("SS_SP", offsetof(struct arm_saved_state, sp)); | |
173 | DECLARE("SS_STATUS", offsetof(struct arm_saved_state, fsr)); | |
174 | DECLARE("SS_VADDR", offsetof(struct arm_saved_state, far)); | |
175 | DECLARE("SS_EXC", offsetof(struct arm_saved_state, exception)); | |
176 | ||
177 | #if __ARM_VFP__ | |
178 | DECLARE("SS_KVFP", offsetof(struct arm_saved_state, VFPdata)); | |
179 | DECLARE("VSS_SIZE", sizeof(struct arm_vfpsaved_state)); | |
180 | DECLARE("VSS_FPSCR", offsetof(struct arm_vfpsaved_state, fpscr)); | |
181 | DECLARE("VSS_FPEXC", offsetof(struct arm_vfpsaved_state, fpexc)); | |
182 | ||
183 | DECLARE("EXC_CTX_SIZE", sizeof(struct arm_saved_state) + | |
184 | sizeof(struct arm_vfpsaved_state) + | |
185 | VFPSAVE_ALIGN); | |
186 | DECLARE("VSS_ALIGN", VFPSAVE_ALIGN); | |
187 | #else | |
188 | DECLARE("EXC_CTX_SIZE", sizeof(struct arm_saved_state)); | |
189 | #endif | |
190 | ||
191 | ||
192 | DECLARE("PGBYTES", ARM_PGBYTES); | |
193 | DECLARE("PGSHIFT", ARM_PGSHIFT); | |
194 | DECLARE("PGMASK", ARM_PGMASK); | |
195 | ||
196 | DECLARE("VM_MIN_ADDRESS", VM_MIN_ADDRESS); | |
197 | DECLARE("VM_MAX_ADDRESS", VM_MAX_ADDRESS); | |
198 | DECLARE("KERNELBASE", VM_MIN_KERNEL_ADDRESS); | |
199 | DECLARE("KERNEL_STACK_SIZE", KERNEL_STACK_SIZE); | |
200 | ||
201 | DECLARE("KERN_INVALID_ADDRESS", KERN_INVALID_ADDRESS); | |
202 | ||
203 | DECLARE("cdeSize", | |
204 | sizeof(struct cpu_data_entry)); | |
205 | ||
206 | DECLARE("cdSize", | |
207 | sizeof(struct cpu_data)); | |
208 | ||
209 | DECLARE("CPU_ACTIVE_THREAD", | |
210 | offsetof(cpu_data_t, cpu_active_thread)); | |
211 | DECLARE("CPU_ACTIVE_STACK", | |
212 | offsetof(cpu_data_t, cpu_active_stack)); | |
213 | DECLARE("CPU_ISTACKPTR", | |
214 | offsetof(cpu_data_t, istackptr)); | |
215 | DECLARE("CPU_INTSTACK_TOP", | |
216 | offsetof(cpu_data_t, intstack_top)); | |
217 | DECLARE("CPU_FIQSTACKPTR", | |
218 | offsetof(cpu_data_t, fiqstackptr)); | |
219 | DECLARE("CPU_FIQSTACK_TOP", | |
220 | offsetof(cpu_data_t, fiqstack_top)); | |
221 | DECLARE("CPU_NUMBER_GS", | |
222 | offsetof(cpu_data_t, cpu_number)); | |
223 | DECLARE("CPU_RUNNING", | |
224 | offsetof(cpu_data_t, cpu_running)); | |
225 | DECLARE("CPU_MCOUNT_OFF", | |
226 | offsetof(cpu_data_t, cpu_mcount_off)); | |
227 | DECLARE("CPU_PENDING_AST", | |
228 | offsetof(cpu_data_t, cpu_pending_ast)); | |
229 | DECLARE("CPU_CACHE_DISPATCH", | |
230 | offsetof(cpu_data_t, cpu_cache_dispatch)); | |
231 | DECLARE("CPU_BASE_TIMEBASE_LOW", | |
232 | offsetof(cpu_data_t, cpu_base_timebase_low)); | |
233 | DECLARE("CPU_BASE_TIMEBASE_HIGH", | |
234 | offsetof(cpu_data_t, cpu_base_timebase_high)); | |
235 | DECLARE("CPU_TIMEBASE_LOW", | |
236 | offsetof(cpu_data_t, cpu_timebase_low)); | |
237 | DECLARE("CPU_TIMEBASE_HIGH", | |
238 | offsetof(cpu_data_t, cpu_timebase_high)); | |
239 | DECLARE("CPU_DECREMENTER", | |
240 | offsetof(cpu_data_t, cpu_decrementer)); | |
241 | DECLARE("CPU_GET_DECREMENTER_FUNC", | |
242 | offsetof(cpu_data_t, cpu_get_decrementer_func)); | |
243 | DECLARE("CPU_SET_DECREMENTER_FUNC", | |
244 | offsetof(cpu_data_t, cpu_set_decrementer_func)); | |
245 | DECLARE("CPU_GET_FIQ_HANDLER", | |
246 | offsetof(cpu_data_t, cpu_get_fiq_handler)); | |
247 | DECLARE("CPU_TBD_HARDWARE_ADDR", | |
248 | offsetof(cpu_data_t, cpu_tbd_hardware_addr)); | |
249 | DECLARE("CPU_TBD_HARDWARE_VAL", | |
250 | offsetof(cpu_data_t, cpu_tbd_hardware_val)); | |
251 | DECLARE("CPU_INT_STATE", | |
252 | offsetof(cpu_data_t, cpu_int_state)); | |
253 | DECLARE("INTERRUPT_HANDLER", | |
254 | offsetof(cpu_data_t, interrupt_handler)); | |
255 | DECLARE("INTERRUPT_TARGET", | |
256 | offsetof(cpu_data_t, interrupt_target)); | |
257 | DECLARE("INTERRUPT_REFCON", | |
258 | offsetof(cpu_data_t, interrupt_refCon)); | |
259 | DECLARE("INTERRUPT_NUB", | |
260 | offsetof(cpu_data_t, interrupt_nub)); | |
261 | DECLARE("INTERRUPT_SOURCE", | |
262 | offsetof(cpu_data_t, interrupt_source)); | |
263 | DECLARE("CPU_USER_DEBUG", | |
264 | offsetof(cpu_data_t, cpu_user_debug)); | |
265 | DECLARE("CPU_STAT_IRQ", | |
266 | offsetof(cpu_data_t, cpu_stat.irq_ex_cnt)); | |
267 | DECLARE("CPU_STAT_IRQ_WAKE", | |
268 | offsetof(cpu_data_t, cpu_stat.irq_ex_cnt_wake)); | |
269 | DECLARE("CPU_RESET_HANDLER", | |
270 | offsetof(cpu_data_t, cpu_reset_handler)); | |
271 | DECLARE("CPU_RESET_ASSIST", | |
272 | offsetof(cpu_data_t, cpu_reset_assist)); | |
273 | DECLARE("RTCLOCK_DATAP", | |
274 | offsetof(cpu_data_t, rtclock_datap)); | |
275 | #ifdef __arm__ | |
276 | DECLARE("CPU_EXC_VECTORS", | |
277 | offsetof(cpu_data_t, cpu_exc_vectors)); | |
278 | #endif | |
279 | ||
280 | DECLARE("RTCLOCKDataSize", | |
281 | sizeof(rtclock_data_t)); | |
282 | DECLARE("RTCLOCK_ADJ_ABSTIME_LOW", | |
283 | offsetof(rtclock_data_t, rtc_adj.abstime_val.low)); | |
284 | DECLARE("RTCLOCK_ADJ_ABSTIME_HIGH", | |
285 | offsetof(rtclock_data_t, rtc_adj.abstime_val.high)); | |
286 | DECLARE("RTCLOCK_BASE_ABSTIME_LOW", | |
287 | offsetof(rtclock_data_t, rtc_base.abstime_val.low)); | |
288 | DECLARE("RTCLOCK_BASE_ABSTIME_HIGH", | |
289 | offsetof(rtclock_data_t, rtc_base.abstime_val.high)); | |
290 | DECLARE("RTCLOCK_TB_FUNC", | |
291 | offsetof(rtclock_data_t, rtc_timebase_func)); | |
292 | DECLARE("RTCLOCK_TB_ADDR", | |
293 | offsetof(rtclock_data_t, rtc_timebase_addr)); | |
294 | DECLARE("RTCLOCK_TB_VAL", | |
295 | offsetof(rtclock_data_t, rtc_timebase_val)); | |
296 | ||
297 | DECLARE("SIGPdec", SIGPdec); | |
298 | ||
299 | DECLARE("rhdSize", | |
300 | sizeof(struct reset_handler_data)); | |
301 | ||
302 | DECLARE("CPU_DATA_ENTRIES", offsetof(struct reset_handler_data, cpu_data_entries)); | |
303 | DECLARE("BOOT_ARGS", offsetof(struct reset_handler_data, boot_args)); | |
304 | DECLARE("ASSIST_RESET_HANDLER", offsetof(struct reset_handler_data, assist_reset_handler)); | |
305 | ||
306 | DECLARE("CPU_DATA_PADDR", offsetof(struct cpu_data_entry, cpu_data_paddr)); | |
307 | ||
308 | DECLARE("INTSTACK_SIZE", INTSTACK_SIZE); | |
309 | DECLARE("FIQSTACK_SIZE", FIQSTACK_SIZE); | |
310 | ||
311 | DECLARE("PAGE_MAX_SIZE", PAGE_MAX_SIZE); | |
312 | ||
313 | /* values from kern/timer.h */ | |
314 | DECLARE("TIMER_LOW", | |
315 | offsetof(struct timer, low_bits)); | |
316 | DECLARE("TIMER_HIGH", | |
317 | offsetof(struct timer, high_bits)); | |
318 | DECLARE("TIMER_HIGHCHK", | |
319 | offsetof(struct timer, high_bits_check)); | |
320 | DECLARE("TIMER_TSTAMP", | |
321 | offsetof(struct timer, tstamp)); | |
322 | DECLARE("THREAD_TIMER", | |
323 | offsetof(struct processor, thread_timer)); | |
324 | DECLARE("KERNEL_TIMER", | |
325 | offsetof(struct processor, kernel_timer)); | |
326 | DECLARE("SYSTEM_STATE", | |
327 | offsetof(struct processor, system_state)); | |
328 | DECLARE("USER_STATE", | |
329 | offsetof(struct processor, user_state)); | |
330 | DECLARE("CURRENT_STATE", | |
331 | offsetof(struct processor, current_state)); | |
332 | ||
333 | DECLARE("SYSTEM_TIMER", | |
334 | offsetof(struct thread, system_timer)); | |
335 | DECLARE("USER_TIMER", | |
336 | offsetof(struct thread, user_timer)); | |
337 | ||
338 | #if !CONFIG_SKIP_PRECISE_USER_KERNEL_TIME || HAS_FAST_CNTVCT | |
339 | DECLARE("PRECISE_USER_KERNEL_TIME", | |
340 | offsetof(struct thread, precise_user_kernel_time)); | |
341 | #endif | |
342 | ||
343 | DECLARE("BA_VIRT_BASE", | |
344 | offsetof(struct boot_args, virtBase)); | |
345 | DECLARE("BA_PHYS_BASE", | |
346 | offsetof(struct boot_args, physBase)); | |
347 | DECLARE("BA_MEM_SIZE", | |
348 | offsetof(struct boot_args, memSize)); | |
349 | DECLARE("BA_TOP_OF_KERNEL_DATA", | |
350 | offsetof(struct boot_args, topOfKernelData)); | |
351 | ||
352 | return 0; | |
353 | } |