]>
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,1989 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 | */ | |
58 | ||
0a7de745 | 59 | #ifndef _ARM_THREAD_H_ |
5ba3f43e A |
60 | #define _ARM_THREAD_H_ |
61 | ||
62 | #include <mach/mach_types.h> | |
63 | #include <mach/boolean.h> | |
64 | #include <mach/arm/vm_types.h> | |
65 | #include <mach/thread_status.h> | |
66 | ||
cb323159 | 67 | #ifdef MACH_KERNEL_PRIVATE |
5ba3f43e A |
68 | #include <arm/cpu_data.h> |
69 | #include <arm/proc_reg.h> | |
f427ee49 | 70 | #include <os/base.h> |
5ba3f43e A |
71 | #endif |
72 | ||
5ba3f43e | 73 | struct perfcontrol_state { |
cb323159 | 74 | uint64_t opaque[8] __attribute__((aligned(8))); |
5ba3f43e A |
75 | }; |
76 | ||
77 | /* | |
78 | * Maps state flavor to number of words in the state: | |
79 | */ | |
80 | extern unsigned int _MachineStateCount[]; | |
81 | ||
cb323159 | 82 | #ifdef MACH_KERNEL_PRIVATE |
5ba3f43e | 83 | #if __arm64__ |
f427ee49 | 84 | typedef arm_kernel_context_t machine_thread_kernel_state; |
5ba3f43e A |
85 | #else |
86 | typedef struct arm_saved_state machine_thread_kernel_state; | |
87 | #endif | |
88 | #include <kern/thread_kernel_state.h> | |
89 | ||
90 | struct machine_thread { | |
94ff46dc | 91 | #if __ARM_USER_PROTECT__ |
94ff46dc A |
92 | unsigned int uptw_ttb; |
93 | unsigned int kptw_ttb; | |
94 | unsigned int asid; | |
2a1bd2d3 A |
95 | #else |
96 | unsigned int reserved0; | |
97 | unsigned int reserved1; | |
98 | unsigned int reserved2; | |
94ff46dc A |
99 | #endif |
100 | ||
5ba3f43e | 101 | #if __arm64__ |
cb323159 | 102 | arm_context_t * contextData; /* allocated user context */ |
f427ee49 | 103 | arm_saved_state_t * XNU_PTRAUTH_SIGNED_PTR("machine_thread.upcb") upcb; /* pointer to user GPR state */ |
cb323159 | 104 | arm_neon_saved_state_t * uNeon; /* pointer to user VFP state */ |
f427ee49 | 105 | arm_saved_state_t * kpcb; /* pointer to kernel GPR state */ |
2a1bd2d3 A |
106 | void * reserved3; |
107 | long reserved4; | |
f427ee49 | 108 | uint64_t recover_far; |
5ba3f43e | 109 | #elif __arm__ |
cb323159 | 110 | struct arm_saved_state PcbData; |
5ba3f43e A |
111 | #else |
112 | #error Unknown arch | |
113 | #endif | |
cb323159 | 114 | |
94ff46dc A |
115 | #if defined(__arm__) && defined(__ARM_VFP__) |
116 | // for packing reasons chtread_self and DebugData | |
117 | // are inside the the PcbData when __ARM_VFP__ is set | |
118 | #define DebugData PcbData.VFPpadding_DebugData | |
119 | #define cthread_self PcbData.VFPpadding_cthread_self | |
120 | #else | |
121 | arm_debug_state_t *DebugData; | |
122 | vm_address_t cthread_self; /* for use of cthread package */ | |
5ba3f43e A |
123 | #endif |
124 | ||
f427ee49 A |
125 | #if __arm64__ |
126 | uint32_t recover_esr; | |
127 | #endif /* __arm64__ */ | |
5ba3f43e | 128 | |
f427ee49 | 129 | vm_offset_t kstackptr; /* top of kernel stack */ |
cb323159 | 130 | struct perfcontrol_state perfctrl_state; |
5ba3f43e | 131 | #if __arm64__ |
cb323159 | 132 | uint64_t energy_estimate_nj; |
5ba3f43e | 133 | #endif |
2a1bd2d3 | 134 | uint64_t reserved5; |
5ba3f43e A |
135 | |
136 | #if INTERRUPT_MASKED_DEBUG | |
f427ee49 A |
137 | uint64_t intmask_timestamp; /* timestamp of when interrupts were manually masked */ |
138 | uint64_t inthandler_timestamp; /* timestamp of when interrupt handler started */ | |
139 | unsigned int int_type; /* interrupt type of the interrupt that was processed */ | |
140 | uintptr_t int_handler_addr; /* slid, ptrauth-stripped virtual address of the interrupt handler */ | |
141 | uintptr_t int_vector; /* IOInterruptVector */ | |
142 | #endif | |
143 | ||
144 | #if __arm64__ && defined(CONFIG_XNUPOST) | |
145 | volatile expected_fault_handler_t expected_fault_handler; | |
146 | volatile uintptr_t expected_fault_addr; | |
147 | #endif | |
148 | ||
2a1bd2d3 | 149 | uint64_t reserved6; |
f427ee49 A |
150 | vm_offset_t pcpu_data_base; |
151 | struct cpu_data * CpuDatap; /* current per cpu data */ | |
152 | unsigned int preemption_count; /* preemption count */ | |
153 | #if __arm64__ | |
154 | uint16_t exception_trace_code; | |
155 | #endif | |
2a1bd2d3 | 156 | uint8_t reserved7; |
f427ee49 A |
157 | #if defined(HAS_APPLE_PAC) |
158 | uint8_t disable_user_jop; | |
159 | uint64_t rop_pid; | |
160 | uint64_t jop_pid; | |
2a1bd2d3 A |
161 | #else |
162 | uint8_t reserved8; | |
163 | uint64_t reserved9; | |
164 | uint64_t reserved10; | |
5ba3f43e A |
165 | #endif |
166 | }; | |
167 | #endif | |
168 | ||
cb323159 A |
169 | extern struct arm_saved_state * get_user_regs(thread_t); |
170 | extern struct arm_saved_state * find_user_regs(thread_t); | |
171 | extern struct arm_saved_state * find_kern_regs(thread_t); | |
172 | extern struct arm_vfpsaved_state * find_user_vfp(thread_t); | |
5ba3f43e | 173 | #if defined(__arm__) |
cb323159 | 174 | extern arm_debug_state_t * find_debug_state(thread_t); |
5ba3f43e | 175 | #elif defined(__arm64__) |
cb323159 | 176 | extern arm_debug_state32_t * find_debug_state32(thread_t); |
f427ee49 | 177 | extern arm_debug_state32_t * find_or_allocate_debug_state32(thread_t); |
cb323159 | 178 | extern arm_debug_state64_t * find_debug_state64(thread_t); |
f427ee49 | 179 | extern arm_debug_state64_t * find_or_allocate_debug_state64(thread_t); |
cb323159 | 180 | extern arm_neon_saved_state_t * get_user_neon_regs(thread_t); |
5ba3f43e A |
181 | #else |
182 | #error unknown arch | |
183 | #endif | |
184 | ||
185 | #define FIND_PERFCONTROL_STATE(th) (&th->machine.perfctrl_state) | |
186 | ||
cb323159 | 187 | #ifdef MACH_KERNEL_PRIVATE |
5ba3f43e | 188 | #if __ARM_VFP__ |
cb323159 A |
189 | extern void vfp_state_initialize(struct arm_vfpsaved_state *vfp_state); |
190 | extern void vfp_save(struct arm_vfpsaved_state *vfp_ss); | |
191 | extern void vfp_load(struct arm_vfpsaved_state *vfp_ss); | |
5ba3f43e | 192 | #endif /* __ARM_VFP__ */ |
cb323159 | 193 | extern void arm_debug_set(arm_debug_state_t *debug_state); |
5ba3f43e | 194 | #if defined(__arm64__) |
cb323159 A |
195 | extern void arm_debug_set32(arm_debug_state_t *debug_state); |
196 | extern void arm_debug_set64(arm_debug_state_t *debug_state); | |
5ba3f43e A |
197 | #endif |
198 | #endif /* MACH_KERNEL_PRIVATE */ | |
199 | ||
200 | extern void *act_thread_csave(void); | |
201 | extern void act_thread_catt(void *ctx); | |
202 | extern void act_thread_cfree(void *ctx); | |
203 | ||
5ba3f43e A |
204 | |
205 | /* | |
cb323159 A |
206 | * Return address of the function that called current function, given |
207 | * address of the first parameter of current function. | |
5ba3f43e | 208 | */ |
cb323159 | 209 | #define GET_RETURN_PC(addr) (__builtin_return_address(0)) |
5ba3f43e | 210 | |
cb323159 | 211 | #endif /* _ARM_THREAD_H_ */ |