]> git.saurik.com Git - apple/xnu.git/blame - osfmk/i386/machine_routines.h
xnu-517.tar.gz
[apple/xnu.git] / osfmk / i386 / machine_routines.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
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
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
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.
1c79356b
A
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
9bccf70c 37#include <sys/appleapiopts.h>
1c79356b
A
38
39/* Interrupt handling */
40
55e303ae
A
41/* Initialize Interrupts */
42void ml_init_interrupt(void);
43
1c79356b
A
44/* Get Interrupts Enabled */
45boolean_t ml_get_interrupts_enabled(void);
46
47/* Set Interrupts Enabled */
48boolean_t ml_set_interrupts_enabled(boolean_t enable);
49
50/* Check if running at interrupt context */
51boolean_t ml_at_interrupt_context(void);
52
53/* Generate a fake interrupt */
54void ml_cause_interrupt(void);
55
9bccf70c 56void ml_get_timebase(unsigned long long *timestamp);
d52fe63f 57
55e303ae
A
58/* Type for the Time Base Enable function */
59typedef void (*time_base_enable_t)(cpu_id_t cpu_id, boolean_t enable);
60
9bccf70c
A
61/* Type for the IPI Hander */
62typedef void (*ipi_handler_t)(void);
63
55e303ae
A
64/* Struct for ml_processor_register */
65struct 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
74typedef struct ml_processor_info ml_processor_info_t;
75
9bccf70c
A
76/* Register a processor */
77kern_return_t ml_processor_register(
55e303ae
A
78 cpu_id_t cpu_id,
79 uint32_t lapic_id,
80 processor_t *processor,
81 ipi_handler_t *ipi_handler,
9bccf70c 82 boolean_t boot_cpu);
d52fe63f 83
1c79356b
A
84/* Initialize Interrupts */
85void ml_install_interrupt_handler(
86 void *nub,
87 int source,
88 void *target,
89 IOInterruptHandler handler,
90 void *refCon);
91
9bccf70c
A
92#ifdef __APPLE_API_UNSTABLE
93vm_offset_t
94ml_static_ptovirt(
95 vm_offset_t);
96
43866e37
A
97/* PCI config cycle probing */
98boolean_t ml_probe_read(
99 vm_offset_t paddr,
100 unsigned int *val);
55e303ae
A
101boolean_t ml_probe_read_64(
102 addr64_t paddr,
103 unsigned int *val);
43866e37
A
104
105/* Read physical address byte */
106unsigned int ml_phys_read_byte(
107 vm_offset_t paddr);
55e303ae
A
108unsigned int ml_phys_read_byte_64(
109 addr64_t paddr);
43866e37
A
110
111/* Read physical address half word */
112unsigned int ml_phys_read_half(
113 vm_offset_t paddr);
55e303ae
A
114unsigned int ml_phys_read_half_64(
115 addr64_t paddr);
43866e37
A
116
117/* Read physical address word*/
118unsigned int ml_phys_read(
119 vm_offset_t paddr);
55e303ae
A
120unsigned int ml_phys_read_64(
121 addr64_t paddr);
43866e37
A
122unsigned int ml_phys_read_word(
123 vm_offset_t paddr);
55e303ae
A
124unsigned int ml_phys_read_word_64(
125 addr64_t paddr);
43866e37
A
126
127/* Read physical address double word */
128unsigned long long ml_phys_read_double(
129 vm_offset_t paddr);
55e303ae
A
130unsigned long long ml_phys_read_double_64(
131 addr64_t paddr);
43866e37
A
132
133/* Write physical address byte */
134void ml_phys_write_byte(
135 vm_offset_t paddr, unsigned int data);
55e303ae
A
136void ml_phys_write_byte_64(
137 addr64_t paddr, unsigned int data);
43866e37
A
138
139/* Write physical address half word */
140void ml_phys_write_half(
141 vm_offset_t paddr, unsigned int data);
55e303ae
A
142void ml_phys_write_half_64(
143 addr64_t paddr, unsigned int data);
43866e37
A
144
145/* Write physical address word */
146void ml_phys_write(
147 vm_offset_t paddr, unsigned int data);
55e303ae
A
148void ml_phys_write_64(
149 addr64_t paddr, unsigned int data);
43866e37
A
150void ml_phys_write_word(
151 vm_offset_t paddr, unsigned int data);
55e303ae
A
152void ml_phys_write_word_64(
153 addr64_t paddr, unsigned int data);
43866e37
A
154
155/* Write physical address double word */
156void ml_phys_write_double(
157 vm_offset_t paddr, unsigned long long data);
55e303ae
A
158void ml_phys_write_double_64(
159 addr64_t paddr, unsigned long long data);
43866e37 160
9bccf70c
A
161void ml_static_mfree(
162 vm_offset_t,
163 vm_size_t);
164
165/* virtual to physical on wired pages */
166vm_offset_t ml_vtophys(
167 vm_offset_t vaddr);
168
43866e37
A
169/* Struct for ml_cpu_get_info */
170struct ml_cpu_info {
171 unsigned long vector_unit;
172 unsigned long cache_line_size;
173 unsigned long l1_icache_size;
174 unsigned long l1_dcache_size;
175 unsigned long l2_settings;
176 unsigned long l2_cache_size;
177 unsigned long l3_settings;
178 unsigned long l3_cache_size;
179};
180
181typedef struct ml_cpu_info ml_cpu_info_t;
182
183/* Get processor info */
184void ml_cpu_get_info(ml_cpu_info_t *cpu_info);
185
9bccf70c
A
186#endif /* __APPLE_API_UNSTABLE */
187
188#ifdef __APPLE_API_PRIVATE
189#if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
190/* IO memory map services */
191
192/* Map memory map IO space */
193vm_offset_t ml_io_map(
194 vm_offset_t phys_addr,
195 vm_size_t size);
196
197/* boot memory allocation */
198vm_offset_t ml_static_malloc(
199 vm_size_t size);
200
201#endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
202
55e303ae
A
203/* Zero bytes starting at a physical address */
204void bzero_phys(
205 addr64_t phys_address,
206 uint32_t length);
207
1c79356b 208#ifdef MACH_KERNEL_PRIVATE
1c79356b
A
209
210void machine_idle(void);
211
212void machine_signal_idle(
213 processor_t processor);
9bccf70c 214#endif /* MACH_KERNEL_PRIVATE */
1c79356b 215
9bccf70c
A
216void ml_thread_policy(
217 thread_t thread,
218 unsigned policy_id,
219 unsigned policy_info);
1c79356b 220
9bccf70c
A
221#define MACHINE_GROUP 0x00000001
222#define MACHINE_NETWORK_GROUP 0x10000000
223#define MACHINE_NETWORK_WORKLOOP 0x00000001
224#define MACHINE_NETWORK_NETISR 0x00000002
1c79356b 225
43866e37
A
226/* Initialize the maximum number of CPUs */
227void ml_init_max_cpus(
228 unsigned long max_cpus);
229
230/* Return the maximum number of CPUs set by ml_init_max_cpus() */
231int ml_get_max_cpus(
232 void);
233
9bccf70c 234#endif /* __APPLE_API_PRIVATE */
1c79356b
A
235
236#endif /* _I386_MACHINE_ROUTINES_H_ */