]> git.saurik.com Git - apple/xnu.git/blame - osfmk/i386/machine_routines.h
xnu-792.13.8.tar.gz
[apple/xnu.git] / osfmk / i386 / machine_routines.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
8ad349bb 4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
1c79356b 5 *
8ad349bb
A
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
1c79356b
A
29 */
30/*
31 * @OSF_COPYRIGHT@
32 */
33
34#ifndef _I386_MACHINE_ROUTINES_H_
35#define _I386_MACHINE_ROUTINES_H_
36
37#include <mach/mach_types.h>
38#include <mach/boolean.h>
39#include <kern/kern_types.h>
40#include <pexpert/pexpert.h>
41
91447636 42#include <sys/cdefs.h>
9bccf70c 43#include <sys/appleapiopts.h>
1c79356b 44
91447636
A
45__BEGIN_DECLS
46
5d5c5d0d
A
47/* are we a 64 bit platform ? */
48
49boolean_t ml_is64bit(void);
50
51/* is this a 64bit thread? */
52
53boolean_t ml_thread_is64bit(thread_t);
54
55/* is this a 64bit thread? */
56
57boolean_t ml_state_is64bit(void *);
58
59/* set state of fpu save area for signal handling */
60
61void ml_fp_setvalid(boolean_t);
62
63void ml_cpu_set_ldt(int);
64
1c79356b
A
65/* Interrupt handling */
66
55e303ae
A
67/* Initialize Interrupts */
68void ml_init_interrupt(void);
69
1c79356b
A
70/* Get Interrupts Enabled */
71boolean_t ml_get_interrupts_enabled(void);
72
73/* Set Interrupts Enabled */
74boolean_t ml_set_interrupts_enabled(boolean_t enable);
75
76/* Check if running at interrupt context */
77boolean_t ml_at_interrupt_context(void);
78
79/* Generate a fake interrupt */
80void ml_cause_interrupt(void);
81
9bccf70c 82void ml_get_timebase(unsigned long long *timestamp);
5d5c5d0d 83void ml_init_lock_timeout(void);
d52fe63f 84
55e303ae
A
85/* Type for the Time Base Enable function */
86typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable);
87
9bccf70c
A
88/* Type for the IPI Hander */
89typedef void (*ipi_handler_t)(void);
90
55e303ae
A
91/* Struct for ml_processor_register */
92struct ml_processor_info {
93 cpu_id_t cpu_id;
94 boolean_t boot_cpu;
95 vm_offset_t start_paddr;
96 boolean_t supports_nap;
97 unsigned long l2cr_value;
98 time_base_enable_t time_base_enable;
99};
100
101typedef struct ml_processor_info ml_processor_info_t;
102
91447636 103
9bccf70c
A
104/* Register a processor */
105kern_return_t ml_processor_register(
55e303ae
A
106 cpu_id_t cpu_id,
107 uint32_t lapic_id,
108 processor_t *processor,
109 ipi_handler_t *ipi_handler,
9bccf70c 110 boolean_t boot_cpu);
d52fe63f 111
1c79356b
A
112/* Initialize Interrupts */
113void ml_install_interrupt_handler(
114 void *nub,
115 int source,
116 void *target,
117 IOInterruptHandler handler,
118 void *refCon);
119
9bccf70c
A
120#ifdef __APPLE_API_UNSTABLE
121vm_offset_t
122ml_static_ptovirt(
123 vm_offset_t);
124
5d5c5d0d
A
125#ifdef XNU_KERNEL_PRIVATE
126vm_offset_t
127ml_boot_ptovirt(
128 vm_offset_t);
129#endif
130
43866e37
A
131/* PCI config cycle probing */
132boolean_t ml_probe_read(
133 vm_offset_t paddr,
134 unsigned int *val);
55e303ae
A
135boolean_t ml_probe_read_64(
136 addr64_t paddr,
137 unsigned int *val);
43866e37
A
138
139/* Read physical address byte */
140unsigned int ml_phys_read_byte(
141 vm_offset_t paddr);
55e303ae
A
142unsigned int ml_phys_read_byte_64(
143 addr64_t paddr);
43866e37
A
144
145/* Read physical address half word */
146unsigned int ml_phys_read_half(
147 vm_offset_t paddr);
55e303ae
A
148unsigned int ml_phys_read_half_64(
149 addr64_t paddr);
43866e37
A
150
151/* Read physical address word*/
152unsigned int ml_phys_read(
153 vm_offset_t paddr);
55e303ae
A
154unsigned int ml_phys_read_64(
155 addr64_t paddr);
43866e37
A
156unsigned int ml_phys_read_word(
157 vm_offset_t paddr);
55e303ae
A
158unsigned int ml_phys_read_word_64(
159 addr64_t paddr);
43866e37
A
160
161/* Read physical address double word */
162unsigned long long ml_phys_read_double(
163 vm_offset_t paddr);
55e303ae
A
164unsigned long long ml_phys_read_double_64(
165 addr64_t paddr);
43866e37
A
166
167/* Write physical address byte */
168void ml_phys_write_byte(
169 vm_offset_t paddr, unsigned int data);
55e303ae
A
170void ml_phys_write_byte_64(
171 addr64_t paddr, unsigned int data);
43866e37
A
172
173/* Write physical address half word */
174void ml_phys_write_half(
175 vm_offset_t paddr, unsigned int data);
55e303ae
A
176void ml_phys_write_half_64(
177 addr64_t paddr, unsigned int data);
43866e37
A
178
179/* Write physical address word */
180void ml_phys_write(
181 vm_offset_t paddr, unsigned int data);
55e303ae
A
182void ml_phys_write_64(
183 addr64_t paddr, unsigned int data);
43866e37
A
184void ml_phys_write_word(
185 vm_offset_t paddr, unsigned int data);
55e303ae
A
186void ml_phys_write_word_64(
187 addr64_t paddr, unsigned int data);
43866e37
A
188
189/* Write physical address double word */
190void ml_phys_write_double(
191 vm_offset_t paddr, unsigned long long data);
55e303ae
A
192void ml_phys_write_double_64(
193 addr64_t paddr, unsigned long long data);
43866e37 194
9bccf70c
A
195void ml_static_mfree(
196 vm_offset_t,
197 vm_size_t);
198
199/* virtual to physical on wired pages */
200vm_offset_t ml_vtophys(
201 vm_offset_t vaddr);
202
43866e37
A
203/* Struct for ml_cpu_get_info */
204struct ml_cpu_info {
205 unsigned long vector_unit;
206 unsigned long cache_line_size;
207 unsigned long l1_icache_size;
208 unsigned long l1_dcache_size;
209 unsigned long l2_settings;
210 unsigned long l2_cache_size;
211 unsigned long l3_settings;
212 unsigned long l3_cache_size;
213};
214
215typedef struct ml_cpu_info ml_cpu_info_t;
216
217/* Get processor info */
91447636 218void ml_cpu_get_info(ml_cpu_info_t *ml_cpu_info);
43866e37 219
9bccf70c
A
220#endif /* __APPLE_API_UNSTABLE */
221
222#ifdef __APPLE_API_PRIVATE
223#if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
224/* IO memory map services */
225
226/* Map memory map IO space */
227vm_offset_t ml_io_map(
228 vm_offset_t phys_addr,
229 vm_size_t size);
230
231/* boot memory allocation */
232vm_offset_t ml_static_malloc(
233 vm_size_t size);
234
5d5c5d0d
A
235
236extern uint32_t bounce_pool_base;
237extern uint32_t bounce_pool_size;
238
239void ml_get_bouncepool_info(
240 vm_offset_t *phys_addr,
241 vm_size_t *size);
242
243
9bccf70c
A
244#endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
245
55e303ae
A
246/* Zero bytes starting at a physical address */
247void bzero_phys(
248 addr64_t phys_address,
249 uint32_t length);
250
9bccf70c
A
251void ml_thread_policy(
252 thread_t thread,
253 unsigned policy_id,
254 unsigned policy_info);
1c79356b 255
9bccf70c
A
256#define MACHINE_GROUP 0x00000001
257#define MACHINE_NETWORK_GROUP 0x10000000
258#define MACHINE_NETWORK_WORKLOOP 0x00000001
259#define MACHINE_NETWORK_NETISR 0x00000002
1c79356b 260
43866e37
A
261/* Initialize the maximum number of CPUs */
262void ml_init_max_cpus(
263 unsigned long max_cpus);
264
265/* Return the maximum number of CPUs set by ml_init_max_cpus() */
266int ml_get_max_cpus(
267 void);
268
91447636
A
269extern void ml_cpu_up(void);
270extern void ml_cpu_down(void);
271
272extern int set_be_bit(void);
273extern int clr_be_bit(void);
274extern int be_tracing(void);
275
5d5c5d0d
A
276extern void ml_set_maxsnoop(uint32_t maxdelay);
277extern unsigned ml_get_maxsnoop(void);
278extern void ml_set_maxbusdelay(uint32_t mdelay);
279extern uint32_t ml_get_maxbusdelay(void);
280extern void ml_hpet_cfg(uint32_t cpu, uint32_t hpetVect);
281
282extern uint64_t tmrCvt(uint64_t time, uint64_t conversion);
283
9bccf70c 284#endif /* __APPLE_API_PRIVATE */
1c79356b 285
91447636
A
286__END_DECLS
287
1c79356b 288#endif /* _I386_MACHINE_ROUTINES_H_ */