- long * dt;
- int i;
- KernelBootArgs_t *kap = (KernelBootArgs_t *)PE_state.bootArgs;
- enum { kMaxBootVar = 128 };
- char *rdValue, *platformValue;
-
- typedef struct {
- char name[32];
- unsigned long length;
- unsigned long value[2];
- } DriversPackageProp;
-
- PE_init_kprintf(TRUE);
- PE_init_printf(TRUE);
-
- /*
- * Update the fake device tree with the driver information provided by
- * the booter.
- */
-
- gDriversProp.length = kap->numBootDrivers * sizeof(DriversPackageProp);
- gMemoryMapNode.length = 2 * sizeof(long);
-
- rdValue = kalloc(kMaxBootVar);
- if ( PE_parse_boot_arg("rd", rdValue) ) {
- if (*rdValue == '*') {
- gRootpathProp.address = (rdValue + 1);
- } else {
- gRootpathProp.address = rdValue;
- }
- strcat(rdValue, ",");
- } else {
- gRootpathProp.address = rdValue;
- rdValue[0] = '\0';
- }
- strcat(rdValue, kap->bootFile);
- gRootpathProp.length = strlen(rdValue) + 1;
-
- platformValue = kalloc(kMaxBootVar);
- if ( ! PE_parse_boot_arg("platform", platformValue) ) {
- strcpy(platformValue, kDefaultPlatformName);
- }
- gCompatibleProp.address = platformValue;
- gCompatibleProp.length = strlen(platformValue) + 1;
-
- dt = (long *) createdt( fakePPCDeviceTree,
- &((boot_args*)PE_state.fakePPCBootArgs)->deviceTreeLength );
-
- kfree(rdValue, kMaxBootVar);
- kfree(platformValue, kMaxBootVar);
-
-
- if ( dt )
- {
- DriversPackageProp * prop = (DriversPackageProp *) gDriversProp.address;
-
- /* Copy driver info in kernBootStruct to fake device tree */
-
- for ( i = 0; i < kap->numBootDrivers; i++, prop++ )
- {
- switch ( kap->driverConfig[i].type )
- {
- case kBootDriverTypeKEXT:
- sprintf(prop->name, "Driver-%lx", kap->driverConfig[i].address);
- break;
-
- case kBootDriverTypeMKEXT:
- sprintf(prop->name, "DriversPackage-%lx", kap->driverConfig[i].address);
- break;
-
- default:
- sprintf(prop->name, "DriverBogus-%lx", kap->driverConfig[i].address);
- break;
- }
- prop->length = sizeof(prop->value);
- prop->value[0] = kap->driverConfig[i].address;
- prop->value[1] = kap->driverConfig[i].size;
- }
-
- *((long *)gMemoryMapNode.address) = kap->numBootDrivers + 1;
- }
-
- /* Setup powermac_info and powermac_machine_info structures */
-
- ((boot_args*)PE_state.fakePPCBootArgs)->deviceTreeP = (unsigned long *) dt;
- ((boot_args*)PE_state.fakePPCBootArgs)->topOfKernelData = (unsigned long) kalloc(0x2000);
-
- /*
- * Setup the OpenFirmware Device Tree routines
- * so the console can be found and the right I/O space
- * can be used..
- */
- DTInit(dt);
-
- /*
- * Fetch the CLUT and the noroot image.
- */
- bcopy( (void *) (uintptr_t) bootClut, (void *) appleClut8, sizeof(appleClut8) );
-
- default_noroot.width = kFailedBootWidth;
- default_noroot.height = kFailedBootHeight;
- default_noroot.dx = 0;
- default_noroot.dy = kFailedBootOffset;
- default_noroot_data = failedBootPict;
-
- /*
- * Initialize the panic UI
- */
- panic_ui_initialize( (unsigned char *) appleClut8 );
-
- /*
- * Initialize the spinning wheel (progress indicator).
- */
- vc_progress_initialize( &default_progress, default_progress_data,
- (unsigned char *) appleClut8 );
-
- (void) StartIOKit( (void*)dt, PE_state.bootArgs, 0, 0);
+ 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();