2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
27 #ifndef _I386_MACHINE_ROUTINES_H_
28 #define _I386_MACHINE_ROUTINES_H_
30 #include <mach/mach_types.h>
31 #include <mach/boolean.h>
32 #include <kern/kern_types.h>
33 #include <pexpert/pexpert.h>
35 #include <sys/cdefs.h>
36 #include <sys/appleapiopts.h>
40 /* Interrupt handling */
42 /* Initialize Interrupts */
43 void ml_init_interrupt(void);
45 /* Get Interrupts Enabled */
46 boolean_t
ml_get_interrupts_enabled(void);
48 /* Set Interrupts Enabled */
49 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
51 /* Check if running at interrupt context */
52 boolean_t
ml_at_interrupt_context(void);
54 /* Generate a fake interrupt */
55 void ml_cause_interrupt(void);
57 void ml_get_timebase(unsigned long long *timestamp
);
59 /* Type for the Time Base Enable function */
60 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
62 /* Type for the IPI Hander */
63 typedef void (*ipi_handler_t
)(void);
65 /* Struct for ml_processor_register */
66 struct ml_processor_info
{
69 vm_offset_t start_paddr
;
70 boolean_t supports_nap
;
71 unsigned long l2cr_value
;
72 time_base_enable_t time_base_enable
;
75 typedef struct ml_processor_info ml_processor_info_t
;
78 /* Register a processor */
79 kern_return_t
ml_processor_register(
82 processor_t
*processor
,
83 ipi_handler_t
*ipi_handler
,
86 /* Initialize Interrupts */
87 void ml_install_interrupt_handler(
91 IOInterruptHandler handler
,
94 #ifdef __APPLE_API_UNSTABLE
99 /* PCI config cycle probing */
100 boolean_t
ml_probe_read(
103 boolean_t
ml_probe_read_64(
107 /* Read physical address byte */
108 unsigned int ml_phys_read_byte(
110 unsigned int ml_phys_read_byte_64(
113 /* Read physical address half word */
114 unsigned int ml_phys_read_half(
116 unsigned int ml_phys_read_half_64(
119 /* Read physical address word*/
120 unsigned int ml_phys_read(
122 unsigned int ml_phys_read_64(
124 unsigned int ml_phys_read_word(
126 unsigned int ml_phys_read_word_64(
129 /* Read physical address double word */
130 unsigned long long ml_phys_read_double(
132 unsigned long long ml_phys_read_double_64(
135 /* Write physical address byte */
136 void ml_phys_write_byte(
137 vm_offset_t paddr
, unsigned int data
);
138 void ml_phys_write_byte_64(
139 addr64_t paddr
, unsigned int data
);
141 /* Write physical address half word */
142 void ml_phys_write_half(
143 vm_offset_t paddr
, unsigned int data
);
144 void ml_phys_write_half_64(
145 addr64_t paddr
, unsigned int data
);
147 /* Write physical address word */
149 vm_offset_t paddr
, unsigned int data
);
150 void ml_phys_write_64(
151 addr64_t paddr
, unsigned int data
);
152 void ml_phys_write_word(
153 vm_offset_t paddr
, unsigned int data
);
154 void ml_phys_write_word_64(
155 addr64_t paddr
, unsigned int data
);
157 /* Write physical address double word */
158 void ml_phys_write_double(
159 vm_offset_t paddr
, unsigned long long data
);
160 void ml_phys_write_double_64(
161 addr64_t paddr
, unsigned long long data
);
163 void ml_static_mfree(
167 /* virtual to physical on wired pages */
168 vm_offset_t
ml_vtophys(
171 /* Struct for ml_cpu_get_info */
173 unsigned long vector_unit
;
174 unsigned long cache_line_size
;
175 unsigned long l1_icache_size
;
176 unsigned long l1_dcache_size
;
177 unsigned long l2_settings
;
178 unsigned long l2_cache_size
;
179 unsigned long l3_settings
;
180 unsigned long l3_cache_size
;
183 typedef struct ml_cpu_info ml_cpu_info_t
;
185 /* Get processor info */
186 void ml_cpu_get_info(ml_cpu_info_t
*ml_cpu_info
);
188 #endif /* __APPLE_API_UNSTABLE */
190 #ifdef __APPLE_API_PRIVATE
191 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
192 /* IO memory map services */
194 /* Map memory map IO space */
195 vm_offset_t
ml_io_map(
196 vm_offset_t phys_addr
,
199 /* boot memory allocation */
200 vm_offset_t
ml_static_malloc(
203 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
205 /* Zero bytes starting at a physical address */
207 addr64_t phys_address
,
210 void ml_thread_policy(
213 unsigned policy_info
);
215 #define MACHINE_GROUP 0x00000001
216 #define MACHINE_NETWORK_GROUP 0x10000000
217 #define MACHINE_NETWORK_WORKLOOP 0x00000001
218 #define MACHINE_NETWORK_NETISR 0x00000002
220 /* Initialize the maximum number of CPUs */
221 void ml_init_max_cpus(
222 unsigned long max_cpus
);
224 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
228 extern void ml_cpu_up(void);
229 extern void ml_cpu_down(void);
231 extern int set_be_bit(void);
232 extern int clr_be_bit(void);
233 extern int be_tracing(void);
235 #endif /* __APPLE_API_PRIVATE */
239 #endif /* _I386_MACHINE_ROUTINES_H_ */