]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
6601e61a | 4 | * @APPLE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
6601e61a A |
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. | |
8f6c56a5 | 11 | * |
6601e61a A |
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 | |
8f6c56a5 A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
6601e61a A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
8f6c56a5 | 19 | * |
6601e61a | 20 | * @APPLE_LICENSE_HEADER_END@ |
1c79356b A |
21 | */ |
22 | /* | |
23 | * @OSF_COPYRIGHT@ | |
24 | */ | |
25 | ||
26 | #ifndef _I386_MACHINE_ROUTINES_H_ | |
27 | #define _I386_MACHINE_ROUTINES_H_ | |
28 | ||
29 | #include <mach/mach_types.h> | |
30 | #include <mach/boolean.h> | |
31 | #include <kern/kern_types.h> | |
32 | #include <pexpert/pexpert.h> | |
33 | ||
91447636 | 34 | #include <sys/cdefs.h> |
9bccf70c | 35 | #include <sys/appleapiopts.h> |
1c79356b | 36 | |
91447636 A |
37 | __BEGIN_DECLS |
38 | ||
1c79356b A |
39 | /* Interrupt handling */ |
40 | ||
55e303ae A |
41 | /* Initialize Interrupts */ |
42 | void ml_init_interrupt(void); | |
43 | ||
1c79356b A |
44 | /* Get Interrupts Enabled */ |
45 | boolean_t ml_get_interrupts_enabled(void); | |
46 | ||
47 | /* Set Interrupts Enabled */ | |
48 | boolean_t ml_set_interrupts_enabled(boolean_t enable); | |
49 | ||
50 | /* Check if running at interrupt context */ | |
51 | boolean_t ml_at_interrupt_context(void); | |
52 | ||
53 | /* Generate a fake interrupt */ | |
54 | void ml_cause_interrupt(void); | |
55 | ||
9bccf70c | 56 | void ml_get_timebase(unsigned long long *timestamp); |
d52fe63f | 57 | |
55e303ae A |
58 | /* Type for the Time Base Enable function */ |
59 | typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable); | |
60 | ||
9bccf70c A |
61 | /* Type for the IPI Hander */ |
62 | typedef void (*ipi_handler_t)(void); | |
63 | ||
55e303ae A |
64 | /* Struct for ml_processor_register */ |
65 | struct ml_processor_info { | |
66 | cpu_id_t cpu_id; | |
67 | boolean_t boot_cpu; | |
68 | vm_offset_t start_paddr; | |
69 | boolean_t supports_nap; | |
70 | unsigned long l2cr_value; | |
71 | time_base_enable_t time_base_enable; | |
72 | }; | |
73 | ||
74 | typedef struct ml_processor_info ml_processor_info_t; | |
75 | ||
91447636 | 76 | |
9bccf70c A |
77 | /* Register a processor */ |
78 | kern_return_t ml_processor_register( | |
55e303ae A |
79 | cpu_id_t cpu_id, |
80 | uint32_t lapic_id, | |
81 | processor_t *processor, | |
82 | ipi_handler_t *ipi_handler, | |
9bccf70c | 83 | boolean_t boot_cpu); |
d52fe63f | 84 | |
1c79356b A |
85 | /* Initialize Interrupts */ |
86 | void ml_install_interrupt_handler( | |
87 | void *nub, | |
88 | int source, | |
89 | void *target, | |
90 | IOInterruptHandler handler, | |
91 | void *refCon); | |
92 | ||
9bccf70c A |
93 | #ifdef __APPLE_API_UNSTABLE |
94 | vm_offset_t | |
95 | ml_static_ptovirt( | |
96 | vm_offset_t); | |
97 | ||
43866e37 A |
98 | /* PCI config cycle probing */ |
99 | boolean_t ml_probe_read( | |
100 | vm_offset_t paddr, | |
101 | unsigned int *val); | |
55e303ae A |
102 | boolean_t ml_probe_read_64( |
103 | addr64_t paddr, | |
104 | unsigned int *val); | |
43866e37 A |
105 | |
106 | /* Read physical address byte */ | |
107 | unsigned int ml_phys_read_byte( | |
108 | vm_offset_t paddr); | |
55e303ae A |
109 | unsigned int ml_phys_read_byte_64( |
110 | addr64_t paddr); | |
43866e37 A |
111 | |
112 | /* Read physical address half word */ | |
113 | unsigned int ml_phys_read_half( | |
114 | vm_offset_t paddr); | |
55e303ae A |
115 | unsigned int ml_phys_read_half_64( |
116 | addr64_t paddr); | |
43866e37 A |
117 | |
118 | /* Read physical address word*/ | |
119 | unsigned int ml_phys_read( | |
120 | vm_offset_t paddr); | |
55e303ae A |
121 | unsigned int ml_phys_read_64( |
122 | addr64_t paddr); | |
43866e37 A |
123 | unsigned int ml_phys_read_word( |
124 | vm_offset_t paddr); | |
55e303ae A |
125 | unsigned int ml_phys_read_word_64( |
126 | addr64_t paddr); | |
43866e37 A |
127 | |
128 | /* Read physical address double word */ | |
129 | unsigned long long ml_phys_read_double( | |
130 | vm_offset_t paddr); | |
55e303ae A |
131 | unsigned long long ml_phys_read_double_64( |
132 | addr64_t paddr); | |
43866e37 A |
133 | |
134 | /* Write physical address byte */ | |
135 | void ml_phys_write_byte( | |
136 | vm_offset_t paddr, unsigned int data); | |
55e303ae A |
137 | void ml_phys_write_byte_64( |
138 | addr64_t paddr, unsigned int data); | |
43866e37 A |
139 | |
140 | /* Write physical address half word */ | |
141 | void ml_phys_write_half( | |
142 | vm_offset_t paddr, unsigned int data); | |
55e303ae A |
143 | void ml_phys_write_half_64( |
144 | addr64_t paddr, unsigned int data); | |
43866e37 A |
145 | |
146 | /* Write physical address word */ | |
147 | void ml_phys_write( | |
148 | vm_offset_t paddr, unsigned int data); | |
55e303ae A |
149 | void ml_phys_write_64( |
150 | addr64_t paddr, unsigned int data); | |
43866e37 A |
151 | void ml_phys_write_word( |
152 | vm_offset_t paddr, unsigned int data); | |
55e303ae A |
153 | void ml_phys_write_word_64( |
154 | addr64_t paddr, unsigned int data); | |
43866e37 A |
155 | |
156 | /* Write physical address double word */ | |
157 | void ml_phys_write_double( | |
158 | vm_offset_t paddr, unsigned long long data); | |
55e303ae A |
159 | void ml_phys_write_double_64( |
160 | addr64_t paddr, unsigned long long data); | |
43866e37 | 161 | |
9bccf70c A |
162 | void ml_static_mfree( |
163 | vm_offset_t, | |
164 | vm_size_t); | |
165 | ||
166 | /* virtual to physical on wired pages */ | |
167 | vm_offset_t ml_vtophys( | |
168 | vm_offset_t vaddr); | |
169 | ||
43866e37 A |
170 | /* Struct for ml_cpu_get_info */ |
171 | struct ml_cpu_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; | |
180 | }; | |
181 | ||
182 | typedef struct ml_cpu_info ml_cpu_info_t; | |
183 | ||
184 | /* Get processor info */ | |
91447636 | 185 | void ml_cpu_get_info(ml_cpu_info_t *ml_cpu_info); |
43866e37 | 186 | |
9bccf70c A |
187 | #endif /* __APPLE_API_UNSTABLE */ |
188 | ||
189 | #ifdef __APPLE_API_PRIVATE | |
190 | #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE) | |
191 | /* IO memory map services */ | |
192 | ||
193 | /* Map memory map IO space */ | |
194 | vm_offset_t ml_io_map( | |
195 | vm_offset_t phys_addr, | |
196 | vm_size_t size); | |
197 | ||
198 | /* boot memory allocation */ | |
199 | vm_offset_t ml_static_malloc( | |
200 | vm_size_t size); | |
201 | ||
202 | #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */ | |
203 | ||
55e303ae A |
204 | /* Zero bytes starting at a physical address */ |
205 | void bzero_phys( | |
206 | addr64_t phys_address, | |
207 | uint32_t length); | |
208 | ||
9bccf70c A |
209 | void ml_thread_policy( |
210 | thread_t thread, | |
211 | unsigned policy_id, | |
212 | unsigned policy_info); | |
1c79356b | 213 | |
9bccf70c A |
214 | #define MACHINE_GROUP 0x00000001 |
215 | #define MACHINE_NETWORK_GROUP 0x10000000 | |
216 | #define MACHINE_NETWORK_WORKLOOP 0x00000001 | |
217 | #define MACHINE_NETWORK_NETISR 0x00000002 | |
1c79356b | 218 | |
43866e37 A |
219 | /* Initialize the maximum number of CPUs */ |
220 | void ml_init_max_cpus( | |
221 | unsigned long max_cpus); | |
222 | ||
223 | /* Return the maximum number of CPUs set by ml_init_max_cpus() */ | |
224 | int ml_get_max_cpus( | |
225 | void); | |
226 | ||
91447636 A |
227 | extern void ml_cpu_up(void); |
228 | extern void ml_cpu_down(void); | |
229 | ||
230 | extern int set_be_bit(void); | |
231 | extern int clr_be_bit(void); | |
232 | extern int be_tracing(void); | |
233 | ||
9bccf70c | 234 | #endif /* __APPLE_API_PRIVATE */ |
1c79356b | 235 | |
91447636 A |
236 | __END_DECLS |
237 | ||
1c79356b | 238 | #endif /* _I386_MACHINE_ROUTINES_H_ */ |