提交 498f8edf 编写于 作者: V vit9696

OpenCorePlatform: Support using MacInfoPkg

上级 9f78930e
......@@ -476,6 +476,7 @@ Add \texttt{.clang\_complete} file with similar content to your UDK root:
-I/UefiPackages/OpenCorePkg/Include
-I/UefiPackages/OcSupportPkg/Include
-I/UefiPackages/IntelFrameworkPkg/Include
-I/UefiPackages/MacInfoPkg/Include
-IInclude
-include
/UefiPackages/MdePkg/Include/Uefi.h
......@@ -1701,7 +1702,8 @@ troubleshooting:
Platform information is comprised of several identification fields
generated or filled manually to be compatible with macOS services. The
base part of the configuration may be obtained from \texttt{MacInfoPkg}
base part of the configuration may be obtained from
\href{https://github.com/acidanthera/MacInfoPkg}{\texttt{MacInfoPkg}}
package, which itself generates a set of interfaces based on a database
in \href{https://yaml.org/spec/1.2/spec.html}{YAML} format. These fields
are written to three select destinations:
......@@ -1739,9 +1741,8 @@ for system configuration.
and \texttt{SMBIOS} sections.
Enabling this option is useful when \texttt{Generic} section is flexible
enough. When enabled \texttt{SMBIOS} and \texttt{DataHub} data is unused.
FIXME: Currently unsupported.
enough. When enabled \texttt{SMBIOS}, \texttt{DataHub}, and
\texttt{PlatformNVRAM} data is unused.
\item
\texttt{UpdateDataHub}\\
\textbf{Type}: \texttt{plist\ boolean}\\
......@@ -1801,21 +1802,25 @@ for system configuration.
\item
\texttt{Generic}\\
\textbf{Type}: \texttt{plist\ dictonary}\\
\textbf{Optional}: When \texttt{Automatic} is \texttt{false}\\
\textbf{Description}: Update all fields. This section is read only
when \texttt{Automatic} is active.
\item
\texttt{DataHub}\\
\textbf{Type}: \texttt{plist\ dictonary}\\
\textbf{Optional}: When \texttt{Automatic} is \texttt{true}\\
\textbf{Description}: Update Data Hub fields. This section is read
only when \texttt{Automatic} is not active.
\item
\texttt{PlatformNVRAM}\\
\textbf{Type}: \texttt{plist\ dictonary}\\
\textbf{Optional}: When \texttt{Automatic} is \texttt{true}\\
\textbf{Description}: Update platform NVRAM fields. This section is
read only when \texttt{Automatic} is not active.
\item
\texttt{SMBIOS}\\
\textbf{Type}: \texttt{plist\ dictonary}\\
\textbf{Optional}: When \texttt{Automatic} is \texttt{true}\\
\textbf{Description}: Update SMBIOS fields. This section is read only
when \texttt{Automatic} is not active.
\end{enumerate}
......
......@@ -16,7 +16,7 @@
[Defines]
PLATFORM_NAME = OpenCorePkg
PLATFORM_GUID = 6B1D3AB4-5C85-462D-9DC5-480F8B17D5CB
PLATFORM_GUID = C46F121D-ABC6-42A3-A241-91B09224C357
PLATFORM_VERSION = 1.0
SUPPORTED_ARCHITECTURES = X64
BUILD_TARGETS = RELEASE|DEBUG|NOOPT
......@@ -50,6 +50,7 @@
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
MacInfoLib|MacInfoPkg/Library/MacInfoLib/MacInfoLib.inf
OcAcpiLib|OcSupportPkg/Library/OcAcpiLib/OcAcpiLib.inf
OcAppleBootPolicyLib|OcSupportPkg/Library/OcAppleBootPolicyLib/OcAppleBootPolicyLib.inf
OcAppleChunklistLib|OcSupportPkg/Library/OcAppleChunklistLib/OcAppleChunklistLib.inf
......@@ -115,4 +116,4 @@
MSFT:RELEASE_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN)
XCODE:DEBUG_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN)
XCODE:NOOPT_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN)
XCODE:RELEASE_*_*_CC_FLAGS = -Wno-error -flto $(OCPKG_BUILD_OPTIONS_GEN)
XCODE:RELEASE_*_*_CC_FLAGS = -flto $(OCPKG_BUILD_OPTIONS_GEN)
......@@ -50,6 +50,7 @@
IntelFrameworkPkg/IntelFrameworkPkg.dec
OpenCorePkg/OpenCorePkg.dec
OcSupportPkg/OcSupportPkg.dec
MacInfoPkg/MacInfoPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
......@@ -81,6 +82,7 @@
OcSmbiosLib
OcStorageLib
OcVirtualFsLib
MacInfoLib
PcdLib
PrintLib
UefiBootServicesTableLib
......
......@@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/MacInfoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PrintLib.h>
#include <Library/OcCpuLib.h>
......@@ -31,15 +32,21 @@ STATIC
VOID
OcPlatformUpdateDataHub (
IN OC_GLOBAL_CONFIG *Config,
IN OC_CPU_INFO *CpuInfo
IN OC_CPU_INFO *CpuInfo,
IN MAC_INFO_DATA *MacInfo
)
{
EFI_STATUS Status;
OC_DATA_HUB_DATA Data;
EFI_GUID Uuid;
UINT64 StartupPowerEvents;
ZeroMem (&Data, sizeof (Data));
if (MacInfo == NULL) {
//
// Manual mode, read data from DataHub.
//
if (OC_BLOB_GET (&Config->PlatformInfo.DataHub.PlatformName)[0] != '\0') {
Data.PlatformName = OC_BLOB_GET (&Config->PlatformInfo.DataHub.PlatformName);
}
......@@ -107,6 +114,32 @@ OcPlatformUpdateDataHub (
|| Config->PlatformInfo.DataHub.SmcPlatform[7] != 0) {
Data.SmcPlatform = &Config->PlatformInfo.DataHub.SmcPlatform[0];
}
} else {
//
// Automatic mode read data from Generic & MacInfo.
//
Data.PlatformName = MacInfo->DataHub.PlatformName;
Data.SystemProductName = MacInfo->DataHub.SystemProductName;
if (OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemSerialNumber)[0] != '\0') {
Data.SystemSerialNumber = OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemSerialNumber);
}
if (Config->PlatformInfo.Generic.SystemUuid.Size == GUID_STRING_LENGTH + 1
&& !EFI_ERROR (AsciiStrToGuid (OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemUuid), &Uuid))) {
Data.SystemUUID = &Uuid;
}
Data.BoardProduct = MacInfo->DataHub.BoardProduct;
Data.BoardRevision = &Config->PlatformInfo.DataHub.BoardRevision[0];
StartupPowerEvents = 0;
Data.StartupPowerEvents = &StartupPowerEvents;
Data.DevicePathsSupported = &MacInfo->DataHub.DevicePathsSupported[0];
Data.SmcRevision = &MacInfo->DataHub.SmcRevision[0];
Data.SmcBranch = &MacInfo->DataHub.SmcBranch[0];
Data.SmcPlatform = &MacInfo->DataHub.SmcPlatform[0];
}
Status = UpdateDataHub (&Data, CpuInfo);
if (EFI_ERROR (Status)) {
......@@ -119,6 +152,7 @@ VOID
OcPlatformUpdateSmbios (
IN OC_GLOBAL_CONFIG *Config,
IN OC_CPU_INFO *CpuInfo,
IN MAC_INFO_DATA *MacInfo,
IN OC_SMBIOS_UPDATE_MODE UpdateMode
)
{
......@@ -128,6 +162,10 @@ OcPlatformUpdateSmbios (
ZeroMem (&Data, sizeof (Data));
if (MacInfo == NULL) {
//
// Manual mode, read data from SMBIOS.
//
if (OC_BLOB_GET (&Config->PlatformInfo.Smbios.BIOSVendor)[0] != '\0') {
Data.BIOSVendor = OC_BLOB_GET (&Config->PlatformInfo.Smbios.BIOSVendor);
}
......@@ -229,6 +267,46 @@ OcPlatformUpdateSmbios (
}
Data.PlatformFeature = Config->PlatformInfo.Smbios.PlatformFeature;
} else {
//
// Automatic mode read data from Generic & MacInfo.
//
Data.BIOSVersion = MacInfo->Smbios.BIOSVersion;
Data.BIOSReleaseDate = MacInfo->Smbios.BIOSReleaseDate;
Data.SystemProductName = MacInfo->Smbios.SystemProductName;
Data.SystemVersion = MacInfo->Smbios.SystemVersion;
if (OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemSerialNumber)[0] != '\0') {
Data.SystemSerialNumber = OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemSerialNumber);
}
if (Config->PlatformInfo.Generic.SystemUuid.Size == GUID_STRING_LENGTH + 1
&& !EFI_ERROR (AsciiStrToGuid (OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemUuid), &Uuid))) {
Data.SystemUUID = &Uuid;
}
Data.BoardType = MacInfo->Smbios.BoardType;
Data.ChassisType = MacInfo->Smbios.ChassisType;
Data.SystemSKUNumber = MacInfo->Smbios.SystemSKUNumber;
Data.SystemFamily = MacInfo->Smbios.SystemFamily;
Data.BoardProduct = MacInfo->Smbios.BoardProduct;
Data.BoardVersion = MacInfo->Smbios.BoardVersion;
Data.BoardSerialNumber = MacInfo->Smbios.BoardSerialNumber;
Data.BoardAssetTag = MacInfo->Smbios.BoardAssetTag;
Data.BoardLocationInChassis = MacInfo->Smbios.BoardLocationInChassis;
Data.ChassisVersion = MacInfo->Smbios.ChassisVersion;
if (OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemSerialNumber)[0] != '\0') {
Data.ChassisSerialNumber = OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemSerialNumber);
}
Data.ChassisAssetTag = MacInfo->Smbios.ChassisAssetTag;
Data.MemoryFormFactor = MacInfo->Smbios.MemoryFormFactor;
Data.FirmwareFeatures = MacInfo->Smbios.FirmwareFeatures;
Data.FirmwareFeaturesMask = MacInfo->Smbios.FirmwareFeaturesMask;
Data.ProcessorType = NULL;
Data.PlatformFeature = MacInfo->Smbios.PlatformFeature;
}
Status = CreateSmbios (&Data, UpdateMode, CpuInfo);
if (EFI_ERROR (Status)) {
......@@ -239,23 +317,33 @@ OcPlatformUpdateSmbios (
STATIC
VOID
OcPlatformUpdateNvram (
IN OC_GLOBAL_CONFIG *Config
IN OC_GLOBAL_CONFIG *Config,
IN MAC_INFO_DATA *MacInfo
)
{
EFI_STATUS Status;
CHAR8 *Bid;
CHAR8 *Mlb;
UINT8 *Rom;
CONST CHAR8 *Bid;
CONST CHAR8 *Mlb;
CONST UINT8 *Rom;
UINT64 ExFeatures;
UINT64 ExFeaturesMask;
UINT32 Features;
UINT32 FeaturesMask;
if (MacInfo == NULL) {
Bid = OC_BLOB_GET (&Config->PlatformInfo.Nvram.Bid);
Mlb = OC_BLOB_GET (&Config->PlatformInfo.Nvram.Mlb);
Rom = &Config->PlatformInfo.Nvram.Rom[0];
ExFeatures = Config->PlatformInfo.Nvram.FirmwareFeatures;
ExFeaturesMask = Config->PlatformInfo.Nvram.FirmwareFeaturesMask;
} else {
Bid = MacInfo->Smbios.BoardProduct;
Mlb = OC_BLOB_GET (&Config->PlatformInfo.Generic.Mlb);
Rom = &Config->PlatformInfo.Generic.Rom[0];
ExFeatures = MacInfo->Smbios.FirmwareFeatures;
ExFeaturesMask = MacInfo->Smbios.FirmwareFeaturesMask;
}
Features = (UINT32) ExFeatures;
FeaturesMask = (UINT32) ExFeaturesMask;
......@@ -265,7 +353,7 @@ OcPlatformUpdateNvram (
&gAppleVendorVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
Config->PlatformInfo.Nvram.Bid.Size - 1,
Bid
(CHAR8 *) Bid
);
DEBUG ((
EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
......@@ -281,7 +369,7 @@ OcPlatformUpdateNvram (
&gAppleVendorVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof (Config->PlatformInfo.Nvram.Rom),
Rom
(UINT8 *) Rom
);
DEBUG ((
EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
......@@ -295,7 +383,7 @@ OcPlatformUpdateNvram (
&gAppleVendorVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof (Config->PlatformInfo.Nvram.Rom),
Rom
(UINT8 *) Rom
);
DEBUG ((
EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
......@@ -311,7 +399,7 @@ OcPlatformUpdateNvram (
&gAppleVendorVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
Config->PlatformInfo.Nvram.Mlb.Size - 1,
Mlb
(CHAR8 *) Mlb
);
DEBUG ((
EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
......@@ -325,7 +413,7 @@ OcPlatformUpdateNvram (
&gAppleVendorVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
Config->PlatformInfo.Nvram.Mlb.Size - 1,
Mlb
(CHAR8 *) Mlb
);
DEBUG ((
EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
......@@ -402,17 +490,18 @@ OcLoadPlatformSupport (
{
CONST CHAR8 *SmbiosUpdateStr;
OC_SMBIOS_UPDATE_MODE SmbiosUpdateMode;
MAC_INFO_DATA InfoData;
MAC_INFO_DATA *UsedMacInfo;
//
// TODO: implement
//
if (Config->PlatformInfo.Automatic) {
DEBUG ((DEBUG_ERROR, "OC: Automatic platform information is unsupported\n"));
return;
GetMacInfo (OC_BLOB_GET (&Config->PlatformInfo.Generic.SystemProductName), &InfoData);
UsedMacInfo = &InfoData;
} else {
UsedMacInfo = NULL;
}
if (Config->PlatformInfo.UpdateDataHub) {
OcPlatformUpdateDataHub (Config, CpuInfo);
OcPlatformUpdateDataHub (Config, CpuInfo, UsedMacInfo);
}
if (Config->PlatformInfo.UpdateSmbios) {
......@@ -431,10 +520,10 @@ OcLoadPlatformSupport (
SmbiosUpdateMode = OcSmbiosUpdateAuto;
}
OcPlatformUpdateSmbios (Config, CpuInfo, SmbiosUpdateMode);
OcPlatformUpdateSmbios (Config, CpuInfo, UsedMacInfo, SmbiosUpdateMode);
}
if (Config->PlatformInfo.UpdateNvram) {
OcPlatformUpdateNvram (Config);
OcPlatformUpdateNvram (Config, UsedMacInfo);
}
}
......@@ -135,6 +135,7 @@ updaterepo "https://github.com/tianocore/edk2" UDK UDK2018 || exit 1
cd UDK
updaterepo "https://github.com/acidanthera/EfiPkg" EfiPkg master || exit 1
updaterepo "https://github.com/acidanthera/OcSupportPkg" OcSupportPkg master || exit 1
updaterepo "https://github.com/acidanthera/MacInfoPkg" MacInfoPkg master || exit 1
if [ ! -d OpenCorePkg ]; then
ln -s .. OpenCorePkg || exit 1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册