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