2 * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 #ifndef _PEXPERT_PEXPERT_H_
29 #define _PEXPERT_PEXPERT_H_
31 #include <sys/cdefs.h>
34 #include <IOKit/IOInterrupts.h>
35 #include <kern/kern_types.h>
39 #include <mach/boolean.h>
40 #include <mach/kern_return.h>
41 #include <mach/machine/vm_types.h>
43 #ifdef PEXPERT_KERNEL_PRIVATE
44 #include <pexpert/protos.h>
46 #include <pexpert/boot.h>
48 #if defined(PEXPERT_KERNEL_PRIVATE) || defined(IOKIT_KERNEL_PRIVATE)
49 typedef void *cpu_id_t
;
51 typedef void *cpu_id_t
;
55 void PE_enter_debugger(
58 void PE_init_platform(
59 boolean_t vm_initialized
,
63 * Copies the requested number of bytes from the "random-seed" property in
64 * the device tree, and zeros the corresponding bytes in the device tree.
65 * Returns the number of bytes actually copied.
67 uint32_t PE_get_random_seed(
68 unsigned char * dst_random_seed
,
69 uint32_t request_size
);
71 uint32_t PE_i_can_has_debugger(
78 * Kexts should consult this bitmask to change behavior, since the kernel
79 * may be configured as RELEASE but have MACH_ASSERT enabled, or boot args
80 * may have changed the kernel behavior for statistics and kexts should
81 * participate similarly
84 #define kPEICanHasAssertions 0x00000001 /* Exceptional conditions should panic() instead of printf() */
85 #define kPEICanHasStatistics 0x00000002 /* Gather expensive statistics (that don't otherwise change behavior */
86 #define kPEICanHasDiagnosticAPI 0x00000004 /* Vend API to userspace or kexts that introspect kernel state */
88 extern uint32_t PE_i_can_has_kernel_configuration(void);
90 #endif /* KERNEL_PRIVATE */
93 boolean_t vm_initialized
);
95 extern int32_t gPESerialBaud
;
97 extern uint8_t gPlatformECID
[8];
99 unsigned int PE_init_taproot(vm_offset_t
*taddr
);
101 extern void (*PE_kputc
)(char c
);
104 boolean_t vm_initialized
);
106 extern void (*PE_putc
)(char c
);
111 struct clock_frequency_info_t
{
112 unsigned long bus_clock_rate_hz
;
113 unsigned long cpu_clock_rate_hz
;
114 unsigned long dec_clock_rate_hz
;
115 unsigned long bus_clock_rate_num
;
116 unsigned long bus_clock_rate_den
;
117 unsigned long bus_to_cpu_rate_num
;
118 unsigned long bus_to_cpu_rate_den
;
119 unsigned long bus_to_dec_rate_num
;
120 unsigned long bus_to_dec_rate_den
;
121 unsigned long timebase_frequency_hz
;
122 unsigned long timebase_frequency_num
;
123 unsigned long timebase_frequency_den
;
124 unsigned long long bus_frequency_hz
;
125 unsigned long long bus_frequency_min_hz
;
126 unsigned long long bus_frequency_max_hz
;
127 unsigned long long cpu_frequency_hz
;
128 unsigned long long cpu_frequency_min_hz
;
129 unsigned long long cpu_frequency_max_hz
;
130 unsigned long long prf_frequency_hz
;
131 unsigned long long prf_frequency_min_hz
;
132 unsigned long long prf_frequency_max_hz
;
133 unsigned long long mem_frequency_hz
;
134 unsigned long long mem_frequency_min_hz
;
135 unsigned long long mem_frequency_max_hz
;
136 unsigned long long fix_frequency_hz
;
139 typedef struct clock_frequency_info_t clock_frequency_info_t
;
141 extern clock_frequency_info_t gPEClockFrequencyInfo
;
143 struct timebase_freq_t
{
144 unsigned long timebase_num
;
145 unsigned long timebase_den
;
148 typedef void (*timebase_callback_func
)(struct timebase_freq_t
*timebase_freq
);
150 void PE_register_timebase_callback(timebase_callback_func callback
);
152 void PE_call_timebase_callback(void);
155 void PE_install_interrupt_handler(
156 void *nub
, int source
,
157 void *target
, IOInterruptHandler handler
, void *refCon
);
162 void kprintf(const char *fmt
, ...) __printflike(1,2);
166 void _consume_kprintf_args(int, ...);
169 #if CONFIG_NO_KPRINTF_STRINGS
171 #define kprintf(x, ...) _consume_kprintf_args( 0, ## __VA_ARGS__ )
173 #define kprintf(x, ...) do {} while (0)
177 void init_display_putc(unsigned char *baseaddr
, int rowbytes
, int height
);
178 void display_putc(char c
);
184 extern int (*PE_read_write_time_of_day
)(
185 unsigned int options
,
189 kPEWaitForInput
= 0x00000001,
190 kPERawInput
= 0x00000002
192 extern int (*PE_poll_input
)(
193 unsigned int options
,
196 extern int (*PE_write_IIC
)(
201 /* Private Stuff - eventually put in pexpertprivate.h */
204 kDebugTypeDisplay
= 1,
208 /* Scale factor values for PE_Video.v_scale */
210 kPEScaleFactorUnknown
= 0,
211 kPEScaleFactor1x
= 1,
216 unsigned long v_baseAddr
; /* Base address of video memory */
217 unsigned long v_rowBytes
; /* Number of bytes per pixel row */
218 unsigned long v_width
; /* Width */
219 unsigned long v_height
; /* Height */
220 unsigned long v_depth
; /* Pixel Depth */
221 unsigned long v_display
; /* Text or Graphics */
222 char v_pixelFormat
[64];
223 unsigned long v_offset
; /* offset into video memory to start at */
224 unsigned long v_length
; /* length of video memory (0 for v_rowBytes * v_height) */
225 unsigned char v_rotate
; /* Rotation: 0:normal, 1:right 90, 2:left 180, 3:left 90 */
226 unsigned char v_scale
; /* Scale Factor for both X & Y */
235 typedef struct PE_Video PE_Video
;
237 extern void initialize_screen(PE_Video
*, unsigned int);
239 extern void dim_screen(void);
241 extern int PE_current_console(
244 extern void PE_create_console(
247 extern int PE_initialize_console(
251 #define kPEGraphicsMode 1
252 #define kPETextMode 2
253 #define kPETextScreen 3
254 #define kPEAcquireScreen 4
255 #define kPEReleaseScreen 5
256 #define kPEEnableScreen 6
257 #define kPEDisableScreen 7
258 #define kPEBaseAddressChange 8
259 #define kPERefreshBootGraphics 9
261 extern void PE_display_icon( unsigned int flags
,
264 typedef struct PE_state
{
265 boolean_t initialized
;
267 void *deviceTreeHead
;
271 extern PE_state_t PE_state
;
273 extern char * PE_boot_args(
276 #if !defined(__LP64__) && !defined(__arm__)
277 extern boolean_t
PE_parse_boot_arg(
278 const char *arg_string
,
279 void *arg_ptr
) __deprecated
;
282 extern boolean_t
PE_parse_boot_argn(
283 const char *arg_string
,
287 extern boolean_t
PE_get_default(
288 const char *property_name
,
290 unsigned int max_property
);
292 #define PE_default_value(_key, _variable, _default) \
294 if (!PE_get_default((_key), &(_variable), sizeof(_variable))) \
295 _variable = _default; \
300 kPECommandKey
= 0x37,
301 kPEControlKey
= 0x36,
305 extern boolean_t
PE_get_hotkey(
308 extern kern_return_t
PE_cpu_start(
310 vm_offset_t start_paddr
,
311 vm_offset_t arg_paddr
);
313 extern void PE_cpu_halt(
316 extern void PE_cpu_signal(
320 extern void PE_cpu_signal_deferred(
324 extern void PE_cpu_signal_cancel(
328 extern void PE_cpu_machine_init(
332 extern void PE_cpu_machine_quiesce(
335 extern void pe_init_debug(void);
337 extern boolean_t
PE_imgsrc_mount_supported(void);
341 boolean_t
PE_reboot_on_panic(void);
346 #endif /* _PEXPERT_PEXPERT_H_ */