]>
Commit | Line | Data |
---|---|---|
4b17d6b6 | 1 | |
6d2010ae A |
2 | /* |
3 | * Copyright (c) 2009 Apple Inc. All rights reserved. | |
4 | * | |
5 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
6 | * | |
7 | * This file contains Original Code and/or Modifications of Original Code | |
8 | * as defined in and that are subject to the Apple Public Source License | |
9 | * Version 2.0 (the 'License'). You may not use this file except in | |
10 | * compliance with the License. The rights granted to you under the License | |
11 | * may not be used to create, or enable the creation or redistribution of, | |
12 | * unlawful or unlicensed copies of an Apple operating system, or to | |
13 | * circumvent, violate, or enable the circumvention or violation of, any | |
14 | * terms of an Apple operating system software license agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
18 | * | |
19 | * The Original Code and all software distributed under the License are | |
20 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
21 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
22 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
23 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
24 | * Please see the License for the specific language governing rights and | |
25 | * limitations under the License. | |
26 | * | |
27 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
28 | */ | |
29 | #ifndef _I386_PAL_ROUTINES_H | |
30 | #define _I386_PAL_ROUTINES_H | |
31 | ||
32 | #include <stdint.h> | |
33 | #include <mach/kern_return.h> | |
34 | #include <mach/mach_types.h> | |
35 | ||
36 | #if defined(__cplusplus) | |
37 | extern "C" { | |
38 | #endif | |
39 | ||
40 | /* PAL routines exported to kexts */ | |
41 | ||
42 | /* | |
43 | * Load registers with these values. In 32-bit mode, | |
44 | * only the low-order half is loaded (if applicable) | |
45 | */ | |
46 | struct pal_efi_registers { | |
47 | uint64_t rcx; | |
48 | uint64_t rdx; | |
49 | uint64_t r8; | |
50 | uint64_t r9; | |
51 | uint64_t rax; | |
52 | }; | |
53 | ||
54 | /* | |
55 | * Load registers and stack with these values before | |
56 | * executing "call" instruction | |
57 | */ | |
58 | kern_return_t | |
59 | pal_efi_call_in_64bit_mode(uint64_t func, | |
60 | struct pal_efi_registers *efi_reg, | |
61 | void *stack_contents, | |
62 | size_t stack_contents_size, /* 16-byte multiple */ | |
63 | uint64_t *efi_status); | |
64 | ||
65 | kern_return_t | |
66 | pal_efi_call_in_32bit_mode(uint32_t func, | |
67 | struct pal_efi_registers *efi_reg, | |
68 | void *stack_contents, | |
69 | size_t stack_contents_size, /* 16-byte multiple */ | |
70 | uint32_t *efi_status); | |
71 | ||
72 | /* Go into ACPI sleep */ | |
73 | ||
74 | boolean_t pal_machine_sleep(uint8_t type_a, | |
75 | uint8_t type_b, | |
76 | uint32_t bit_position, | |
77 | uint32_t disable_mask, | |
78 | uint32_t enable_mask); | |
79 | ||
80 | /* xnu internal PAL routines */ | |
81 | #ifdef XNU_KERNEL_PRIVATE | |
82 | ||
83 | /* Define any PAL-specific types for x86 */ | |
84 | #ifdef __i386__ | |
85 | typedef uint32_t pal_cr_t; | |
86 | #else | |
87 | typedef uint64_t pal_cr_t; | |
88 | #endif | |
89 | ||
90 | struct pal_cpu_data; /* Defined per-platform */ | |
91 | struct pal_pcb; /* Defined per-platform */ | |
92 | struct pal_apic_table; /* Defined per-platform */ | |
93 | ||
94 | /* For use by APIC kext */ | |
95 | extern struct pal_apic_table *apic_table; | |
96 | ||
97 | /* serial / debug output routines */ | |
98 | extern int pal_serial_init(void); | |
99 | extern void pal_serial_putc(char); | |
100 | extern int pal_serial_getc(void); | |
101 | ||
102 | /* Generic I386 PAL functions go here */ | |
103 | extern void pal_i386_init(void); | |
104 | extern void pal_set_signal_delivery(thread_t); | |
105 | ||
106 | /* Get values for cr0..4 */ | |
107 | extern void pal_get_control_registers( pal_cr_t *cr0, pal_cr_t *cr2, | |
108 | pal_cr_t *cr3, pal_cr_t *cr4 ); | |
109 | ||
110 | /* Debug hook invoked in the page-fault path */ | |
111 | extern void pal_dbg_page_fault( thread_t thread, user_addr_t vadddr, | |
112 | kern_return_t kr ); | |
113 | ||
114 | /* Set a task's name in the platform kernel debugger */ | |
115 | extern void pal_dbg_set_task_name( task_t task ); | |
116 | ||
117 | /* wind-back to the start of a system call */ | |
118 | void pal_syscall_restart(thread_t thread, x86_saved_state_t *state); | |
119 | ||
120 | /* Hook for non-vfork exec */ | |
121 | void pal_execve_return(thread_t thread); | |
122 | ||
123 | /* Called by thread_terminate_self() */ | |
124 | void pal_thread_terminate_self(thread_t thread); | |
125 | ||
126 | /* Called by ast_check() */ | |
127 | void pal_ast_check(thread_t thread); | |
128 | ||
129 | /* Called by sync_iss_to_iks */ | |
130 | extern void pal_get_kern_regs( x86_saved_state_t *state ); | |
131 | ||
132 | /* Called by load_machfile */ | |
133 | void pal_switch_pmap(thread_t, pmap_t, boolean_t); | |
134 | ||
135 | /* | |
136 | * Platform-specific hlt/sti. | |
137 | */ | |
138 | extern void pal_hlt(void); | |
139 | extern void pal_sti(void); | |
140 | extern void pal_cli(void); | |
141 | ||
142 | /* | |
143 | * Mark in-memory thread register cache state validity. | |
144 | */ | |
145 | typedef enum { DIRTY, VALID } pal_cache_state_t; | |
146 | void pal_register_cache_state(thread_t thread, pal_cache_state_t state); | |
147 | ||
148 | ||
149 | /* Catch code running on the except thread that shouldn't be */ | |
150 | void pal_preemption_assert(void); | |
151 | ||
152 | void hibernate_pal_prepare(void); | |
153 | void pal_efi_hibernate_prepare(void); | |
154 | ||
155 | /* Include a PAL-specific header, too, for xnu-internal overrides */ | |
156 | #include <i386/pal_native.h> | |
157 | ||
4b17d6b6 A |
158 | extern boolean_t virtualized; |
159 | #define PAL_VIRTUALIZED_PROPERTY_VALUE 4 | |
6d2010ae A |
160 | |
161 | /* Allow for tricky IOKit property matching */ | |
162 | #define PAL_AICPM_PROPERTY_NAME "intel_cpupm_matching" | |
163 | static inline void | |
164 | pal_get_resource_property(const char **property_name, int *property_value) | |
165 | { | |
4b17d6b6 A |
166 | *property_name = PAL_AICPM_PROPERTY_NAME; |
167 | *property_value = PAL_AICPM_PROPERTY_VALUE; | |
168 | if (virtualized) | |
169 | *property_value = PAL_VIRTUALIZED_PROPERTY_VALUE; | |
6d2010ae A |
170 | } |
171 | ||
172 | /* assembly function to update TSC / timebase info */ | |
173 | extern void _pal_rtc_nanotime_store( | |
174 | uint64_t tsc, | |
175 | uint64_t nsec, | |
176 | uint32_t scale, | |
177 | uint32_t shift, | |
178 | struct pal_rtc_nanotime *dst); | |
179 | ||
180 | /* global nanotime info */ | |
181 | extern struct pal_rtc_nanotime pal_rtc_nanotime_info; | |
182 | ||
183 | #endif /* XNU_KERNEL_PRIVATE */ | |
184 | ||
185 | #if defined(__cplusplus) | |
186 | } | |
187 | #endif | |
188 | ||
189 | #endif /* _I386_PAL_ROUTINES_H */ |