]>
Commit | Line | Data |
---|---|---|
6d2010ae | 1 | /* |
39236c6e | 2 | * Copyright (c) 2009-2012 Apple Inc. All rights reserved. |
6d2010ae A |
3 | * |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
0a7de745 | 5 | * |
6d2010ae A |
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. | |
0a7de745 | 14 | * |
6d2010ae A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
0a7de745 | 17 | * |
6d2010ae A |
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. | |
0a7de745 | 25 | * |
6d2010ae A |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
27 | */ | |
28 | #ifndef _I386_PAL_ROUTINES_H | |
29 | #define _I386_PAL_ROUTINES_H | |
30 | ||
31 | #include <stdint.h> | |
32 | #include <mach/kern_return.h> | |
33 | #include <mach/mach_types.h> | |
34 | ||
35 | #if defined(__cplusplus) | |
36 | extern "C" { | |
37 | #endif | |
38 | ||
39 | /* PAL routines exported to kexts */ | |
40 | ||
41 | /* | |
42 | * Load registers with these values. In 32-bit mode, | |
43 | * only the low-order half is loaded (if applicable) | |
44 | */ | |
45 | struct pal_efi_registers { | |
0a7de745 A |
46 | uint64_t rcx; |
47 | uint64_t rdx; | |
48 | uint64_t r8; | |
49 | uint64_t r9; | |
50 | uint64_t rax; | |
6d2010ae A |
51 | }; |
52 | ||
53 | /* | |
54 | * Load registers and stack with these values before | |
55 | * executing "call" instruction | |
56 | */ | |
57 | kern_return_t | |
58 | pal_efi_call_in_64bit_mode(uint64_t func, | |
0a7de745 A |
59 | struct pal_efi_registers *efi_reg, |
60 | void *stack_contents, | |
61 | size_t stack_contents_size, /* 16-byte multiple */ | |
62 | uint64_t *efi_status); | |
6d2010ae A |
63 | |
64 | kern_return_t | |
65 | pal_efi_call_in_32bit_mode(uint32_t func, | |
0a7de745 A |
66 | struct pal_efi_registers *efi_reg, |
67 | void *stack_contents, | |
68 | size_t stack_contents_size, /* 16-byte multiple */ | |
69 | uint32_t *efi_status); | |
6d2010ae A |
70 | |
71 | /* Go into ACPI sleep */ | |
72 | ||
0a7de745 A |
73 | boolean_t pal_machine_sleep(uint8_t type_a, |
74 | uint8_t type_b, | |
75 | uint32_t bit_position, | |
76 | uint32_t disable_mask, | |
77 | uint32_t enable_mask); | |
6d2010ae A |
78 | |
79 | /* xnu internal PAL routines */ | |
80 | #ifdef XNU_KERNEL_PRIVATE | |
81 | ||
82 | /* Define any PAL-specific types for x86 */ | |
6d2010ae | 83 | typedef uint64_t pal_cr_t; |
6d2010ae A |
84 | |
85 | struct pal_cpu_data; /* Defined per-platform */ | |
86 | struct pal_pcb; /* Defined per-platform */ | |
87 | struct pal_apic_table; /* Defined per-platform */ | |
88 | ||
89 | /* For use by APIC kext */ | |
90 | extern struct pal_apic_table *apic_table; | |
0a7de745 | 91 | |
6d2010ae A |
92 | /* serial / debug output routines */ |
93 | extern int pal_serial_init(void); | |
94 | extern void pal_serial_putc(char); | |
39037602 | 95 | extern void pal_serial_putc_nocr(char); |
6d2010ae A |
96 | extern int pal_serial_getc(void); |
97 | ||
98 | /* Generic I386 PAL functions go here */ | |
99 | extern void pal_i386_init(void); | |
100 | extern void pal_set_signal_delivery(thread_t); | |
101 | ||
102 | /* Get values for cr0..4 */ | |
0a7de745 A |
103 | extern void pal_get_control_registers( pal_cr_t *cr0, pal_cr_t *cr2, |
104 | pal_cr_t *cr3, pal_cr_t *cr4 ); | |
6d2010ae A |
105 | |
106 | /* Debug hook invoked in the page-fault path */ | |
0a7de745 A |
107 | extern void pal_dbg_page_fault( thread_t thread, user_addr_t vadddr, |
108 | kern_return_t kr ); | |
6d2010ae A |
109 | |
110 | /* Set a task's name in the platform kernel debugger */ | |
111 | extern void pal_dbg_set_task_name( task_t task ); | |
112 | ||
113 | /* wind-back to the start of a system call */ | |
114 | void pal_syscall_restart(thread_t thread, x86_saved_state_t *state); | |
115 | ||
116 | /* Hook for non-vfork exec */ | |
117 | void pal_execve_return(thread_t thread); | |
118 | ||
119 | /* Called by thread_terminate_self() */ | |
120 | void pal_thread_terminate_self(thread_t thread); | |
121 | ||
122 | /* Called by ast_check() */ | |
123 | void pal_ast_check(thread_t thread); | |
124 | ||
125 | /* Called by sync_iss_to_iks */ | |
cb323159 | 126 | extern void pal_get_kern_regs( x86_saved_state_t *state ) __dead2; |
6d2010ae | 127 | |
6d2010ae A |
128 | /* |
129 | * Platform-specific hlt/sti. | |
0a7de745 | 130 | */ |
6d2010ae A |
131 | extern void pal_hlt(void); |
132 | extern void pal_sti(void); | |
133 | extern void pal_cli(void); | |
134 | ||
135 | /* | |
136 | * Mark in-memory thread register cache state validity. | |
137 | */ | |
138 | typedef enum { DIRTY, VALID } pal_cache_state_t; | |
139 | void pal_register_cache_state(thread_t thread, pal_cache_state_t state); | |
140 | ||
141 | ||
142 | /* Catch code running on the except thread that shouldn't be */ | |
143 | void pal_preemption_assert(void); | |
144 | ||
6d2010ae A |
145 | /* Include a PAL-specific header, too, for xnu-internal overrides */ |
146 | #include <i386/pal_native.h> | |
147 | ||
bd504ef0 | 148 | |
4b17d6b6 A |
149 | extern boolean_t virtualized; |
150 | #define PAL_VIRTUALIZED_PROPERTY_VALUE 4 | |
0a7de745 | 151 | |
6d2010ae A |
152 | /* Allow for tricky IOKit property matching */ |
153 | #define PAL_AICPM_PROPERTY_NAME "intel_cpupm_matching" | |
0a7de745 | 154 | static inline void |
6d2010ae A |
155 | pal_get_resource_property(const char **property_name, int *property_value) |
156 | { | |
39236c6e A |
157 | *property_name = PAL_AICPM_PROPERTY_NAME; |
158 | *property_value = PAL_AICPM_PROPERTY_VALUE; | |
0a7de745 | 159 | if (virtualized) { |
39236c6e | 160 | *property_value = PAL_VIRTUALIZED_PROPERTY_VALUE; |
0a7de745 | 161 | } |
6d2010ae A |
162 | } |
163 | ||
164 | /* assembly function to update TSC / timebase info */ | |
165 | extern void _pal_rtc_nanotime_store( | |
0a7de745 A |
166 | uint64_t tsc, |
167 | uint64_t nsec, | |
168 | uint32_t scale, | |
169 | uint32_t shift, | |
170 | struct pal_rtc_nanotime *dst); | |
6d2010ae A |
171 | |
172 | /* global nanotime info */ | |
173 | extern struct pal_rtc_nanotime pal_rtc_nanotime_info; | |
174 | ||
175 | #endif /* XNU_KERNEL_PRIVATE */ | |
176 | ||
177 | #if defined(__cplusplus) | |
178 | } | |
179 | #endif | |
180 | ||
181 | #endif /* _I386_PAL_ROUTINES_H */ |