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