]> git.saurik.com Git - apple/xnu.git/blob - pexpert/pexpert/pexpert.h
506361341763945d17ebf5faa37930d42dc8837e
[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 #ifdef KERNEL
34 #include <IOKit/IOInterrupts.h>
35 #include <kern/kern_types.h>
36 #endif
37
38 __BEGIN_DECLS
39 #include <mach/boolean.h>
40 #include <mach/kern_return.h>
41 #include <mach/machine/vm_types.h>
42
43 #ifdef PEXPERT_KERNEL_PRIVATE
44 #include <pexpert/protos.h>
45 #endif
46 #include <pexpert/boot.h>
47
48 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(IOKIT_KERNEL_PRIVATE)
49 typedef void *cpu_id_t;
50 #else
51 typedef void *cpu_id_t;
52 #endif
53
54
55 void PE_enter_debugger(
56 const char *cause);
57
58 void PE_init_platform(
59 boolean_t vm_initialized,
60 void *args);
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 #ifdef KERNEL
124 void PE_install_interrupt_handler(
125 void *nub, int source,
126 void *target, IOInterruptHandler handler, void *refCon);
127 #endif
128
129 #ifndef _FN_KPRINTF
130 #define _FN_KPRINTF
131 void kprintf(const char *fmt, ...) __printflike(1,2);
132 #endif
133
134 #if KERNEL_PRIVATE
135 void _consume_kprintf_args(int, ...);
136 #endif
137
138 #if CONFIG_NO_KPRINTF_STRINGS
139 #if KERNEL_PRIVATE
140 #define kprintf(x, ...) _consume_kprintf_args( 0, ## __VA_ARGS__ )
141 #else
142 #define kprintf(x, ...) do {} while (0)
143 #endif
144 #endif
145
146 void init_display_putc(unsigned char *baseaddr, int rowbytes, int height);
147 void display_putc(char c);
148
149 enum {
150 kPEReadTOD,
151 kPEWriteTOD
152 };
153 extern int (*PE_read_write_time_of_day)(
154 unsigned int options,
155 long * secs);
156
157 enum {
158 kPEWaitForInput = 0x00000001,
159 kPERawInput = 0x00000002
160 };
161 extern int (*PE_poll_input)(
162 unsigned int options,
163 char * c);
164
165 extern int (*PE_write_IIC)(
166 unsigned char addr,
167 unsigned char reg,
168 unsigned char data);
169
170 /* Private Stuff - eventually put in pexpertprivate.h */
171 enum {
172 kDebugTypeNone = 0,
173 kDebugTypeDisplay = 1,
174 kDebugTypeSerial = 2
175 };
176
177 /* Scale factor values for PE_Video.v_scale */
178 enum {
179 kPEScaleFactorUnknown = 0,
180 kPEScaleFactor1x = 1,
181 kPEScaleFactor2x = 2
182 };
183
184 struct PE_Video {
185 unsigned long v_baseAddr; /* Base address of video memory */
186 unsigned long v_rowBytes; /* Number of bytes per pixel row */
187 unsigned long v_width; /* Width */
188 unsigned long v_height; /* Height */
189 unsigned long v_depth; /* Pixel Depth */
190 unsigned long v_display; /* Text or Graphics */
191 char v_pixelFormat[64];
192 unsigned long v_offset; /* offset into video memory to start at */
193 unsigned long v_length; /* length of video memory (0 for v_rowBytes * v_height) */
194 unsigned char v_rotate; /* Rotation: 0:normal, 1:right 90, 2:left 180, 3:left 90 */
195 unsigned char v_scale; /* Scale Factor for both X & Y */
196 char reserved1[2];
197 #ifdef __LP64__
198 long reserved2;
199 #else
200 long v_baseAddrHigh;
201 #endif
202 };
203
204 typedef struct PE_Video PE_Video;
205
206 extern void initialize_screen(PE_Video *, unsigned int);
207
208 extern void dim_screen(void);
209
210 extern int PE_current_console(
211 PE_Video *info);
212
213 extern void PE_create_console(
214 void);
215
216 extern int PE_initialize_console(
217 PE_Video *newInfo,
218 int op);
219
220 #define kPEGraphicsMode 1
221 #define kPETextMode 2
222 #define kPETextScreen 3
223 #define kPEAcquireScreen 4
224 #define kPEReleaseScreen 5
225 #define kPEEnableScreen 6
226 #define kPEDisableScreen 7
227 #define kPEBaseAddressChange 8
228
229 extern void PE_display_icon( unsigned int flags,
230 const char * name );
231
232 typedef struct PE_state {
233 boolean_t initialized;
234 PE_Video video;
235 void *deviceTreeHead;
236 void *bootArgs;
237 } PE_state_t;
238
239 extern PE_state_t PE_state;
240
241 extern char * PE_boot_args(
242 void);
243
244 #if !defined(__LP64__) && !defined(__arm__)
245 extern boolean_t PE_parse_boot_arg(
246 const char *arg_string,
247 void *arg_ptr) __deprecated;
248 #endif
249
250 extern boolean_t PE_parse_boot_argn(
251 const char *arg_string,
252 void *arg_ptr,
253 int max_arg);
254
255 extern boolean_t PE_get_default(
256 const char *property_name,
257 void *property_ptr,
258 unsigned int max_property);
259
260 #define PE_default_value(_key, _variable, _default) \
261 do { \
262 if (!PE_get_default((_key), &(_variable), sizeof(_variable))) \
263 _variable = _default; \
264 } while(0)
265
266 enum {
267 kPEOptionKey = 0x3a,
268 kPECommandKey = 0x37,
269 kPEControlKey = 0x36,
270 kPEShiftKey = 0x38
271 };
272
273 extern boolean_t PE_get_hotkey(
274 unsigned char key);
275
276 extern kern_return_t PE_cpu_start(
277 cpu_id_t target,
278 vm_offset_t start_paddr,
279 vm_offset_t arg_paddr);
280
281 extern void PE_cpu_halt(
282 cpu_id_t target);
283
284 extern void PE_cpu_signal(
285 cpu_id_t source,
286 cpu_id_t target);
287
288 extern void PE_cpu_machine_init(
289 cpu_id_t target,
290 boolean_t bootb);
291
292 extern void PE_cpu_machine_quiesce(
293 cpu_id_t target);
294
295 extern void pe_init_debug(void);
296
297 extern boolean_t PE_imgsrc_mount_supported(void);
298
299
300 #if KERNEL_PRIVATE
301 boolean_t PE_reboot_on_panic(void);
302 #endif
303
304 __END_DECLS
305
306 #endif /* _PEXPERT_PEXPERT_H_ */