2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 #ifndef _I386_MACHINE_ROUTINES_H_
33 #define _I386_MACHINE_ROUTINES_H_
35 #include <mach/mach_types.h>
36 #include <mach/boolean.h>
37 #include <kern/kern_types.h>
38 #include <pexpert/pexpert.h>
40 #include <sys/cdefs.h>
41 #include <sys/appleapiopts.h>
45 /* Interrupt handling */
47 /* Initialize Interrupts */
48 void ml_init_interrupt(void);
50 /* Get Interrupts Enabled */
51 boolean_t
ml_get_interrupts_enabled(void);
53 /* Set Interrupts Enabled */
54 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
56 /* Check if running at interrupt context */
57 boolean_t
ml_at_interrupt_context(void);
59 /* Generate a fake interrupt */
60 void ml_cause_interrupt(void);
62 void ml_get_timebase(unsigned long long *timestamp
);
64 /* Type for the Time Base Enable function */
65 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
67 /* Type for the IPI Hander */
68 typedef void (*ipi_handler_t
)(void);
70 /* Struct for ml_processor_register */
71 struct ml_processor_info
{
74 vm_offset_t start_paddr
;
75 boolean_t supports_nap
;
76 unsigned long l2cr_value
;
77 time_base_enable_t time_base_enable
;
80 typedef struct ml_processor_info ml_processor_info_t
;
83 /* Register a processor */
84 kern_return_t
ml_processor_register(
87 processor_t
*processor
,
88 ipi_handler_t
*ipi_handler
,
91 /* Initialize Interrupts */
92 void ml_install_interrupt_handler(
96 IOInterruptHandler handler
,
99 #ifdef __APPLE_API_UNSTABLE
104 /* PCI config cycle probing */
105 boolean_t
ml_probe_read(
108 boolean_t
ml_probe_read_64(
112 /* Read physical address byte */
113 unsigned int ml_phys_read_byte(
115 unsigned int ml_phys_read_byte_64(
118 /* Read physical address half word */
119 unsigned int ml_phys_read_half(
121 unsigned int ml_phys_read_half_64(
124 /* Read physical address word*/
125 unsigned int ml_phys_read(
127 unsigned int ml_phys_read_64(
129 unsigned int ml_phys_read_word(
131 unsigned int ml_phys_read_word_64(
134 /* Read physical address double word */
135 unsigned long long ml_phys_read_double(
137 unsigned long long ml_phys_read_double_64(
140 /* Write physical address byte */
141 void ml_phys_write_byte(
142 vm_offset_t paddr
, unsigned int data
);
143 void ml_phys_write_byte_64(
144 addr64_t paddr
, unsigned int data
);
146 /* Write physical address half word */
147 void ml_phys_write_half(
148 vm_offset_t paddr
, unsigned int data
);
149 void ml_phys_write_half_64(
150 addr64_t paddr
, unsigned int data
);
152 /* Write physical address word */
154 vm_offset_t paddr
, unsigned int data
);
155 void ml_phys_write_64(
156 addr64_t paddr
, unsigned int data
);
157 void ml_phys_write_word(
158 vm_offset_t paddr
, unsigned int data
);
159 void ml_phys_write_word_64(
160 addr64_t paddr
, unsigned int data
);
162 /* Write physical address double word */
163 void ml_phys_write_double(
164 vm_offset_t paddr
, unsigned long long data
);
165 void ml_phys_write_double_64(
166 addr64_t paddr
, unsigned long long data
);
168 void ml_static_mfree(
172 /* virtual to physical on wired pages */
173 vm_offset_t
ml_vtophys(
176 /* Struct for ml_cpu_get_info */
178 unsigned long vector_unit
;
179 unsigned long cache_line_size
;
180 unsigned long l1_icache_size
;
181 unsigned long l1_dcache_size
;
182 unsigned long l2_settings
;
183 unsigned long l2_cache_size
;
184 unsigned long l3_settings
;
185 unsigned long l3_cache_size
;
188 typedef struct ml_cpu_info ml_cpu_info_t
;
190 /* Get processor info */
191 void ml_cpu_get_info(ml_cpu_info_t
*ml_cpu_info
);
193 #endif /* __APPLE_API_UNSTABLE */
195 #ifdef __APPLE_API_PRIVATE
196 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
197 /* IO memory map services */
199 /* Map memory map IO space */
200 vm_offset_t
ml_io_map(
201 vm_offset_t phys_addr
,
204 /* boot memory allocation */
205 vm_offset_t
ml_static_malloc(
208 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
210 /* Zero bytes starting at a physical address */
212 addr64_t phys_address
,
215 void ml_thread_policy(
218 unsigned policy_info
);
220 #define MACHINE_GROUP 0x00000001
221 #define MACHINE_NETWORK_GROUP 0x10000000
222 #define MACHINE_NETWORK_WORKLOOP 0x00000001
223 #define MACHINE_NETWORK_NETISR 0x00000002
225 /* Initialize the maximum number of CPUs */
226 void ml_init_max_cpus(
227 unsigned long max_cpus
);
229 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
233 extern void ml_cpu_up(void);
234 extern void ml_cpu_down(void);
236 extern int set_be_bit(void);
237 extern int clr_be_bit(void);
238 extern int be_tracing(void);
240 #endif /* __APPLE_API_PRIVATE */
244 #endif /* _I386_MACHINE_ROUTINES_H_ */