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