]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/machine_routines.h
607db91d0cae5b9809bb15c0e31f979205df7e63
[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
84 /* Read physical address byte */
85 unsigned int ml_phys_read_byte(
86 vm_offset_t paddr);
87
88 /* Read physical address half word */
89 unsigned int ml_phys_read_half(
90 vm_offset_t paddr);
91
92 /* Read physical address word*/
93 unsigned int ml_phys_read(
94 vm_offset_t paddr);
95 unsigned int ml_phys_read_word(
96 vm_offset_t paddr);
97
98 /* Read physical address double word */
99 unsigned long long ml_phys_read_double(
100 vm_offset_t paddr);
101
102 /* Write physical address byte */
103 void ml_phys_write_byte(
104 vm_offset_t paddr, unsigned int data);
105
106 /* Write physical address half word */
107 void ml_phys_write_half(
108 vm_offset_t paddr, unsigned int data);
109
110 /* Write physical address word */
111 void ml_phys_write(
112 vm_offset_t paddr, unsigned int data);
113 void ml_phys_write_word(
114 vm_offset_t paddr, unsigned int data);
115
116 /* Write physical address double word */
117 void ml_phys_write_double(
118 vm_offset_t paddr, unsigned long long data);
119
120 void ml_static_mfree(
121 vm_offset_t,
122 vm_size_t);
123
124 /* virtual to physical on wired pages */
125 vm_offset_t ml_vtophys(
126 vm_offset_t vaddr);
127
128 /* Struct for ml_cpu_get_info */
129 struct ml_cpu_info {
130 unsigned long vector_unit;
131 unsigned long cache_line_size;
132 unsigned long l1_icache_size;
133 unsigned long l1_dcache_size;
134 unsigned long l2_settings;
135 unsigned long l2_cache_size;
136 unsigned long l3_settings;
137 unsigned long l3_cache_size;
138 };
139
140 typedef struct ml_cpu_info ml_cpu_info_t;
141
142 /* Get processor info */
143 void ml_cpu_get_info(ml_cpu_info_t *cpu_info);
144
145 #endif /* __APPLE_API_UNSTABLE */
146
147 #ifdef __APPLE_API_PRIVATE
148 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(MACH_KERNEL_PRIVATE)
149 /* IO memory map services */
150
151 /* Map memory map IO space */
152 vm_offset_t ml_io_map(
153 vm_offset_t phys_addr,
154 vm_size_t size);
155
156 /* boot memory allocation */
157 vm_offset_t ml_static_malloc(
158 vm_size_t size);
159
160 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE */
161
162 #ifdef MACH_KERNEL_PRIVATE
163 /* check pending timers */
164 #define machine_clock_assist()
165
166 void machine_idle(void);
167
168 void machine_signal_idle(
169 processor_t processor);
170 #endif /* MACH_KERNEL_PRIVATE */
171
172 void ml_thread_policy(
173 thread_t thread,
174 unsigned policy_id,
175 unsigned policy_info);
176
177 #define MACHINE_GROUP 0x00000001
178 #define MACHINE_NETWORK_GROUP 0x10000000
179 #define MACHINE_NETWORK_WORKLOOP 0x00000001
180 #define MACHINE_NETWORK_NETISR 0x00000002
181
182 /* Initialize the maximum number of CPUs */
183 void ml_init_max_cpus(
184 unsigned long max_cpus);
185
186 /* Return the maximum number of CPUs set by ml_init_max_cpus() */
187 int ml_get_max_cpus(
188 void);
189
190 /* Return the current number of CPUs */
191 int ml_get_current_cpus(
192 void);
193
194 #endif /* __APPLE_API_PRIVATE */
195
196 #endif /* _I386_MACHINE_ROUTINES_H_ */