2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
29 #ifndef _I386_MACHINE_ROUTINES_H_
30 #define _I386_MACHINE_ROUTINES_H_
32 #include <mach/mach_types.h>
33 #include <mach/boolean.h>
34 #include <kern/kern_types.h>
35 #include <pexpert/pexpert.h>
37 #include <sys/appleapiopts.h>
39 /* Interrupt handling */
41 /* Get Interrupts Enabled */
42 boolean_t
ml_get_interrupts_enabled(void);
44 /* Set Interrupts Enabled */
45 boolean_t
ml_set_interrupts_enabled(boolean_t enable
);
47 /* Check if running at interrupt context */
48 boolean_t
ml_at_interrupt_context(void);
50 /* Generate a fake interrupt */
51 void ml_cause_interrupt(void);
53 void ml_get_timebase(unsigned long long *timestamp
);
55 /* Type for the IPI Hander */
56 typedef void (*ipi_handler_t
)(void);
58 /* Register a processor */
59 kern_return_t
ml_processor_register(
61 vm_offset_t start_paddr
,
62 processor_t
*processor
,
63 ipi_handler_t
*ipi_handler
,
66 /* Initialize Interrupts */
67 void ml_install_interrupt_handler(
71 IOInterruptHandler handler
,
74 #ifdef __APPLE_API_UNSTABLE
79 /* PCI config cycle probing */
80 boolean_t
ml_probe_read(
83 boolean_t
ml_probe_read_64(
87 /* Read physical address byte */
88 unsigned int ml_phys_read_byte(
90 unsigned int ml_phys_read_byte_64(
93 /* Read physical address half word */
94 unsigned int ml_phys_read_half(
96 unsigned int ml_phys_read_half_64(
99 /* Read physical address word*/
100 unsigned int ml_phys_read(
102 unsigned int ml_phys_read_64(
104 unsigned int ml_phys_read_word(
106 unsigned int ml_phys_read_word_64(
109 /* Read physical address double word */
110 unsigned long long ml_phys_read_double(
112 unsigned long long ml_phys_read_double_64(
115 /* Write physical address byte */
116 void ml_phys_write_byte(
117 vm_offset_t paddr
, unsigned int data
);
118 void ml_phys_write_byte_64(
119 addr64_t paddr
, unsigned int data
);
121 /* Write physical address half word */
122 void ml_phys_write_half(
123 vm_offset_t paddr
, unsigned int data
);
124 void ml_phys_write_half_64(
125 addr64_t paddr
, unsigned int data
);
127 /* Write physical address word */
129 vm_offset_t paddr
, unsigned int data
);
130 void ml_phys_write_64(
131 addr64_t paddr
, unsigned int data
);
132 void ml_phys_write_word(
133 vm_offset_t paddr
, unsigned int data
);
134 void ml_phys_write_word_64(
135 addr64_t paddr
, unsigned int data
);
137 /* Write physical address double word */
138 void ml_phys_write_double(
139 vm_offset_t paddr
, unsigned long long data
);
140 void ml_phys_write_double_64(
141 addr64_t paddr
, unsigned long long data
);
143 void ml_static_mfree(
147 /* virtual to physical on wired pages */
148 vm_offset_t
ml_vtophys(
151 /* Struct for ml_cpu_get_info */
153 unsigned long vector_unit
;
154 unsigned long cache_line_size
;
155 unsigned long l1_icache_size
;
156 unsigned long l1_dcache_size
;
157 unsigned long l2_settings
;
158 unsigned long l2_cache_size
;
159 unsigned long l3_settings
;
160 unsigned long l3_cache_size
;
163 typedef struct ml_cpu_info ml_cpu_info_t
;
165 /* Get processor info */
166 void ml_cpu_get_info(ml_cpu_info_t
*cpu_info
);
168 #endif /* __APPLE_API_UNSTABLE */
170 #ifdef __APPLE_API_PRIVATE
171 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
172 /* IO memory map services */
174 /* Map memory map IO space */
175 vm_offset_t
ml_io_map(
176 vm_offset_t phys_addr
,
179 /* boot memory allocation */
180 vm_offset_t
ml_static_malloc(
183 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
185 #ifdef MACH_KERNEL_PRIVATE
187 void machine_idle(void);
189 void machine_signal_idle(
190 processor_t processor
);
191 #endif /* MACH_KERNEL_PRIVATE */
193 void ml_thread_policy(
196 unsigned policy_info
);
198 #define MACHINE_GROUP 0x00000001
199 #define MACHINE_NETWORK_GROUP 0x10000000
200 #define MACHINE_NETWORK_WORKLOOP 0x00000001
201 #define MACHINE_NETWORK_NETISR 0x00000002
203 /* Initialize the maximum number of CPUs */
204 void ml_init_max_cpus(
205 unsigned long max_cpus
);
207 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
211 /* Return the current number of CPUs */
212 int ml_get_current_cpus(
215 #endif /* __APPLE_API_PRIVATE */
217 #endif /* _I386_MACHINE_ROUTINES_H_ */