2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
29 #ifndef _PPC_MACHINE_ROUTINES_H_
30 #define _PPC_MACHINE_ROUTINES_H_
32 #include <mach/mach_types.h>
33 #include <mach/boolean.h>
34 #include <kern/kern_types.h>
35 #include <kern/sched_prim.h>
36 #include <pexpert/pexpert.h>
38 #include <sys/appleapiopts.h>
40 /* Get Interrupts Enabled */
41 boolean_t
ml_get_interrupts_enabled(void);
43 /* Set Interrupts Enabled */
44 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
46 /* Check if running at interrupt context */
47 boolean_t
ml_at_interrupt_context(void);
49 /* Generate a fake interrupt */
50 void ml_cause_interrupt(void);
52 /* Type for the IPI Hander */
53 typedef void (*ipi_handler_t
)(void);
55 /* Type for the Time Base Enable function */
56 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
58 /* enables (or disables) the processor nap mode the function returns the previous value*/
59 boolean_t
ml_enable_nap(
61 boolean_t nap_enabled
);
63 /* Put the processor to sleep */
64 void ml_ppc_sleep(void);
65 void ml_get_timebase(unsigned long long *timstamp
);
66 void ml_sense__nmi(void);
68 int ml_enable_cache_level(int cache_level
, int enable
);
75 void ml_install_interrupt_handler(
79 IOInterruptHandler handler
,
82 #ifdef __APPLE_API_UNSTABLE
88 /* virtual to physical on wired pages */
89 vm_offset_t
ml_vtophys(
92 /* PCI config cycle probing */
93 boolean_t
ml_probe_read(
96 boolean_t
ml_probe_read_64(
100 /* Read physical address byte */
101 unsigned int ml_phys_read_byte(
103 unsigned int ml_phys_read_byte_64(
106 /* Read physical address half word */
107 unsigned int ml_phys_read_half(
109 unsigned int ml_phys_read_half_64(
112 /* Read physical address word*/
113 unsigned int ml_phys_read(
115 unsigned int ml_phys_read_64(
117 unsigned int ml_phys_read_word(
119 unsigned int ml_phys_read_word_64(
122 /* Read physical address double word */
123 unsigned long long ml_phys_read_double(
125 unsigned long long ml_phys_read_double_64(
128 /* Write physical address byte */
129 void ml_phys_write_byte(
130 vm_offset_t paddr
, unsigned int data
);
131 void ml_phys_write_byte_64(
132 addr64_t paddr
, unsigned int data
);
134 /* Write physical address half word */
135 void ml_phys_write_half(
136 vm_offset_t paddr
, unsigned int data
);
137 void ml_phys_write_half_64(
138 addr64_t paddr
, unsigned int data
);
140 /* Write physical address word */
142 vm_offset_t paddr
, unsigned int data
);
143 void ml_phys_write_64(
144 addr64_t paddr
, unsigned int data
);
145 void ml_phys_write_word(
146 vm_offset_t paddr
, unsigned int data
);
147 void ml_phys_write_word_64(
148 addr64_t paddr
, unsigned int data
);
150 /* Write physical address double word */
151 void ml_phys_write_double(
152 vm_offset_t paddr
, unsigned long long data
);
153 void ml_phys_write_double_64(
154 addr64_t paddr
, unsigned long long data
);
156 /* Struct for ml_processor_register */
157 struct ml_processor_info
{
160 vm_offset_t start_paddr
;
161 boolean_t supports_nap
;
162 unsigned long l2cr_value
;
163 time_base_enable_t time_base_enable
;
166 typedef struct ml_processor_info ml_processor_info_t
;
168 /* Register a processor */
169 kern_return_t
ml_processor_register(
170 ml_processor_info_t
*processor_info
,
171 processor_t
*processor
,
172 ipi_handler_t
*ipi_handler
);
174 /* Zero bytes starting at a physical address */
176 addr64_t phys_address
,
179 #endif /* __APPLE_API_UNSTABLE */
181 #ifdef __APPLE_API_PRIVATE
182 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
183 /* IO memory map services */
185 /* Map memory map IO space */
186 vm_offset_t
ml_io_map(
187 vm_offset_t phys_addr
,
190 /* boot memory allocation */
191 vm_offset_t
ml_static_malloc(
194 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
196 #ifdef MACH_KERNEL_PRIVATE
197 void ml_init_interrupt(void);
199 boolean_t
fake_get_interrupts_enabled(void);
201 boolean_t
fake_set_interrupts_enabled(
204 void machine_idle(void);
206 void machine_signal_idle(
207 processor_t processor
);
209 void cacheInit(void);
211 void cacheDisable(void);
213 void ml_thrm_init(void);
214 unsigned int ml_read_temp(void);
220 unsigned int ml_throttle(
223 void ml_init_lock_timeout(void);
225 #endif /* MACH_KERNEL_PRIVATE */
227 void ml_thread_policy(
230 unsigned policy_info
);
232 #define MACHINE_GROUP 0x00000001
233 #define MACHINE_NETWORK_GROUP 0x10000000
234 #define MACHINE_NETWORK_WORKLOOP 0x00000001
235 #define MACHINE_NETWORK_NETISR 0x00000002
237 /* Initialize the maximum number of CPUs */
238 void ml_init_max_cpus(
239 unsigned long max_cpus
);
241 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
245 /* Return the current number of CPUs */
246 int ml_get_current_cpus(
249 /* Struct for ml_cpu_get_info */
251 unsigned long vector_unit
;
252 unsigned long cache_line_size
;
253 unsigned long l1_icache_size
;
254 unsigned long l1_dcache_size
;
255 unsigned long l2_settings
;
256 unsigned long l2_cache_size
;
257 unsigned long l3_settings
;
258 unsigned long l3_cache_size
;
261 typedef struct ml_cpu_info ml_cpu_info_t
;
263 /* Get processor info */
264 void ml_cpu_get_info(ml_cpu_info_t
*cpu_info
);
266 void ml_set_processor_speed(unsigned long speed
);
267 void ml_set_processor_voltage(unsigned long voltage
);
269 #endif /* __APPLE_API_PRIVATE */
271 #endif /* _PPC_MACHINE_ROUTINES_H_ */