提交 1672d8fb 编写于 作者: V vit9696

Add AppleMajorType to CPU_INFO

上级 8ea219ed
......@@ -12,8 +12,8 @@
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef OC_CPU_LIB_H_
#define OC_CPU_LIB_H_
#ifndef OC_CPU_LIB_H
#define OC_CPU_LIB_H
// CPU_INFO
typedef struct {
......@@ -30,6 +30,7 @@ typedef struct {
UINT64 ExtFeatures;
UINT32 Signature;
UINT8 Brand;
UINT8 AppleMajorType;
UINT32 MaxExtId;
......@@ -60,7 +61,7 @@ typedef struct {
**/
EFI_STATUS
OcCpuScanProcessor (
IN CPU_INFO *Platform
IN OUT CPU_INFO *Cpu
);
#endif // OC_CPU_LIB_H_
......@@ -17,6 +17,7 @@
#include <IndustryStandard/CpuId.h>
#include <IndustryStandard/GenericIch.h>
#include <IndustryStandard/Pci.h>
#include <IndustryStandard/AppleSmBios.h>
#include <Protocol/PciIo.h>
......@@ -27,6 +28,7 @@
#include <Library/IoLib.h>
#include <Library/OcCpuLib.h>
#include <Library/PciLib.h>
#include <Library/OcStringLib.h>
#include <Library/OcTimerLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
......@@ -44,7 +46,7 @@
**/
EFI_STATUS
OcCpuScanProcessor (
IN CPU_INFO *Cpu
IN OUT CPU_INFO *Cpu
)
{
EFI_STATUS Status;
......@@ -54,6 +56,7 @@ OcCpuScanProcessor (
UINT32 CpuidEcx;
UINT32 CpuidEdx;
UINT64 Msr = 0;
CONST CHAR8 *BrandInfix;
DEBUG_FUNCTION_ENTRY (DEBUG_VERBOSE);
......@@ -133,6 +136,58 @@ OcCpuScanProcessor (
if (*(UINT32 *)Cpu->Vendor == CPUID_VENDOR_INTEL) {
BrandInfix = AsciiStrStr (Cpu->BrandString, "Core");
if (BrandInfix != NULL) {
while ((*BrandInfix != ' ') && (*BrandInfix != '\0')) {
++BrandInfix;
}
while (*BrandInfix == ' ') {
++BrandInfix;
}
if (AsciiStrnCmp (BrandInfix, "i7", L_STR_LEN("i7")) == 0) {
Cpu->AppleMajorType = AppleProcessorMajorI7;
} else if (AsciiStrnCmp (BrandInfix, "i5", L_STR_LEN("i5")) == 0) {
Cpu->AppleMajorType = AppleProcessorMajorI5;
} else if (AsciiStrnCmp (BrandInfix, "i3", L_STR_LEN("i3")) == 0) {
Cpu->AppleMajorType = AppleProcessorMajorI3;
} else if (AsciiStrnCmp (BrandInfix, "i9", L_STR_LEN("i9")) == 0) {
Cpu->AppleMajorType = AppleProcessorMajorI9;
} else if (AsciiStrnCmp (BrandInfix, "m3", L_STR_LEN("m3")) == 0) {
Cpu->AppleMajorType = AppleProcessorMajorM3;
} else if (AsciiStrnCmp (BrandInfix, "m5", L_STR_LEN("m5")) == 0) {
Cpu->AppleMajorType = AppleProcessorMajorM5;
} else if (AsciiStrnCmp (BrandInfix, "m7", L_STR_LEN("m7")) == 0) {
Cpu->AppleMajorType = AppleProcessorMajorM7;
} else if (AsciiStrnCmp (BrandInfix, "M", L_STR_LEN("M")) == 0) {
Cpu->AppleMajorType = AppleProcessorMajorM;
} else if (AsciiStrnCmp (BrandInfix, "2 Duo", L_STR_LEN("2 Duo")) == 0) {
Cpu->AppleMajorType = AppleProcessorMajorCore2;
} else {
Cpu->AppleMajorType = AppleProcessorMajorCore;
}
} else {
BrandInfix = AsciiStrStr (Cpu->BrandString, "Xeon");
if (BrandInfix != NULL) {
while ((*BrandInfix != ' ') && (*BrandInfix != '\0')) {
++BrandInfix;
}
while (*BrandInfix == ' ') {
++BrandInfix;
}
if (AsciiStrnCmp (BrandInfix, "E5", L_STR_LEN("E5")) == 0) {
Cpu->AppleMajorType = AppleProcessorMajorXeonE5;
} else if (AsciiStrnCmp (BrandInfix, "W", L_STR_LEN("W")) == 0) {
Cpu->AppleMajorType = AppleProcessorMajorXeonW;
} else {
Cpu->AppleMajorType = AppleProcessorMajorXeonNehalem;
}
}
}
Msr = AsmReadMsr64 (MSR_PKG_CST_CONFIG_CONTROL);
if ((Cpu->Family == 0x06 && Cpu->Model >= 0x0c) ||
......
......@@ -31,6 +31,7 @@
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
EfiPkg/EfiPkg.dec
[LibraryClasses]
BaseLib
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册