2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
34 #ifndef _PPC_MACHINE_ROUTINES_H_
35 #define _PPC_MACHINE_ROUTINES_H_
37 #include <mach/mach_types.h>
38 #include <mach/boolean.h>
39 #include <kern/kern_types.h>
40 #include <pexpert/pexpert.h>
42 /* Get Interrupts Enabled */
43 extern boolean_t
ml_get_interrupts_enabled(
46 /* Set Interrupts Enabled */
47 extern boolean_t
ml_set_interrupts_enabled(
50 /* Check if running at interrupt context */
51 extern boolean_t
ml_at_interrupt_context(
56 /* Generate a fake interrupt */
57 extern void ml_cause_interrupt(
60 /* Type for the IPI Hander */
61 typedef void (*ipi_handler_t
)(void);
63 /* Type for the Time Base Enable function */
64 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
66 /* enables (or disables) the processor nap mode the function returns the previous value*/
67 extern boolean_t
ml_enable_nap(
69 boolean_t nap_enabled
);
71 /* Put the processor to sleep */
72 extern void ml_ppc_sleep(
75 extern void ml_get_timebase(
76 unsigned long long *timstamp
);
78 extern int ml_enable_cache_level(
82 extern void ml_static_mfree(
87 extern void ml_install_interrupt_handler(
91 IOInterruptHandler handler
,
94 extern vm_offset_t
ml_static_ptovirt(
97 /* virtual to physical on wired pages */
98 extern vm_offset_t
ml_vtophys(
101 /* PCI config cycle probing */
102 extern boolean_t
ml_probe_read(
106 extern boolean_t
ml_probe_read_64(
110 /* Read physical address byte */
111 extern unsigned int ml_phys_read_byte(
114 extern unsigned int ml_phys_read_byte_64(
117 /* Read physical address half word */
118 extern unsigned int ml_phys_read_half(
121 extern unsigned int ml_phys_read_half_64(
124 /* Read physical address word*/
125 extern unsigned int ml_phys_read(
128 extern unsigned int ml_phys_read_64(
131 extern unsigned int ml_phys_read_word(
134 extern unsigned int ml_phys_read_word_64(
137 /* Read physical address double word */
138 extern unsigned long long ml_phys_read_double(
141 extern unsigned long long ml_phys_read_double_64(
144 /* Write physical address byte */
145 extern void ml_phys_write_byte(
149 extern void ml_phys_write_byte_64(
153 /* Write physical address half word */
154 extern void ml_phys_write_half(
158 extern void ml_phys_write_half_64(
162 /* Write physical address word */
163 extern void ml_phys_write(
167 extern void ml_phys_write_64(
171 extern void ml_phys_write_word(
175 extern void ml_phys_write_word_64(
179 /* Write physical address double word */
180 extern void ml_phys_write_double(
182 unsigned long long data
);
184 extern void ml_phys_write_double_64(
186 unsigned long long data
);
188 /* Struct for ml_processor_register */
189 struct ml_processor_info
{
192 vm_offset_t start_paddr
;
193 boolean_t supports_nap
;
194 unsigned long l2cr_value
;
195 time_base_enable_t time_base_enable
;
196 uint32_t power_mode_0
;
197 uint32_t power_mode_1
;
200 typedef struct ml_processor_info ml_processor_info_t
;
202 /* Register a processor */
203 extern kern_return_t
ml_processor_register(
204 ml_processor_info_t
*ml_processor_info
,
205 processor_t
*processor
,
206 ipi_handler_t
*ipi_handler
);
208 /* Zero bytes starting at a physical address */
209 extern void bzero_phys(
210 addr64_t phys_address
,
213 #endif /* KERNEL_PRIVATE */
215 #ifdef XNU_KERNEL_PRIVATE
216 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
218 /* Map memory map IO space */
219 extern vm_offset_t
ml_io_map(
220 vm_offset_t phys_addr
,
223 void ml_get_bouncepool_info(
224 vm_offset_t
*phys_addr
,
228 /* boot memory allocation */
229 extern vm_offset_t
ml_static_malloc(
232 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
234 #if defined(BSD_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
236 extern int set_be_bit(
239 extern int clr_be_bit(
242 extern int be_tracing(
245 #endif /* BSD_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
247 #ifdef MACH_KERNEL_PRIVATE
248 extern void ml_init_interrupt(
251 extern void cacheInit(
254 extern void cacheDisable(
257 extern void ml_init_lock_timeout(
260 void ml_ppc_do_sleep(void);
262 #endif /* MACH_KERNEL_PRIVATE */
263 #endif /* XNU_KERNEL_PRIVATE */
265 #ifdef KERNEL_PRIVATE
266 extern void ml_thread_policy(
269 unsigned policy_info
);
271 #define MACHINE_GROUP 0x00000001
272 #define MACHINE_NETWORK_GROUP 0x10000000
273 #define MACHINE_NETWORK_WORKLOOP 0x00000001
274 #define MACHINE_NETWORK_NETISR 0x00000002
276 /* Initialize the maximum number of CPUs */
277 extern void ml_init_max_cpus(
278 unsigned int max_cpus
);
280 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
281 extern unsigned int ml_get_max_cpus(
284 extern void ml_cpu_up(void);
285 extern void ml_cpu_down(void);
287 /* Struct for ml_cpu_get_info */
289 unsigned long vector_unit
;
290 unsigned long cache_line_size
;
291 unsigned long l1_icache_size
;
292 unsigned long l1_dcache_size
;
293 unsigned long l2_settings
;
294 unsigned long l2_cache_size
;
295 unsigned long l3_settings
;
296 unsigned long l3_cache_size
;
299 typedef struct ml_cpu_info ml_cpu_info_t
;
301 /* Get processor info */
302 extern void ml_cpu_get_info(
303 ml_cpu_info_t
*ml_cpu_info
);
305 extern void ml_set_processor_speed(
306 unsigned long speed
);
307 extern void ml_set_processor_speed_slave(
308 unsigned long speed
);
309 extern void ml_set_processor_speed_dpll(
310 unsigned long speed
);
311 extern void ml_set_processor_speed_dfs(
312 unsigned long speed
);
313 extern void ml_set_processor_speed_powertune(
314 unsigned long speed
);
316 extern void ml_set_processor_voltage(
317 unsigned long voltage
);
319 extern unsigned int ml_scom_write(
323 extern unsigned int ml_scom_read(
327 extern uint32_t ml_hdec_ratio(void);
329 #endif /* KERNEL_PRIVATE */
331 #endif /* _PPC_MACHINE_ROUTINES_H_ */