]> git.saurik.com Git - apple/xnu.git/blame - osfmk/arm/genassym.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / osfmk / arm / genassym.c
CommitLineData
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>
0a7de745 67#include <kern/lock_stat.h>
5ba3f43e
A
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>
f427ee49 84#include <machine/config.h>
5ba3f43e
A
85#include <vm/vm_map.h>
86#include <pexpert/arm/boot.h>
87#include <arm/proc_reg.h>
f427ee49 88#include <prng/entropy.h>
5ba3f43e 89
5ba3f43e
A
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
0a7de745 103#define DECLARE(SYM, VAL) \
5ba3f43e
A
104 __asm("DEFINITION__define__" SYM ":\t .ascii \"%0\"" : : "n" ((u_int)(VAL)))
105
106
0a7de745
A
107int main(
108 int argc,
109 char ** argv);
5ba3f43e
A
110
111int
112main(
0a7de745
A
113 int argc,
114 char **argv)
5ba3f43e 115{
0a7de745
A
116 DECLARE("T_PREFETCH_ABT", T_PREFETCH_ABT);
117 DECLARE("T_DATA_ABT", T_DATA_ABT);
5ba3f43e 118
0a7de745
A
119 DECLARE("AST_URGENT", AST_URGENT);
120 DECLARE("AST_PREEMPTION", AST_PREEMPTION);
5ba3f43e 121
0a7de745
A
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));
5ba3f43e
A
127
128 DECLARE("TASK_MACH_EXC_PORT",
0a7de745 129 offsetof(struct task, exc_actions[EXC_MACH_SYSCALL].port));
5ba3f43e
A
130
131 /* These fields are being added on demand */
0a7de745
A
132 DECLARE("ACT_TASK", offsetof(struct thread, task));
133 DECLARE("ACT_PCBDATA", offsetof(struct thread, machine.PcbData));
5ba3f43e 134#if __ARM_VFP__
94ff46dc 135 DECLARE("ACT_UVFP", offsetof(struct thread, machine.PcbData.VFPdata));
5ba3f43e 136#endif
0a7de745 137 DECLARE("TH_CTH_SELF", offsetof(struct thread, machine.cthread_self));
0a7de745
A
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));
5ba3f43e 143#if __ARM_USER_PROTECT__
5ba3f43e
A
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
0a7de745
A
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));
f427ee49 151 DECLARE("TH_TMP_ALLOC_CNT", offsetof(struct thread, t_temp_alloc_count));
0a7de745
A
152 DECLARE("TH_SCHED_FLAGS", offsetof(struct thread, sched_flags));
153 DECLARE("TH_SFLAG_RW_PROMOTED", TH_SFLAG_RW_PROMOTED);
5ba3f43e
A
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
0a7de745 162 DECLARE("MAP_PMAP", offsetof(struct _vm_map, pmap));
5ba3f43e 163
0a7de745 164 DECLARE("SS_SIZE", sizeof(struct arm_saved_state));
5ba3f43e
A
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__
94ff46dc 178 DECLARE("SS_KVFP", offsetof(struct arm_saved_state, VFPdata));
5ba3f43e
A
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) +
0a7de745
A
184 sizeof(struct arm_vfpsaved_state) +
185 VFPSAVE_ALIGN);
5ba3f43e
A
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
0a7de745
A
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);
5ba3f43e 200
0a7de745 201 DECLARE("KERN_INVALID_ADDRESS", KERN_INVALID_ADDRESS);
5ba3f43e 202
5ba3f43e 203 DECLARE("cdeSize",
0a7de745 204 sizeof(struct cpu_data_entry));
5ba3f43e
A
205
206 DECLARE("cdSize",
0a7de745
A
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));
0a7de745
A
223 DECLARE("CPU_RUNNING",
224 offsetof(cpu_data_t, cpu_running));
225 DECLARE("CPU_MCOUNT_OFF",
226 offsetof(cpu_data_t, cpu_mcount_off));
5ba3f43e 227 DECLARE("CPU_PENDING_AST",
0a7de745 228 offsetof(cpu_data_t, cpu_pending_ast));
5ba3f43e 229 DECLARE("CPU_CACHE_DISPATCH",
0a7de745
A
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));
5ba3f43e 239 DECLARE("CPU_DECREMENTER",
0a7de745 240 offsetof(cpu_data_t, cpu_decrementer));
5ba3f43e 241 DECLARE("CPU_GET_DECREMENTER_FUNC",
0a7de745 242 offsetof(cpu_data_t, cpu_get_decrementer_func));
5ba3f43e 243 DECLARE("CPU_SET_DECREMENTER_FUNC",
0a7de745 244 offsetof(cpu_data_t, cpu_set_decrementer_func));
5ba3f43e 245 DECLARE("CPU_GET_FIQ_HANDLER",
0a7de745 246 offsetof(cpu_data_t, cpu_get_fiq_handler));
5ba3f43e 247 DECLARE("CPU_TBD_HARDWARE_ADDR",
0a7de745 248 offsetof(cpu_data_t, cpu_tbd_hardware_addr));
5ba3f43e 249 DECLARE("CPU_TBD_HARDWARE_VAL",
0a7de745 250 offsetof(cpu_data_t, cpu_tbd_hardware_val));
5ba3f43e 251 DECLARE("CPU_INT_STATE",
0a7de745 252 offsetof(cpu_data_t, cpu_int_state));
5ba3f43e 253 DECLARE("INTERRUPT_HANDLER",
0a7de745 254 offsetof(cpu_data_t, interrupt_handler));
5ba3f43e 255 DECLARE("INTERRUPT_TARGET",
0a7de745 256 offsetof(cpu_data_t, interrupt_target));
5ba3f43e 257 DECLARE("INTERRUPT_REFCON",
0a7de745 258 offsetof(cpu_data_t, interrupt_refCon));
5ba3f43e 259 DECLARE("INTERRUPT_NUB",
0a7de745 260 offsetof(cpu_data_t, interrupt_nub));
5ba3f43e 261 DECLARE("INTERRUPT_SOURCE",
0a7de745 262 offsetof(cpu_data_t, interrupt_source));
5ba3f43e 263 DECLARE("CPU_USER_DEBUG",
0a7de745 264 offsetof(cpu_data_t, cpu_user_debug));
5ba3f43e 265 DECLARE("CPU_STAT_IRQ",
0a7de745 266 offsetof(cpu_data_t, cpu_stat.irq_ex_cnt));
5ba3f43e 267 DECLARE("CPU_STAT_IRQ_WAKE",
0a7de745 268 offsetof(cpu_data_t, cpu_stat.irq_ex_cnt_wake));
5ba3f43e 269 DECLARE("CPU_RESET_HANDLER",
0a7de745 270 offsetof(cpu_data_t, cpu_reset_handler));
5ba3f43e 271 DECLARE("CPU_RESET_ASSIST",
0a7de745 272 offsetof(cpu_data_t, cpu_reset_assist));
5ba3f43e 273 DECLARE("RTCLOCK_DATAP",
0a7de745
A
274 offsetof(cpu_data_t, rtclock_datap));
275#ifdef __arm__
5ba3f43e 276 DECLARE("CPU_EXC_VECTORS",
0a7de745 277 offsetof(cpu_data_t, cpu_exc_vectors));
5ba3f43e
A
278#endif
279
280 DECLARE("RTCLOCKDataSize",
0a7de745 281 sizeof(rtclock_data_t));
5ba3f43e 282 DECLARE("RTCLOCK_ADJ_ABSTIME_LOW",
0a7de745 283 offsetof(rtclock_data_t, rtc_adj.abstime_val.low));
5ba3f43e 284 DECLARE("RTCLOCK_ADJ_ABSTIME_HIGH",
0a7de745 285 offsetof(rtclock_data_t, rtc_adj.abstime_val.high));
5ba3f43e 286 DECLARE("RTCLOCK_BASE_ABSTIME_LOW",
0a7de745 287 offsetof(rtclock_data_t, rtc_base.abstime_val.low));
5ba3f43e 288 DECLARE("RTCLOCK_BASE_ABSTIME_HIGH",
0a7de745 289 offsetof(rtclock_data_t, rtc_base.abstime_val.high));
5ba3f43e 290 DECLARE("RTCLOCK_TB_FUNC",
0a7de745 291 offsetof(rtclock_data_t, rtc_timebase_func));
5ba3f43e 292 DECLARE("RTCLOCK_TB_ADDR",
0a7de745 293 offsetof(rtclock_data_t, rtc_timebase_addr));
5ba3f43e 294 DECLARE("RTCLOCK_TB_VAL",
0a7de745 295 offsetof(rtclock_data_t, rtc_timebase_val));
5ba3f43e 296
0a7de745 297 DECLARE("SIGPdec", SIGPdec);
5ba3f43e
A
298
299 DECLARE("rhdSize",
0a7de745 300 sizeof(struct reset_handler_data));
5ba3f43e 301
0a7de745
A
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));
5ba3f43e 305
0a7de745 306 DECLARE("CPU_DATA_PADDR", offsetof(struct cpu_data_entry, cpu_data_paddr));
5ba3f43e 307
0a7de745
A
308 DECLARE("INTSTACK_SIZE", INTSTACK_SIZE);
309 DECLARE("FIQSTACK_SIZE", FIQSTACK_SIZE);
d9a64523 310
0a7de745 311 DECLARE("PAGE_MAX_SIZE", PAGE_MAX_SIZE);
5ba3f43e
A
312
313 /* values from kern/timer.h */
314 DECLARE("TIMER_LOW",
0a7de745 315 offsetof(struct timer, low_bits));
5ba3f43e 316 DECLARE("TIMER_HIGH",
0a7de745 317 offsetof(struct timer, high_bits));
5ba3f43e 318 DECLARE("TIMER_HIGHCHK",
0a7de745 319 offsetof(struct timer, high_bits_check));
5ba3f43e 320 DECLARE("TIMER_TSTAMP",
0a7de745 321 offsetof(struct timer, tstamp));
5ba3f43e 322 DECLARE("THREAD_TIMER",
f427ee49 323 offsetof(struct processor, thread_timer));
5ba3f43e 324 DECLARE("KERNEL_TIMER",
f427ee49 325 offsetof(struct processor, kernel_timer));
5ba3f43e 326 DECLARE("SYSTEM_STATE",
f427ee49 327 offsetof(struct processor, system_state));
5ba3f43e 328 DECLARE("USER_STATE",
f427ee49 329 offsetof(struct processor, user_state));
5ba3f43e 330 DECLARE("CURRENT_STATE",
f427ee49 331 offsetof(struct processor, current_state));
5ba3f43e
A
332
333 DECLARE("SYSTEM_TIMER",
0a7de745 334 offsetof(struct thread, system_timer));
5ba3f43e 335 DECLARE("USER_TIMER",
0a7de745 336 offsetof(struct thread, user_timer));
5ba3f43e 337
f427ee49 338#if !CONFIG_SKIP_PRECISE_USER_KERNEL_TIME || HAS_FAST_CNTVCT
5ba3f43e 339 DECLARE("PRECISE_USER_KERNEL_TIME",
0a7de745 340 offsetof(struct thread, precise_user_kernel_time));
5ba3f43e
A
341#endif
342
343 DECLARE("BA_VIRT_BASE",
0a7de745 344 offsetof(struct boot_args, virtBase));
5ba3f43e 345 DECLARE("BA_PHYS_BASE",
0a7de745 346 offsetof(struct boot_args, physBase));
5ba3f43e 347 DECLARE("BA_MEM_SIZE",
0a7de745 348 offsetof(struct boot_args, memSize));
5ba3f43e 349 DECLARE("BA_TOP_OF_KERNEL_DATA",
0a7de745 350 offsetof(struct boot_args, topOfKernelData));
5ba3f43e 351
0a7de745 352 return 0;
5ba3f43e 353}