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