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