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 /* Interrupt handling */
41 /* Initialize Interrupts */
42 void ml_init_interrupt(void);
44 /* Get Interrupts Enabled */
45 boolean_t
ml_get_interrupts_enabled(void);
47 /* Set Interrupts Enabled */
48 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
50 /* Check if running at interrupt context */
51 boolean_t
ml_at_interrupt_context(void);
53 /* Generate a fake interrupt */
54 void ml_cause_interrupt(void);
56 void ml_get_timebase(unsigned long long *timestamp
);
58 /* Type for the Time Base Enable function */
59 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
61 /* Type for the IPI Hander */
62 typedef void (*ipi_handler_t
)(void);
64 /* Struct for ml_processor_register */
65 struct ml_processor_info
{
68 vm_offset_t start_paddr
;
69 boolean_t supports_nap
;
70 unsigned long l2cr_value
;
71 time_base_enable_t time_base_enable
;
74 typedef struct ml_processor_info ml_processor_info_t
;
77 /* Register a processor */
78 kern_return_t
ml_processor_register(
81 processor_t
*processor
,
82 ipi_handler_t
*ipi_handler
,
85 /* Initialize Interrupts */
86 void ml_install_interrupt_handler(
90 IOInterruptHandler handler
,
93 #ifdef __APPLE_API_UNSTABLE
98 /* PCI config cycle probing */
99 boolean_t
ml_probe_read(
102 boolean_t
ml_probe_read_64(
106 /* Read physical address byte */
107 unsigned int ml_phys_read_byte(
109 unsigned int ml_phys_read_byte_64(
112 /* Read physical address half word */
113 unsigned int ml_phys_read_half(
115 unsigned int ml_phys_read_half_64(
118 /* Read physical address word*/
119 unsigned int ml_phys_read(
121 unsigned int ml_phys_read_64(
123 unsigned int ml_phys_read_word(
125 unsigned int ml_phys_read_word_64(
128 /* Read physical address double word */
129 unsigned long long ml_phys_read_double(
131 unsigned long long ml_phys_read_double_64(
134 /* Write physical address byte */
135 void ml_phys_write_byte(
136 vm_offset_t paddr
, unsigned int data
);
137 void ml_phys_write_byte_64(
138 addr64_t paddr
, unsigned int data
);
140 /* Write physical address half word */
141 void ml_phys_write_half(
142 vm_offset_t paddr
, unsigned int data
);
143 void ml_phys_write_half_64(
144 addr64_t paddr
, unsigned int data
);
146 /* Write physical address word */
148 vm_offset_t paddr
, unsigned int data
);
149 void ml_phys_write_64(
150 addr64_t paddr
, unsigned int data
);
151 void ml_phys_write_word(
152 vm_offset_t paddr
, unsigned int data
);
153 void ml_phys_write_word_64(
154 addr64_t paddr
, unsigned int data
);
156 /* Write physical address double word */
157 void ml_phys_write_double(
158 vm_offset_t paddr
, unsigned long long data
);
159 void ml_phys_write_double_64(
160 addr64_t paddr
, unsigned long long data
);
162 void ml_static_mfree(
166 /* virtual to physical on wired pages */
167 vm_offset_t
ml_vtophys(
170 /* Struct for ml_cpu_get_info */
172 unsigned long vector_unit
;
173 unsigned long cache_line_size
;
174 unsigned long l1_icache_size
;
175 unsigned long l1_dcache_size
;
176 unsigned long l2_settings
;
177 unsigned long l2_cache_size
;
178 unsigned long l3_settings
;
179 unsigned long l3_cache_size
;
182 typedef struct ml_cpu_info ml_cpu_info_t
;
184 /* Get processor info */
185 void ml_cpu_get_info(ml_cpu_info_t
*ml_cpu_info
);
187 #endif /* __APPLE_API_UNSTABLE */
189 #ifdef __APPLE_API_PRIVATE
190 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
191 /* IO memory map services */
193 /* Map memory map IO space */
194 vm_offset_t
ml_io_map(
195 vm_offset_t phys_addr
,
198 /* boot memory allocation */
199 vm_offset_t
ml_static_malloc(
202 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
204 /* Zero bytes starting at a physical address */
206 addr64_t phys_address
,
209 void ml_thread_policy(
212 unsigned policy_info
);
214 #define MACHINE_GROUP 0x00000001
215 #define MACHINE_NETWORK_GROUP 0x10000000
216 #define MACHINE_NETWORK_WORKLOOP 0x00000001
217 #define MACHINE_NETWORK_NETISR 0x00000002
219 /* Initialize the maximum number of CPUs */
220 void ml_init_max_cpus(
221 unsigned long max_cpus
);
223 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
227 extern void ml_cpu_up(void);
228 extern void ml_cpu_down(void);
230 extern int set_be_bit(void);
231 extern int clr_be_bit(void);
232 extern int be_tracing(void);
234 #endif /* __APPLE_API_PRIVATE */
238 #endif /* _I386_MACHINE_ROUTINES_H_ */