]> git.saurik.com Git - apple/xnu.git/blob - pexpert/pexpert/pexpert.h
31209ff7865822a0813e2435c9b41439feae64f3
[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 void PE_init_kprintf(
62 boolean_t vm_initialized);
63
64 extern int32_t gPESerialBaud;
65
66 unsigned int PE_init_taproot(vm_offset_t *taddr);
67
68 extern void (*PE_kputc)(char c);
69
70 void PE_init_printf(
71 boolean_t vm_initialized);
72
73 extern void (*PE_putc)(char c);
74
75 void PE_init_iokit(
76 void);
77
78 struct clock_frequency_info_t {
79 unsigned long bus_clock_rate_hz;
80 unsigned long cpu_clock_rate_hz;
81 unsigned long dec_clock_rate_hz;
82 unsigned long bus_clock_rate_num;
83 unsigned long bus_clock_rate_den;
84 unsigned long bus_to_cpu_rate_num;
85 unsigned long bus_to_cpu_rate_den;
86 unsigned long bus_to_dec_rate_num;
87 unsigned long bus_to_dec_rate_den;
88 unsigned long timebase_frequency_hz;
89 unsigned long timebase_frequency_num;
90 unsigned long timebase_frequency_den;
91 unsigned long long bus_frequency_hz;
92 unsigned long long bus_frequency_min_hz;
93 unsigned long long bus_frequency_max_hz;
94 unsigned long long cpu_frequency_hz;
95 unsigned long long cpu_frequency_min_hz;
96 unsigned long long cpu_frequency_max_hz;
97 unsigned long long prf_frequency_hz;
98 unsigned long long prf_frequency_min_hz;
99 unsigned long long prf_frequency_max_hz;
100 unsigned long long mem_frequency_hz;
101 unsigned long long mem_frequency_min_hz;
102 unsigned long long mem_frequency_max_hz;
103 unsigned long long fix_frequency_hz;
104 };
105
106 typedef struct clock_frequency_info_t clock_frequency_info_t;
107
108 extern clock_frequency_info_t gPEClockFrequencyInfo;
109
110 struct timebase_freq_t {
111 unsigned long timebase_num;
112 unsigned long timebase_den;
113 };
114
115 typedef void (*timebase_callback_func)(struct timebase_freq_t *timebase_freq);
116
117 void PE_register_timebase_callback(timebase_callback_func callback);
118
119 void PE_call_timebase_callback(void);
120
121 void PE_install_interrupt_handler(
122 void *nub, int source,
123 void *target, IOInterruptHandler handler, void *refCon);
124
125 #ifndef _FN_KPRINTF
126 #define _FN_KPRINTF
127 void kprintf(const char *fmt, ...) __printflike(1,2);
128 #endif
129
130 #if KERNEL_PRIVATE
131 void _consume_kprintf_args(int, ...);
132 #endif
133
134 #if CONFIG_NO_KPRINTF_STRINGS
135 #if KERNEL_PRIVATE
136 #define kprintf(x, ...) _consume_kprintf_args( 0, ## __VA_ARGS__ )
137 #else
138 #define kprintf(x, ...) do {} while (0)
139 #endif
140 #endif
141
142 void init_display_putc(unsigned char *baseaddr, int rowbytes, int height);
143 void display_putc(char c);
144
145 enum {
146 kPEReadTOD,
147 kPEWriteTOD
148 };
149 extern int (*PE_read_write_time_of_day)(
150 unsigned int options,
151 long * secs);
152
153 enum {
154 kPEWaitForInput = 0x00000001,
155 kPERawInput = 0x00000002
156 };
157 extern int (*PE_poll_input)(
158 unsigned int options,
159 char * c);
160
161 extern int (*PE_write_IIC)(
162 unsigned char addr,
163 unsigned char reg,
164 unsigned char data);
165
166 /* Private Stuff - eventually put in pexpertprivate.h */
167 enum {
168 kDebugTypeNone = 0,
169 kDebugTypeDisplay = 1,
170 kDebugTypeSerial = 2
171 };
172
173 /* Scale factor values for PE_Video.v_scale */
174 enum {
175 kPEScaleFactorUnknown = 0,
176 kPEScaleFactor1x = 1,
177 kPEScaleFactor2x = 2
178 };
179
180 struct PE_Video {
181 unsigned long v_baseAddr; /* Base address of video memory */
182 unsigned long v_rowBytes; /* Number of bytes per pixel row */
183 unsigned long v_width; /* Width */
184 unsigned long v_height; /* Height */
185 unsigned long v_depth; /* Pixel Depth */
186 unsigned long v_display; /* Text or Graphics */
187 char v_pixelFormat[64];
188 unsigned long v_offset; /* offset into video memory to start at */
189 unsigned long v_length; /* length of video memory (0 for v_rowBytes * v_height) */
190 unsigned char v_rotate; /* Rotation: 0:normal, 1:right 90, 2:left 180, 3:left 90 */
191 unsigned char v_scale; /* Scale Factor for both X & Y */
192 char reserved1[2];
193 #ifdef __LP64__
194 long reserved2;
195 #else
196 long v_baseAddrHigh;
197 #endif
198 };
199
200 typedef struct PE_Video PE_Video;
201
202 extern void initialize_screen(PE_Video *, unsigned int);
203
204 extern void dim_screen(void);
205
206 extern int PE_current_console(
207 PE_Video *info);
208
209 extern void PE_create_console(
210 void);
211
212 extern int PE_initialize_console(
213 PE_Video *newInfo,
214 int op);
215
216 #define kPEGraphicsMode 1
217 #define kPETextMode 2
218 #define kPETextScreen 3
219 #define kPEAcquireScreen 4
220 #define kPEReleaseScreen 5
221 #define kPEEnableScreen 6
222 #define kPEDisableScreen 7
223 #define kPEBaseAddressChange 8
224
225 extern void PE_display_icon( unsigned int flags,
226 const char * name );
227
228 typedef struct PE_state {
229 boolean_t initialized;
230 PE_Video video;
231 void *deviceTreeHead;
232 void *bootArgs;
233 } PE_state_t;
234
235 extern PE_state_t PE_state;
236
237 extern char * PE_boot_args(
238 void);
239
240 #if !defined(__LP64__) && !defined(__arm__)
241 extern boolean_t PE_parse_boot_arg(
242 const char *arg_string,
243 void *arg_ptr) __deprecated;
244 #endif
245
246 extern boolean_t PE_parse_boot_argn(
247 const char *arg_string,
248 void *arg_ptr,
249 int max_arg);
250
251 extern boolean_t PE_get_default(
252 const char *property_name,
253 void *property_ptr,
254 unsigned int max_property);
255
256 #define PE_default_value(_key, _variable, _default) \
257 do { \
258 if (!PE_get_default((_key), &(_variable), sizeof(_variable))) \
259 _variable = _default; \
260 } while(0)
261
262 enum {
263 kPEOptionKey = 0x3a,
264 kPECommandKey = 0x37,
265 kPEControlKey = 0x36,
266 kPEShiftKey = 0x38
267 };
268
269 extern boolean_t PE_get_hotkey(
270 unsigned char key);
271
272 extern kern_return_t PE_cpu_start(
273 cpu_id_t target,
274 vm_offset_t start_paddr,
275 vm_offset_t arg_paddr);
276
277 extern void PE_cpu_halt(
278 cpu_id_t target);
279
280 extern void PE_cpu_signal(
281 cpu_id_t source,
282 cpu_id_t target);
283
284 extern void PE_cpu_machine_init(
285 cpu_id_t target,
286 boolean_t bootb);
287
288 extern void PE_cpu_machine_quiesce(
289 cpu_id_t target);
290
291 extern void pe_init_debug(void);
292
293 extern boolean_t PE_imgsrc_mount_supported(void);
294
295
296 #if KERNEL_PRIVATE
297 boolean_t PE_reboot_on_panic(void);
298 #endif
299
300 __END_DECLS
301
302 #endif /* _PEXPERT_PEXPERT_H_ */