]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/machine_routines.h
827e1b2c46b93bb11df620241f0e99bf8d33fd8f
[apple/xnu.git] / osfmk / ppc / machine_routines.h
1 /*
2 * Copyright (c) 2000-2004 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 /* PCI config cycle probing */
100 extern boolean_t ml_probe_read(
101 vm_offset_t paddr,
102 unsigned int *val);
103
104 extern boolean_t ml_probe_read_64(
105 addr64_t paddr,
106 unsigned int *val);
107
108 /* Read physical address byte */
109 extern unsigned int ml_phys_read_byte(
110 vm_offset_t paddr);
111
112 extern unsigned int ml_phys_read_byte_64(
113 addr64_t paddr);
114
115 /* Read physical address half word */
116 extern unsigned int ml_phys_read_half(
117 vm_offset_t paddr);
118
119 extern unsigned int ml_phys_read_half_64(
120 addr64_t paddr);
121
122 /* Read physical address word*/
123 extern unsigned int ml_phys_read(
124 vm_offset_t paddr);
125
126 extern unsigned int ml_phys_read_64(
127 addr64_t paddr);
128
129 extern unsigned int ml_phys_read_word(
130 vm_offset_t paddr);
131
132 extern unsigned int ml_phys_read_word_64(
133 addr64_t paddr);
134
135 /* Read physical address double word */
136 extern unsigned long long ml_phys_read_double(
137 vm_offset_t paddr);
138
139 extern unsigned long long ml_phys_read_double_64(
140 addr64_t paddr);
141
142 /* Write physical address byte */
143 extern void ml_phys_write_byte(
144 vm_offset_t paddr,
145 unsigned int data);
146
147 extern void ml_phys_write_byte_64(
148 addr64_t paddr,
149 unsigned int data);
150
151 /* Write physical address half word */
152 extern void ml_phys_write_half(
153 vm_offset_t paddr,
154 unsigned int data);
155
156 extern void ml_phys_write_half_64(
157 addr64_t paddr,
158 unsigned int data);
159
160 /* Write physical address word */
161 extern void ml_phys_write(
162 vm_offset_t paddr,
163 unsigned int data);
164
165 extern void ml_phys_write_64(
166 addr64_t paddr,
167 unsigned int data);
168
169 extern void ml_phys_write_word(
170 vm_offset_t paddr,
171 unsigned int data);
172
173 extern void ml_phys_write_word_64(
174 addr64_t paddr,
175 unsigned int data);
176
177 /* Write physical address double word */
178 extern void ml_phys_write_double(
179 vm_offset_t paddr,
180 unsigned long long data);
181
182 extern void ml_phys_write_double_64(
183 addr64_t paddr,
184 unsigned long long data);
185
186 /* Struct for ml_processor_register */
187 struct ml_processor_info {
188 cpu_id_t cpu_id;
189 boolean_t boot_cpu;
190 vm_offset_t start_paddr;
191 boolean_t supports_nap;
192 unsigned long l2cr_value;
193 time_base_enable_t time_base_enable;
194 uint32_t power_mode_0;
195 uint32_t power_mode_1;
196 };
197
198 typedef struct ml_processor_info ml_processor_info_t;
199
200 /* Register a processor */
201 extern kern_return_t ml_processor_register(
202 ml_processor_info_t *ml_processor_info,
203 processor_t *processor,
204 ipi_handler_t *ipi_handler);
205
206 /* Zero bytes starting at a physical address */
207 extern void bzero_phys(
208 addr64_t phys_address,
209 uint32_t length);
210
211 #endif /* KERNEL_PRIVATE */
212
213 #ifdef XNU_KERNEL_PRIVATE
214 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
215
216 /* Map memory map IO space */
217 extern vm_offset_t ml_io_map(
218 vm_offset_t phys_addr,
219 vm_size_t size);
220
221 /* boot memory allocation */
222 extern vm_offset_t ml_static_malloc(
223 vm_size_t size);
224
225 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
226
227 #if defined(BSD_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
228
229 extern int set_be_bit(
230 void);
231
232 extern int clr_be_bit(
233 void);
234
235 extern int be_tracing(
236 void);
237
238 #endif /* BSD_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
239
240 #ifdef MACH_KERNEL_PRIVATE
241 extern void ml_init_interrupt(
242 void);
243
244 extern void cacheInit(
245 void);
246
247 extern void cacheDisable(
248 void);
249
250 extern void ml_init_lock_timeout(
251 void);
252
253 void ml_ppc_do_sleep(void);
254
255 #endif /* MACH_KERNEL_PRIVATE */
256 #endif /* XNU_KERNEL_PRIVATE */
257
258 #ifdef KERNEL_PRIVATE
259 extern void ml_thread_policy(
260 thread_t thread,
261 unsigned policy_id,
262 unsigned policy_info);
263
264 #define MACHINE_GROUP 0x00000001
265 #define MACHINE_NETWORK_GROUP 0x10000000
266 #define MACHINE_NETWORK_WORKLOOP 0x00000001
267 #define MACHINE_NETWORK_NETISR 0x00000002
268
269 /* Initialize the maximum number of CPUs */
270 extern void ml_init_max_cpus(
271 unsigned int max_cpus);
272
273 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
274 extern unsigned int ml_get_max_cpus(
275 void);
276
277 extern void ml_cpu_up(void);
278 extern void ml_cpu_down(void);
279
280 /* Struct for ml_cpu_get_info */
281 struct ml_cpu_info {
282 unsigned long vector_unit;
283 unsigned long cache_line_size;
284 unsigned long l1_icache_size;
285 unsigned long l1_dcache_size;
286 unsigned long l2_settings;
287 unsigned long l2_cache_size;
288 unsigned long l3_settings;
289 unsigned long l3_cache_size;
290 };
291
292 typedef struct ml_cpu_info ml_cpu_info_t;
293
294 /* Get processor info */
295 extern void ml_cpu_get_info(
296 ml_cpu_info_t *ml_cpu_info);
297
298 extern void ml_set_processor_speed(
299 unsigned long speed);
300 extern void ml_set_processor_speed_slave(
301 unsigned long speed);
302 extern void ml_set_processor_speed_dpll(
303 unsigned long speed);
304 extern void ml_set_processor_speed_dfs(
305 unsigned long speed);
306 extern void ml_set_processor_speed_powertune(
307 unsigned long speed);
308
309 extern void ml_set_processor_voltage(
310 unsigned long voltage);
311
312 extern unsigned int ml_scom_write(
313 uint32_t reg,
314 uint64_t data);
315
316 extern unsigned int ml_scom_read(
317 uint32_t reg,
318 uint64_t *data);
319
320 extern uint32_t ml_hdec_ratio(void);
321
322 #endif /* KERNEL_PRIVATE */
323
324 #endif /* _PPC_MACHINE_ROUTINES_H_ */