void setupEfiDeviceTree(void) { Node *node; const char * sz_system_id=0; EFI_CHAR8* ret=0; node = DT__FindNode("/", false); if (node == 0) { stop("Couldn't get root node"); } /* We could also just do DT__FindNode("/efi/platform", true) * But I think eventually we want to fill stuff in the efi node * too so we might as well create it so we have a pointer for it too. */ node = DT__AddChild(node, "efi"); DT__AddProperty(node, FIRMWARE_REVISION_PROP, sizeof(FIRMWARE_REVISION), (EFI_UINT32*)&FIRMWARE_REVISION); DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_PROP_VALUE), (char*)FIRMWARE_ABI_PROP_VALUE); DT__AddProperty(node, FIRMWARE_VENDOR_PROP, sizeof(FIRMWARE_VENDOR), (EFI_CHAR16*)FIRMWARE_VENDOR); /* TODO: Fill in other efi properties if necessary */ /* Set up the /efi/runtime-services table node similar to the way a child node of configuration-table * is set up. That is, name and table properties */ Node *runtimeServicesNode = DT__AddChild(node, "runtime-services"); /* The value of the table property is the 32-bit physical address for the RuntimeServices table. * Sice the EFI system table already has a pointer to it, we simply use the address of that pointer * for the pointer to the property data. Warning.. DT finalization calls free on that but we're not * the only thing to use a non-malloc'd pointer for something in the DT */ DT__AddProperty(runtimeServicesNode, "table", sizeof(uint64_t), &gST->RuntimeServices); /* Set up the /efi/configuration-table node which will eventually have several child nodes for * all of the configuration tables needed by various kernel extensions. */ gEfiConfigurationTableNode = DT__AddChild(node, "configuration-table"); /* Now fill in the /efi/platform Node */ Node *efiPlatformNode = DT__AddChild(node, "platform"); /* NOTE WELL: If you do add FSB Frequency detection, make sure to store * the value in the fsbFrequency global and not an malloc'd pointer * because the DT_AddProperty function does not copy its args. */ if(fsbFrequency != 0) DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &fsbFrequency); // rek: Give the user a chance to set a fixed/reproduceable system UUID from the bootConfig sz_system_id = newStringForKey("SystemID", &bootInfo->bootConfig); ret = getUUIDFromString(sz_system_id); if (sz_system_id) { if (ret) { verbose("Customizing SystemID with : %s\n", sz_system_id); DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, sizeof(SYSTEM_ID), (EFI_UINT32*) ret); } free((void*) sz_system_id); } else // unable to determine UUID for host. Error: 35 fix DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, sizeof(SYSTEM_ID), (EFI_UINT32*)&SYSTEM_ID); /* Export TSC and CPU frequencies for use by the kernel or KEXTs */ if(tscFrequency != 0) DT__AddProperty(efiPlatformNode, TSC_Frequency_prop, sizeof(uint64_t), &tscFrequency); if(cpuFrequency != 0) DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &cpuFrequency); /* Fill /efi/device-properties node. */ setupDeviceProperties(node); }
void setupEfiDeviceTree(void) { EFI_CHAR8* ret = 0; EFI_CHAR16* ret16 = 0; size_t len = 0; Node *node; node = DT__FindNode("/", false); if (node == 0) stop("Couldn't get root node"); // We could also just do DT__FindNode("/efi/platform", true) // But I think eventually we want to fill stuff in the efi node // too so we might as well create it so we have a pointer for it too. node = DT__AddChild(node, "efi"); if (archCpuType == CPU_TYPE_I386) { DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_32_PROP_VALUE), (char*)FIRMWARE_ABI_32_PROP_VALUE); } else { DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_64_PROP_VALUE), (char*)FIRMWARE_ABI_64_PROP_VALUE); } DT__AddProperty(node, FIRMWARE_REVISION_PROP, sizeof(FIRMWARE_REVISION), (EFI_UINT32*)&FIRMWARE_REVISION); DT__AddProperty(node, FIRMWARE_VENDOR_PROP, sizeof(FIRMWARE_VENDOR), (EFI_CHAR16*)FIRMWARE_VENDOR); // TODO: Fill in other efi properties if necessary // Set up the /efi/runtime-services table node similar to the way a child node of configuration-table // is set up. That is, name and table properties Node *runtimeServicesNode = DT__AddChild(node, "runtime-services"); if (archCpuType == CPU_TYPE_I386) { // The value of the table property is the 32-bit physical address for the RuntimeServices table. // Since the EFI system table already has a pointer to it, we simply use the address of that pointer // for the pointer to the property data. Warning.. DT finalization calls free on that but we're not // the only thing to use a non-malloc'd pointer for something in the DT DT__AddProperty(runtimeServicesNode, "table", sizeof(uint64_t), &gST32->RuntimeServices); } else { DT__AddProperty(runtimeServicesNode, "table", sizeof(uint64_t), &gST64->RuntimeServices); } // Set up the /efi/configuration-table node which will eventually have several child nodes for // all of the configuration tables needed by various kernel extensions. gEfiConfigurationTableNode = DT__AddChild(node, "configuration-table"); // Now fill in the /efi/platform Node Node *efiPlatformNode = DT__AddChild(node, "platform"); // NOTE WELL: If you do add FSB Frequency detection, make sure to store // the value in the fsbFrequency global and not an malloc'd pointer // because the DT_AddProperty function does not copy its args. if (Platform.CPU.FSBFrequency != 0) DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &Platform.CPU.FSBFrequency); // Export TSC and CPU frequencies for use by the kernel or KEXTs if (Platform.CPU.TSCFrequency != 0) DT__AddProperty(efiPlatformNode, TSC_Frequency_prop, sizeof(uint64_t), &Platform.CPU.TSCFrequency); if (Platform.CPU.CPUFrequency != 0) DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform.CPU.CPUFrequency); // Export system-id. Can be disabled with SystemId=No in com.apple.Boot.plist if ((ret=getSystemID())) DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32*) ret); // Export SystemSerialNumber if present if ((ret16=getSmbiosChar16("SMserial", &len))) DT__AddProperty(efiPlatformNode, SYSTEM_SERIAL_PROP, len, ret16); // Export Model if present if ((ret16=getSmbiosChar16("SMproductname", &len))) DT__AddProperty(efiPlatformNode, MODEL_PROP, len, ret16); // Fill /efi/device-properties node. setupDeviceProperties(node); }
static void setupEfiDeviceTree(void) { Node *node; const char *value; int len; bool doit; if ((node = DT__FindNode("/", false)) == NULL) { stop("Couldn't find EFI root node"); } /* Export system-type. Allowed values are: * 0x01 for desktop computer (default) * 0x02 for portable computers */ SystemType[0] = 1; if (getValueForKey(kSystemType, &value, &len, &bootInfo->bootConfig) && value != NULL) { SystemType[0] = (unsigned char) strtoul(value, NULL, 10); if (SystemType[0] != 1 && SystemType[0] != 2) { verbose("Error: system-type must be 1 (desktop) or 2 (portable). Defaulting to 1!\n"); SystemType[0] = 1; } } verbose("Using system-type=0x%02x\n", SystemType[0]); DT__AddProperty(node, SystemType_prop, sizeof(SystemType), &SystemType); /* We could also just do DT__FindNode("/efi/platform", true) * But I think eventually we want to fill stuff in the efi node * too so we might as well create it so we have a pointer for it too. */ node = DT__AddChild(node, "efi"); DT__AddProperty(node, FIRMWARE_REVISION_PROP, sizeof(FIRMWARE_REVISION), (EFI_UINT32*)&FIRMWARE_REVISION); DT__AddProperty(node, FIRMWARE_ABI_PROP, sizeof(FIRMWARE_ABI_PROP_VALUE), (char*)FIRMWARE_ABI_PROP_VALUE); DT__AddProperty(node, FIRMWARE_VENDOR_PROP, sizeof(FIRMWARE_VENDOR), (EFI_CHAR16*)FIRMWARE_VENDOR); /* TODO: Fill in other efi properties if necessary */ /* Set up the /efi/runtime-services table node similar to the way a child node of configuration-table * is set up. That is, name and table properties */ Node *runtimeServicesNode = DT__AddChild(node, "runtime-services"); /* The value of the table property is the 32-bit physical address for the RuntimeServices table. * Sice the EFI system table already has a pointer to it, we simply use the address of that pointer * for the pointer to the property data. Warning.. DT finalization calls free on that but we're not * the only thing to use a non-malloc'd pointer for something in the DT */ DT__AddProperty(runtimeServicesNode, "table", sizeof(uint64_t), &gST->RuntimeServices); /* Set up the /efi/configuration-table node which will eventually have several child nodes for * all of the configuration tables needed by various kernel extensions. */ gEfiConfigurationTableNode = DT__AddChild(node, "configuration-table"); /* Now fill in the /efi/platform Node */ Node *efiPlatformNode = DT__AddChild(node, "platform"); /* NOTE WELL: If you do add FSB Frequency detection, make sure to store * the value in the fsbFrequency global and not an malloc'd pointer * because the DT_AddProperty function does not copy its args. */ if(Platform.CPU.FSBFrequency != 0) { DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &Platform.CPU.FSBFrequency); } /* Export TSC and CPU frequencies for use by the kernel or KEXTs */ if(Platform.CPU.TSCFrequency != 0) { DT__AddProperty(efiPlatformNode, TSC_Frequency_prop, sizeof(uint64_t), &Platform.CPU.TSCFrequency); } if(Platform.CPU.CPUFrequency != 0) { DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform.CPU.CPUFrequency); } /* Export system-id. Can be disabled with system-id=No in com.apple.Boot.plist */ doit = true; getBoolForKey(kSystemID, &doit, &bootInfo->bootConfig); if (doit) { DT__AddProperty(efiPlatformNode, SystemID_prop, sizeof(SystemID), &SystemID); } /* Export SystemSerialNumber if present */ if (SystemSerialLength > 0) { DT__AddProperty(efiPlatformNode, SystemSerial_prop, SystemSerialLength, &SystemSerial); } /* Export Model if present */ if (ModelLength > 0) { DT__AddProperty(efiPlatformNode, Model_prop, ModelLength, &Model); } /* Fill /efi/device-properties node */ setupDeviceProperties(node); }