]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/machine_routines.h
cdde41a1d3843a331dc303b3709d7ca664cf4002
[apple/xnu.git] / osfmk / ppc / machine_routines.h
1 /*
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
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
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
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.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * @OSF_COPYRIGHT@
32 */
33
34 #ifndef _PPC_MACHINE_ROUTINES_H_
35 #define _PPC_MACHINE_ROUTINES_H_
36
37 #include <mach/mach_types.h>
38 #include <mach/boolean.h>
39 #include <kern/kern_types.h>
40 #include <pexpert/pexpert.h>
41
42 /* Get Interrupts Enabled */
43 extern boolean_t ml_get_interrupts_enabled(
44 void);
45
46 /* Set Interrupts Enabled */
47 extern boolean_t ml_set_interrupts_enabled(
48 boolean_t enable);
49
50 /* Check if running at interrupt context */
51 extern boolean_t ml_at_interrupt_context(
52 void);
53
54 #ifdef KERNEL_PRIVATE
55
56 /* Generate a fake interrupt */
57 extern void ml_cause_interrupt(
58 void);
59
60 /* Type for the IPI Hander */
61 typedef void (*ipi_handler_t)(void);
62
63 /* Type for the Time Base Enable function */
64 typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable);
65
66 /* enables (or disables) the processor nap mode the function returns the previous value*/
67 extern boolean_t ml_enable_nap(
68 int target_cpu,
69 boolean_t nap_enabled);
70
71 /* Put the processor to sleep */
72 extern void ml_ppc_sleep(
73 void);
74
75 extern void ml_get_timebase(
76 unsigned long long *timstamp);
77
78 extern int ml_enable_cache_level(
79 int cache_level,
80 int enable);
81
82 extern void ml_static_mfree(
83 vm_offset_t vaddr,
84 vm_size_t size);
85
86 /* Init Interrupts */
87 extern void ml_install_interrupt_handler(
88 void *nub,
89 int source,
90 void *target,
91 IOInterruptHandler handler,
92 void *refCon);
93
94 extern vm_offset_t ml_static_ptovirt(
95 vm_offset_t paddr);
96
97 /* virtual to physical on wired pages */
98 extern vm_offset_t ml_vtophys(
99 vm_offset_t vaddr);
100
101 /* PCI config cycle probing */
102 extern boolean_t ml_probe_read(
103 vm_offset_t paddr,
104 unsigned int *val);
105
106 extern boolean_t ml_probe_read_64(
107 addr64_t paddr,
108 unsigned int *val);
109
110 /* Read physical address byte */
111 extern unsigned int ml_phys_read_byte(
112 vm_offset_t paddr);
113
114 extern unsigned int ml_phys_read_byte_64(
115 addr64_t paddr);
116
117 /* Read physical address half word */
118 extern unsigned int ml_phys_read_half(
119 vm_offset_t paddr);
120
121 extern unsigned int ml_phys_read_half_64(
122 addr64_t paddr);
123
124 /* Read physical address word*/
125 extern unsigned int ml_phys_read(
126 vm_offset_t paddr);
127
128 extern unsigned int ml_phys_read_64(
129 addr64_t paddr);
130
131 extern unsigned int ml_phys_read_word(
132 vm_offset_t paddr);
133
134 extern unsigned int ml_phys_read_word_64(
135 addr64_t paddr);
136
137 /* Read physical address double word */
138 extern unsigned long long ml_phys_read_double(
139 vm_offset_t paddr);
140
141 extern unsigned long long ml_phys_read_double_64(
142 addr64_t paddr);
143
144 /* Write physical address byte */
145 extern void ml_phys_write_byte(
146 vm_offset_t paddr,
147 unsigned int data);
148
149 extern void ml_phys_write_byte_64(
150 addr64_t paddr,
151 unsigned int data);
152
153 /* Write physical address half word */
154 extern void ml_phys_write_half(
155 vm_offset_t paddr,
156 unsigned int data);
157
158 extern void ml_phys_write_half_64(
159 addr64_t paddr,
160 unsigned int data);
161
162 /* Write physical address word */
163 extern void ml_phys_write(
164 vm_offset_t paddr,
165 unsigned int data);
166
167 extern void ml_phys_write_64(
168 addr64_t paddr,
169 unsigned int data);
170
171 extern void ml_phys_write_word(
172 vm_offset_t paddr,
173 unsigned int data);
174
175 extern void ml_phys_write_word_64(
176 addr64_t paddr,
177 unsigned int data);
178
179 /* Write physical address double word */
180 extern void ml_phys_write_double(
181 vm_offset_t paddr,
182 unsigned long long data);
183
184 extern void ml_phys_write_double_64(
185 addr64_t paddr,
186 unsigned long long data);
187
188 /* Struct for ml_processor_register */
189 struct ml_processor_info {
190 cpu_id_t cpu_id;
191 boolean_t boot_cpu;
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;
198 };
199
200 typedef struct ml_processor_info ml_processor_info_t;
201
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);
207
208 /* Zero bytes starting at a physical address */
209 extern void bzero_phys(
210 addr64_t phys_address,
211 uint32_t length);
212
213 #endif /* KERNEL_PRIVATE */
214
215 #ifdef XNU_KERNEL_PRIVATE
216 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
217
218 /* Map memory map IO space */
219 extern vm_offset_t ml_io_map(
220 vm_offset_t phys_addr,
221 vm_size_t size);
222
223 /* boot memory allocation */
224 extern vm_offset_t ml_static_malloc(
225 vm_size_t size);
226
227 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
228
229 #if defined(BSD_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
230
231 extern int set_be_bit(
232 void);
233
234 extern int clr_be_bit(
235 void);
236
237 extern int be_tracing(
238 void);
239
240 #endif /* BSD_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
241
242 #ifdef MACH_KERNEL_PRIVATE
243 extern void ml_init_interrupt(
244 void);
245
246 extern void cacheInit(
247 void);
248
249 extern void cacheDisable(
250 void);
251
252 extern void ml_init_lock_timeout(
253 void);
254
255 void ml_ppc_do_sleep(void);
256
257 #endif /* MACH_KERNEL_PRIVATE */
258 #endif /* XNU_KERNEL_PRIVATE */
259
260 #ifdef KERNEL_PRIVATE
261 extern void ml_thread_policy(
262 thread_t thread,
263 unsigned policy_id,
264 unsigned policy_info);
265
266 #define MACHINE_GROUP 0x00000001
267 #define MACHINE_NETWORK_GROUP 0x10000000
268 #define MACHINE_NETWORK_WORKLOOP 0x00000001
269 #define MACHINE_NETWORK_NETISR 0x00000002
270
271 /* Initialize the maximum number of CPUs */
272 extern void ml_init_max_cpus(
273 unsigned int max_cpus);
274
275 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
276 extern unsigned int ml_get_max_cpus(
277 void);
278
279 extern void ml_cpu_up(void);
280 extern void ml_cpu_down(void);
281
282 /* Struct for ml_cpu_get_info */
283 struct ml_cpu_info {
284 unsigned long vector_unit;
285 unsigned long cache_line_size;
286 unsigned long l1_icache_size;
287 unsigned long l1_dcache_size;
288 unsigned long l2_settings;
289 unsigned long l2_cache_size;
290 unsigned long l3_settings;
291 unsigned long l3_cache_size;
292 };
293
294 typedef struct ml_cpu_info ml_cpu_info_t;
295
296 /* Get processor info */
297 extern void ml_cpu_get_info(
298 ml_cpu_info_t *ml_cpu_info);
299
300 extern void ml_set_processor_speed(
301 unsigned long speed);
302 extern void ml_set_processor_speed_slave(
303 unsigned long speed);
304 extern void ml_set_processor_speed_dpll(
305 unsigned long speed);
306 extern void ml_set_processor_speed_dfs(
307 unsigned long speed);
308 extern void ml_set_processor_speed_powertune(
309 unsigned long speed);
310
311 extern void ml_set_processor_voltage(
312 unsigned long voltage);
313
314 extern unsigned int ml_scom_write(
315 uint32_t reg,
316 uint64_t data);
317
318 extern unsigned int ml_scom_read(
319 uint32_t reg,
320 uint64_t *data);
321
322 extern uint32_t ml_hdec_ratio(void);
323
324 #endif /* KERNEL_PRIVATE */
325
326 #endif /* _PPC_MACHINE_ROUTINES_H_ */