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