aboutsummaryrefslogtreecommitdiff
path: root/src/vendorcode/amd/agesa/f14/Lib/amdlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vendorcode/amd/agesa/f14/Lib/amdlib.c')
-rw-r--r--src/vendorcode/amd/agesa/f14/Lib/amdlib.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/vendorcode/amd/agesa/f14/Lib/amdlib.c b/src/vendorcode/amd/agesa/f14/Lib/amdlib.c
index 963aa7e2e1..24c162a731 100644
--- a/src/vendorcode/amd/agesa/f14/Lib/amdlib.c
+++ b/src/vendorcode/amd/agesa/f14/Lib/amdlib.c
@@ -343,17 +343,25 @@ LibAmdBitScanForward (
}
return (UINT8) Index;
}
+
UINT8
LibAmdBitScanReverse (
IN UINT32 value
)
{
- UINT8 Index;
- for (Index = 31; Index >= 0; Index--){
- if (value & (1 << Index)) return Index;
- }
- return 0xFF;
+ uint8_t bit = 31;
+ do {
+ if (value & (1 << 31))
+ return bit;
+
+ value <<= 1;
+ bit--;
+
+ } while (value != 0);
+
+ return 0xFF; /* Error code indicating no bit found */
}
+
VOID
LibAmdMsrRead (
IN UINT32 MsrAddress,