未验证 提交 fded5114 编写于 作者: P PMheart 提交者: GitHub

OpenCore: Add CPU Info (MSRs) to SysReport (#267)

上级 0bd7dbd5
......@@ -37,6 +37,7 @@
[Packages]
MdePkg/MdePkg.dec
OpenCorePkg/OpenCorePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
BaseLib
......
......@@ -18,6 +18,8 @@
#include <Uefi.h>
#include <IndustryStandard/CpuId.h>
#include <IndustryStandard/AppleIntelCpuInfo.h>
#include <Protocol/FrameworkMpService.h>
#include <Protocol/MpService.h>
/**
Assumed CPU frequency when it cannot be detected.
......@@ -160,16 +162,109 @@ typedef struct {
UINT64 FSBFrequency;
} OC_CPU_INFO;
typedef struct {
//
// MSR_PLATFORM_INFO
//
BOOLEAN CpuHasMsrPlatformInfo;
UINT64 CpuMsrPlatformInfoValue;
//
// MSR_TURBO_RATIO_LIMIT
//
BOOLEAN CpuHasMsrTurboRatioLimit;
UINT64 CpuMsrTurboRatioLimitValue;
//
// MSR_PKG_POWER_INFO (TODO: To be confirmed)
//
BOOLEAN CpuHasMsrPkgPowerInfo;
UINT64 CpuMsrPkgPowerInfoValue;
//
// IA32_MISC_ENABLE
//
BOOLEAN CpuHasMsrIa32MiscEnable;
UINT64 CpuMsrIa32MiscEnableValue;
//
// MSR_IA32_EXT_CONFIG
//
BOOLEAN CpuHasMsrIa32ExtConfig;
UINT64 CpuMsrIa32ExtConfigValue;
//
// MSR_FSB_FREQ
//
BOOLEAN CpuHasMsrFsbFreq;
UINT64 CpuMsrFsbFreqValue;
//
// MSR_IA32_PERF_STATUS
//
BOOLEAN CpuHasMsrIa32PerfStatus;
UINT64 CpuMsrIa32PerfStatusValue;
//
// MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER (0xE2)
//
BOOLEAN CpuHasMsrE2;
UINT64 CpuMsrE2Value;
} OC_CPU_MSR_REPORT;
typedef struct {
EFI_MP_SERVICES_PROTOCOL *MpServices;
OC_CPU_MSR_REPORT *Reports;
OC_CPU_INFO *CpuInfo;
} OC_CPU_MSR_REPORT_PROCEDURE_ARGUMENT;
/**
Scan the processor and fill the cpu info structure with results.
@param[in] Cpu A pointer to the cpu info structure to fill with results.
@param[in,out] Cpu A pointer to the cpu info structure to fill with results.
**/
VOID
OcCpuScanProcessor (
IN OUT OC_CPU_INFO *Cpu
);
/**
Get the MSR report of the CPU.
@param[in] CpuInfo A pointer to the cpu info.
@param[out] Report The report generated based on CpuInfo.
**/
VOID
OcCpuGetMsrReport (
IN OC_CPU_INFO *CpuInfo,
OUT OC_CPU_MSR_REPORT *Report
);
/**
Get the MSR report of a single core on the CPU.
@param[in,out] Buffer The pointer to private data buffer.
**/
VOID
EFIAPI
OcCpuGetMsrReportPerCore (
IN OUT VOID *Buffer
);
/**
Get the MSR reports of all cores on the CPU.
@param[in] CpuInfo A pointer to the cpu info.
@param[out] EntryCount Count of cores on the CPU.
@return Array of reports of MSR status at each core.
**/
OC_CPU_MSR_REPORT *
OcCpuGetMsrReports (
IN OC_CPU_INFO *CpuInfo,
OUT UINTN *EntryCount
);
/**
Disable flex ratio if it has invalid value.
Commonly fixes early reboot on APTIO IV (Ivy/Haswell).
......
......@@ -16,6 +16,8 @@
#define OC_DEVICE_MISC_LIB_H
#include <Uefi.h>
#include <Library/OcCpuLib.h>
#include <Library/OcFileLib.h>
#include <Library/OcStringLib.h>
/**
......@@ -51,6 +53,20 @@ ActivateHpetSupport (
VOID
);
/**
Dump CPU MSR data to the specified directory.
@param[in] CpuInfo A pointer to the CPU info.
@param[in] Root Directory to write CPU data.
@retval EFI_SUCCESS on success.
**/
EFI_STATUS
OcMsrDump (
IN OC_CPU_INFO *CpuInfo,
IN EFI_FILE_PROTOCOL *Root
);
/**
Upgrade UEFI version to 2.x.
......
......@@ -129,12 +129,12 @@ AsciiUint64ToLowerHex (
/**
Alternative to AsciiSPrint, which checks that the buffer can contain all the characters.
@param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
ASCII string.
@param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param FormatString A Null-terminated ASCII format string.
@param ... Variable argument list whose contents are accessed based on the
format string specified by FormatString.
@param[out] StartOfBuffer A pointer to the output buffer for the produced Null-terminated
ASCII string.
@param[in] BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param[in] FormatString A Null-terminated ASCII format string.
@param[in] ... Variable argument list whose contents are accessed based on the
format string specified by FormatString.
@retval EFI_SUCCESS When data was printed to supplied buffer.
@retval EFI_OUT_OF_RESOURCES When supplied buffer cannot contain all the characters.
......@@ -173,9 +173,9 @@ OcAsciiSafeSPrint (
than PcdMaximumAsciiStringLength ASCII characters, not including the
Null-terminator, then ASSERT().
@param FirstString A pointer to a Null-terminated ASCII string.
@param SecondString A pointer to a Null-terminated ASCII string.
@param Length The maximum number of ASCII characters to compare.
@param[in] FirstString A pointer to a Null-terminated ASCII string.
@param[in] SecondString A pointer to a Null-terminated ASCII string.
@param[in] Length The maximum number of ASCII characters to compare.
@retval ==0 FirstString is identical to SecondString using case
insensitive comparisons.
......@@ -245,8 +245,8 @@ OcAsciiStartsWith (
than PcdMaximumUnicodeStringLength Unicode characters, not including the
Null-terminator, then ASSERT().
@param FirstString A pointer to a Null-terminated Unicode string.
@param SecondString A pointer to a Null-terminated Unicode string.
@param[in] FirstString A pointer to a Null-terminated Unicode string.
@param[in] SecondString A pointer to a Null-terminated Unicode string.
@retval ==0 FirstString is identical to SecondString using case
insensitiv comparisons.
......@@ -289,9 +289,9 @@ OcStriCmp (
than PcdMaximumUnicodeStringLength Unicode characters, not including the
Null-terminator, then ASSERT().
@param FirstString A pointer to a Null-terminated Unicode string.
@param SecondString A pointer to a Null-terminated Unicode string.
@param Length The maximum number of Unicode characters to compare.
@param[in] FirstString A pointer to a Null-terminated Unicode string.
@param[in] SecondString A pointer to a Null-terminated Unicode string.
@param[in] Length The maximum number of Unicode characters to compare.
@retval ==0 FirstString is identical to SecondString using case
insensitive comparisons.
......@@ -323,8 +323,8 @@ OcStrniCmp (
or String contains more than PcdMaximumAsciiStringLength ASCII
characters, not including the Null-terminator, then ASSERT().
@param String The pointer to a Null-terminated ASCII string.
@param SearchString The pointer to a Null-terminated ASCII string to search for.
@param[in] String The pointer to a Null-terminated ASCII string.
@param[in] SearchString The pointer to a Null-terminated ASCII string to search for.
@retval NULL If the SearchString does not appear in String.
@return others If there is a match.
......@@ -347,8 +347,8 @@ OcAsciiStriStr (
contains more than PcdMaximumAsciiStringLength ASCII
characters, not including the Null-terminator, then ASSERT().
@param String The pointer to a Null-terminated ASCII string.
@param Char Character to be located.
@param[in] String The pointer to a Null-terminated ASCII string.
@param[in] Char Character to be located.
@return A pointer to the first occurrence of Char in String.
@retval NULL If Char cannot be found in String.
......@@ -370,8 +370,8 @@ OcAsciiStrChr (
contains more than PcdMaximumAsciiStringLength ASCII
characters, not including the Null-terminator, then ASSERT().
@param String The pointer to a Null-terminated ASCII string.
@param Char Character to be located.
@param[in] String The pointer to a Null-terminated ASCII string.
@param[in] Char Character to be located.
@return A pointer to the last occurrence of Char in String.
@retval NULL If Char cannot be found in String.
......@@ -401,8 +401,8 @@ OcAsciiStringNPrintable (
Convert a Null-terminated ASCII GUID string to a value of type
EFI_GUID with RFC 4122 (raw) encoding.
@param String Pointer to a Null-terminated ASCII string.
@param Guid Pointer to the converted GUID.
@param[in] String Pointer to a Null-terminated ASCII string.
@param[out] Guid Pointer to the converted GUID.
@retval EFI_SUCCESS Guid is translated from String.
@retval EFI_INVALID_PARAMETER If String is NULL.
......@@ -416,6 +416,24 @@ OcAsciiStrToRawGuid (
OUT GUID *Guid
);
/**
Write formatted ASCII strings to buffers.
@param[in,out] AsciiBuffer A pointer to the output buffer for the produced Null-terminated
ASCII string.
@param[in,out] AsciiBufferSize The size, in bytes, of the output buffer specified by AsciiBuffer.
@param[in] FormatString A Null-terminated ASCII format string.
@param[in] ... Variable argument list whose contents are accessed based on the
format string specified by FormatString.
**/
VOID
EFIAPI
OcAsciiPrintBuffer (
IN OUT CHAR8 **AsciiBuffer,
IN OUT UINTN *AsciiBufferSize,
IN CONST CHAR8 *FormatString,
...
);
/**
Returns the first occurrence of a Null-terminated Unicode sub-string
in a Null-terminated Unicode string through a case insensitive comparison.
......@@ -434,8 +452,8 @@ OcAsciiStrToRawGuid (
or String contains more than PcdMaximumUnicodeStringLength Unicode
characters, not including the Null-terminator, then ASSERT().
@param String The pointer to a Null-terminated Unicode string.
@param SearchString The pointer to a Null-terminated Unicode string to search for.
@param[in] String The pointer to a Null-terminated Unicode string.
@param[in] SearchString The pointer to a Null-terminated Unicode string to search for.
@retval NULL If the SearchString does not appear in String.
@return others If there is a match.
......@@ -470,12 +488,12 @@ OcStrStrLength (
/**
Alternative to UnicodeSPrint, which checks that the buffer can contain all the characters.
@param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
Unicode string.
@param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param FormatString A Null-terminated Unicode format string.
@param ... Variable argument list whose contents are accessed based on the
format string specified by FormatString.
@param[out] StartOfBuffer A pointer to the output buffer for the produced Null-terminated
Unicode string.
@param[in] BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param[in] FormatString A Null-terminated Unicode format string.
@param[in] ... Variable argument list whose contents are accessed based on the
format string specified by FormatString.
@retval EFI_SUCCESS When data was printed to supplied buffer.
@retval EFI_OUT_OF_RESOURCES When supplied buffer cannot contain all the characters.
......@@ -613,8 +631,8 @@ HasValidGuidStringPrefix (
mismatched character in SecondString subtracted from the first mismatched
character in FirstString.
@param FirstString A pointer to a Null-terminated Unicode string.
@param SecondString A pointer to a Null-terminated ASCII string.
@param[in] FirstString A pointer to a Null-terminated Unicode string.
@param[in] SecondString A pointer to a Null-terminated ASCII string.
@retval ==0 FirstString is identical to SecondString.
@retval !=0 FirstString is not identical to SecondString.
......
......@@ -223,6 +223,20 @@ typedef struct {
UINT64 ProcessorTestMask;
} EFI_MP_PROC_CONTEXT;
/**
The function prototype for invoking a function on an Application Processor.
This definition is used by the UEFI MP Serices Protocol, and the
PI SMM System Table.
@param[in,out] Buffer The pointer to private data buffer.
**/
typedef
VOID
(EFIAPI *EFI_AP_PROCEDURE)(
IN OUT VOID *Buffer
);
/**
Functions of this type are used with the Framework MP Services Protocol and
the SMM Services Table to execute a procedure on enabled APs. The context
......
此差异已折叠。
......@@ -22,6 +22,7 @@
#include <Library/DebugLib.h>
#include <Library/OcCpuLib.h>
#include <Library/OcGuardLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <IndustryStandard/ProcessorInfo.h>
#include <Register/Microcode.h>
......@@ -737,11 +738,10 @@ ScanAmdProcessor (
}
}
/** Scan the processor and fill the cpu info structure with results
/**
Scan the processor and fill the cpu info structure with results.
@param[in] Cpu A pointer to the cpu info structure to fill with results
@retval EFI_SUCCESS The scan was completed successfully.
@param[in,out] Cpu A pointer to the cpu info structure to fill with results.
**/
VOID
OcCpuScanProcessor (
......@@ -958,6 +958,172 @@ OcCpuScanProcessor (
));
}
VOID
OcCpuGetMsrReport (
IN OC_CPU_INFO *CpuInfo,
OUT OC_CPU_MSR_REPORT *Report
)
{
ASSERT (CpuInfo != NULL);
ASSERT (Report != NULL);
ZeroMem (Report, sizeof (*Report));
//
// The CPU model must be Intel.
//
if (CpuInfo->Vendor[0] != CPUID_VENDOR_INTEL) {
return;
}
if (CpuInfo->CpuGeneration >= OcCpuGenerationNehalem) {
//
// MSR_PLATFORM_INFO
//
Report->CpuHasMsrPlatformInfo = TRUE;
Report->CpuMsrPlatformInfoValue = AsmReadMsr64 (MSR_NEHALEM_PLATFORM_INFO);
//
// MSR_TURBO_RATIO_LIMIT
//
Report->CpuHasMsrTurboRatioLimit = TRUE;
Report->CpuMsrTurboRatioLimitValue = AsmReadMsr64 (MSR_NEHALEM_TURBO_RATIO_LIMIT);
//
// MSR_PKG_POWER_INFO (TODO: To be confirmed)
//
Report->CpuHasMsrPkgPowerInfo = TRUE;
Report->CpuMsrPkgPowerInfoValue = AsmReadMsr64 (MSR_GOLDMONT_PKG_POWER_INFO);
} else {
//
// IA32_MISC_ENABLE
//
Report->CpuHasMsrIa32MiscEnable = TRUE;
Report->CpuMsrIa32MiscEnableValue = AsmReadMsr64 (MSR_IA32_MISC_ENABLES);
//
// MSR_IA32_EXT_CONFIG
//
Report->CpuHasMsrIa32ExtConfig = TRUE;
Report->CpuMsrIa32ExtConfigValue = AsmReadMsr64 (MSR_IA32_EXT_CONFIG);
//
// MSR_CORE_FSB_FREQ
//
Report->CpuHasMsrFsbFreq = TRUE;
Report->CpuMsrFsbFreqValue = AsmReadMsr64 (MSR_CORE_FSB_FREQ);
//
// MSR_IA32_PERF_STATUS
//
Report->CpuHasMsrIa32PerfStatus = TRUE;
Report->CpuMsrIa32PerfStatusValue = AsmReadMsr64 (MSR_IA32_PERF_STATUS);
}
if (CpuInfo->CpuGeneration >= OcCpuGenerationSandyBridge) {
//
// MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER (MSR 0xE2)
//
Report->CpuHasMsrE2 = TRUE;
Report->CpuMsrE2Value = AsmReadMsr64 (MSR_BROADWELL_PKG_CST_CONFIG_CONTROL);
}
}
VOID
EFIAPI
OcCpuGetMsrReportPerCore (
IN OUT VOID *Buffer
)
{
OC_CPU_MSR_REPORT_PROCEDURE_ARGUMENT *Argument;
EFI_STATUS Status;
UINTN CoreIndex;
Argument = (OC_CPU_MSR_REPORT_PROCEDURE_ARGUMENT *) Buffer;
Status = Argument->MpServices->WhoAmI (
Argument->MpServices,
&CoreIndex
);
if (EFI_ERROR (Status)) {
return;
}
OcCpuGetMsrReport (Argument->CpuInfo, &Argument->Reports[CoreIndex]);
}
OC_CPU_MSR_REPORT *
OcCpuGetMsrReports (
IN OC_CPU_INFO *CpuInfo,
OUT UINTN *EntryCount
)
{
OC_CPU_MSR_REPORT *Reports;
EFI_STATUS Status;
EFI_MP_SERVICES_PROTOCOL *MpServices;
UINTN NumberOfProcessors;
UINTN NumberOfEnabledProcessors;
OC_CPU_MSR_REPORT_PROCEDURE_ARGUMENT Argument;
ASSERT (CpuInfo != NULL);
ASSERT (EntryCount != NULL);
MpServices = NULL;
Status = gBS->LocateProtocol (
&gEfiMpServiceProtocolGuid,
NULL,
(VOID **) &MpServices
);
if (!EFI_ERROR (Status)) {
Status = MpServices->GetNumberOfProcessors (
MpServices,
&NumberOfProcessors,
&NumberOfEnabledProcessors
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCCPU: Failed to get the number of processors - %r, assuming one core\n", Status));
NumberOfProcessors = 1;
}
} else {
DEBUG ((DEBUG_INFO, "OCCPU: Failed to find mp services - %r, assuming one core\n", Status));
MpServices = NULL;
NumberOfProcessors = 1;
}
Reports = (OC_CPU_MSR_REPORT *) AllocateZeroPool (NumberOfProcessors * sizeof (OC_CPU_MSR_REPORT));
if (Reports == NULL) {
return NULL;
}
//
// Call OcCpuGetMsrReport on the 0th member firstly.
//
OcCpuGetMsrReport (CpuInfo, &Reports[0]);
//
// Then call StartupAllAPs to fill in the rest.
//
if (MpServices != NULL) {
Argument.MpServices = MpServices;
Argument.Reports = Reports;
Argument.CpuInfo = CpuInfo;
Status = MpServices->StartupAllAPs (
MpServices,
OcCpuGetMsrReportPerCore,
TRUE,
NULL,
5000000,
&Argument,
NULL
);
}
*EntryCount = NumberOfProcessors;
return Reports;
}
VOID
OcCpuCorrectFlexRatio (
IN OC_CPU_INFO *Cpu
......
/** @file
Copyright (C) 2021, PMheart. All rights reserved.
All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PrintLib.h>
#include <Library/OcDeviceMiscLib.h>
#include <Library/OcStringLib.h>
EFI_STATUS
OcMsrDump (
IN OC_CPU_INFO *CpuInfo,
IN EFI_FILE_PROTOCOL *Root
)
{
EFI_STATUS Status;
OC_CPU_MSR_REPORT *Reports;
UINTN EntryCount;
UINTN Index;
CHAR8 *FileBuffer;
UINTN FileBufferSize;
CHAR16 TmpFileName[32];
ASSERT (CpuInfo != NULL);
ASSERT (Root != NULL);
FileBufferSize = SIZE_1KB;
FileBuffer = (CHAR8 *) AllocateZeroPool (FileBufferSize);
if (FileBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Reports = OcCpuGetMsrReports (CpuInfo, &EntryCount);
if (Reports == NULL) {
return EFI_UNSUPPORTED;
}
OcAsciiPrintBuffer (
&FileBuffer,
&FileBufferSize,
"CPU BrandString: %a\nMicrocodeRevision: 0x%08X\nVirtualization %d\n",
CpuInfo->BrandString,
CpuInfo->MicrocodeRevision,
CpuInfo->Hypervisor
);
OcAsciiPrintBuffer (
&FileBuffer,
&FileBufferSize,
"CPUID %08X %08X %08X %08X\nExtSigEcx %08X\nExtSigEdx %08X\n",
CpuInfo->CpuidVerEax.Uint32,
CpuInfo->CpuidVerEbx.Uint32,
CpuInfo->CpuidVerEcx.Uint32,
CpuInfo->CpuidVerEdx.Uint32,
CpuInfo->CpuidExtSigEcx.Uint32,
CpuInfo->CpuidExtSigEdx.Uint32
);
OcAsciiPrintBuffer (
&FileBuffer,
&FileBufferSize,
"Type 0x%02X\nFamily 0x%02X\nModel 0x%02X\nExtModel 0x%02X\nExtFamily 0x%02X\nStepping 0x%02X\n",
CpuInfo->Type,
CpuInfo->Family,
CpuInfo->Model,
CpuInfo->ExtModel,
CpuInfo->ExtFamily,
CpuInfo->Stepping
);
OcAsciiPrintBuffer (
&FileBuffer,
&FileBufferSize,
"Features 0x%16LX\nExtFeatures 0x%16LX\nSignature 0x%08X\n",
CpuInfo->Features,
CpuInfo->ExtFeatures,
CpuInfo->Signature
);
OcAsciiPrintBuffer (
&FileBuffer,
&FileBufferSize,
"Brand 0x%02X\nAppleProcessorType 0x%04X\nCstConfigLock %d\nCpuGeneration %d\n",
CpuInfo->Brand,
CpuInfo->AppleProcessorType,
CpuInfo->CstConfigLock,
CpuInfo->CpuGeneration
);
OcAsciiPrintBuffer (
&FileBuffer,
&FileBufferSize,
"MaxId 0x%08X\nMaxExtId 0x%08X\n",
CpuInfo->MaxId,
CpuInfo->MaxExtId
);
OcAsciiPrintBuffer (
&FileBuffer,
&FileBufferSize,
"PackageCount %u\nCoreCount %u\nThreadCount %u\n",
CpuInfo->PackageCount,
CpuInfo->CoreCount,
CpuInfo->ThreadCount
);
OcAsciiPrintBuffer (
&FileBuffer,
&FileBufferSize,
"ExternalClock %u\n",
CpuInfo->ExternalClock
);
OcAsciiPrintBuffer (
&FileBuffer,
&FileBufferSize,
"ARTFrequency %Lu\nCPUFrequency %Lu\nCPUFrequencyFromTSC %Lu\nCPUFrequencyFromART %Lu\nTscAdjust %Lu\nCPUFrequencyFromApple %Lu\nCPUFrequencyFromVMT %Lu\nFSBFrequency %Lu\n\n",
CpuInfo->ARTFrequency,
CpuInfo->CPUFrequency,
CpuInfo->CPUFrequencyFromTSC,
CpuInfo->CPUFrequencyFromART,
CpuInfo->TscAdjust,
CpuInfo->CPUFrequencyFromApple,
CpuInfo->CPUFrequencyFromVMT,
CpuInfo->FSBFrequency
);
for (Index = 0; Index < EntryCount; ++Index) {
OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize, "CPU%02d:\n", Index);
//
// MSR_PLATFORM_INFO
//
if (Reports[Index].CpuHasMsrPlatformInfo) {
OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize, "MSR_PLATFORM_INFO: 0x%llX\n", Reports[Index].CpuMsrPlatformInfoValue);
}
//
// MSR_TURBO_RATIO_LIMIT
//
if (Reports[Index].CpuHasMsrTurboRatioLimit) {
OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize, "MSR_TURBO_RATIO_LIMIT: 0x%llX\n", Reports[Index].CpuMsrTurboRatioLimitValue);
}
//
// MSR_PKG_POWER_INFO (TODO: To be confirmed)
//
if (Reports[Index].CpuHasMsrPkgPowerInfo) {
OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize, "MSR_PKG_POWER_INFO: 0x%llX\n", Reports[Index].CpuMsrPkgPowerInfoValue);
}
//
// MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER (0xE2)
//
if (Reports[Index].CpuHasMsrE2) {
OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize, "MSR_BROADWELL_PKG_CST_CONFIG_CONTROL_REGISTER (0xE2): 0x%llX\n", Reports[Index].CpuMsrPkgPowerInfoValue);
}
//
// IA32_MISC_ENABLE
//
if (Reports[Index].CpuHasMsrIa32MiscEnable) {
OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize, "IA32_MISC_ENABLE: 0x%llX\n", Reports[Index].CpuMsrIa32MiscEnableValue);
}
//
// MSR_IA32_EXT_CONFIG
//
if (Reports[Index].CpuHasMsrIa32ExtConfig) {
OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize, "MSR_IA32_EXT_CONFIG: 0x%llX\n", Reports[Index].CpuMsrIa32ExtConfigValue);
}
//
// MSR_FSB_FREQ
//
if (Reports[Index].CpuHasMsrFsbFreq) {
OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize, "MSR_FSB_FREQ: 0x%llX\n", Reports[Index].CpuMsrFsbFreqValue);
}
//
// MSR_IA32_PERF_STATUS
//
if (Reports[Index].CpuHasMsrIa32PerfStatus) {
OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize, "MSR_IA32_PERF_STATUS: 0x%llX\n", Reports[Index].CpuMsrIa32PerfStatusValue);
}
OcAsciiPrintBuffer (&FileBuffer, &FileBufferSize, "\n");
}
//
// Save dumped MSR data to file.
//
if (FileBuffer != NULL) {
UnicodeSPrint (TmpFileName, sizeof (TmpFileName), L"MSRStatus.txt");
Status = SetFileData (Root, TmpFileName, FileBuffer, (UINT32) AsciiStrLen (FileBuffer));
DEBUG ((DEBUG_INFO, "OCDM: Dumped MSR data - %r\n", Status));
FreePool (FileBuffer);
}
FreePool (Reports);
return EFI_SUCCESS;
}
......@@ -30,6 +30,7 @@
OpenCorePkg/OpenCorePkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[Guids]
gEfiEventExitBootServicesGuid
......@@ -66,6 +67,7 @@
ActivateHpetSupport.c
DirectReset.c
ForgeUefi.c
MsrDump.c
ReleaseUsbOwnership.c
ReloadOptionRoms.c
ResetAudioTrafficClass.c
......
......@@ -28,7 +28,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/OcAudioLib.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcConsoleLib.h>
#include <Library/OcCpuLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/OcDeviceMiscLib.h>
#include <Library/OcSmbiosLib.h>
#include <Library/OcStringLib.h>
#include <Library/PrintLib.h>
......@@ -90,6 +92,9 @@ ProduceDebugReport (
EFI_FILE_PROTOCOL *Fs;
EFI_FILE_PROTOCOL *SysReport;
EFI_FILE_PROTOCOL *SubReport;
OC_CPU_INFO CpuInfo;
OcCpuScanProcessor (&CpuInfo);
if (VolumeHandle != NULL) {
Fs = LocateRootVolume (VolumeHandle, NULL);
......@@ -174,6 +179,20 @@ ProduceDebugReport (
}
DEBUG ((DEBUG_INFO, "OC: Audio dumping - %r\n", Status));
Status = SafeFileOpen (
SysReport,
&SubReport,
L"MSRStatus",
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
EFI_FILE_DIRECTORY
);
if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OC: Dumping MSRStatus for report...\n"));
Status = OcMsrDump (&CpuInfo, SubReport);
SubReport->Close (SubReport);
}
DEBUG ((DEBUG_INFO, "OC: MSRStatus dumping - %r\n", Status));
SysReport->Close (SysReport);
Fs->Close (Fs);
......
......@@ -22,6 +22,7 @@
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
OpenCorePkg/OpenCorePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
BaseLib
......
......@@ -18,6 +18,7 @@
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PrintLib.h>
#include <Library/OcGuardLib.h>
#include <Library/OcStringLib.h>
// IsAsciiPrint
......@@ -480,3 +481,48 @@ AsciiFilterString (
++String;
}
}
VOID
EFIAPI
OcAsciiPrintBuffer (
IN OUT CHAR8 **AsciiBuffer,
IN OUT UINTN *AsciiBufferSize,
IN CONST CHAR8 *FormatString,
...
)
{
EFI_STATUS Status;
VA_LIST Marker;
CHAR8 Tmp[256];
CHAR8 *NewBuffer;
UINTN NewBufferSize;
if (*AsciiBuffer == NULL) {
return;
}
VA_START (Marker, FormatString);
AsciiVSPrint (Tmp, sizeof (Tmp), FormatString, Marker);
VA_END (Marker);
Status = AsciiStrCatS (*AsciiBuffer, *AsciiBufferSize, Tmp);
if (Status == EFI_BUFFER_TOO_SMALL) {
if (OcOverflowMulUN (*AsciiBufferSize, 2, &NewBufferSize)) {
return;
}
NewBuffer = ReallocatePool (*AsciiBufferSize, NewBufferSize, *AsciiBuffer);
if (NewBuffer == NULL) {
FreePool (*AsciiBuffer);
*AsciiBuffer = NULL;
*AsciiBufferSize = 0;
return;
}
*AsciiBuffer = NewBuffer;
*AsciiBufferSize = NewBufferSize;
AsciiStrCatS (*AsciiBuffer, *AsciiBufferSize, Tmp);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册