]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/machine_routines.h
9133cef9f11885f83afb073869c9c522c0ab50a0
[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 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * @OSF_COPYRIGHT@
27 */
28
29 #ifndef _PPC_MACHINE_ROUTINES_H_
30 #define _PPC_MACHINE_ROUTINES_H_
31
32 #include <mach/mach_types.h>
33 #include <mach/boolean.h>
34 #include <kern/kern_types.h>
35 #include <pexpert/pexpert.h>
36
37 #include <sys/appleapiopts.h>
38
39 /* Get Interrupts Enabled */
40 boolean_t ml_get_interrupts_enabled(void);
41
42 /* Set Interrupts Enabled */
43 boolean_t ml_set_interrupts_enabled(boolean_t enable);
44
45 /* Check if running at interrupt context */
46 boolean_t ml_at_interrupt_context(void);
47
48 /* Generate a fake interrupt */
49 void ml_cause_interrupt(void);
50
51 /* Type for the IPI Hander */
52 typedef void (*ipi_handler_t)(void);
53
54 /* Type for the Time Base Enable function */
55 typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable);
56
57 /* enables (or disables) the processor nap mode the function returns the previous value*/
58 boolean_t ml_enable_nap(
59 int target_cpu,
60 boolean_t nap_enabled);
61
62 /* Put the processor to sleep */
63 void ml_ppc_sleep(void);
64 void ml_get_timebase(unsigned long long *timstamp);
65 void ml_sense__nmi(void);
66
67 int ml_enable_cache_level(int cache_level, int enable);
68
69 void ml_static_mfree(
70 vm_offset_t,
71 vm_size_t);
72
73 /* Init Interrupts */
74 void ml_install_interrupt_handler(
75 void *nub,
76 int source,
77 void *target,
78 IOInterruptHandler handler,
79 void *refCon);
80
81 #ifdef __APPLE_API_UNSTABLE
82
83 vm_offset_t
84 ml_static_ptovirt(
85 vm_offset_t);
86
87 /* virtual to physical on wired pages */
88 vm_offset_t ml_vtophys(
89 vm_offset_t vaddr);
90
91 /* PCI config cycle probing */
92 boolean_t ml_probe_read(
93 vm_offset_t paddr,
94 unsigned int *val);
95
96 /* Read physical address byte */
97 unsigned int ml_phys_read_byte(
98 vm_offset_t paddr);
99
100 /* Read physical address */
101 unsigned int ml_phys_read(
102 vm_offset_t paddr);
103
104 /* Write physical address byte */
105 void ml_phys_write_byte(
106 vm_offset_t paddr, unsigned int data);
107
108 /* Write physical address */
109 void ml_phys_write(
110 vm_offset_t paddr, unsigned int data);
111
112 /* Struct for ml_processor_register */
113 struct ml_processor_info_t {
114 cpu_id_t cpu_id;
115 boolean_t boot_cpu;
116 vm_offset_t start_paddr;
117 boolean_t supports_nap;
118 unsigned long l2cr_value;
119 time_base_enable_t time_base_enable;
120 };
121
122 typedef struct ml_processor_info_t ml_processor_info_t;
123
124 /* Register a processor */
125 kern_return_t ml_processor_register(
126 ml_processor_info_t *processor_info,
127 processor_t *processor,
128 ipi_handler_t *ipi_handler);
129
130 #endif /* __APPLE_API_UNSTABLE */
131
132 #ifdef __APPLE_API_PRIVATE
133 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
134 /* IO memory map services */
135
136 /* Map memory map IO space */
137 vm_offset_t ml_io_map(
138 vm_offset_t phys_addr,
139 vm_size_t size);
140
141 /* boot memory allocation */
142 vm_offset_t ml_static_malloc(
143 vm_size_t size);
144
145 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
146
147 #ifdef MACH_KERNEL_PRIVATE
148 void ml_init_interrupt(void);
149
150 boolean_t fake_get_interrupts_enabled(void);
151
152 boolean_t fake_set_interrupts_enabled(
153 boolean_t enable);
154
155 /* check pending timers */
156 void machine_clock_assist(void);
157
158 void machine_idle(void);
159
160 void machine_signal_idle(
161 processor_t processor);
162
163 void cacheInit(void);
164
165 void cacheDisable(void);
166
167 void ml_thrm_init(void);
168 unsigned int ml_read_temp(void);
169
170 void ml_thrm_set(
171 unsigned int low,
172 unsigned int high);
173
174 unsigned int ml_throttle(
175 unsigned int);
176
177 #endif /* MACH_KERNEL_PRIVATE */
178
179 void ml_thread_policy(
180 thread_t thread,
181 unsigned policy_id,
182 unsigned policy_info);
183
184 #define MACHINE_GROUP 0x00000001
185 #define MACHINE_NETWORK_GROUP 0x10000000
186 #define MACHINE_NETWORK_WORKLOOP 0x00000001
187 #define MACHINE_NETWORK_NETISR 0x00000002
188
189 /* Initialize the maximum number of CPUs */
190 void ml_init_max_cpus(
191 unsigned long max_cpus);
192
193 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
194 int ml_get_max_cpus(
195 void);
196
197 /* Return the current number of CPUs */
198 int ml_get_current_cpus(
199 void);
200
201 /* Struct for ml_cpu_get_info */
202 struct ml_cpu_info {
203 unsigned long vector_unit;
204 unsigned long cache_line_size;
205 unsigned long l1_icache_size;
206 unsigned long l1_dcache_size;
207 unsigned long l2_settings;
208 unsigned long l2_cache_size;
209 unsigned long l3_settings;
210 unsigned long l3_cache_size;
211 };
212
213 typedef struct ml_cpu_info ml_cpu_info_t;
214
215 /* Get processor info */
216 void ml_cpu_get_info(ml_cpu_info_t *cpu_info);
217
218 void ml_set_processor_speed(unsigned long speed);
219 void ml_set_processor_voltage(unsigned long voltage);
220
221 #endif /* __APPLE_API_PRIVATE */
222
223 #endif /* _PPC_MACHINE_ROUTINES_H_ */