2 * Copyright (c) 2000 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/appleapiopts.h>
36 /* Interrupt handling */
38 /* Initialize Interrupts */
39 void ml_init_interrupt(void);
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 Time Base Enable function */
56 typedef void (*time_base_enable_t
)(cpu_id_t cpu_id
, boolean_t enable
);
58 /* Type for the IPI Hander */
59 typedef void (*ipi_handler_t
)(void);
61 /* Struct for ml_processor_register */
62 struct ml_processor_info
{
65 vm_offset_t start_paddr
;
66 boolean_t supports_nap
;
67 unsigned long l2cr_value
;
68 time_base_enable_t time_base_enable
;
71 typedef struct ml_processor_info ml_processor_info_t
;
73 /* Register a processor */
74 kern_return_t
ml_processor_register(
77 processor_t
*processor
,
78 ipi_handler_t
*ipi_handler
,
81 /* Initialize Interrupts */
82 void ml_install_interrupt_handler(
86 IOInterruptHandler handler
,
89 #ifdef __APPLE_API_UNSTABLE
94 /* PCI config cycle probing */
95 boolean_t
ml_probe_read(
98 boolean_t
ml_probe_read_64(
102 /* Read physical address byte */
103 unsigned int ml_phys_read_byte(
105 unsigned int ml_phys_read_byte_64(
108 /* Read physical address half word */
109 unsigned int ml_phys_read_half(
111 unsigned int ml_phys_read_half_64(
114 /* Read physical address word*/
115 unsigned int ml_phys_read(
117 unsigned int ml_phys_read_64(
119 unsigned int ml_phys_read_word(
121 unsigned int ml_phys_read_word_64(
124 /* Read physical address double word */
125 unsigned long long ml_phys_read_double(
127 unsigned long long ml_phys_read_double_64(
130 /* Write physical address byte */
131 void ml_phys_write_byte(
132 vm_offset_t paddr
, unsigned int data
);
133 void ml_phys_write_byte_64(
134 addr64_t paddr
, unsigned int data
);
136 /* Write physical address half word */
137 void ml_phys_write_half(
138 vm_offset_t paddr
, unsigned int data
);
139 void ml_phys_write_half_64(
140 addr64_t paddr
, unsigned int data
);
142 /* Write physical address word */
144 vm_offset_t paddr
, unsigned int data
);
145 void ml_phys_write_64(
146 addr64_t paddr
, unsigned int data
);
147 void ml_phys_write_word(
148 vm_offset_t paddr
, unsigned int data
);
149 void ml_phys_write_word_64(
150 addr64_t paddr
, unsigned int data
);
152 /* Write physical address double word */
153 void ml_phys_write_double(
154 vm_offset_t paddr
, unsigned long long data
);
155 void ml_phys_write_double_64(
156 addr64_t paddr
, unsigned long long data
);
158 void ml_static_mfree(
162 /* virtual to physical on wired pages */
163 vm_offset_t
ml_vtophys(
166 /* Struct for ml_cpu_get_info */
168 unsigned long vector_unit
;
169 unsigned long cache_line_size
;
170 unsigned long l1_icache_size
;
171 unsigned long l1_dcache_size
;
172 unsigned long l2_settings
;
173 unsigned long l2_cache_size
;
174 unsigned long l3_settings
;
175 unsigned long l3_cache_size
;
178 typedef struct ml_cpu_info ml_cpu_info_t
;
180 /* Get processor info */
181 void ml_cpu_get_info(ml_cpu_info_t
*cpu_info
);
183 #endif /* __APPLE_API_UNSTABLE */
185 #ifdef __APPLE_API_PRIVATE
186 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
187 /* IO memory map services */
189 /* Map memory map IO space */
190 vm_offset_t
ml_io_map(
191 vm_offset_t phys_addr
,
194 /* boot memory allocation */
195 vm_offset_t
ml_static_malloc(
198 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
200 /* Zero bytes starting at a physical address */
202 addr64_t phys_address
,
205 #ifdef MACH_KERNEL_PRIVATE
207 void machine_idle(void);
209 void machine_signal_idle(
210 processor_t processor
);
211 #endif /* MACH_KERNEL_PRIVATE */
213 void ml_thread_policy(
216 unsigned policy_info
);
218 #define MACHINE_GROUP 0x00000001
219 #define MACHINE_NETWORK_GROUP 0x10000000
220 #define MACHINE_NETWORK_WORKLOOP 0x00000001
221 #define MACHINE_NETWORK_NETISR 0x00000002
223 /* Initialize the maximum number of CPUs */
224 void ml_init_max_cpus(
225 unsigned long max_cpus
);
227 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
231 #endif /* __APPLE_API_PRIVATE */
233 #endif /* _I386_MACHINE_ROUTINES_H_ */