2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
27 #ifndef _PPC_MACHINE_ROUTINES_H_
28 #define _PPC_MACHINE_ROUTINES_H_
30 #include <mach/mach_types.h>
31 #include <mach/boolean.h>
32 #include <kern/kern_types.h>
33 #include <pexpert/pexpert.h>
35 /* Get Interrupts Enabled */
36 extern boolean_t
ml_get_interrupts_enabled(
39 /* Set Interrupts Enabled */
40 extern boolean_t
ml_set_interrupts_enabled(
43 /* Check if running at interrupt context */
44 extern boolean_t
ml_at_interrupt_context(
49 /* Generate a fake interrupt */
50 extern void ml_cause_interrupt(
53 /* Type for the IPI Hander */
54 typedef void (*ipi_handler_t
)(void);
56 /* Type for the Time Base Enable function */
57 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
59 /* enables (or disables) the processor nap mode the function returns the previous value*/
60 extern boolean_t
ml_enable_nap(
62 boolean_t nap_enabled
);
64 /* Put the processor to sleep */
65 extern void ml_ppc_sleep(
68 extern void ml_get_timebase(
69 unsigned long long *timstamp
);
71 extern int ml_enable_cache_level(
75 extern void ml_static_mfree(
80 extern void ml_install_interrupt_handler(
84 IOInterruptHandler handler
,
87 extern vm_offset_t
ml_static_ptovirt(
90 /* virtual to physical on wired pages */
91 extern vm_offset_t
ml_vtophys(
94 /* PCI config cycle probing */
95 extern boolean_t
ml_probe_read(
99 extern boolean_t
ml_probe_read_64(
103 /* Read physical address byte */
104 extern unsigned int ml_phys_read_byte(
107 extern unsigned int ml_phys_read_byte_64(
110 /* Read physical address half word */
111 extern unsigned int ml_phys_read_half(
114 extern unsigned int ml_phys_read_half_64(
117 /* Read physical address word*/
118 extern unsigned int ml_phys_read(
121 extern unsigned int ml_phys_read_64(
124 extern unsigned int ml_phys_read_word(
127 extern unsigned int ml_phys_read_word_64(
130 /* Read physical address double word */
131 extern unsigned long long ml_phys_read_double(
134 extern unsigned long long ml_phys_read_double_64(
137 /* Write physical address byte */
138 extern void ml_phys_write_byte(
142 extern void ml_phys_write_byte_64(
146 /* Write physical address half word */
147 extern void ml_phys_write_half(
151 extern void ml_phys_write_half_64(
155 /* Write physical address word */
156 extern void ml_phys_write(
160 extern void ml_phys_write_64(
164 extern void ml_phys_write_word(
168 extern void ml_phys_write_word_64(
172 /* Write physical address double word */
173 extern void ml_phys_write_double(
175 unsigned long long data
);
177 extern void ml_phys_write_double_64(
179 unsigned long long data
);
181 /* Struct for ml_processor_register */
182 struct ml_processor_info
{
185 vm_offset_t start_paddr
;
186 boolean_t supports_nap
;
187 unsigned long l2cr_value
;
188 time_base_enable_t time_base_enable
;
189 uint32_t power_mode_0
;
190 uint32_t power_mode_1
;
193 typedef struct ml_processor_info ml_processor_info_t
;
195 /* Register a processor */
196 extern kern_return_t
ml_processor_register(
197 ml_processor_info_t
*ml_processor_info
,
198 processor_t
*processor
,
199 ipi_handler_t
*ipi_handler
);
201 /* Zero bytes starting at a physical address */
202 extern void bzero_phys(
203 addr64_t phys_address
,
206 #endif /* KERNEL_PRIVATE */
208 #ifdef XNU_KERNEL_PRIVATE
209 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
211 /* Map memory map IO space */
212 extern vm_offset_t
ml_io_map(
213 vm_offset_t phys_addr
,
216 /* boot memory allocation */
217 extern vm_offset_t
ml_static_malloc(
220 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
222 #if defined(BSD_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
224 extern int set_be_bit(
227 extern int clr_be_bit(
230 extern int be_tracing(
233 #endif /* BSD_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
235 #ifdef MACH_KERNEL_PRIVATE
236 extern void ml_init_interrupt(
239 extern void cacheInit(
242 extern void cacheDisable(
245 extern void ml_init_lock_timeout(
248 void ml_ppc_do_sleep(void);
250 #endif /* MACH_KERNEL_PRIVATE */
251 #endif /* XNU_KERNEL_PRIVATE */
253 #ifdef KERNEL_PRIVATE
254 extern void ml_thread_policy(
257 unsigned policy_info
);
259 #define MACHINE_GROUP 0x00000001
260 #define MACHINE_NETWORK_GROUP 0x10000000
261 #define MACHINE_NETWORK_WORKLOOP 0x00000001
262 #define MACHINE_NETWORK_NETISR 0x00000002
264 /* Initialize the maximum number of CPUs */
265 extern void ml_init_max_cpus(
266 unsigned int max_cpus
);
268 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
269 extern unsigned int ml_get_max_cpus(
272 extern void ml_cpu_up(void);
273 extern void ml_cpu_down(void);
275 /* Struct for ml_cpu_get_info */
277 unsigned long vector_unit
;
278 unsigned long cache_line_size
;
279 unsigned long l1_icache_size
;
280 unsigned long l1_dcache_size
;
281 unsigned long l2_settings
;
282 unsigned long l2_cache_size
;
283 unsigned long l3_settings
;
284 unsigned long l3_cache_size
;
287 typedef struct ml_cpu_info ml_cpu_info_t
;
289 /* Get processor info */
290 extern void ml_cpu_get_info(
291 ml_cpu_info_t
*ml_cpu_info
);
293 extern void ml_set_processor_speed(
294 unsigned long speed
);
295 extern void ml_set_processor_speed_slave(
296 unsigned long speed
);
297 extern void ml_set_processor_speed_dpll(
298 unsigned long speed
);
299 extern void ml_set_processor_speed_dfs(
300 unsigned long speed
);
301 extern void ml_set_processor_speed_powertune(
302 unsigned long speed
);
304 extern void ml_set_processor_voltage(
305 unsigned long voltage
);
307 extern unsigned int ml_scom_write(
311 extern unsigned int ml_scom_read(
315 extern uint32_t ml_hdec_ratio(void);
317 #endif /* KERNEL_PRIVATE */
319 #endif /* _PPC_MACHINE_ROUTINES_H_ */