summaryrefslogtreecommitdiff
path: root/src/vendorcode/amd/agesa/f12/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/vendorcode/amd/agesa/f12/Lib')
-rw-r--r--src/vendorcode/amd/agesa/f12/Lib/amdlib.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/vendorcode/amd/agesa/f12/Lib/amdlib.c b/src/vendorcode/amd/agesa/f12/Lib/amdlib.c
index 1ca9b552b8..9ce10b635d 100644
--- a/src/vendorcode/amd/agesa/f12/Lib/amdlib.c
+++ b/src/vendorcode/amd/agesa/f12/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,