]> git.saurik.com Git - apple/xnu.git/blob - pexpert/pexpert/pexpert.h
b57d59edb2a57a74ffb3dc7cc7fae61648fc8cd5
[apple/xnu.git] / pexpert / pexpert / pexpert.h
1 /*
2 * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 #ifndef _PEXPERT_PEXPERT_H_
29 #define _PEXPERT_PEXPERT_H_
30
31 #include <sys/cdefs.h>
32
33 #include <IOKit/IOInterrupts.h>
34 #include <kern/kern_types.h>
35
36 __BEGIN_DECLS
37 #include <mach/boolean.h>
38 #include <mach/kern_return.h>
39 #include <mach/machine/vm_types.h>
40
41 #ifdef PEXPERT_KERNEL_PRIVATE
42 #include <pexpert/protos.h>
43 #endif
44 #include <pexpert/boot.h>
45
46 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(IOKIT_KERNEL_PRIVATE)
47 typedef void *cpu_id_t;
48 #else
49 typedef void *cpu_id_t;
50 #endif
51
52
53 void PE_enter_debugger(
54 const char *cause);
55
56 void PE_init_platform(
57 boolean_t vm_initialized,
58 void *args);
59
60
61
62
63 void PE_init_kprintf(
64 boolean_t vm_initialized);
65
66 extern int32_t gPESerialBaud;
67
68 unsigned int PE_init_taproot(vm_offset_t *taddr);
69
70 extern void (*PE_kputc)(char c);
71
72 void PE_init_printf(
73 boolean_t vm_initialized);
74
75 extern void (*PE_putc)(char c);
76
77 void PE_init_iokit(
78 void);
79
80 struct clock_frequency_info_t {
81 unsigned long bus_clock_rate_hz;
82 unsigned long cpu_clock_rate_hz;
83 unsigned long dec_clock_rate_hz;
84 unsigned long bus_clock_rate_num;
85 unsigned long bus_clock_rate_den;
86 unsigned long bus_to_cpu_rate_num;
87 unsigned long bus_to_cpu_rate_den;
88 unsigned long bus_to_dec_rate_num;
89 unsigned long bus_to_dec_rate_den;
90 unsigned long timebase_frequency_hz;
91 unsigned long timebase_frequency_num;
92 unsigned long timebase_frequency_den;
93 unsigned long long bus_frequency_hz;
94 unsigned long long bus_frequency_min_hz;
95 unsigned long long bus_frequency_max_hz;
96 unsigned long long cpu_frequency_hz;
97 unsigned long long cpu_frequency_min_hz;
98 unsigned long long cpu_frequency_max_hz;
99 unsigned long long prf_frequency_hz;
100 unsigned long long prf_frequency_min_hz;
101 unsigned long long prf_frequency_max_hz;
102 unsigned long long mem_frequency_hz;
103 unsigned long long mem_frequency_min_hz;
104 unsigned long long mem_frequency_max_hz;
105 unsigned long long fix_frequency_hz;
106 };
107
108 typedef struct clock_frequency_info_t clock_frequency_info_t;
109
110 extern clock_frequency_info_t gPEClockFrequencyInfo;
111
112 struct timebase_freq_t {
113 unsigned long timebase_num;
114 unsigned long timebase_den;
115 };
116
117 typedef void (*timebase_callback_func)(struct timebase_freq_t *timebase_freq);
118
119 void PE_register_timebase_callback(timebase_callback_func callback);
120
121 void PE_call_timebase_callback(void);
122
123 void PE_install_interrupt_handler(
124 void *nub, int source,
125 void *target, IOInterruptHandler handler, void *refCon);
126
127 #ifndef _FN_KPRINTF
128 #define _FN_KPRINTF
129 void kprintf(const char *fmt, ...) __printflike(1,2);
130 #endif
131
132 #if KERNEL_PRIVATE
133 void _consume_kprintf_args(int, ...);
134 #endif
135
136 #if CONFIG_NO_KPRINTF_STRINGS
137 #if KERNEL_PRIVATE
138 #define kprintf(x, ...) _consume_kprintf_args( 0, ## __VA_ARGS__ )
139 #else
140 #define kprintf(x, ...) do {} while (0)
141 #endif
142 #endif
143
144 void init_display_putc(unsigned char *baseaddr, int rowbytes, int height);
145 void display_putc(char c);
146
147 enum {
148 kPEReadTOD,
149 kPEWriteTOD
150 };
151 extern int (*PE_read_write_time_of_day)(
152 unsigned int options,
153 long * secs);
154
155 enum {
156 kPEWaitForInput = 0x00000001,
157 kPERawInput = 0x00000002
158 };
159 extern int (*PE_poll_input)(
160 unsigned int options,
161 char * c);
162
163 extern int (*PE_write_IIC)(
164 unsigned char addr,
165 unsigned char reg,
166 unsigned char data);
167
168 /* Private Stuff - eventually put in pexpertprivate.h */
169 enum {
170 kDebugTypeNone = 0,
171 kDebugTypeDisplay = 1,
172 kDebugTypeSerial = 2
173 };
174
175 struct PE_Video {
176 unsigned long v_baseAddr; /* Base address of video memory */
177 unsigned long v_rowBytes; /* Number of bytes per pixel row */
178 unsigned long v_width; /* Width */
179 unsigned long v_height; /* Height */
180 unsigned long v_depth; /* Pixel Depth */
181 unsigned long v_display; /* Text or Graphics */
182 char v_pixelFormat[64];
183 unsigned long v_offset; /* offset into video memory to start at */
184 unsigned long v_length; /* length of video memory (0 for v_rowBytes * v_height) */
185 unsigned char v_rotate; /* Rotation: 0:normal, 1:right 90, 2:left 180, 3:left 90 */
186 unsigned char v_scale; /* Scale Factor for both X & Y */
187 char reserved1[2];
188 #ifdef __LP64__
189 long reserved2;
190 #else
191 long v_baseAddrHigh;
192 #endif
193 };
194
195 typedef struct PE_Video PE_Video;
196
197 extern void initialize_screen(PE_Video *, unsigned int);
198
199 extern void dim_screen(void);
200
201 extern int PE_current_console(
202 PE_Video *info);
203
204 extern void PE_create_console(
205 void);
206
207 extern int PE_initialize_console(
208 PE_Video *newInfo,
209 int op);
210
211 #define kPEGraphicsMode 1
212 #define kPETextMode 2
213 #define kPETextScreen 3
214 #define kPEAcquireScreen 4
215 #define kPEReleaseScreen 5
216 #define kPEEnableScreen 6
217 #define kPEDisableScreen 7
218 #define kPEBaseAddressChange 8
219
220 extern void PE_display_icon( unsigned int flags,
221 const char * name );
222
223 typedef struct PE_state {
224 boolean_t initialized;
225 PE_Video video;
226 void *deviceTreeHead;
227 void *bootArgs;
228 } PE_state_t;
229
230 extern PE_state_t PE_state;
231
232 extern char * PE_boot_args(
233 void);
234
235 #if !defined(__LP64__) && !defined(__arm__)
236 extern boolean_t PE_parse_boot_arg(
237 const char *arg_string,
238 void *arg_ptr) __deprecated;
239 #endif
240
241 extern boolean_t PE_parse_boot_argn(
242 const char *arg_string,
243 void *arg_ptr,
244 int max_arg);
245
246 extern boolean_t PE_get_default(
247 const char *property_name,
248 void *property_ptr,
249 unsigned int max_property);
250
251 #define PE_default_value(_key, _variable, _default) \
252 do { \
253 if (!PE_get_default((_key), &(_variable), sizeof(_variable))) \
254 _variable = _default; \
255 } while(0)
256
257 enum {
258 kPEOptionKey = 0x3a,
259 kPECommandKey = 0x37,
260 kPEControlKey = 0x36,
261 kPEShiftKey = 0x38
262 };
263
264 extern boolean_t PE_get_hotkey(
265 unsigned char key);
266
267 extern kern_return_t PE_cpu_start(
268 cpu_id_t target,
269 vm_offset_t start_paddr,
270 vm_offset_t arg_paddr);
271
272 extern void PE_cpu_halt(
273 cpu_id_t target);
274
275 extern void PE_cpu_signal(
276 cpu_id_t source,
277 cpu_id_t target);
278
279 extern void PE_cpu_machine_init(
280 cpu_id_t target,
281 boolean_t bootb);
282
283 extern void PE_cpu_machine_quiesce(
284 cpu_id_t target);
285
286 extern void pe_init_debug(void);
287
288 extern boolean_t PE_imgsrc_mount_supported(void);
289
290
291 #if KERNEL_PRIVATE
292 boolean_t PE_reboot_on_panic(void);
293 #endif
294
295 __END_DECLS
296
297 #endif /* _PEXPERT_PEXPERT_H_ */