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 /* 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 vm_size_t
ml_nofault_copy(
100 vm_offset_t virtsrc
, vm_offset_t virtdst
, vm_size_t size
);
102 /* PCI config cycle probing */
103 extern boolean_t
ml_probe_read(
107 extern boolean_t
ml_probe_read_64(
111 /* Read physical address byte */
112 extern unsigned int ml_phys_read_byte(
115 extern unsigned int ml_phys_read_byte_64(
118 /* Read physical address half word */
119 extern unsigned int ml_phys_read_half(
122 extern unsigned int ml_phys_read_half_64(
125 /* Read physical address word*/
126 extern unsigned int ml_phys_read(
129 extern unsigned int ml_phys_read_64(
132 extern unsigned int ml_phys_read_word(
135 extern unsigned int ml_phys_read_word_64(
138 /* Read physical address double word */
139 extern unsigned long long ml_phys_read_double(
142 extern unsigned long long ml_phys_read_double_64(
145 /* Write physical address byte */
146 extern void ml_phys_write_byte(
150 extern void ml_phys_write_byte_64(
154 /* Write physical address half word */
155 extern void ml_phys_write_half(
159 extern void ml_phys_write_half_64(
163 /* Write physical address word */
164 extern void ml_phys_write(
168 extern void ml_phys_write_64(
172 extern void ml_phys_write_word(
176 extern void ml_phys_write_word_64(
180 /* Write physical address double word */
181 extern void ml_phys_write_double(
183 unsigned long long data
);
185 extern void ml_phys_write_double_64(
187 unsigned long long data
);
189 /* Struct for ml_processor_register */
190 struct ml_processor_info
{
193 vm_offset_t start_paddr
;
194 boolean_t supports_nap
;
195 unsigned long l2cr_value
;
196 time_base_enable_t time_base_enable
;
197 uint32_t power_mode_0
;
198 uint32_t power_mode_1
;
201 typedef struct ml_processor_info ml_processor_info_t
;
203 /* Register a processor */
204 extern kern_return_t
ml_processor_register(
205 ml_processor_info_t
*ml_processor_info
,
206 processor_t
*processor
,
207 ipi_handler_t
*ipi_handler
);
209 /* Zero bytes starting at a physical address */
210 extern void bzero_phys(
211 addr64_t phys_address
,
214 /* Zero bytes starting at a physical address that's uncacheable */
215 extern void bzero_phys_nc(
216 addr64_t phys_address
,
219 #endif /* KERNEL_PRIVATE */
221 #ifdef XNU_KERNEL_PRIVATE
222 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
224 /* Map memory map IO space */
225 extern vm_offset_t
ml_io_map(
226 vm_offset_t phys_addr
,
229 void ml_get_bouncepool_info(
230 vm_offset_t
*phys_addr
,
234 /* boot memory allocation */
235 extern vm_offset_t
ml_static_malloc(
238 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
241 #ifdef MACH_KERNEL_PRIVATE
242 extern void ml_init_interrupt(
245 extern void cacheInit(
248 extern void cacheDisable(
251 extern void ml_init_lock_timeout(
254 void ml_ppc_do_sleep(void);
256 #endif /* MACH_KERNEL_PRIVATE */
257 #endif /* XNU_KERNEL_PRIVATE */
259 #ifdef KERNEL_PRIVATE
260 extern void ml_thread_policy(
263 unsigned policy_info
);
265 #define MACHINE_GROUP 0x00000001
266 #define MACHINE_NETWORK_GROUP 0x10000000
267 #define MACHINE_NETWORK_WORKLOOP 0x00000001
268 #define MACHINE_NETWORK_NETISR 0x00000002
270 /* Initialize the maximum number of CPUs */
271 extern void ml_init_max_cpus(
272 unsigned int max_cpus
);
274 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
275 extern unsigned int ml_get_max_cpus(
278 extern void ml_cpu_up(void);
279 extern void ml_cpu_down(void);
281 /* Struct for ml_cpu_get_info */
283 unsigned long vector_unit
;
284 unsigned long cache_line_size
;
285 unsigned long l1_icache_size
;
286 unsigned long l1_dcache_size
;
287 unsigned long l2_settings
;
288 unsigned long l2_cache_size
;
289 unsigned long l3_settings
;
290 unsigned long l3_cache_size
;
293 typedef struct ml_cpu_info ml_cpu_info_t
;
295 /* Get processor info */
296 extern void ml_cpu_get_info(
297 ml_cpu_info_t
*ml_cpu_info
);
299 extern void ml_set_processor_speed(
300 unsigned long speed
);
301 extern void ml_set_processor_speed_slave(
302 unsigned long speed
);
303 extern void ml_set_processor_speed_dpll(
304 unsigned long speed
);
305 extern void ml_set_processor_speed_dfs(
306 unsigned long speed
);
307 extern void ml_set_processor_speed_powertune(
308 unsigned long speed
);
310 extern void ml_set_processor_voltage(
311 unsigned long voltage
);
313 extern unsigned int ml_scom_write(
317 extern unsigned int ml_scom_read(
321 extern uint32_t ml_hdec_ratio(void);
323 extern int boffSettingsInit
;
325 #endif /* KERNEL_PRIVATE */
327 #endif /* _PPC_MACHINE_ROUTINES_H_ */