]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/machine_routines.h
xnu-1504.9.37.tar.gz
[apple/xnu.git] / osfmk / ppc / machine_routines.h
1 /*
2 * Copyright (c) 2000-2006 Apple Computer, 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 */
31
32 #ifndef _PPC_MACHINE_ROUTINES_H_
33 #define _PPC_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
40 #include <sys/cdefs.h>
41 #include <sys/appleapiopts.h>
42
43 __BEGIN_DECLS
44
45 /* Get Interrupts Enabled */
46 extern boolean_t ml_get_interrupts_enabled(
47 void);
48
49 /* Set Interrupts Enabled */
50 extern boolean_t ml_set_interrupts_enabled(
51 boolean_t enable);
52
53 /* Check if running at interrupt context */
54 extern boolean_t ml_at_interrupt_context(
55 void);
56
57 #ifdef KERNEL_PRIVATE
58
59 /* Generate a fake interrupt */
60 extern void ml_cause_interrupt(
61 void);
62
63 /* Type for the IPI Hander */
64 typedef void (*ipi_handler_t)(void);
65
66 /* Type for the Time Base Enable function */
67 typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable);
68
69 /* enables (or disables) the processor nap mode the function returns the previous value*/
70 extern boolean_t ml_enable_nap(
71 int target_cpu,
72 boolean_t nap_enabled);
73
74 /* Put the processor to sleep */
75 extern void ml_ppc_sleep(
76 void);
77
78 extern void ml_get_timebase(
79 unsigned long long *timstamp);
80
81 extern int ml_enable_cache_level(
82 int cache_level,
83 int enable);
84
85 extern void ml_static_mfree(
86 vm_offset_t vaddr,
87 vm_size_t size);
88
89 /* Init Interrupts */
90 extern void ml_install_interrupt_handler(
91 void *nub,
92 int source,
93 void *target,
94 IOInterruptHandler handler,
95 void *refCon);
96
97 extern vm_offset_t ml_static_ptovirt(
98 vm_offset_t paddr);
99
100 /* virtual to physical on wired pages */
101 extern vm_offset_t ml_vtophys(
102 vm_offset_t vaddr);
103
104 vm_size_t ml_nofault_copy(
105 vm_offset_t virtsrc, vm_offset_t virtdst, vm_size_t size);
106
107 /* PCI config cycle probing */
108 extern boolean_t ml_probe_read(
109 vm_offset_t paddr,
110 unsigned int *val);
111
112 extern boolean_t ml_probe_read_64(
113 addr64_t paddr,
114 unsigned int *val);
115
116 /* Read physical address byte */
117 extern unsigned int ml_phys_read_byte(
118 vm_offset_t paddr);
119
120 extern unsigned int ml_phys_read_byte_64(
121 addr64_t paddr);
122
123 /* Read physical address half word */
124 extern unsigned int ml_phys_read_half(
125 vm_offset_t paddr);
126
127 extern unsigned int ml_phys_read_half_64(
128 addr64_t paddr);
129
130 /* Read physical address word*/
131 extern unsigned int ml_phys_read(
132 vm_offset_t paddr);
133
134 extern unsigned int ml_phys_read_64(
135 addr64_t paddr);
136
137 extern unsigned int ml_phys_read_word(
138 vm_offset_t paddr);
139
140 extern unsigned int ml_phys_read_word_64(
141 addr64_t paddr);
142
143 /* Read physical address double word */
144 extern unsigned long long ml_phys_read_double(
145 vm_offset_t paddr);
146
147 extern unsigned long long ml_phys_read_double_64(
148 addr64_t paddr);
149
150 /* Write physical address byte */
151 extern void ml_phys_write_byte(
152 vm_offset_t paddr,
153 unsigned int data);
154
155 extern void ml_phys_write_byte_64(
156 addr64_t paddr,
157 unsigned int data);
158
159 /* Write physical address half word */
160 extern void ml_phys_write_half(
161 vm_offset_t paddr,
162 unsigned int data);
163
164 extern void ml_phys_write_half_64(
165 addr64_t paddr,
166 unsigned int data);
167
168 /* Write physical address word */
169 extern void ml_phys_write(
170 vm_offset_t paddr,
171 unsigned int data);
172
173 extern void ml_phys_write_64(
174 addr64_t paddr,
175 unsigned int data);
176
177 extern void ml_phys_write_word(
178 vm_offset_t paddr,
179 unsigned int data);
180
181 extern void ml_phys_write_word_64(
182 addr64_t paddr,
183 unsigned int data);
184
185 /* Write physical address double word */
186 extern void ml_phys_write_double(
187 vm_offset_t paddr,
188 unsigned long long data);
189
190 extern void ml_phys_write_double_64(
191 addr64_t paddr,
192 unsigned long long data);
193
194 /* Struct for ml_processor_register */
195 struct ml_processor_info {
196 cpu_id_t cpu_id;
197 boolean_t boot_cpu;
198 vm_offset_t start_paddr;
199 boolean_t supports_nap;
200 unsigned long l2cr_value;
201 time_base_enable_t time_base_enable;
202 uint32_t power_mode_0;
203 uint32_t power_mode_1;
204 };
205
206 typedef struct ml_processor_info ml_processor_info_t;
207
208 /* Register a processor */
209 extern kern_return_t ml_processor_register(
210 ml_processor_info_t *ml_processor_info,
211 processor_t *processor,
212 ipi_handler_t *ipi_handler);
213
214 /* Zero bytes starting at a physical address */
215 extern void bzero_phys(
216 addr64_t phys_address,
217 uint32_t length);
218
219 /* Zero bytes starting at a physical address that's uncacheable */
220 extern void bzero_phys_nc(
221 addr64_t phys_address,
222 uint32_t length);
223
224 /* Bytes available on current stack */
225 vm_offset_t ml_stack_remaining(void);
226
227 #endif /* KERNEL_PRIVATE */
228
229 #ifdef XNU_KERNEL_PRIVATE
230 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
231
232 /* Map memory map IO space */
233 extern vm_offset_t ml_io_map(
234 vm_offset_t phys_addr,
235 vm_size_t size);
236
237 void ml_get_bouncepool_info(
238 vm_offset_t *phys_addr,
239 vm_size_t *size);
240
241
242 /* boot memory allocation */
243 extern vm_offset_t ml_static_malloc(
244 vm_size_t size);
245
246 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
247
248
249 #ifdef MACH_KERNEL_PRIVATE
250 extern void ml_init_interrupt(
251 void);
252
253 extern void cacheInit(
254 void);
255
256 extern void cacheDisable(
257 void);
258
259 extern void ml_init_lock_timeout(
260 void);
261
262 void ml_ppc_do_sleep(void);
263
264 #endif /* MACH_KERNEL_PRIVATE */
265 #endif /* XNU_KERNEL_PRIVATE */
266
267 #ifdef KERNEL_PRIVATE
268 extern void ml_thread_policy(
269 thread_t thread,
270 unsigned policy_id,
271 unsigned policy_info);
272
273 #define MACHINE_GROUP 0x00000001
274 #define MACHINE_NETWORK_GROUP 0x10000000
275 #define MACHINE_NETWORK_WORKLOOP 0x00000001
276 #define MACHINE_NETWORK_NETISR 0x00000002
277
278 /* Initialize the maximum number of CPUs */
279 extern void ml_init_max_cpus(
280 unsigned int max_cpus);
281
282 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
283 extern unsigned int ml_get_max_cpus(
284 void);
285
286 extern void ml_cpu_up(void);
287 extern void ml_cpu_down(void);
288
289 /* Struct for ml_cpu_get_info */
290 struct ml_cpu_info {
291 unsigned long vector_unit;
292 unsigned long cache_line_size;
293 unsigned long l1_icache_size;
294 unsigned long l1_dcache_size;
295 unsigned long l2_settings;
296 unsigned long l2_cache_size;
297 unsigned long l3_settings;
298 unsigned long l3_cache_size;
299 };
300
301 typedef struct ml_cpu_info ml_cpu_info_t;
302
303 /* Get processor info */
304 extern void ml_cpu_get_info(
305 ml_cpu_info_t *ml_cpu_info);
306
307 extern void ml_set_processor_speed(
308 unsigned long speed);
309 extern void ml_set_processor_speed_slave(
310 unsigned long speed);
311 extern void ml_set_processor_speed_dpll(
312 unsigned long speed);
313 extern void ml_set_processor_speed_dfs(
314 unsigned long speed);
315 extern void ml_set_processor_speed_powertune(
316 unsigned long speed);
317
318 extern void ml_set_processor_voltage(
319 unsigned long voltage);
320
321 extern unsigned int ml_scom_write(
322 uint32_t reg,
323 uint64_t data);
324
325 extern unsigned int ml_scom_read(
326 uint32_t reg,
327 uint64_t *data);
328
329 extern uint32_t ml_hdec_ratio(void);
330
331 extern int boffSettingsInit;
332
333 #endif /* KERNEL_PRIVATE */
334
335 __END_DECLS
336
337 #endif /* _PPC_MACHINE_ROUTINES_H_ */