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 /* Interrupt handling */
49 /* Initialize Interrupts */
50 void ml_init_interrupt(void);
52 /* Get Interrupts Enabled */
53 boolean_t
ml_get_interrupts_enabled(void);
55 /* Set Interrupts Enabled */
56 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
58 /* Check if running at interrupt context */
59 boolean_t
ml_at_interrupt_context(void);
61 /* Generate a fake interrupt */
62 void ml_cause_interrupt(void);
64 void ml_get_timebase(unsigned long long *timestamp
);
66 /* Type for the Time Base Enable function */
67 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
69 /* Type for the IPI Hander */
70 typedef void (*ipi_handler_t
)(void);
72 /* Struct for ml_processor_register */
73 struct ml_processor_info
{
76 vm_offset_t start_paddr
;
77 boolean_t supports_nap
;
78 unsigned long l2cr_value
;
79 time_base_enable_t time_base_enable
;
82 typedef struct ml_processor_info ml_processor_info_t
;
85 /* Register a processor */
86 kern_return_t
ml_processor_register(
89 processor_t
*processor
,
90 ipi_handler_t
*ipi_handler
,
93 /* Initialize Interrupts */
94 void ml_install_interrupt_handler(
98 IOInterruptHandler handler
,
101 #ifdef __APPLE_API_UNSTABLE
106 /* PCI config cycle probing */
107 boolean_t
ml_probe_read(
110 boolean_t
ml_probe_read_64(
114 /* Read physical address byte */
115 unsigned int ml_phys_read_byte(
117 unsigned int ml_phys_read_byte_64(
120 /* Read physical address half word */
121 unsigned int ml_phys_read_half(
123 unsigned int ml_phys_read_half_64(
126 /* Read physical address word*/
127 unsigned int ml_phys_read(
129 unsigned int ml_phys_read_64(
131 unsigned int ml_phys_read_word(
133 unsigned int ml_phys_read_word_64(
136 /* Read physical address double word */
137 unsigned long long ml_phys_read_double(
139 unsigned long long ml_phys_read_double_64(
142 /* Write physical address byte */
143 void ml_phys_write_byte(
144 vm_offset_t paddr
, unsigned int data
);
145 void ml_phys_write_byte_64(
146 addr64_t paddr
, unsigned int data
);
148 /* Write physical address half word */
149 void ml_phys_write_half(
150 vm_offset_t paddr
, unsigned int data
);
151 void ml_phys_write_half_64(
152 addr64_t paddr
, unsigned int data
);
154 /* Write physical address word */
156 vm_offset_t paddr
, unsigned int data
);
157 void ml_phys_write_64(
158 addr64_t paddr
, unsigned int data
);
159 void ml_phys_write_word(
160 vm_offset_t paddr
, unsigned int data
);
161 void ml_phys_write_word_64(
162 addr64_t paddr
, unsigned int data
);
164 /* Write physical address double word */
165 void ml_phys_write_double(
166 vm_offset_t paddr
, unsigned long long data
);
167 void ml_phys_write_double_64(
168 addr64_t paddr
, unsigned long long data
);
170 void ml_static_mfree(
174 /* virtual to physical on wired pages */
175 vm_offset_t
ml_vtophys(
178 /* Struct for ml_cpu_get_info */
180 unsigned long vector_unit
;
181 unsigned long cache_line_size
;
182 unsigned long l1_icache_size
;
183 unsigned long l1_dcache_size
;
184 unsigned long l2_settings
;
185 unsigned long l2_cache_size
;
186 unsigned long l3_settings
;
187 unsigned long l3_cache_size
;
190 typedef struct ml_cpu_info ml_cpu_info_t
;
192 /* Get processor info */
193 void ml_cpu_get_info(ml_cpu_info_t
*ml_cpu_info
);
195 #endif /* __APPLE_API_UNSTABLE */
197 #ifdef __APPLE_API_PRIVATE
198 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
199 /* IO memory map services */
201 /* Map memory map IO space */
202 vm_offset_t
ml_io_map(
203 vm_offset_t phys_addr
,
206 /* boot memory allocation */
207 vm_offset_t
ml_static_malloc(
210 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
212 /* Zero bytes starting at a physical address */
214 addr64_t phys_address
,
217 void ml_thread_policy(
220 unsigned policy_info
);
222 #define MACHINE_GROUP 0x00000001
223 #define MACHINE_NETWORK_GROUP 0x10000000
224 #define MACHINE_NETWORK_WORKLOOP 0x00000001
225 #define MACHINE_NETWORK_NETISR 0x00000002
227 /* Initialize the maximum number of CPUs */
228 void ml_init_max_cpus(
229 unsigned long max_cpus
);
231 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
235 extern void ml_cpu_up(void);
236 extern void ml_cpu_down(void);
238 extern int set_be_bit(void);
239 extern int clr_be_bit(void);
240 extern int be_tracing(void);
242 #endif /* __APPLE_API_PRIVATE */
246 #endif /* _I386_MACHINE_ROUTINES_H_ */