Skip to content

Commit

Permalink
Formatting fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaneee committed Sep 10, 2024
1 parent 9656a0c commit 256e8db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
5 changes: 2 additions & 3 deletions Library/OcAppleKernelLib/CpuidPatches.c
Original file line number Diff line number Diff line change
Expand Up @@ -1651,16 +1651,15 @@ PatchProvideCurrentCpuInfo (
busFreqValue = CpuInfo->FSBFrequency;

// Handle case where FSBFrequency is zero, providing a fallback
if (busFreqValue == 0)
{
if (busFreqValue == 0) {
busFreqValue = 100000000; // Assume 100 MHz FSB as fallback
DEBUG ((DEBUG_WARN, "OCAK: FSBFrequency is zero, using fallback value: 100 MHz\n"));
}

busFCvtt2nValue = DivU64x64Remainder ((1000000000ULL << 32), busFreqValue, NULL);
busFCvtn2tValue = DivU64x64Remainder ((1000000000ULL << 32), busFCvtt2nValue, NULL);

tscFreqValue = CpuInfo->CPUFrequency;
tscFreqValue = CpuInfo->CPUFrequency;
tscFCvtt2nValue = DivU64x64Remainder ((1000000000ULL << 32), tscFreqValue, NULL);
tscFCvtn2tValue = DivU64x64Remainder ((1000000000ULL << 32), tscFCvtt2nValue, NULL);
}
Expand Down
24 changes: 13 additions & 11 deletions Library/OcCpuLib/OcCpuLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,9 @@ ScanAmdProcessor (
switch (Cpu->ExtFamily) {
case AMD_CPU_EXT_FAMILY_1AH:
if (Cpu->CPUFrequencyFromVMT == 0) {
CofVid = AsmReadMsr64(K10_PSTATE_STATUS);
CoreFrequencyID = (UINT16)BitFieldRead64(CofVid, 0, 11); // 12-bit field for FID
CofVid = AsmReadMsr64 (K10_PSTATE_STATUS);
CoreFrequencyID = (UINT16)BitFieldRead64 (CofVid, 0, 11); // 12-bit field for FID

// On AMD Family 1Ah and later, if the Frequency ID (FID) exceeds 0x0f,
// the core frequency is scaled by a factor of 5. This scaling behavior
// is based on Linux kernel logic for handling higher frequency multipliers
Expand All @@ -703,19 +703,21 @@ ScanAmdProcessor (
if (CoreFrequencyID > 0x0f) {
CoreFrequencyID *= 5;
}

MaxBusRatio = (UINT8)(CoreFrequencyID);
}

//
// Get core count from CPUID
//
if (Cpu->MaxExtId >= 0x8000001E) {
AsmCpuid(0x8000001E, NULL, &CpuidEbx, NULL, NULL);
Cpu->CoreCount = (UINT16)DivU64x32(
Cpu->ThreadCount,
(BitFieldRead32(CpuidEbx, 8, 15) + 1)
);
AsmCpuid (0x8000001E, NULL, &CpuidEbx, NULL, NULL);
Cpu->CoreCount = (UINT16)DivU64x32 (
Cpu->ThreadCount,
(BitFieldRead32 (CpuidEbx, 8, 15) + 1)
);
}

break;
case AMD_CPU_EXT_FAMILY_17H:
case AMD_CPU_EXT_FAMILY_19H:
Expand Down Expand Up @@ -815,9 +817,9 @@ ScanAmdProcessor (
} else {
// Special handling for Family 1Ah
if (Cpu->ExtFamily == AMD_CPU_EXT_FAMILY_1AH) {
Cpu->FSBFrequency = DivU64x32(Cpu->CPUFrequency, CoreFrequencyID); // No divisor for Family 1Ah
Cpu->FSBFrequency = DivU64x32 (Cpu->CPUFrequency, CoreFrequencyID); // No divisor for Family 1Ah
} else {
Cpu->FSBFrequency = DivU64x32(Cpu->CPUFrequency, MaxBusRatio);
Cpu->FSBFrequency = DivU64x32 (Cpu->CPUFrequency, MaxBusRatio);
}
}
}
Expand Down

0 comments on commit 256e8db

Please sign in to comment.