2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
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.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
34 #ifndef _I386_MACHINE_ROUTINES_H_
35 #define _I386_MACHINE_ROUTINES_H_
37 #include <mach/mach_types.h>
38 #include <mach/boolean.h>
39 #include <kern/kern_types.h>
40 #include <pexpert/pexpert.h>
42 #include <sys/cdefs.h>
43 #include <sys/appleapiopts.h>
47 /* are we a 64 bit platform ? */
49 boolean_t
ml_is64bit(void);
51 /* is this a 64bit thread? */
53 boolean_t
ml_thread_is64bit(thread_t
);
55 /* is this a 64bit thread? */
57 boolean_t
ml_state_is64bit(void *);
59 /* set state of fpu save area for signal handling */
61 void ml_fp_setvalid(boolean_t
);
63 void ml_cpu_set_ldt(int);
65 /* Interrupt handling */
67 /* Initialize Interrupts */
68 void ml_init_interrupt(void);
70 /* Get Interrupts Enabled */
71 boolean_t
ml_get_interrupts_enabled(void);
73 /* Set Interrupts Enabled */
74 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
76 /* Check if running at interrupt context */
77 boolean_t
ml_at_interrupt_context(void);
79 /* Generate a fake interrupt */
80 void ml_cause_interrupt(void);
82 void ml_get_timebase(unsigned long long *timestamp
);
83 void ml_init_lock_timeout(void);
85 /* Type for the Time Base Enable function */
86 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
88 /* Type for the IPI Hander */
89 typedef void (*ipi_handler_t
)(void);
91 /* Struct for ml_processor_register */
92 struct ml_processor_info
{
95 vm_offset_t start_paddr
;
96 boolean_t supports_nap
;
97 unsigned long l2cr_value
;
98 time_base_enable_t time_base_enable
;
101 typedef struct ml_processor_info ml_processor_info_t
;
104 /* Register a processor */
105 kern_return_t
ml_processor_register(
108 processor_t
*processor
,
109 ipi_handler_t
*ipi_handler
,
112 /* Initialize Interrupts */
113 void ml_install_interrupt_handler(
117 IOInterruptHandler handler
,
120 #ifdef __APPLE_API_UNSTABLE
125 #ifdef XNU_KERNEL_PRIVATE
131 /* PCI config cycle probing */
132 boolean_t
ml_probe_read(
135 boolean_t
ml_probe_read_64(
139 /* Read physical address byte */
140 unsigned int ml_phys_read_byte(
142 unsigned int ml_phys_read_byte_64(
145 /* Read physical address half word */
146 unsigned int ml_phys_read_half(
148 unsigned int ml_phys_read_half_64(
151 /* Read physical address word*/
152 unsigned int ml_phys_read(
154 unsigned int ml_phys_read_64(
156 unsigned int ml_phys_read_word(
158 unsigned int ml_phys_read_word_64(
161 /* Read physical address double word */
162 unsigned long long ml_phys_read_double(
164 unsigned long long ml_phys_read_double_64(
167 /* Write physical address byte */
168 void ml_phys_write_byte(
169 vm_offset_t paddr
, unsigned int data
);
170 void ml_phys_write_byte_64(
171 addr64_t paddr
, unsigned int data
);
173 /* Write physical address half word */
174 void ml_phys_write_half(
175 vm_offset_t paddr
, unsigned int data
);
176 void ml_phys_write_half_64(
177 addr64_t paddr
, unsigned int data
);
179 /* Write physical address word */
181 vm_offset_t paddr
, unsigned int data
);
182 void ml_phys_write_64(
183 addr64_t paddr
, unsigned int data
);
184 void ml_phys_write_word(
185 vm_offset_t paddr
, unsigned int data
);
186 void ml_phys_write_word_64(
187 addr64_t paddr
, unsigned int data
);
189 /* Write physical address double word */
190 void ml_phys_write_double(
191 vm_offset_t paddr
, unsigned long long data
);
192 void ml_phys_write_double_64(
193 addr64_t paddr
, unsigned long long data
);
195 void ml_static_mfree(
199 /* virtual to physical on wired pages */
200 vm_offset_t
ml_vtophys(
203 /* Struct for ml_cpu_get_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
;
215 typedef struct ml_cpu_info ml_cpu_info_t
;
217 /* Get processor info */
218 void ml_cpu_get_info(ml_cpu_info_t
*ml_cpu_info
);
220 #endif /* __APPLE_API_UNSTABLE */
222 #ifdef __APPLE_API_PRIVATE
223 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
224 /* IO memory map services */
226 /* Map memory map IO space */
227 vm_offset_t
ml_io_map(
228 vm_offset_t phys_addr
,
231 /* boot memory allocation */
232 vm_offset_t
ml_static_malloc(
236 extern uint32_t bounce_pool_base
;
237 extern uint32_t bounce_pool_size
;
239 void ml_get_bouncepool_info(
240 vm_offset_t
*phys_addr
,
244 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
246 /* Zero bytes starting at a physical address */
248 addr64_t phys_address
,
251 void ml_thread_policy(
254 unsigned policy_info
);
256 #define MACHINE_GROUP 0x00000001
257 #define MACHINE_NETWORK_GROUP 0x10000000
258 #define MACHINE_NETWORK_WORKLOOP 0x00000001
259 #define MACHINE_NETWORK_NETISR 0x00000002
261 /* Initialize the maximum number of CPUs */
262 void ml_init_max_cpus(
263 unsigned long max_cpus
);
265 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
269 extern void ml_cpu_up(void);
270 extern void ml_cpu_down(void);
272 extern int set_be_bit(void);
273 extern int clr_be_bit(void);
274 extern int be_tracing(void);
276 extern void ml_set_maxsnoop(uint32_t maxdelay
);
277 extern unsigned ml_get_maxsnoop(void);
278 extern void ml_set_maxbusdelay(uint32_t mdelay
);
279 extern uint32_t ml_get_maxbusdelay(void);
280 extern void ml_hpet_cfg(uint32_t cpu
, uint32_t hpetVect
);
282 extern uint64_t tmrCvt(uint64_t time
, uint64_t conversion
);
284 #endif /* __APPLE_API_PRIVATE */
288 #endif /* _I386_MACHINE_ROUTINES_H_ */