2 * Copyright (c) 2000-2004 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 /* Get Interrupts Enabled */
41 extern boolean_t
ml_get_interrupts_enabled(
44 /* Set Interrupts Enabled */
45 extern boolean_t
ml_set_interrupts_enabled(
48 /* Check if running at interrupt context */
49 extern boolean_t
ml_at_interrupt_context(
54 /* Generate a fake interrupt */
55 extern void ml_cause_interrupt(
58 /* Type for the IPI Hander */
59 typedef void (*ipi_handler_t
)(void);
61 /* Type for the Time Base Enable function */
62 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
64 /* enables (or disables) the processor nap mode the function returns the previous value*/
65 extern boolean_t
ml_enable_nap(
67 boolean_t nap_enabled
);
69 /* Put the processor to sleep */
70 extern void ml_ppc_sleep(
73 extern void ml_get_timebase(
74 unsigned long long *timstamp
);
76 extern int ml_enable_cache_level(
80 extern void ml_static_mfree(
85 extern void ml_install_interrupt_handler(
89 IOInterruptHandler handler
,
92 extern vm_offset_t
ml_static_ptovirt(
95 /* virtual to physical on wired pages */
96 extern vm_offset_t
ml_vtophys(
99 /* PCI config cycle probing */
100 extern boolean_t
ml_probe_read(
104 extern boolean_t
ml_probe_read_64(
108 /* Read physical address byte */
109 extern unsigned int ml_phys_read_byte(
112 extern unsigned int ml_phys_read_byte_64(
115 /* Read physical address half word */
116 extern unsigned int ml_phys_read_half(
119 extern unsigned int ml_phys_read_half_64(
122 /* Read physical address word*/
123 extern unsigned int ml_phys_read(
126 extern unsigned int ml_phys_read_64(
129 extern unsigned int ml_phys_read_word(
132 extern unsigned int ml_phys_read_word_64(
135 /* Read physical address double word */
136 extern unsigned long long ml_phys_read_double(
139 extern unsigned long long ml_phys_read_double_64(
142 /* Write physical address byte */
143 extern void ml_phys_write_byte(
147 extern void ml_phys_write_byte_64(
151 /* Write physical address half word */
152 extern void ml_phys_write_half(
156 extern void ml_phys_write_half_64(
160 /* Write physical address word */
161 extern void ml_phys_write(
165 extern void ml_phys_write_64(
169 extern void ml_phys_write_word(
173 extern void ml_phys_write_word_64(
177 /* Write physical address double word */
178 extern void ml_phys_write_double(
180 unsigned long long data
);
182 extern void ml_phys_write_double_64(
184 unsigned long long data
);
186 /* Struct for ml_processor_register */
187 struct ml_processor_info
{
190 vm_offset_t start_paddr
;
191 boolean_t supports_nap
;
192 unsigned long l2cr_value
;
193 time_base_enable_t time_base_enable
;
194 uint32_t power_mode_0
;
195 uint32_t power_mode_1
;
198 typedef struct ml_processor_info ml_processor_info_t
;
200 /* Register a processor */
201 extern kern_return_t
ml_processor_register(
202 ml_processor_info_t
*ml_processor_info
,
203 processor_t
*processor
,
204 ipi_handler_t
*ipi_handler
);
206 /* Zero bytes starting at a physical address */
207 extern void bzero_phys(
208 addr64_t phys_address
,
211 #endif /* KERNEL_PRIVATE */
213 #ifdef XNU_KERNEL_PRIVATE
214 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
216 /* Map memory map IO space */
217 extern vm_offset_t
ml_io_map(
218 vm_offset_t phys_addr
,
221 /* boot memory allocation */
222 extern vm_offset_t
ml_static_malloc(
225 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
227 #if defined(BSD_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
229 extern int set_be_bit(
232 extern int clr_be_bit(
235 extern int be_tracing(
238 #endif /* BSD_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
240 #ifdef MACH_KERNEL_PRIVATE
241 extern void ml_init_interrupt(
244 extern void cacheInit(
247 extern void cacheDisable(
250 extern void ml_init_lock_timeout(
253 void ml_ppc_do_sleep(void);
255 #endif /* MACH_KERNEL_PRIVATE */
256 #endif /* XNU_KERNEL_PRIVATE */
258 #ifdef KERNEL_PRIVATE
259 extern void ml_thread_policy(
262 unsigned policy_info
);
264 #define MACHINE_GROUP 0x00000001
265 #define MACHINE_NETWORK_GROUP 0x10000000
266 #define MACHINE_NETWORK_WORKLOOP 0x00000001
267 #define MACHINE_NETWORK_NETISR 0x00000002
269 /* Initialize the maximum number of CPUs */
270 extern void ml_init_max_cpus(
271 unsigned int max_cpus
);
273 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
274 extern unsigned int ml_get_max_cpus(
277 extern void ml_cpu_up(void);
278 extern void ml_cpu_down(void);
280 /* Struct for ml_cpu_get_info */
282 unsigned long vector_unit
;
283 unsigned long cache_line_size
;
284 unsigned long l1_icache_size
;
285 unsigned long l1_dcache_size
;
286 unsigned long l2_settings
;
287 unsigned long l2_cache_size
;
288 unsigned long l3_settings
;
289 unsigned long l3_cache_size
;
292 typedef struct ml_cpu_info ml_cpu_info_t
;
294 /* Get processor info */
295 extern void ml_cpu_get_info(
296 ml_cpu_info_t
*ml_cpu_info
);
298 extern void ml_set_processor_speed(
299 unsigned long speed
);
300 extern void ml_set_processor_speed_slave(
301 unsigned long speed
);
302 extern void ml_set_processor_speed_dpll(
303 unsigned long speed
);
304 extern void ml_set_processor_speed_dfs(
305 unsigned long speed
);
306 extern void ml_set_processor_speed_powertune(
307 unsigned long speed
);
309 extern void ml_set_processor_voltage(
310 unsigned long voltage
);
312 extern unsigned int ml_scom_write(
316 extern unsigned int ml_scom_read(
320 extern uint32_t ml_hdec_ratio(void);
322 #endif /* KERNEL_PRIVATE */
324 #endif /* _PPC_MACHINE_ROUTINES_H_ */