]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/machine_routines.h
aee0f8785085f58c042378d0d1399496fdecaedb
[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 void ml_get_bouncepool_info(
224 vm_offset_t *phys_addr,
225 vm_size_t *size);
226
227
228 /* boot memory allocation */
229 extern vm_offset_t ml_static_malloc(
230 vm_size_t size);
231
232 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
233
234 #if defined(BSD_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
235
236 extern int set_be_bit(
237 void);
238
239 extern int clr_be_bit(
240 void);
241
242 extern int be_tracing(
243 void);
244
245 #endif /* BSD_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
246
247 #ifdef MACH_KERNEL_PRIVATE
248 extern void ml_init_interrupt(
249 void);
250
251 extern void cacheInit(
252 void);
253
254 extern void cacheDisable(
255 void);
256
257 extern void ml_init_lock_timeout(
258 void);
259
260 void ml_ppc_do_sleep(void);
261
262 #endif /* MACH_KERNEL_PRIVATE */
263 #endif /* XNU_KERNEL_PRIVATE */
264
265 #ifdef KERNEL_PRIVATE
266 extern void ml_thread_policy(
267 thread_t thread,
268 unsigned policy_id,
269 unsigned policy_info);
270
271 #define MACHINE_GROUP 0x00000001
272 #define MACHINE_NETWORK_GROUP 0x10000000
273 #define MACHINE_NETWORK_WORKLOOP 0x00000001
274 #define MACHINE_NETWORK_NETISR 0x00000002
275
276 /* Initialize the maximum number of CPUs */
277 extern void ml_init_max_cpus(
278 unsigned int max_cpus);
279
280 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
281 extern unsigned int ml_get_max_cpus(
282 void);
283
284 extern void ml_cpu_up(void);
285 extern void ml_cpu_down(void);
286
287 /* Struct for ml_cpu_get_info */
288 struct ml_cpu_info {
289 unsigned long vector_unit;
290 unsigned long cache_line_size;
291 unsigned long l1_icache_size;
292 unsigned long l1_dcache_size;
293 unsigned long l2_settings;
294 unsigned long l2_cache_size;
295 unsigned long l3_settings;
296 unsigned long l3_cache_size;
297 };
298
299 typedef struct ml_cpu_info ml_cpu_info_t;
300
301 /* Get processor info */
302 extern void ml_cpu_get_info(
303 ml_cpu_info_t *ml_cpu_info);
304
305 extern void ml_set_processor_speed(
306 unsigned long speed);
307 extern void ml_set_processor_speed_slave(
308 unsigned long speed);
309 extern void ml_set_processor_speed_dpll(
310 unsigned long speed);
311 extern void ml_set_processor_speed_dfs(
312 unsigned long speed);
313 extern void ml_set_processor_speed_powertune(
314 unsigned long speed);
315
316 extern void ml_set_processor_voltage(
317 unsigned long voltage);
318
319 extern unsigned int ml_scom_write(
320 uint32_t reg,
321 uint64_t data);
322
323 extern unsigned int ml_scom_read(
324 uint32_t reg,
325 uint64_t *data);
326
327 extern uint32_t ml_hdec_ratio(void);
328
329 #endif /* KERNEL_PRIVATE */
330
331 #endif /* _PPC_MACHINE_ROUTINES_H_ */