]> git.saurik.com Git - apple/xnu.git/blob - pexpert/pexpert/pexpert.h
d69c8cbd1188a939e1216ba24398ad83f45b6fd1
[apple/xnu.git] / pexpert / pexpert / pexpert.h
1 /*
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 #ifndef _PEXPERT_PEXPERT_H_
23 #define _PEXPERT_PEXPERT_H_
24
25 #include <sys/cdefs.h>
26
27 #include <IOKit/IOInterrupts.h>
28 #include <kern/kern_types.h>
29
30 __BEGIN_DECLS
31 #include <mach/boolean.h>
32 #include <mach/kern_return.h>
33 #include <mach/machine/vm_types.h>
34
35 #ifdef PEXPERT_KERNEL_PRIVATE
36 #include <pexpert/protos.h>
37 #endif
38 #include <pexpert/boot.h>
39
40 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(IOKIT_KERNEL_PRIVATE)
41 typedef void *cpu_id_t;
42 #else
43 typedef void *cpu_id_t;
44 #endif
45
46
47 void PE_enter_debugger(
48 char *cause);
49
50 void PE_init_platform(
51 boolean_t vm_initialized,
52 void *args);
53
54 void PE_init_kprintf(
55 boolean_t vm_initialized);
56
57 extern int32_t gPESerialBaud;
58
59 unsigned int PE_init_taproot(vm_offset_t *taddr);
60
61 extern void (*PE_kputc)(char c);
62
63 void PE_init_printf(
64 boolean_t vm_initialized);
65
66 extern void (*PE_putc)(char c);
67
68 void PE_init_iokit(
69 void);
70
71 struct clock_frequency_info_t {
72 unsigned long bus_clock_rate_hz;
73 unsigned long cpu_clock_rate_hz;
74 unsigned long dec_clock_rate_hz;
75 unsigned long bus_clock_rate_num;
76 unsigned long bus_clock_rate_den;
77 unsigned long bus_to_cpu_rate_num;
78 unsigned long bus_to_cpu_rate_den;
79 unsigned long bus_to_dec_rate_num;
80 unsigned long bus_to_dec_rate_den;
81 unsigned long timebase_frequency_hz;
82 unsigned long timebase_frequency_num;
83 unsigned long timebase_frequency_den;
84 unsigned long long bus_frequency_hz;
85 unsigned long long bus_frequency_min_hz;
86 unsigned long long bus_frequency_max_hz;
87 unsigned long long cpu_frequency_hz;
88 unsigned long long cpu_frequency_min_hz;
89 unsigned long long cpu_frequency_max_hz;
90 };
91
92 typedef struct clock_frequency_info_t clock_frequency_info_t;
93
94 extern clock_frequency_info_t gPEClockFrequencyInfo;
95
96 struct timebase_freq_t {
97 unsigned long timebase_num;
98 unsigned long timebase_den;
99 };
100
101 typedef void (*timebase_callback_func)(struct timebase_freq_t *timebase_freq);
102
103 void PE_register_timebase_callback(timebase_callback_func callback);
104
105 void PE_call_timebase_callback(void);
106
107 void PE_install_interrupt_handler(
108 void *nub, int source,
109 void *target, IOInterruptHandler handler, void *refCon);
110
111 #ifndef _FN_KPRINTF
112 #define _FN_KPRINTF
113 void kprintf(const char *fmt, ...);
114 #endif
115
116 void init_display_putc(unsigned char *baseaddr, int rowbytes, int height);
117 void display_putc(char c);
118
119 enum {
120 kPEReadTOD,
121 kPEWriteTOD
122 };
123 extern int (*PE_read_write_time_of_day)(
124 unsigned int options,
125 long * secs);
126
127 enum {
128 kPEWaitForInput = 0x00000001,
129 kPERawInput = 0x00000002
130 };
131 extern int (*PE_poll_input)(
132 unsigned int options,
133 char * c);
134
135 extern int (*PE_write_IIC)(
136 unsigned char addr,
137 unsigned char reg,
138 unsigned char data);
139
140 /* Private Stuff - eventually put in pexpertprivate.h */
141 enum {
142 kDebugTypeNone = 0,
143 kDebugTypeDisplay = 1,
144 kDebugTypeSerial = 2
145 };
146
147 struct PE_Video {
148 unsigned long v_baseAddr; /* Base address of video memory */
149 unsigned long v_rowBytes; /* Number of bytes per pixel row */
150 unsigned long v_width; /* Width */
151 unsigned long v_height; /* Height */
152 unsigned long v_depth; /* Pixel Depth */
153 unsigned long v_display; /* Text or Graphics */
154 char v_pixelFormat[64];
155 long v_resv[ 4 ];
156 };
157
158 typedef struct PE_Video PE_Video;
159
160 extern int PE_current_console(
161 PE_Video *info);
162
163 extern void PE_create_console(
164 void);
165
166 extern int PE_initialize_console(
167 PE_Video *newInfo,
168 int op);
169
170 #define kPEGraphicsMode 1
171 #define kPETextMode 2
172 #define kPETextScreen 3
173 #define kPEAcquireScreen 4
174 #define kPEReleaseScreen 5
175 #define kPEEnableScreen 6
176 #define kPEDisableScreen 7
177
178 extern void PE_display_icon( unsigned int flags,
179 const char * name );
180
181 typedef struct PE_state {
182 boolean_t initialized;
183 PE_Video video;
184 void *deviceTreeHead;
185 void *bootArgs;
186 #if __i386__
187 void *fakePPCBootArgs;
188 #endif
189 } PE_state_t;
190
191 extern PE_state_t PE_state;
192
193 extern char * PE_boot_args(
194 void);
195
196 extern boolean_t PE_parse_boot_arg(
197 const char *arg_string,
198 void *arg_ptr);
199
200 extern boolean_t PE_parse_boot_argn(
201 const char *arg_string,
202 void *arg_ptr,
203 int max_arg);
204
205 enum {
206 kPEOptionKey = 0x3a,
207 kPECommandKey = 0x37,
208 kPEControlKey = 0x36,
209 kPEShiftKey = 0x38
210 };
211
212 extern boolean_t PE_get_hotkey(
213 unsigned char key);
214
215 extern kern_return_t PE_cpu_start(
216 cpu_id_t target,
217 vm_offset_t start_paddr,
218 vm_offset_t arg_paddr);
219
220 extern void PE_cpu_halt(
221 cpu_id_t target);
222
223 extern void PE_cpu_signal(
224 cpu_id_t source,
225 cpu_id_t target);
226
227 extern void PE_cpu_machine_init(
228 cpu_id_t target,
229 boolean_t boot);
230
231 extern void PE_cpu_machine_quiesce(
232 cpu_id_t target);
233
234 extern void pe_init_debug(void);
235
236 __END_DECLS
237
238 #endif /* _PEXPERT_PEXPERT_H_ */