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