]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/machine_routines.h
xnu-344.21.74.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 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
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
13 * file.
14 *
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.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * @OSF_COPYRIGHT@
27 */
28
29 #ifndef _I386_MACHINE_ROUTINES_H_
30 #define _I386_MACHINE_ROUTINES_H_
31
32 #include <mach/mach_types.h>
33 #include <mach/boolean.h>
34 #include <kern/kern_types.h>
35 #include <pexpert/pexpert.h>
36
37 #include <sys/appleapiopts.h>
38
39 /* Interrupt handling */
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 IPI Hander */
56 typedef void (*ipi_handler_t)(void);
57
58 /* Register a processor */
59 kern_return_t ml_processor_register(
60 cpu_id_t cpu_id,
61 vm_offset_t start_paddr,
62 processor_t *processor,
63 ipi_handler_t *ipi_handler,
64 boolean_t boot_cpu);
65
66 /* Initialize Interrupts */
67 void ml_install_interrupt_handler(
68 void *nub,
69 int source,
70 void *target,
71 IOInterruptHandler handler,
72 void *refCon);
73
74 #ifdef __APPLE_API_UNSTABLE
75 vm_offset_t
76 ml_static_ptovirt(
77 vm_offset_t);
78
79 /* PCI config cycle probing */
80 boolean_t ml_probe_read(
81 vm_offset_t paddr,
82 unsigned int *val);
83 boolean_t ml_probe_read_64(
84 addr64_t paddr,
85 unsigned int *val);
86
87 /* Read physical address byte */
88 unsigned int ml_phys_read_byte(
89 vm_offset_t paddr);
90 unsigned int ml_phys_read_byte_64(
91 addr64_t paddr);
92
93 /* Read physical address half word */
94 unsigned int ml_phys_read_half(
95 vm_offset_t paddr);
96 unsigned int ml_phys_read_half_64(
97 addr64_t paddr);
98
99 /* Read physical address word*/
100 unsigned int ml_phys_read(
101 vm_offset_t paddr);
102 unsigned int ml_phys_read_64(
103 addr64_t paddr);
104 unsigned int ml_phys_read_word(
105 vm_offset_t paddr);
106 unsigned int ml_phys_read_word_64(
107 addr64_t paddr);
108
109 /* Read physical address double word */
110 unsigned long long ml_phys_read_double(
111 vm_offset_t paddr);
112 unsigned long long ml_phys_read_double_64(
113 addr64_t paddr);
114
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);
120
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);
126
127 /* Write physical address word */
128 void ml_phys_write(
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);
136
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);
142
143 void ml_static_mfree(
144 vm_offset_t,
145 vm_size_t);
146
147 /* virtual to physical on wired pages */
148 vm_offset_t ml_vtophys(
149 vm_offset_t vaddr);
150
151 /* Struct for ml_cpu_get_info */
152 struct ml_cpu_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;
161 };
162
163 typedef struct ml_cpu_info ml_cpu_info_t;
164
165 /* Get processor info */
166 void ml_cpu_get_info(ml_cpu_info_t *cpu_info);
167
168 #endif /* __APPLE_API_UNSTABLE */
169
170 #ifdef __APPLE_API_PRIVATE
171 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
172 /* IO memory map services */
173
174 /* Map memory map IO space */
175 vm_offset_t ml_io_map(
176 vm_offset_t phys_addr,
177 vm_size_t size);
178
179 /* boot memory allocation */
180 vm_offset_t ml_static_malloc(
181 vm_size_t size);
182
183 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
184
185 #ifdef MACH_KERNEL_PRIVATE
186
187 void machine_idle(void);
188
189 void machine_signal_idle(
190 processor_t processor);
191 #endif /* MACH_KERNEL_PRIVATE */
192
193 void ml_thread_policy(
194 thread_t thread,
195 unsigned policy_id,
196 unsigned policy_info);
197
198 #define MACHINE_GROUP 0x00000001
199 #define MACHINE_NETWORK_GROUP 0x10000000
200 #define MACHINE_NETWORK_WORKLOOP 0x00000001
201 #define MACHINE_NETWORK_NETISR 0x00000002
202
203 /* Initialize the maximum number of CPUs */
204 void ml_init_max_cpus(
205 unsigned long max_cpus);
206
207 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
208 int ml_get_max_cpus(
209 void);
210
211 /* Return the current number of CPUs */
212 int ml_get_current_cpus(
213 void);
214
215 #endif /* __APPLE_API_PRIVATE */
216
217 #endif /* _I386_MACHINE_ROUTINES_H_ */