MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / GetCPUProperties

Function GetCPUProperties

rEFIt_UEFI/Platform/cpu.cpp:110–1163  ·  view source on GitHub ↗

Should be used after PrepatchSmbios() but before users's config.plist reading

Source from the content-addressed store, hash-verified

108// Should be used after PrepatchSmbios() but before users's config.plist reading
109//
110VOID GetCPUProperties (VOID)
111{
112 UINT32 reg[4];
113 UINT64 msr = 0;
114
115 EFI_STATUS Status;
116 EFI_HANDLE *HandleBuffer;
117 // EFI_GUID **ProtocolGuidArray;
118 EFI_PCI_IO_PROTOCOL *PciIo;
119 PCI_TYPE00 Pci;
120 UINTN HandleCount;
121 // UINTN ArrayCount;
122 UINTN HandleIndex;
123 // UINTN ProtocolIndex;
124 UINT64 qpibusspeed; //units=kHz
125 UINT32 qpimult = 2;
126 UINT32 BusSpeed = 0; //units kHz
127 UINT64 ExternalClock;
128 UINT64 tmpU;
129 UINT16 did, vid;
130 UINTN Segment;
131 UINTN Bus;
132 UINTN Device;
133 UINTN Function;
134 CHAR8 str[128];
135
136 DbgHeader("GetCPUProperties");
137
138 //initial values
139 gCPUStructure.MaxRatio = 10; //keep it as K*10
140 gCPUStructure.MinRatio = 10; //same
141 gCPUStructure.SubDivider = 0;
142 gSettings.CpuFreqMHz = 0;
143 gCPUStructure.FSBFrequency = MultU64x32(gCPUStructure.ExternalClock, kilo); //kHz -> Hz
144 gCPUStructure.ProcessorInterconnectSpeed = 0;
145 gCPUStructure.Mobile = FALSE; //not same as gMobile
146
147 if (!gCPUStructure.CurrentSpeed) {
148 gCPUStructure.CurrentSpeed = (UINT32)DivU64x32(gCPUStructure.TSCCalibr + (Mega >> 1), Mega);
149 }
150 if (!gCPUStructure.MaxSpeed) {
151 gCPUStructure.MaxSpeed = gCPUStructure.CurrentSpeed;
152 }
153
154 /* get CPUID Values */
155 DoCpuid(0, gCPUStructure.CPUID[CPUID_0]);
156 gCPUStructure.Vendor = gCPUStructure.CPUID[CPUID_0][EBX];
157 /*
158 * Get processor signature and decode
159 * and bracket this with the approved procedure for reading the
160 * the microcode version number a.k.a. signature a.k.a. BIOS ID
161 */
162 if (gCPUStructure.Vendor == CPU_VENDOR_INTEL) {
163 AsmWriteMsr64(MSR_IA32_BIOS_SIGN_ID, 0);
164 }
165 DoCpuid(1, gCPUStructure.CPUID[CPUID_1]);
166 gCPUStructure.Signature = gCPUStructure.CPUID[CPUID_1][EAX];
167 DBG("CPU Vendor = %X Model=%X\n", gCPUStructure.Vendor, gCPUStructure.Signature);

Callers 1

RefitMainFunction · 0.85

Calls 15

DbgHeaderFunction · 0.85
MultU64x32Function · 0.85
DivU64x32Function · 0.85
DoCpuidFunction · 0.85
RShiftU64Function · 0.85
AsciiStrnCpySFunction · 0.85
strncmpFunction · 0.85
iStrLenFunction · 0.85
post_startup_cpu_fixupsFunction · 0.85
LShiftU64Function · 0.85
DivU64x64RemainderFunction · 0.85
MultU64x64Function · 0.85

Tested by

no test coverage detected