]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/machine_routines.h
xnu-792.1.5.tar.gz
[apple/xnu.git] / osfmk / i386 / machine_routines.h
1 /*
2 * Copyright (c) 2000-2005 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 _I386_MACHINE_ROUTINES_H_
27 #define _I386_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
34 #include <sys/cdefs.h>
35 #include <sys/appleapiopts.h>
36
37 __BEGIN_DECLS
38
39 /* Interrupt handling */
40
41 /* Initialize Interrupts */
42 void ml_init_interrupt(void);
43
44 /* Get Interrupts Enabled */
45 boolean_t ml_get_interrupts_enabled(void);
46
47 /* Set Interrupts Enabled */
48 boolean_t ml_set_interrupts_enabled(boolean_t enable);
49
50 /* Check if running at interrupt context */
51 boolean_t ml_at_interrupt_context(void);
52
53 /* Generate a fake interrupt */
54 void ml_cause_interrupt(void);
55
56 void ml_get_timebase(unsigned long long *timestamp);
57
58 /* Type for the Time Base Enable function */
59 typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable);
60
61 /* Type for the IPI Hander */
62 typedef void (*ipi_handler_t)(void);
63
64 /* Struct for ml_processor_register */
65 struct ml_processor_info {
66 cpu_id_t cpu_id;
67 boolean_t boot_cpu;
68 vm_offset_t start_paddr;
69 boolean_t supports_nap;
70 unsigned long l2cr_value;
71 time_base_enable_t time_base_enable;
72 };
73
74 typedef struct ml_processor_info ml_processor_info_t;
75
76
77 /* Register a processor */
78 kern_return_t ml_processor_register(
79 cpu_id_t cpu_id,
80 uint32_t lapic_id,
81 processor_t *processor,
82 ipi_handler_t *ipi_handler,
83 boolean_t boot_cpu);
84
85 /* Initialize Interrupts */
86 void ml_install_interrupt_handler(
87 void *nub,
88 int source,
89 void *target,
90 IOInterruptHandler handler,
91 void *refCon);
92
93 #ifdef __APPLE_API_UNSTABLE
94 vm_offset_t
95 ml_static_ptovirt(
96 vm_offset_t);
97
98 /* PCI config cycle probing */
99 boolean_t ml_probe_read(
100 vm_offset_t paddr,
101 unsigned int *val);
102 boolean_t ml_probe_read_64(
103 addr64_t paddr,
104 unsigned int *val);
105
106 /* Read physical address byte */
107 unsigned int ml_phys_read_byte(
108 vm_offset_t paddr);
109 unsigned int ml_phys_read_byte_64(
110 addr64_t paddr);
111
112 /* Read physical address half word */
113 unsigned int ml_phys_read_half(
114 vm_offset_t paddr);
115 unsigned int ml_phys_read_half_64(
116 addr64_t paddr);
117
118 /* Read physical address word*/
119 unsigned int ml_phys_read(
120 vm_offset_t paddr);
121 unsigned int ml_phys_read_64(
122 addr64_t paddr);
123 unsigned int ml_phys_read_word(
124 vm_offset_t paddr);
125 unsigned int ml_phys_read_word_64(
126 addr64_t paddr);
127
128 /* Read physical address double word */
129 unsigned long long ml_phys_read_double(
130 vm_offset_t paddr);
131 unsigned long long ml_phys_read_double_64(
132 addr64_t paddr);
133
134 /* Write physical address byte */
135 void ml_phys_write_byte(
136 vm_offset_t paddr, unsigned int data);
137 void ml_phys_write_byte_64(
138 addr64_t paddr, unsigned int data);
139
140 /* Write physical address half word */
141 void ml_phys_write_half(
142 vm_offset_t paddr, unsigned int data);
143 void ml_phys_write_half_64(
144 addr64_t paddr, unsigned int data);
145
146 /* Write physical address word */
147 void ml_phys_write(
148 vm_offset_t paddr, unsigned int data);
149 void ml_phys_write_64(
150 addr64_t paddr, unsigned int data);
151 void ml_phys_write_word(
152 vm_offset_t paddr, unsigned int data);
153 void ml_phys_write_word_64(
154 addr64_t paddr, unsigned int data);
155
156 /* Write physical address double word */
157 void ml_phys_write_double(
158 vm_offset_t paddr, unsigned long long data);
159 void ml_phys_write_double_64(
160 addr64_t paddr, unsigned long long data);
161
162 void ml_static_mfree(
163 vm_offset_t,
164 vm_size_t);
165
166 /* virtual to physical on wired pages */
167 vm_offset_t ml_vtophys(
168 vm_offset_t vaddr);
169
170 /* Struct for ml_cpu_get_info */
171 struct ml_cpu_info {
172 unsigned long vector_unit;
173 unsigned long cache_line_size;
174 unsigned long l1_icache_size;
175 unsigned long l1_dcache_size;
176 unsigned long l2_settings;
177 unsigned long l2_cache_size;
178 unsigned long l3_settings;
179 unsigned long l3_cache_size;
180 };
181
182 typedef struct ml_cpu_info ml_cpu_info_t;
183
184 /* Get processor info */
185 void ml_cpu_get_info(ml_cpu_info_t *ml_cpu_info);
186
187 #endif /* __APPLE_API_UNSTABLE */
188
189 #ifdef __APPLE_API_PRIVATE
190 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
191 /* IO memory map services */
192
193 /* Map memory map IO space */
194 vm_offset_t ml_io_map(
195 vm_offset_t phys_addr,
196 vm_size_t size);
197
198 /* boot memory allocation */
199 vm_offset_t ml_static_malloc(
200 vm_size_t size);
201
202 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
203
204 /* Zero bytes starting at a physical address */
205 void bzero_phys(
206 addr64_t phys_address,
207 uint32_t length);
208
209 void ml_thread_policy(
210 thread_t thread,
211 unsigned policy_id,
212 unsigned policy_info);
213
214 #define MACHINE_GROUP 0x00000001
215 #define MACHINE_NETWORK_GROUP 0x10000000
216 #define MACHINE_NETWORK_WORKLOOP 0x00000001
217 #define MACHINE_NETWORK_NETISR 0x00000002
218
219 /* Initialize the maximum number of CPUs */
220 void ml_init_max_cpus(
221 unsigned long max_cpus);
222
223 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
224 int ml_get_max_cpus(
225 void);
226
227 extern void ml_cpu_up(void);
228 extern void ml_cpu_down(void);
229
230 extern int set_be_bit(void);
231 extern int clr_be_bit(void);
232 extern int be_tracing(void);
233
234 #endif /* __APPLE_API_PRIVATE */
235
236 __END_DECLS
237
238 #endif /* _I386_MACHINE_ROUTINES_H_ */