41 IN OC_GLOBAL_CONFIG *Config,
49 UINT64 StartupPowerEvents;
54 if (DataHub == NULL) {
55 DEBUG ((DEBUG_WARN,
"OC: Failed to install Data Hub\n"));
61 if (MacInfo == NULL) {
65 if (
OC_BLOB_GET (&Config->PlatformInfo.DataHub.PlatformName)[0] !=
'\0') {
69 if (
OC_BLOB_GET (&Config->PlatformInfo.DataHub.SystemProductName)[0] !=
'\0') {
73 if (
OC_BLOB_GET (&Config->PlatformInfo.DataHub.SystemSerialNumber)[0] !=
'\0') {
81 if (
OC_BLOB_GET (&Config->PlatformInfo.DataHub.BoardProduct)[0] !=
'\0') {
85 Data.
BoardRevision = &Config->PlatformInfo.DataHub.BoardRevision[0];
87 Data.
InitialTSC = &Config->PlatformInfo.DataHub.InitialTSC;
89 if (Config->PlatformInfo.DataHub.FSBFrequency != 0) {
90 Data.
FSBFrequency = &Config->PlatformInfo.DataHub.FSBFrequency;
93 if (Config->PlatformInfo.DataHub.ARTFrequency != 0) {
94 Data.
ARTFrequency = &Config->PlatformInfo.DataHub.ARTFrequency;
97 if (Config->PlatformInfo.DataHub.DevicePathsSupported != 0) {
101 if ( (Config->PlatformInfo.DataHub.SmcRevision[0] != 0)
102 || (Config->PlatformInfo.DataHub.SmcRevision[1] != 0)
103 || (Config->PlatformInfo.DataHub.SmcRevision[2] != 0)
104 || (Config->PlatformInfo.DataHub.SmcRevision[3] != 0)
105 || (Config->PlatformInfo.DataHub.SmcRevision[4] != 0)
106 || (Config->PlatformInfo.DataHub.SmcRevision[5] != 0))
108 Data.
SmcRevision = &Config->PlatformInfo.DataHub.SmcRevision[0];
111 if ( (Config->PlatformInfo.DataHub.SmcBranch[0] != 0)
112 || (Config->PlatformInfo.DataHub.SmcBranch[1] != 0)
113 || (Config->PlatformInfo.DataHub.SmcBranch[2] != 0)
114 || (Config->PlatformInfo.DataHub.SmcBranch[3] != 0)
115 || (Config->PlatformInfo.DataHub.SmcBranch[4] != 0)
116 || (Config->PlatformInfo.DataHub.SmcBranch[5] != 0)
117 || (Config->PlatformInfo.DataHub.SmcBranch[6] != 0)
118 || (Config->PlatformInfo.DataHub.SmcBranch[7] != 0))
120 Data.
SmcBranch = &Config->PlatformInfo.DataHub.SmcBranch[0];
123 if ( (Config->PlatformInfo.DataHub.SmcPlatform[0] != 0)
124 || (Config->PlatformInfo.DataHub.SmcPlatform[1] != 0)
125 || (Config->PlatformInfo.DataHub.SmcPlatform[2] != 0)
126 || (Config->PlatformInfo.DataHub.SmcPlatform[3] != 0)
127 || (Config->PlatformInfo.DataHub.SmcPlatform[4] != 0)
128 || (Config->PlatformInfo.DataHub.SmcPlatform[5] != 0)
129 || (Config->PlatformInfo.DataHub.SmcPlatform[6] != 0)
130 || (Config->PlatformInfo.DataHub.SmcPlatform[7] != 0))
132 Data.
SmcPlatform = &Config->PlatformInfo.DataHub.SmcPlatform[0];
141 if (MacInfo->Oem.SystemSerialNumber[0] !=
'\0') {
152 StartupPowerEvents = 0;
158 Data.
SmcRevision = &MacInfo->DataHub.SmcRevision[0];
159 Data.
SmcBranch = &MacInfo->DataHub.SmcBranch[0];
160 Data.
SmcPlatform = &MacInfo->DataHub.SmcPlatform[0];
164 if (EFI_ERROR (Status)) {
165 DEBUG ((DEBUG_WARN,
"OC: Failed to update Data Hub - %r\n", Status));
172 IN OC_GLOBAL_CONFIG *Config,
184 CONST CHAR8 *SystemMemoryStatus;
187 OC_PLATFORM_MEMORY_DEVICE_ENTRY *MemoryEntry;
189 ZeroMem (&Data,
sizeof (Data));
196 if (MacInfo == NULL) {
200 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.BIOSVendor)[0] !=
'\0') {
204 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.BIOSVersion)[0] !=
'\0') {
208 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.BIOSReleaseDate)[0] !=
'\0') {
212 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.SystemManufacturer)[0] !=
'\0') {
216 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.SystemProductName)[0] !=
'\0') {
220 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.SystemVersion)[0] !=
'\0') {
224 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.SystemSerialNumber)[0] !=
'\0') {
228 if (Config->PlatformInfo.UseRawUuidEncoding) {
230 OC_BLOB_GET (&Config->PlatformInfo.Smbios.SystemUuid),
234 Status = AsciiStrToGuid (
235 OC_BLOB_GET (&Config->PlatformInfo.Smbios.SystemUuid),
240 if (!EFI_ERROR (Status)) {
244 if (Config->PlatformInfo.Smbios.BoardType != 0) {
245 Data.
BoardType = &Config->PlatformInfo.Smbios.BoardType;
248 if (Config->PlatformInfo.Smbios.ChassisType != 0) {
249 Data.
ChassisType = &Config->PlatformInfo.Smbios.ChassisType;
252 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.SystemSKUNumber)[0] !=
'\0') {
256 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.SystemFamily)[0] !=
'\0') {
260 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.BoardManufacturer)[0] !=
'\0') {
264 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.BoardProduct)[0] !=
'\0') {
268 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.BoardVersion)[0] !=
'\0') {
272 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.BoardSerialNumber)[0] !=
'\0') {
276 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.BoardAssetTag)[0] !=
'\0') {
280 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.BoardLocationInChassis)[0] !=
'\0') {
284 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.ChassisManufacturer)[0] !=
'\0') {
288 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.ChassisVersion)[0] !=
'\0') {
292 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.ChassisSerialNumber)[0] !=
'\0') {
296 if (
OC_BLOB_GET (&Config->PlatformInfo.Smbios.ChassisAssetTag)[0] !=
'\0') {
303 if (Config->PlatformInfo.Smbios.ProcessorType != 0) {
304 Data.
ProcessorType = &Config->PlatformInfo.Smbios.ProcessorType;
307 if (Config->PlatformInfo.Smbios.PlatformFeature != 0xFFFFFFFFU) {
311 if (Config->PlatformInfo.Smbios.SmcVersion[0] !=
'\0') {
312 Data.
SmcVersion = &Config->PlatformInfo.Smbios.SmcVersion[0];
318 if (Config->PlatformInfo.Generic.SpoofVendor) {
330 if (MacInfo->Oem.SystemSerialNumber[0] !=
'\0') {
336 if (!Config->PlatformInfo.UseRawUuidEncoding) {
340 Uuid.Data1 = SwapBytes32 (
Uuid.Data1);
341 Uuid.Data2 = SwapBytes16 (
Uuid.Data2);
342 Uuid.Data3 = SwapBytes16 (
Uuid.Data3);
348 Data.
BoardType = MacInfo->Smbios.BoardType;
355 if (MacInfo->Oem.Mlb[0] !=
'\0') {
363 if (MacInfo->Oem.SystemSerialNumber[0] !=
'\0') {
375 if (Config->PlatformInfo.Generic.AdviseFeatures) {
389 if (Config->PlatformInfo.Generic.ProcessorType != 0) {
390 Data.
ProcessorType = &Config->PlatformInfo.Generic.ProcessorType;
400 if (
OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemMemoryStatus)[0] !=
'\0') {
401 SystemMemoryStatus =
OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemMemoryStatus);
403 if (AsciiStrCmp (SystemMemoryStatus,
"Upgradable") == 0) {
406 }
else if (AsciiStrCmp (SystemMemoryStatus,
"Soldered") == 0) {
409 }
else if (AsciiStrCmp (SystemMemoryStatus,
"Auto") != 0) {
410 DEBUG ((DEBUG_WARN,
"OC: Invalid SMBIOS system memory status %a\n", SystemMemoryStatus));
417 if (Config->PlatformInfo.Generic.MaxBIOSVersion) {
421 if (MacInfo->DataHub.SmcRevision != NULL) {
430 if (Config->PlatformInfo.CustomMemory) {
433 if (Config->PlatformInfo.Memory.Devices.Count <= MAX_UINT16) {
444 Data.
MemoryType = &Config->PlatformInfo.Memory.Type;
450 DEBUG ((DEBUG_WARN,
"OC: Failed to allocate custom memory devices\n"));
455 MemoryEntry = Config->PlatformInfo.Memory.Devices.Values[Index];
472 if (EFI_ERROR (Status)) {
473 DEBUG ((DEBUG_INFO,
"OC: Failed to copy new SMBIOS product name %a\n", Data.
SystemProductName));
477 Status =
OcSmbiosCreate (SmbiosTable, &Data, UpdateMode, CpuInfo);
478 if (EFI_ERROR (Status)) {
479 DEBUG ((DEBUG_WARN,
"OC: Failed to update SMBIOS - %r\n", Status));
490 IN OC_GLOBAL_CONFIG *Config,
505 UINT64 ExFeaturesMask;
509 if (MacInfo == NULL) {
510 Bid =
OC_BLOB_GET (&Config->PlatformInfo.Nvram.Bid);
511 BidSize = Config->PlatformInfo.Nvram.Bid.Size - 1;
512 Mlb =
OC_BLOB_GET (&Config->PlatformInfo.Nvram.Mlb);
513 MlbSize = Config->PlatformInfo.Nvram.Mlb.Size - 1;
514 Ssn =
OC_BLOB_GET (&Config->PlatformInfo.Nvram.SystemSerialNumber);
515 SsnSize = Config->PlatformInfo.Nvram.SystemSerialNumber.Size - 1;
516 Rom = &Config->PlatformInfo.Nvram.Rom[0];
517 RomSize =
sizeof (Config->PlatformInfo.Nvram.Rom);
519 if (EFI_ERROR (Status)) {
523 ExFeatures = Config->PlatformInfo.Nvram.FirmwareFeatures;
524 ExFeaturesMask = Config->PlatformInfo.Nvram.FirmwareFeaturesMask;
526 Bid = MacInfo->Smbios.BoardProduct;
527 BidSize = AsciiStrLen (Bid);
528 Mlb = MacInfo->Oem.Mlb;
529 MlbSize = AsciiStrLen (Mlb);
530 Ssn = MacInfo->Oem.SystemSerialNumber;
531 SsnSize = AsciiStrLen (Ssn);
532 Rom = &MacInfo->Oem.Rom[0];
535 ExFeatures = MacInfo->Smbios.FirmwareFeatures;
536 ExFeaturesMask = MacInfo->Smbios.FirmwareFeaturesMask;
546 if (Config->PlatformInfo.Generic.AdviseFeatures) {
558 Features = (UINT32)ExFeatures;
559 FeaturesMask = (UINT32)ExFeaturesMask;
561 if (Bid[0] !=
'\0') {
562 Status =
gRT->SetVariable (
565 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
570 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
571 "OC: Setting HW_BID %a - %r\n",
577 if ((Rom[0] != 0) || (Rom[1] != 0) || (Rom[2] != 0) || (Rom[3] != 0) || (Rom[4] != 0) || (Rom[5] != 0)) {
578 Status =
gRT->SetVariable (
581 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
586 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
587 "OC: Setting HW_ROM %02x:%02x:%02x:%02x:%02x:%02x - %r\n",
597 Status =
gRT->SetVariable (
600 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
605 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
606 "OC: Setting ROM %02x:%02x:%02x:%02x:%02x:%02x - %r\n",
617 if (Mlb[0] !=
'\0') {
618 Status =
gRT->SetVariable (
621 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
626 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
627 "OC: Setting HW_MLB %a - %r\n",
632 Status =
gRT->SetVariable (
635 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
640 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
641 "OC: Setting MLB %a - %r\n",
647 if (Ssn[0] !=
'\0') {
648 Status =
gRT->SetVariable (
651 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
656 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
657 "OC: Setting HW_SSN %a - %r\n",
662 Status =
gRT->SetVariable (
665 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
670 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
671 "OC: Setting SSN %a - %r\n",
682 Status =
gRT->SetVariable (
685 EFI_VARIABLE_BOOTSERVICE_ACCESS,
690 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
691 "OC: Setting system-id %g - %r\n",
697 if ((ExFeatures != 0) || (ExFeaturesMask != 0)) {
698 Status =
gRT->SetVariable (
701 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
706 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
707 "OC: Setting FirmwareFeatures %08x - %r\n",
712 Status =
gRT->SetVariable (
713 L
"ExtendedFirmwareFeatures",
715 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
720 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
721 "OC: Setting ExtendedFirmwareFeatures %016Lx - %r\n",
726 Status =
gRT->SetVariable (
727 L
"FirmwareFeaturesMask",
729 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
730 sizeof (FeaturesMask),
734 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
735 "OC: Setting FirmwareFeaturesMask %08x - %r\n",
740 Status =
gRT->SetVariable (
741 L
"ExtendedFirmwareFeaturesMask",
743 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
744 sizeof (ExFeaturesMask),
748 EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
749 "OC: Setting ExtendedFirmwareFeaturesMask %016Lx - %r\n",
758 IN OC_GLOBAL_CONFIG *Config,
768 BOOLEAN UseOemSerial;
773 if (Config->PlatformInfo.Automatic) {
775 UsedMacInfo = &InfoData;
776 UseOemSerial = AsciiStrCmp (
OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemSerialNumber),
"OEM") == 0;
777 UseOemUuid = AsciiStrCmp (
OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemUuid),
"OEM") == 0;
778 UseOemMlb = AsciiStrCmp (
OC_BLOB_GET (&Config->PlatformInfo.Generic.Mlb),
"OEM") == 0;
779 UseOemRom = AsciiStrCmp ((CHAR8 *)Config->PlatformInfo.Generic.Rom,
"OEM") == 0;
782 UseOemSerial = FALSE;
791 if (!EFI_ERROR (Status)) {
797 UseOemMlb ? InfoData.
Oem.
Mlb : NULL,
798 UseOemRom ? InfoData.
Oem.
Rom : NULL,
799 Config->PlatformInfo.UseRawUuidEncoding,
806 "OC: PlatformInfo auto %d OEM SN %d OEM UUID %d OEM MLB %d OEM ROM %d - %r\n",
807 Config->PlatformInfo.Automatic,
815 if (Config->PlatformInfo.Automatic) {
820 OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemSerialNumber)
826 OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemUuid),
844 if (!EFI_ERROR (Status)) {
845 if (Config->PlatformInfo.UpdateSmbios) {
847 OC_BLOB_GET (&Config->PlatformInfo.UpdateSmbiosMode)
860 DEBUG ((DEBUG_WARN,
"OC: Unable to obtain SMBIOS - %r\n", Status));
863 if (Config->PlatformInfo.UpdateDataHub) {
867 if (Config->PlatformInfo.UpdateNvram) {