]> git.saurik.com Git - apple/xnu.git/blob - osfmk/arm/genassym.c
xnu-6153.11.26.tar.gz
[apple/xnu.git] / osfmk / arm / genassym.c
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 <vm/vm_map.h>
85 #include <pexpert/arm/boot.h>
86 #include <arm/proc_reg.h>
87 #include <prng/random.h>
88
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
102 #define DECLARE(SYM, VAL) \
103 __asm("DEFINITION__define__" SYM ":\t .ascii \"%0\"" : : "n" ((u_int)(VAL)))
104
105
106 int main(
107 int argc,
108 char ** argv);
109
110 int
111 main(
112 int argc,
113 char **argv)
114 {
115 DECLARE("T_PREFETCH_ABT", T_PREFETCH_ABT);
116 DECLARE("T_DATA_ABT", T_DATA_ABT);
117
118 DECLARE("AST_URGENT", AST_URGENT);
119 DECLARE("AST_PREEMPTION", AST_PREEMPTION);
120
121 DECLARE("TH_RECOVER", offsetof(struct thread, recover));
122 DECLARE("TH_CONTINUATION", offsetof(struct thread, continuation));
123 DECLARE("TH_KERNEL_STACK", offsetof(struct thread, kernel_stack));
124 DECLARE("TH_KSTACKPTR", offsetof(struct thread, machine.kstackptr));
125 DECLARE("TH_UTHREAD", offsetof(struct thread, uthread));
126
127 DECLARE("TASK_MACH_EXC_PORT",
128 offsetof(struct task, exc_actions[EXC_MACH_SYSCALL].port));
129
130 /* These fields are being added on demand */
131 DECLARE("ACT_TASK", offsetof(struct thread, task));
132 DECLARE("ACT_PCBDATA", offsetof(struct thread, machine.PcbData));
133 #if __ARM_VFP__
134 DECLARE("ACT_UVFP", offsetof(struct thread, machine.uVFPdata));
135 DECLARE("ACT_KVFP", offsetof(struct thread, machine.kVFPdata));
136 #endif
137 DECLARE("TH_CTH_SELF", offsetof(struct thread, machine.cthread_self));
138 DECLARE("TH_CTH_DATA", offsetof(struct thread, machine.cthread_data));
139 DECLARE("ACT_PCBDATA_PC", offsetof(struct thread, machine.PcbData.pc));
140 DECLARE("ACT_PCBDATA_R0", offsetof(struct thread, machine.PcbData.r[0]));
141 DECLARE("ACT_PREEMPT_CNT", offsetof(struct thread, machine.preemption_count));
142 DECLARE("ACT_CPUDATAP", offsetof(struct thread, machine.CpuDatap));
143 DECLARE("ACT_MAP", offsetof(struct thread, map));
144 #if __ARM_USER_PROTECT__
145 DECLARE("ACT_UPTW_TTC", offsetof(struct thread, machine.uptw_ttc));
146 DECLARE("ACT_UPTW_TTB", offsetof(struct thread, machine.uptw_ttb));
147 DECLARE("ACT_KPTW_TTB", offsetof(struct thread, machine.kptw_ttb));
148 DECLARE("ACT_ASID", offsetof(struct thread, machine.asid));
149 #endif
150 DECLARE("ACT_DEBUGDATA", offsetof(struct thread, machine.DebugData));
151 DECLARE("TH_IOTIER_OVERRIDE", offsetof(struct thread, iotier_override));
152 DECLARE("TH_RWLOCK_CNT", offsetof(struct thread, rwlock_count));
153 DECLARE("TH_SCHED_FLAGS", offsetof(struct thread, sched_flags));
154 DECLARE("TH_SFLAG_RW_PROMOTED", TH_SFLAG_RW_PROMOTED);
155
156 DECLARE("TH_MACH_SYSCALLS", offsetof(struct thread, syscalls_mach));
157 DECLARE("TH_UNIX_SYSCALLS", offsetof(struct thread, syscalls_unix));
158 DECLARE("TASK_BSD_INFO", offsetof(struct task, bsd_info));
159
160 DECLARE("MACH_TRAP_TABLE_COUNT", MACH_TRAP_TABLE_COUNT);
161 DECLARE("MACH_TRAP_TABLE_ENTRY_SIZE", sizeof(mach_trap_t));
162
163 DECLARE("MAP_PMAP", offsetof(struct _vm_map, pmap));
164
165 DECLARE("SS_SIZE", sizeof(struct arm_saved_state));
166 DECLARE("SS_LR", offsetof(struct arm_saved_state, lr));
167 DECLARE("SS_CPSR", offsetof(struct arm_saved_state, cpsr));
168 DECLARE("SS_PC", offsetof(struct arm_saved_state, pc));
169 DECLARE("SS_R0", offsetof(struct arm_saved_state, r[0]));
170 DECLARE("SS_R4", offsetof(struct arm_saved_state, r[4]));
171 DECLARE("SS_R9", offsetof(struct arm_saved_state, r[9]));
172 DECLARE("SS_R12", offsetof(struct arm_saved_state, r[12]));
173 DECLARE("SS_SP", offsetof(struct arm_saved_state, sp));
174 DECLARE("SS_STATUS", offsetof(struct arm_saved_state, fsr));
175 DECLARE("SS_VADDR", offsetof(struct arm_saved_state, far));
176 DECLARE("SS_EXC", offsetof(struct arm_saved_state, exception));
177
178 #if __ARM_VFP__
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("MAX_CPUS", MAX_CPUS);
204
205 DECLARE("cdeSize",
206 sizeof(struct cpu_data_entry));
207
208 DECLARE("cdSize",
209 sizeof(struct cpu_data));
210
211 DECLARE("CPU_ACTIVE_THREAD",
212 offsetof(cpu_data_t, cpu_active_thread));
213 DECLARE("CPU_ACTIVE_STACK",
214 offsetof(cpu_data_t, cpu_active_stack));
215 DECLARE("CPU_ISTACKPTR",
216 offsetof(cpu_data_t, istackptr));
217 DECLARE("CPU_INTSTACK_TOP",
218 offsetof(cpu_data_t, intstack_top));
219 DECLARE("CPU_FIQSTACKPTR",
220 offsetof(cpu_data_t, fiqstackptr));
221 DECLARE("CPU_FIQSTACK_TOP",
222 offsetof(cpu_data_t, fiqstack_top));
223 DECLARE("CPU_NUMBER_GS",
224 offsetof(cpu_data_t, cpu_number));
225 DECLARE("CPU_IDENT",
226 offsetof(cpu_data_t, cpu_ident));
227 DECLARE("CPU_RUNNING",
228 offsetof(cpu_data_t, cpu_running));
229 DECLARE("CPU_MCOUNT_OFF",
230 offsetof(cpu_data_t, cpu_mcount_off));
231 DECLARE("CPU_PENDING_AST",
232 offsetof(cpu_data_t, cpu_pending_ast));
233 DECLARE("CPU_PROCESSOR",
234 offsetof(cpu_data_t, cpu_processor));
235 DECLARE("CPU_CACHE_DISPATCH",
236 offsetof(cpu_data_t, cpu_cache_dispatch));
237 DECLARE("CPU_BASE_TIMEBASE_LOW",
238 offsetof(cpu_data_t, cpu_base_timebase_low));
239 DECLARE("CPU_BASE_TIMEBASE_HIGH",
240 offsetof(cpu_data_t, cpu_base_timebase_high));
241 DECLARE("CPU_TIMEBASE_LOW",
242 offsetof(cpu_data_t, cpu_timebase_low));
243 DECLARE("CPU_TIMEBASE_HIGH",
244 offsetof(cpu_data_t, cpu_timebase_high));
245 DECLARE("CPU_DECREMENTER",
246 offsetof(cpu_data_t, cpu_decrementer));
247 DECLARE("CPU_GET_DECREMENTER_FUNC",
248 offsetof(cpu_data_t, cpu_get_decrementer_func));
249 DECLARE("CPU_SET_DECREMENTER_FUNC",
250 offsetof(cpu_data_t, cpu_set_decrementer_func));
251 DECLARE("CPU_GET_FIQ_HANDLER",
252 offsetof(cpu_data_t, cpu_get_fiq_handler));
253 DECLARE("CPU_TBD_HARDWARE_ADDR",
254 offsetof(cpu_data_t, cpu_tbd_hardware_addr));
255 DECLARE("CPU_TBD_HARDWARE_VAL",
256 offsetof(cpu_data_t, cpu_tbd_hardware_val));
257 DECLARE("CPU_INT_STATE",
258 offsetof(cpu_data_t, cpu_int_state));
259 DECLARE("INTERRUPT_HANDLER",
260 offsetof(cpu_data_t, interrupt_handler));
261 DECLARE("INTERRUPT_TARGET",
262 offsetof(cpu_data_t, interrupt_target));
263 DECLARE("INTERRUPT_REFCON",
264 offsetof(cpu_data_t, interrupt_refCon));
265 DECLARE("INTERRUPT_NUB",
266 offsetof(cpu_data_t, interrupt_nub));
267 DECLARE("INTERRUPT_SOURCE",
268 offsetof(cpu_data_t, interrupt_source));
269 DECLARE("CPU_USER_DEBUG",
270 offsetof(cpu_data_t, cpu_user_debug));
271 DECLARE("CPU_STAT_IRQ",
272 offsetof(cpu_data_t, cpu_stat.irq_ex_cnt));
273 DECLARE("CPU_STAT_IRQ_WAKE",
274 offsetof(cpu_data_t, cpu_stat.irq_ex_cnt_wake));
275 DECLARE("CPU_RESET_HANDLER",
276 offsetof(cpu_data_t, cpu_reset_handler));
277 DECLARE("CPU_RESET_ASSIST",
278 offsetof(cpu_data_t, cpu_reset_assist));
279 DECLARE("RTCLOCK_DATAP",
280 offsetof(cpu_data_t, rtclock_datap));
281 #ifdef __arm__
282 DECLARE("CPU_EXC_VECTORS",
283 offsetof(cpu_data_t, cpu_exc_vectors));
284 #endif
285
286 DECLARE("RTCLOCKDataSize",
287 sizeof(rtclock_data_t));
288 DECLARE("RTCLOCK_ADJ_ABSTIME_LOW",
289 offsetof(rtclock_data_t, rtc_adj.abstime_val.low));
290 DECLARE("RTCLOCK_ADJ_ABSTIME_HIGH",
291 offsetof(rtclock_data_t, rtc_adj.abstime_val.high));
292 DECLARE("RTCLOCK_BASE_ABSTIME_LOW",
293 offsetof(rtclock_data_t, rtc_base.abstime_val.low));
294 DECLARE("RTCLOCK_BASE_ABSTIME_HIGH",
295 offsetof(rtclock_data_t, rtc_base.abstime_val.high));
296 DECLARE("RTCLOCK_TB_FUNC",
297 offsetof(rtclock_data_t, rtc_timebase_func));
298 DECLARE("RTCLOCK_TB_ADDR",
299 offsetof(rtclock_data_t, rtc_timebase_addr));
300 DECLARE("RTCLOCK_TB_VAL",
301 offsetof(rtclock_data_t, rtc_timebase_val));
302
303 DECLARE("SIGPdec", SIGPdec);
304
305 DECLARE("rhdSize",
306 sizeof(struct reset_handler_data));
307
308 DECLARE("CPU_DATA_ENTRIES", offsetof(struct reset_handler_data, cpu_data_entries));
309 DECLARE("BOOT_ARGS", offsetof(struct reset_handler_data, boot_args));
310 DECLARE("ASSIST_RESET_HANDLER", offsetof(struct reset_handler_data, assist_reset_handler));
311
312 DECLARE("CPU_DATA_PADDR", offsetof(struct cpu_data_entry, cpu_data_paddr));
313
314 DECLARE("INTSTACK_SIZE", INTSTACK_SIZE);
315 DECLARE("FIQSTACK_SIZE", FIQSTACK_SIZE);
316
317 DECLARE("PAGE_MAX_SIZE", PAGE_MAX_SIZE);
318
319 /* values from kern/timer.h */
320 DECLARE("TIMER_LOW",
321 offsetof(struct timer, low_bits));
322 DECLARE("TIMER_HIGH",
323 offsetof(struct timer, high_bits));
324 DECLARE("TIMER_HIGHCHK",
325 offsetof(struct timer, high_bits_check));
326 DECLARE("TIMER_TSTAMP",
327 offsetof(struct timer, tstamp));
328 DECLARE("THREAD_TIMER",
329 offsetof(struct processor, processor_data.thread_timer));
330 DECLARE("KERNEL_TIMER",
331 offsetof(struct processor, processor_data.kernel_timer));
332 DECLARE("SYSTEM_STATE",
333 offsetof(struct processor, processor_data.system_state));
334 DECLARE("USER_STATE",
335 offsetof(struct processor, processor_data.user_state));
336 DECLARE("CURRENT_STATE",
337 offsetof(struct processor, processor_data.current_state));
338
339 DECLARE("SYSTEM_TIMER",
340 offsetof(struct thread, system_timer));
341 DECLARE("USER_TIMER",
342 offsetof(struct thread, user_timer));
343
344 #if !CONFIG_SKIP_PRECISE_USER_KERNEL_TIME
345 DECLARE("PRECISE_USER_KERNEL_TIME",
346 offsetof(struct thread, precise_user_kernel_time));
347 #endif
348
349 DECLARE("BA_VIRT_BASE",
350 offsetof(struct boot_args, virtBase));
351 DECLARE("BA_PHYS_BASE",
352 offsetof(struct boot_args, physBase));
353 DECLARE("BA_MEM_SIZE",
354 offsetof(struct boot_args, memSize));
355 DECLARE("BA_TOP_OF_KERNEL_DATA",
356 offsetof(struct boot_args, topOfKernelData));
357
358 DECLARE("ENTROPY_SAMPLE_COUNT",
359 offsetof(entropy_data_t, sample_count));
360 DECLARE("ENTROPY_BUFFER",
361 offsetof(entropy_data_t, buffer));
362 DECLARE("ENTROPY_BUFFER_INDEX_MASK", ENTROPY_BUFFER_INDEX_MASK);
363
364 return 0;
365 }