2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
26 #ifndef _I386_MACHINE_ROUTINES_H_
27 #define _I386_MACHINE_ROUTINES_H_
29 #include <mach/mach_types.h>
30 #include <mach/boolean.h>
31 #include <kern/kern_types.h>
32 #include <pexpert/pexpert.h>
34 #include <sys/cdefs.h>
35 #include <sys/appleapiopts.h>
39 /* are we a 64 bit platform ? */
41 boolean_t
ml_is64bit(void);
43 /* is this a 64bit thread? */
45 boolean_t
ml_thread_is64bit(thread_t
);
47 /* is this a 64bit thread? */
49 boolean_t
ml_state_is64bit(void *);
51 /* set state of fpu save area for signal handling */
53 void ml_fp_setvalid(boolean_t
);
55 void ml_cpu_set_ldt(int);
57 /* Interrupt handling */
59 /* Initialize Interrupts */
60 void ml_init_interrupt(void);
62 /* Get Interrupts Enabled */
63 boolean_t
ml_get_interrupts_enabled(void);
65 /* Set Interrupts Enabled */
66 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
68 /* Check if running at interrupt context */
69 boolean_t
ml_at_interrupt_context(void);
71 /* Generate a fake interrupt */
72 void ml_cause_interrupt(void);
74 void ml_get_timebase(unsigned long long *timestamp
);
75 void ml_init_lock_timeout(void);
77 /* Type for the Time Base Enable function */
78 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
80 /* Type for the IPI Hander */
81 typedef void (*ipi_handler_t
)(void);
83 /* Struct for ml_processor_register */
84 struct ml_processor_info
{
87 vm_offset_t start_paddr
;
88 boolean_t supports_nap
;
89 unsigned long l2cr_value
;
90 time_base_enable_t time_base_enable
;
93 typedef struct ml_processor_info ml_processor_info_t
;
96 /* Register a processor */
97 kern_return_t
ml_processor_register(
100 processor_t
*processor
,
101 ipi_handler_t
*ipi_handler
,
104 /* Initialize Interrupts */
105 void ml_install_interrupt_handler(
109 IOInterruptHandler handler
,
112 #ifdef __APPLE_API_UNSTABLE
117 #ifdef XNU_KERNEL_PRIVATE
123 /* PCI config cycle probing */
124 boolean_t
ml_probe_read(
127 boolean_t
ml_probe_read_64(
131 /* Read physical address byte */
132 unsigned int ml_phys_read_byte(
134 unsigned int ml_phys_read_byte_64(
137 /* Read physical address half word */
138 unsigned int ml_phys_read_half(
140 unsigned int ml_phys_read_half_64(
143 /* Read physical address word*/
144 unsigned int ml_phys_read(
146 unsigned int ml_phys_read_64(
148 unsigned int ml_phys_read_word(
150 unsigned int ml_phys_read_word_64(
153 /* Read physical address double word */
154 unsigned long long ml_phys_read_double(
156 unsigned long long ml_phys_read_double_64(
159 /* Write physical address byte */
160 void ml_phys_write_byte(
161 vm_offset_t paddr
, unsigned int data
);
162 void ml_phys_write_byte_64(
163 addr64_t paddr
, unsigned int data
);
165 /* Write physical address half word */
166 void ml_phys_write_half(
167 vm_offset_t paddr
, unsigned int data
);
168 void ml_phys_write_half_64(
169 addr64_t paddr
, unsigned int data
);
171 /* Write physical address word */
173 vm_offset_t paddr
, unsigned int data
);
174 void ml_phys_write_64(
175 addr64_t paddr
, unsigned int data
);
176 void ml_phys_write_word(
177 vm_offset_t paddr
, unsigned int data
);
178 void ml_phys_write_word_64(
179 addr64_t paddr
, unsigned int data
);
181 /* Write physical address double word */
182 void ml_phys_write_double(
183 vm_offset_t paddr
, unsigned long long data
);
184 void ml_phys_write_double_64(
185 addr64_t paddr
, unsigned long long data
);
187 void ml_static_mfree(
191 /* virtual to physical on wired pages */
192 vm_offset_t
ml_vtophys(
195 /* Struct for ml_cpu_get_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
;
207 typedef struct ml_cpu_info ml_cpu_info_t
;
209 /* Get processor info */
210 void ml_cpu_get_info(ml_cpu_info_t
*ml_cpu_info
);
212 #endif /* __APPLE_API_UNSTABLE */
214 #ifdef __APPLE_API_PRIVATE
215 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
216 /* IO memory map services */
218 /* Map memory map IO space */
219 vm_offset_t
ml_io_map(
220 vm_offset_t phys_addr
,
223 /* boot memory allocation */
224 vm_offset_t
ml_static_malloc(
228 extern uint32_t bounce_pool_base
;
229 extern uint32_t bounce_pool_size
;
231 void ml_get_bouncepool_info(
232 vm_offset_t
*phys_addr
,
236 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
238 /* Zero bytes starting at a physical address */
240 addr64_t phys_address
,
243 void ml_thread_policy(
246 unsigned policy_info
);
248 #define MACHINE_GROUP 0x00000001
249 #define MACHINE_NETWORK_GROUP 0x10000000
250 #define MACHINE_NETWORK_WORKLOOP 0x00000001
251 #define MACHINE_NETWORK_NETISR 0x00000002
253 /* Initialize the maximum number of CPUs */
254 void ml_init_max_cpus(
255 unsigned long max_cpus
);
257 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
261 extern void ml_cpu_up(void);
262 extern void ml_cpu_down(void);
264 extern int set_be_bit(void);
265 extern int clr_be_bit(void);
266 extern int be_tracing(void);
268 extern void ml_set_maxsnoop(uint32_t maxdelay
);
269 extern unsigned ml_get_maxsnoop(void);
270 extern void ml_set_maxbusdelay(uint32_t mdelay
);
271 extern uint32_t ml_get_maxbusdelay(void);
272 extern void ml_hpet_cfg(uint32_t cpu
, uint32_t hpetVect
);
274 extern uint64_t tmrCvt(uint64_t time
, uint64_t conversion
);
276 #endif /* __APPLE_API_PRIVATE */
280 #endif /* _I386_MACHINE_ROUTINES_H_ */