2 * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 #ifndef _PPC_MACHINE_ROUTINES_H_
33 #define _PPC_MACHINE_ROUTINES_H_
35 #include <mach/mach_types.h>
36 #include <mach/boolean.h>
37 #include <kern/kern_types.h>
38 #include <pexpert/pexpert.h>
40 #include <sys/cdefs.h>
41 #include <sys/appleapiopts.h>
45 /* Get Interrupts Enabled */
46 extern boolean_t
ml_get_interrupts_enabled(
49 /* Set Interrupts Enabled */
50 extern boolean_t
ml_set_interrupts_enabled(
53 /* Check if running at interrupt context */
54 extern boolean_t
ml_at_interrupt_context(
59 /* Generate a fake interrupt */
60 extern void ml_cause_interrupt(
63 /* Type for the IPI Hander */
64 typedef void (*ipi_handler_t
)(void);
66 /* Type for the Time Base Enable function */
67 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
69 /* enables (or disables) the processor nap mode the function returns the previous value*/
70 extern boolean_t
ml_enable_nap(
72 boolean_t nap_enabled
);
74 /* Put the processor to sleep */
75 extern void ml_ppc_sleep(
78 extern void ml_get_timebase(
79 unsigned long long *timstamp
);
81 extern int ml_enable_cache_level(
85 extern void ml_static_mfree(
90 extern void ml_install_interrupt_handler(
94 IOInterruptHandler handler
,
97 extern vm_offset_t
ml_static_ptovirt(
100 /* virtual to physical on wired pages */
101 extern vm_offset_t
ml_vtophys(
104 vm_size_t
ml_nofault_copy(
105 vm_offset_t virtsrc
, vm_offset_t virtdst
, vm_size_t size
);
107 /* PCI config cycle probing */
108 extern boolean_t
ml_probe_read(
112 extern boolean_t
ml_probe_read_64(
116 /* Read physical address byte */
117 extern unsigned int ml_phys_read_byte(
120 extern unsigned int ml_phys_read_byte_64(
123 /* Read physical address half word */
124 extern unsigned int ml_phys_read_half(
127 extern unsigned int ml_phys_read_half_64(
130 /* Read physical address word*/
131 extern unsigned int ml_phys_read(
134 extern unsigned int ml_phys_read_64(
137 extern unsigned int ml_phys_read_word(
140 extern unsigned int ml_phys_read_word_64(
143 /* Read physical address double word */
144 extern unsigned long long ml_phys_read_double(
147 extern unsigned long long ml_phys_read_double_64(
150 /* Write physical address byte */
151 extern void ml_phys_write_byte(
155 extern void ml_phys_write_byte_64(
159 /* Write physical address half word */
160 extern void ml_phys_write_half(
164 extern void ml_phys_write_half_64(
168 /* Write physical address word */
169 extern void ml_phys_write(
173 extern void ml_phys_write_64(
177 extern void ml_phys_write_word(
181 extern void ml_phys_write_word_64(
185 /* Write physical address double word */
186 extern void ml_phys_write_double(
188 unsigned long long data
);
190 extern void ml_phys_write_double_64(
192 unsigned long long data
);
194 /* Struct for ml_processor_register */
195 struct ml_processor_info
{
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
;
206 typedef struct ml_processor_info ml_processor_info_t
;
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
);
214 /* Zero bytes starting at a physical address */
215 extern void bzero_phys(
216 addr64_t phys_address
,
219 /* Zero bytes starting at a physical address that's uncacheable */
220 extern void bzero_phys_nc(
221 addr64_t phys_address
,
224 /* Bytes available on current stack */
225 vm_offset_t
ml_stack_remaining(void);
227 #endif /* KERNEL_PRIVATE */
229 #ifdef XNU_KERNEL_PRIVATE
230 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
232 /* Map memory map IO space */
233 extern vm_offset_t
ml_io_map(
234 vm_offset_t phys_addr
,
237 void ml_get_bouncepool_info(
238 vm_offset_t
*phys_addr
,
242 /* boot memory allocation */
243 extern vm_offset_t
ml_static_malloc(
246 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
249 #ifdef MACH_KERNEL_PRIVATE
250 extern void ml_init_interrupt(
253 extern void cacheInit(
256 extern void cacheDisable(
259 extern void ml_init_lock_timeout(
262 void ml_ppc_do_sleep(void);
264 #endif /* MACH_KERNEL_PRIVATE */
265 #endif /* XNU_KERNEL_PRIVATE */
267 #ifdef KERNEL_PRIVATE
268 extern void ml_thread_policy(
271 unsigned policy_info
);
273 #define MACHINE_GROUP 0x00000001
274 #define MACHINE_NETWORK_GROUP 0x10000000
275 #define MACHINE_NETWORK_WORKLOOP 0x00000001
276 #define MACHINE_NETWORK_NETISR 0x00000002
278 /* Initialize the maximum number of CPUs */
279 extern void ml_init_max_cpus(
280 unsigned int max_cpus
);
282 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
283 extern unsigned int ml_get_max_cpus(
286 extern void ml_cpu_up(void);
287 extern void ml_cpu_down(void);
289 /* Struct for ml_cpu_get_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
;
301 typedef struct ml_cpu_info ml_cpu_info_t
;
303 /* Get processor info */
304 extern void ml_cpu_get_info(
305 ml_cpu_info_t
*ml_cpu_info
);
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
);
318 extern void ml_set_processor_voltage(
319 unsigned long voltage
);
321 extern unsigned int ml_scom_write(
325 extern unsigned int ml_scom_read(
329 extern uint32_t ml_hdec_ratio(void);
331 extern int boffSettingsInit
;
333 #endif /* KERNEL_PRIVATE */
337 #endif /* _PPC_MACHINE_ROUTINES_H_ */