- static int last_console = -1;
- Boot_Video bootInfo;
- Boot_Video * bInfo;
-
- /*
- * Refuse changes from outside pexpert.
- * The video mode setup by the booter cannot be changed.
- */
- if ( info && (info == &PE_state.video) )
- {
- bootInfo.v_baseAddr = PE_fb_vaddr;
- bootInfo.v_rowBytes = info->v_rowBytes;
- bootInfo.v_width = info->v_width;
- bootInfo.v_height = info->v_height;
- bootInfo.v_depth = info->v_depth;
- bootInfo.v_display = PE_fb_mode;
- bInfo = &bootInfo;
- }
- else
- bInfo = 0;
-
- switch ( op ) {
-
- case kPEDisableScreen:
- initialize_screen((void *) bInfo, op);
-#ifdef FIXME
- last_console = switch_to_serial_console();
-#endif
- kprintf("kPEDisableScreen %d\n", last_console);
- break;
-
- case kPEEnableScreen:
- initialize_screen((void *) bInfo, op);
- kprintf("kPEEnableScreen %d\n", last_console);
-#ifdef FIXME
- if( last_console != -1)
- switch_to_old_console( last_console);
-#endif
- break;
-
- default:
- initialize_screen((void *) bInfo, op);
- break;
- }
-
- return 0;
+ static int last_console = -1;
+
+ if (info) {
+ info->v_offset = 0;
+ info->v_length = 0;
+ info->v_display = GRAPHICS_MODE;
+ }
+
+ switch (op) {
+ case kPEDisableScreen:
+ initialize_screen(info, op);
+ kprintf("kPEDisableScreen %d\n", last_console);
+ if (!console_is_serial()) {
+ last_console = switch_to_serial_console();
+ }
+ break;
+
+ case kPEEnableScreen:
+ initialize_screen(info, op);
+ if (info) {
+ PE_state.video = *info;
+ }
+ kprintf("kPEEnableScreen %d\n", last_console);
+ if (last_console != -1) {
+ switch_to_old_console( last_console);
+ }
+ break;
+
+ case kPEBaseAddressChange:
+ if (info) {
+ PE_state.video = *info;
+ }
+ OS_FALLTHROUGH;
+
+ default:
+ initialize_screen(info, op);
+ break;
+ }
+
+ return 0;
+}
+
+void
+PE_init_iokit(void)
+{
+ enum { kMaxBootVar = 128 };
+
+ boolean_t bootClutInitialized = FALSE;
+ boolean_t noroot_rle_Initialized = FALSE;
+
+ DTEntry entry;
+ unsigned int size;
+ uint32_t const *map;
+ boot_progress_element *bootPict;
+
+ norootIcon_lzss = NULL;
+ norootClut_lzss = NULL;
+
+ PE_init_printf(TRUE);
+
+ kprintf("Kernel boot args: '%s'\n", PE_boot_args());
+
+ /*
+ * Fetch the CLUT and the noroot image.
+ */
+
+ if (kSuccess == SecureDTLookupEntry(NULL, "/chosen/memory-map", &entry)) {
+ if (kSuccess == SecureDTGetProperty(entry, "BootCLUT", (void const **) &map, &size)) {
+ if (sizeof(appleClut8) <= map[1]) {
+ bcopy((void *)ml_static_ptovirt(map[0]), appleClut8, sizeof(appleClut8));
+ bootClutInitialized = TRUE;
+ }
+ }
+
+ if (kSuccess == SecureDTGetProperty(entry, "Pict-FailedBoot", (void const **) &map, &size)) {
+ bootPict = (boot_progress_element *) ml_static_ptovirt(map[0]);
+ default_noroot.width = bootPict->width;
+ default_noroot.height = bootPict->height;
+ default_noroot.dx = 0;
+ default_noroot.dy = bootPict->yOffset;
+ default_noroot_data = &bootPict->data[0];
+ noroot_rle_Initialized = TRUE;
+ }
+
+ if (kSuccess == SecureDTGetProperty(entry, "FailedCLUT", (void const **) &map, &size)) {
+ norootClut_lzss = (uint8_t*) ml_static_ptovirt(map[0]);
+ }
+
+ if (kSuccess == SecureDTGetProperty(entry, "FailedImage", (void const **) &map, &size)) {
+ norootIcon_lzss = (boot_icon_element *) ml_static_ptovirt(map[0]);
+ if (norootClut_lzss == NULL) {
+ printf("ERROR: No FailedCLUT provided for noroot icon!\n");
+ }
+ }
+ }
+
+ if (!bootClutInitialized) {
+ bcopy((void *) (uintptr_t) bootClut, (void *) appleClut8, sizeof(appleClut8));
+ }
+
+ if (!noroot_rle_Initialized) {
+ default_noroot.width = kFailedBootWidth;
+ default_noroot.height = kFailedBootHeight;
+ default_noroot.dx = 0;
+ default_noroot.dy = kFailedBootOffset;
+ default_noroot_data = failedBootPict;
+ }
+
+ /*
+ * Initialize the spinning wheel (progress indicator).
+ */
+ vc_progress_initialize(&default_progress,
+ default_progress_data1x,
+ default_progress_data2x,
+ default_progress_data3x,
+ (unsigned char *) appleClut8);
+
+ /*
+ * x86 only minimally enforces lockdown in hardware. Additionally, some pre-lockdown functionality
+ * such as commpage initialization requires IOKit enumeration of CPUs, which is heavily entangled
+ * with the ACPI stack. Therefore, we start the IOKit matching process immediately on x86.
+ */
+ InitIOKit(PE_state.deviceTreeHead);
+ StartIOKitMatching();