]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/machine_routines.h
5ce506b19e35290350a282c219415778788e2307
[apple/xnu.git] / osfmk / ppc / machine_routines.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
19 *
20 * @APPLE_LICENSE_HEADER_END@
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 <kern/sched_prim.h>
33 #include <pexpert/pexpert.h>
34
35 #include <sys/appleapiopts.h>
36
37 /* Get Interrupts Enabled */
38 boolean_t ml_get_interrupts_enabled(void);
39
40 /* Set Interrupts Enabled */
41 boolean_t ml_set_interrupts_enabled(boolean_t enable);
42
43 /* Check if running at interrupt context */
44 boolean_t ml_at_interrupt_context(void);
45
46 /* Generate a fake interrupt */
47 void ml_cause_interrupt(void);
48
49 /* Type for the IPI Hander */
50 typedef void (*ipi_handler_t)(void);
51
52 /* Type for the Time Base Enable function */
53 typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable);
54
55 /* enables (or disables) the processor nap mode the function returns the previous value*/
56 boolean_t ml_enable_nap(
57 int target_cpu,
58 boolean_t nap_enabled);
59
60 /* Put the processor to sleep */
61 void ml_ppc_sleep(void);
62 void ml_get_timebase(unsigned long long *timstamp);
63 void ml_sense__nmi(void);
64
65 int ml_enable_cache_level(int cache_level, int enable);
66
67 void ml_static_mfree(
68 vm_offset_t,
69 vm_size_t);
70
71 /* Init Interrupts */
72 void ml_install_interrupt_handler(
73 void *nub,
74 int source,
75 void *target,
76 IOInterruptHandler handler,
77 void *refCon);
78
79 #ifdef __APPLE_API_UNSTABLE
80
81 vm_offset_t
82 ml_static_ptovirt(
83 vm_offset_t);
84
85 /* virtual to physical on wired pages */
86 vm_offset_t ml_vtophys(
87 vm_offset_t vaddr);
88
89 /* PCI config cycle probing */
90 boolean_t ml_probe_read(
91 vm_offset_t paddr,
92 unsigned int *val);
93 boolean_t ml_probe_read_64(
94 addr64_t paddr,
95 unsigned int *val);
96
97 /* Read physical address byte */
98 unsigned int ml_phys_read_byte(
99 vm_offset_t paddr);
100 unsigned int ml_phys_read_byte_64(
101 addr64_t paddr);
102
103 /* Read physical address half word */
104 unsigned int ml_phys_read_half(
105 vm_offset_t paddr);
106 unsigned int ml_phys_read_half_64(
107 addr64_t paddr);
108
109 /* Read physical address word*/
110 unsigned int ml_phys_read(
111 vm_offset_t paddr);
112 unsigned int ml_phys_read_64(
113 addr64_t paddr);
114 unsigned int ml_phys_read_word(
115 vm_offset_t paddr);
116 unsigned int ml_phys_read_word_64(
117 addr64_t paddr);
118
119 /* Read physical address double word */
120 unsigned long long ml_phys_read_double(
121 vm_offset_t paddr);
122 unsigned long long ml_phys_read_double_64(
123 addr64_t paddr);
124
125 /* Write physical address byte */
126 void ml_phys_write_byte(
127 vm_offset_t paddr, unsigned int data);
128 void ml_phys_write_byte_64(
129 addr64_t paddr, unsigned int data);
130
131 /* Write physical address half word */
132 void ml_phys_write_half(
133 vm_offset_t paddr, unsigned int data);
134 void ml_phys_write_half_64(
135 addr64_t paddr, unsigned int data);
136
137 /* Write physical address word */
138 void ml_phys_write(
139 vm_offset_t paddr, unsigned int data);
140 void ml_phys_write_64(
141 addr64_t paddr, unsigned int data);
142 void ml_phys_write_word(
143 vm_offset_t paddr, unsigned int data);
144 void ml_phys_write_word_64(
145 addr64_t paddr, unsigned int data);
146
147 /* Write physical address double word */
148 void ml_phys_write_double(
149 vm_offset_t paddr, unsigned long long data);
150 void ml_phys_write_double_64(
151 addr64_t paddr, unsigned long long data);
152
153 /* Struct for ml_processor_register */
154 struct ml_processor_info {
155 cpu_id_t cpu_id;
156 boolean_t boot_cpu;
157 vm_offset_t start_paddr;
158 boolean_t supports_nap;
159 unsigned long l2cr_value;
160 time_base_enable_t time_base_enable;
161 uint32_t power_mode_0;
162 uint32_t power_mode_1;
163 };
164
165 typedef struct ml_processor_info ml_processor_info_t;
166
167 /* Register a processor */
168 kern_return_t ml_processor_register(
169 ml_processor_info_t *processor_info,
170 processor_t *processor,
171 ipi_handler_t *ipi_handler);
172
173 /* Zero bytes starting at a physical address */
174 void bzero_phys(
175 addr64_t phys_address,
176 uint32_t length);
177
178 #endif /* __APPLE_API_UNSTABLE */
179
180 #ifdef __APPLE_API_PRIVATE
181 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
182 /* IO memory map services */
183
184 /* Map memory map IO space */
185 vm_offset_t ml_io_map(
186 vm_offset_t phys_addr,
187 vm_size_t size);
188
189 /* boot memory allocation */
190 vm_offset_t ml_static_malloc(
191 vm_size_t size);
192
193 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
194
195 #ifdef MACH_KERNEL_PRIVATE
196 void ml_init_interrupt(void);
197
198 boolean_t fake_get_interrupts_enabled(void);
199
200 boolean_t fake_set_interrupts_enabled(
201 boolean_t enable);
202
203 void machine_idle(void);
204
205 void machine_signal_idle(
206 processor_t processor);
207
208 void cacheInit(void);
209
210 void cacheDisable(void);
211
212 void ml_thrm_init(void);
213 unsigned int ml_read_temp(void);
214
215 void ml_thrm_set(
216 unsigned int low,
217 unsigned int high);
218
219 unsigned int ml_throttle(
220 unsigned int);
221
222 void ml_init_lock_timeout(void);
223
224 #endif /* MACH_KERNEL_PRIVATE */
225
226 void ml_thread_policy(
227 thread_t thread,
228 unsigned policy_id,
229 unsigned policy_info);
230
231 #define MACHINE_GROUP 0x00000001
232 #define MACHINE_NETWORK_GROUP 0x10000000
233 #define MACHINE_NETWORK_WORKLOOP 0x00000001
234 #define MACHINE_NETWORK_NETISR 0x00000002
235
236 /* Initialize the maximum number of CPUs */
237 void ml_init_max_cpus(
238 unsigned long max_cpus);
239
240 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
241 int ml_get_max_cpus(
242 void);
243
244 /* Return the current number of CPUs */
245 int ml_get_current_cpus(
246 void);
247
248 /* Struct for ml_cpu_get_info */
249 struct ml_cpu_info {
250 unsigned long vector_unit;
251 unsigned long cache_line_size;
252 unsigned long l1_icache_size;
253 unsigned long l1_dcache_size;
254 unsigned long l2_settings;
255 unsigned long l2_cache_size;
256 unsigned long l3_settings;
257 unsigned long l3_cache_size;
258 };
259
260 typedef struct ml_cpu_info ml_cpu_info_t;
261
262 /* Get processor info */
263 void ml_cpu_get_info(ml_cpu_info_t *cpu_info);
264
265 void ml_set_processor_speed(unsigned long speed);
266 void ml_set_processor_voltage(unsigned long voltage);
267 unsigned int ml_scom_write(uint32_t reg, uint64_t data);
268 unsigned int ml_scom_read(uint32_t reg, uint64_t *data);
269
270 #endif /* __APPLE_API_PRIVATE */
271
272 #endif /* _PPC_MACHINE_ROUTINES_H_ */