]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/machine_routines.h
xnu-517.7.7.tar.gz
[apple/xnu.git] / osfmk / i386 / machine_routines.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
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
34 #include <sys/appleapiopts.h>
35
36 /* Interrupt handling */
37
38 /* Initialize Interrupts */
39 void ml_init_interrupt(void);
40
41 /* Get Interrupts Enabled */
42 boolean_t ml_get_interrupts_enabled(void);
43
44 /* Set Interrupts Enabled */
45 boolean_t ml_set_interrupts_enabled(boolean_t enable);
46
47 /* Check if running at interrupt context */
48 boolean_t ml_at_interrupt_context(void);
49
50 /* Generate a fake interrupt */
51 void ml_cause_interrupt(void);
52
53 void ml_get_timebase(unsigned long long *timestamp);
54
55 /* Type for the Time Base Enable function */
56 typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable);
57
58 /* Type for the IPI Hander */
59 typedef void (*ipi_handler_t)(void);
60
61 /* Struct for ml_processor_register */
62 struct ml_processor_info {
63 cpu_id_t cpu_id;
64 boolean_t boot_cpu;
65 vm_offset_t start_paddr;
66 boolean_t supports_nap;
67 unsigned long l2cr_value;
68 time_base_enable_t time_base_enable;
69 };
70
71 typedef struct ml_processor_info ml_processor_info_t;
72
73 /* Register a processor */
74 kern_return_t ml_processor_register(
75 cpu_id_t cpu_id,
76 uint32_t lapic_id,
77 processor_t *processor,
78 ipi_handler_t *ipi_handler,
79 boolean_t boot_cpu);
80
81 /* Initialize Interrupts */
82 void ml_install_interrupt_handler(
83 void *nub,
84 int source,
85 void *target,
86 IOInterruptHandler handler,
87 void *refCon);
88
89 #ifdef __APPLE_API_UNSTABLE
90 vm_offset_t
91 ml_static_ptovirt(
92 vm_offset_t);
93
94 /* PCI config cycle probing */
95 boolean_t ml_probe_read(
96 vm_offset_t paddr,
97 unsigned int *val);
98 boolean_t ml_probe_read_64(
99 addr64_t paddr,
100 unsigned int *val);
101
102 /* Read physical address byte */
103 unsigned int ml_phys_read_byte(
104 vm_offset_t paddr);
105 unsigned int ml_phys_read_byte_64(
106 addr64_t paddr);
107
108 /* Read physical address half word */
109 unsigned int ml_phys_read_half(
110 vm_offset_t paddr);
111 unsigned int ml_phys_read_half_64(
112 addr64_t paddr);
113
114 /* Read physical address word*/
115 unsigned int ml_phys_read(
116 vm_offset_t paddr);
117 unsigned int ml_phys_read_64(
118 addr64_t paddr);
119 unsigned int ml_phys_read_word(
120 vm_offset_t paddr);
121 unsigned int ml_phys_read_word_64(
122 addr64_t paddr);
123
124 /* Read physical address double word */
125 unsigned long long ml_phys_read_double(
126 vm_offset_t paddr);
127 unsigned long long ml_phys_read_double_64(
128 addr64_t paddr);
129
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);
135
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);
141
142 /* Write physical address word */
143 void ml_phys_write(
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);
151
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);
157
158 void ml_static_mfree(
159 vm_offset_t,
160 vm_size_t);
161
162 /* virtual to physical on wired pages */
163 vm_offset_t ml_vtophys(
164 vm_offset_t vaddr);
165
166 /* Struct for ml_cpu_get_info */
167 struct ml_cpu_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;
176 };
177
178 typedef struct ml_cpu_info ml_cpu_info_t;
179
180 /* Get processor info */
181 void ml_cpu_get_info(ml_cpu_info_t *cpu_info);
182
183 #endif /* __APPLE_API_UNSTABLE */
184
185 #ifdef __APPLE_API_PRIVATE
186 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
187 /* IO memory map services */
188
189 /* Map memory map IO space */
190 vm_offset_t ml_io_map(
191 vm_offset_t phys_addr,
192 vm_size_t size);
193
194 /* boot memory allocation */
195 vm_offset_t ml_static_malloc(
196 vm_size_t size);
197
198 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
199
200 /* Zero bytes starting at a physical address */
201 void bzero_phys(
202 addr64_t phys_address,
203 uint32_t length);
204
205 #ifdef MACH_KERNEL_PRIVATE
206
207 void machine_idle(void);
208
209 void machine_signal_idle(
210 processor_t processor);
211 #endif /* MACH_KERNEL_PRIVATE */
212
213 void ml_thread_policy(
214 thread_t thread,
215 unsigned policy_id,
216 unsigned policy_info);
217
218 #define MACHINE_GROUP 0x00000001
219 #define MACHINE_NETWORK_GROUP 0x10000000
220 #define MACHINE_NETWORK_WORKLOOP 0x00000001
221 #define MACHINE_NETWORK_NETISR 0x00000002
222
223 /* Initialize the maximum number of CPUs */
224 void ml_init_max_cpus(
225 unsigned long max_cpus);
226
227 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
228 int ml_get_max_cpus(
229 void);
230
231 #endif /* __APPLE_API_PRIVATE */
232
233 #endif /* _I386_MACHINE_ROUTINES_H_ */