]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
30 | */ | |
31 | ||
32 | #ifndef _I386_MACHINE_ROUTINES_H_ | |
33 | #define _I386_MACHINE_ROUTINES_H_ | |
34 | ||
35 | #include <mach/mach_types.h> | |
36 | #include <mach/boolean.h> | |
37 | #include <kern/kern_types.h> | |
38 | #include <pexpert/pexpert.h> | |
39 | ||
91447636 | 40 | #include <sys/cdefs.h> |
9bccf70c | 41 | #include <sys/appleapiopts.h> |
1c79356b | 42 | |
91447636 A |
43 | __BEGIN_DECLS |
44 | ||
0c530ab8 A |
45 | /* are we a 64 bit platform ? */ |
46 | ||
47 | boolean_t ml_is64bit(void); | |
48 | ||
49 | /* is this a 64bit thread? */ | |
50 | ||
51 | boolean_t ml_thread_is64bit(thread_t); | |
52 | ||
53 | /* is this a 64bit thread? */ | |
54 | ||
55 | boolean_t ml_state_is64bit(void *); | |
56 | ||
57 | /* set state of fpu save area for signal handling */ | |
58 | ||
59 | void ml_fp_setvalid(boolean_t); | |
60 | ||
61 | void ml_cpu_set_ldt(int); | |
62 | ||
1c79356b A |
63 | /* Interrupt handling */ |
64 | ||
55e303ae A |
65 | /* Initialize Interrupts */ |
66 | void ml_init_interrupt(void); | |
67 | ||
1c79356b A |
68 | /* Get Interrupts Enabled */ |
69 | boolean_t ml_get_interrupts_enabled(void); | |
70 | ||
71 | /* Set Interrupts Enabled */ | |
72 | boolean_t ml_set_interrupts_enabled(boolean_t enable); | |
73 | ||
74 | /* Check if running at interrupt context */ | |
75 | boolean_t ml_at_interrupt_context(void); | |
76 | ||
77 | /* Generate a fake interrupt */ | |
78 | void ml_cause_interrupt(void); | |
79 | ||
9bccf70c | 80 | void ml_get_timebase(unsigned long long *timestamp); |
0c530ab8 | 81 | void ml_init_lock_timeout(void); |
d52fe63f | 82 | |
55e303ae A |
83 | /* Type for the Time Base Enable function */ |
84 | typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable); | |
85 | ||
9bccf70c A |
86 | /* Type for the IPI Hander */ |
87 | typedef void (*ipi_handler_t)(void); | |
88 | ||
55e303ae A |
89 | /* Struct for ml_processor_register */ |
90 | struct ml_processor_info { | |
91 | cpu_id_t cpu_id; | |
92 | boolean_t boot_cpu; | |
93 | vm_offset_t start_paddr; | |
94 | boolean_t supports_nap; | |
95 | unsigned long l2cr_value; | |
96 | time_base_enable_t time_base_enable; | |
97 | }; | |
98 | ||
99 | typedef struct ml_processor_info ml_processor_info_t; | |
100 | ||
91447636 | 101 | |
9bccf70c A |
102 | /* Register a processor */ |
103 | kern_return_t ml_processor_register( | |
55e303ae A |
104 | cpu_id_t cpu_id, |
105 | uint32_t lapic_id, | |
106 | processor_t *processor, | |
107 | ipi_handler_t *ipi_handler, | |
9bccf70c | 108 | boolean_t boot_cpu); |
d52fe63f | 109 | |
1c79356b A |
110 | /* Initialize Interrupts */ |
111 | void ml_install_interrupt_handler( | |
112 | void *nub, | |
113 | int source, | |
114 | void *target, | |
115 | IOInterruptHandler handler, | |
116 | void *refCon); | |
117 | ||
9bccf70c A |
118 | #ifdef __APPLE_API_UNSTABLE |
119 | vm_offset_t | |
120 | ml_static_ptovirt( | |
121 | vm_offset_t); | |
122 | ||
0c530ab8 A |
123 | #ifdef XNU_KERNEL_PRIVATE |
124 | vm_offset_t | |
125 | ml_boot_ptovirt( | |
126 | vm_offset_t); | |
127 | #endif | |
128 | ||
43866e37 A |
129 | /* PCI config cycle probing */ |
130 | boolean_t ml_probe_read( | |
131 | vm_offset_t paddr, | |
132 | unsigned int *val); | |
55e303ae A |
133 | boolean_t ml_probe_read_64( |
134 | addr64_t paddr, | |
135 | unsigned int *val); | |
43866e37 A |
136 | |
137 | /* Read physical address byte */ | |
138 | unsigned int ml_phys_read_byte( | |
139 | vm_offset_t paddr); | |
55e303ae A |
140 | unsigned int ml_phys_read_byte_64( |
141 | addr64_t paddr); | |
43866e37 A |
142 | |
143 | /* Read physical address half word */ | |
144 | unsigned int ml_phys_read_half( | |
145 | vm_offset_t paddr); | |
55e303ae A |
146 | unsigned int ml_phys_read_half_64( |
147 | addr64_t paddr); | |
43866e37 A |
148 | |
149 | /* Read physical address word*/ | |
150 | unsigned int ml_phys_read( | |
151 | vm_offset_t paddr); | |
55e303ae A |
152 | unsigned int ml_phys_read_64( |
153 | addr64_t paddr); | |
43866e37 A |
154 | unsigned int ml_phys_read_word( |
155 | vm_offset_t paddr); | |
55e303ae A |
156 | unsigned int ml_phys_read_word_64( |
157 | addr64_t paddr); | |
43866e37 A |
158 | |
159 | /* Read physical address double word */ | |
160 | unsigned long long ml_phys_read_double( | |
161 | vm_offset_t paddr); | |
55e303ae A |
162 | unsigned long long ml_phys_read_double_64( |
163 | addr64_t paddr); | |
43866e37 A |
164 | |
165 | /* Write physical address byte */ | |
166 | void ml_phys_write_byte( | |
167 | vm_offset_t paddr, unsigned int data); | |
55e303ae A |
168 | void ml_phys_write_byte_64( |
169 | addr64_t paddr, unsigned int data); | |
43866e37 A |
170 | |
171 | /* Write physical address half word */ | |
172 | void ml_phys_write_half( | |
173 | vm_offset_t paddr, unsigned int data); | |
55e303ae A |
174 | void ml_phys_write_half_64( |
175 | addr64_t paddr, unsigned int data); | |
43866e37 A |
176 | |
177 | /* Write physical address word */ | |
178 | void ml_phys_write( | |
179 | vm_offset_t paddr, unsigned int data); | |
55e303ae A |
180 | void ml_phys_write_64( |
181 | addr64_t paddr, unsigned int data); | |
43866e37 A |
182 | void ml_phys_write_word( |
183 | vm_offset_t paddr, unsigned int data); | |
55e303ae A |
184 | void ml_phys_write_word_64( |
185 | addr64_t paddr, unsigned int data); | |
43866e37 A |
186 | |
187 | /* Write physical address double word */ | |
188 | void ml_phys_write_double( | |
189 | vm_offset_t paddr, unsigned long long data); | |
55e303ae A |
190 | void ml_phys_write_double_64( |
191 | addr64_t paddr, unsigned long long data); | |
43866e37 | 192 | |
9bccf70c A |
193 | void ml_static_mfree( |
194 | vm_offset_t, | |
195 | vm_size_t); | |
196 | ||
197 | /* virtual to physical on wired pages */ | |
198 | vm_offset_t ml_vtophys( | |
199 | vm_offset_t vaddr); | |
200 | ||
2d21ac55 A |
201 | vm_size_t ml_nofault_copy( |
202 | vm_offset_t virtsrc, vm_offset_t virtdst, vm_size_t size); | |
203 | ||
43866e37 A |
204 | /* Struct for ml_cpu_get_info */ |
205 | struct ml_cpu_info { | |
206 | unsigned long vector_unit; | |
207 | unsigned long cache_line_size; | |
208 | unsigned long l1_icache_size; | |
209 | unsigned long l1_dcache_size; | |
210 | unsigned long l2_settings; | |
211 | unsigned long l2_cache_size; | |
212 | unsigned long l3_settings; | |
213 | unsigned long l3_cache_size; | |
214 | }; | |
215 | ||
216 | typedef struct ml_cpu_info ml_cpu_info_t; | |
217 | ||
218 | /* Get processor info */ | |
91447636 | 219 | void ml_cpu_get_info(ml_cpu_info_t *ml_cpu_info); |
43866e37 | 220 | |
2d21ac55 A |
221 | /* Machine topology info */ |
222 | uint64_t ml_cpu_cache_size(unsigned int level); | |
223 | uint64_t ml_cpu_cache_sharing(unsigned int level); | |
224 | ||
9bccf70c A |
225 | #endif /* __APPLE_API_UNSTABLE */ |
226 | ||
227 | #ifdef __APPLE_API_PRIVATE | |
228 | #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE) | |
229 | /* IO memory map services */ | |
230 | ||
231 | /* Map memory map IO space */ | |
232 | vm_offset_t ml_io_map( | |
233 | vm_offset_t phys_addr, | |
234 | vm_size_t size); | |
235 | ||
236 | /* boot memory allocation */ | |
237 | vm_offset_t ml_static_malloc( | |
238 | vm_size_t size); | |
239 | ||
0c530ab8 A |
240 | |
241 | extern uint32_t bounce_pool_base; | |
242 | extern uint32_t bounce_pool_size; | |
243 | ||
244 | void ml_get_bouncepool_info( | |
245 | vm_offset_t *phys_addr, | |
246 | vm_size_t *size); | |
247 | ||
248 | ||
9bccf70c A |
249 | #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */ |
250 | ||
55e303ae A |
251 | /* Zero bytes starting at a physical address */ |
252 | void bzero_phys( | |
253 | addr64_t phys_address, | |
254 | uint32_t length); | |
255 | ||
2d21ac55 A |
256 | void bzero_phys_nc( |
257 | addr64_t phys_address, | |
258 | uint32_t length); | |
259 | ||
9bccf70c A |
260 | void ml_thread_policy( |
261 | thread_t thread, | |
262 | unsigned policy_id, | |
263 | unsigned policy_info); | |
1c79356b | 264 | |
9bccf70c A |
265 | #define MACHINE_GROUP 0x00000001 |
266 | #define MACHINE_NETWORK_GROUP 0x10000000 | |
267 | #define MACHINE_NETWORK_WORKLOOP 0x00000001 | |
268 | #define MACHINE_NETWORK_NETISR 0x00000002 | |
1c79356b | 269 | |
43866e37 A |
270 | /* Initialize the maximum number of CPUs */ |
271 | void ml_init_max_cpus( | |
272 | unsigned long max_cpus); | |
273 | ||
274 | /* Return the maximum number of CPUs set by ml_init_max_cpus() */ | |
275 | int ml_get_max_cpus( | |
276 | void); | |
277 | ||
91447636 A |
278 | extern void ml_cpu_up(void); |
279 | extern void ml_cpu_down(void); | |
280 | ||
2d21ac55 A |
281 | /* |
282 | * The following are in pmCPU.c not machine_routines.c. | |
283 | */ | |
0c530ab8 A |
284 | extern void ml_set_maxsnoop(uint32_t maxdelay); |
285 | extern unsigned ml_get_maxsnoop(void); | |
286 | extern void ml_set_maxbusdelay(uint32_t mdelay); | |
287 | extern uint32_t ml_get_maxbusdelay(void); | |
2d21ac55 A |
288 | |
289 | ||
0c530ab8 A |
290 | extern void ml_hpet_cfg(uint32_t cpu, uint32_t hpetVect); |
291 | ||
292 | extern uint64_t tmrCvt(uint64_t time, uint64_t conversion); | |
293 | ||
2d21ac55 A |
294 | extern uint64_t ml_cpu_int_event_time(void); |
295 | ||
9bccf70c | 296 | #endif /* __APPLE_API_PRIVATE */ |
1c79356b | 297 | |
91447636 A |
298 | __END_DECLS |
299 | ||
1c79356b | 300 | #endif /* _I386_MACHINE_ROUTINES_H_ */ |