Skip to content

Commit 24165f1

Browse files
author
jief
committed
Improve log messages of ACPI pacthing methods.
1 parent 671353f commit 24165f1

1 file changed

Lines changed: 31 additions & 26 deletions

File tree

rEFIt_UEFI/Platform/FixBiosDsdt.cpp

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,6 @@ UINT32 FixAny (UINT8* dsdt, UINT32 len, const XBuffer<UINT8> ToFind, const XBuff
17831783
INT32 sizeoffset = 0; // Initialization just to silence warning.
17841784
INT32 adr;
17851785
// UINT32 i;
1786-
XBool found = false;
17871786
if ( ToFind.isEmpty() || ToReplace.isEmpty() ) {
17881787
DBG(" invalid patches!\n");
17891788
return len;
@@ -1808,47 +1807,49 @@ UINT32 FixAny (UINT8* dsdt, UINT32 len, const XBuffer<UINT8> ToFind, const XBuff
18081807
sizeoffset = (INT32)(ToFind.size() - ToReplace.size()); // Safe cast because of earlier check
18091808
sizeoffset = -sizeoffset;
18101809
}
1810+
XBool found = false;
1811+
UINT32 nb_replaced = 0;
18111812
for (UINT32 i = 20; i < len; ) {
18121813
adr = FindBin(dsdt + i, len - i, ToFind);
18131814
if (adr < 0) {
1814-
if (found) {
1815-
MsgLog(" ]\n");
1816-
} else {
1817-
MsgLog(" bin not found / already patched!\n");
1818-
}
1819-
return len;
1815+
break;
18201816
}
18211817

18221818
if (!found) {
18231819
MsgLog(" patched at: [");
1824-
MsgLog(" (%X)", adr); //print once because whole duration is 26 seconds!!!
1820+
}else{
1821+
MsgLog(", ");
18251822
}
18261823

1827-
// MsgLog(" (%X)", adr);
18281824
found = true;
18291825
if ( Skip == 0 )
18301826
{
1827+
MsgLog("%X", adr);
18311828
len = move_data(adr + i, dsdt, len, sizeoffset);
18321829
CopyMem(dsdt + adr + i, ToReplace.data(), ToReplace.size());
18331830
len = CorrectOuterMethod(dsdt, len, adr + i - 2, sizeoffset);
18341831
len = CorrectOuters(dsdt, len, adr + i - 3, sizeoffset);
18351832
i += (UINT32)(adr + ToReplace.size()); // if there is no bug before, it should be safe cast.
1833+
nb_replaced += 1;
18361834
if (--count == 0) break;
18371835
}else{
1838-
MsgLog("Skip i=%d ",i);
1836+
MsgLog("Skip %X", adr);
18391837
i += (UINT32)(adr + ToFind.size()); // if there is no bug before, it should be safe cast.
18401838
Skip--;
18411839
}
18421840
}
1843-
MsgLog(" ]\n"); //should not be here
1841+
if ( nb_replaced > 0 ) {
1842+
MsgLog("]\n");
1843+
} else {
1844+
MsgLog(" bin not found / already patched!\n");
1845+
}
18441846
return len;
18451847
}
18461848

18471849
//new method. by goodwin_c
18481850
UINT32 FixRenameByBridge2(UINT8* dsdt, UINT32 len, const XBuffer<UINT8>& TgtBrgName, const XBuffer<UINT8>& ToFind, const XBuffer<UINT8>& ToReplace, uint64_t Skip, int count)
18491851
{
18501852
INT32 adr;
1851-
XBool found = false;
18521853
UINT32 BrdADR = 0, BridgeSize;
18531854

18541855
if ( ToFind.isEmpty() || ToReplace.isEmpty() ) {
@@ -1868,10 +1869,13 @@ UINT32 FixRenameByBridge2(UINT8* dsdt, UINT32 len, const XBuffer<UINT8>& TgtBrgN
18681869
MsgLog(", ");
18691870
}
18701871
if ((ToFind.size() + sizeof(EFI_ACPI_DESCRIPTION_HEADER)) > len) {
1871-
DBG(" the patch is too large!\n");
1872+
MsgLog(" the patch is too large!\n");
18721873
return len;
18731874
}
18741875

1876+
XBool found = false;
1877+
UINT32 nb_replaced = 0;
1878+
18751879
DBG("Start ByBridge Rename Fix\n");
18761880
for (UINT32 i=0x20; len >= 10 && i < len - 10; i++) {
18771881
if (CmpDev(dsdt, i, TgtBrgName)) {
@@ -1883,39 +1887,40 @@ UINT32 FixRenameByBridge2(UINT8* dsdt, UINT32 len, const XBuffer<UINT8>& TgtBrgN
18831887
if(!BridgeSize) continue;
18841888
if(BridgeSize <= ToFind.size()) continue;
18851889

1886-
UINT32 k = 0;
18871890
found = false;
1888-
while (k <= 100) {
1891+
for ( UINT32 k = 0 ; k <= 100 ; ++k ) {
18891892
adr = FindBin(dsdt + BrdADR, BridgeSize, ToFind);
18901893
if (adr < 0) {
1891-
if (found) {
1892-
DBG(" ]\n");
1893-
} else {
1894-
DBG(" bin not found / already patched!\n");
1895-
}
1896-
return len;
1894+
break;
18971895
}
18981896

18991897
if (!found) {
1900-
DBG(" patched at: [");
1898+
MsgLog(" patched at: [");
1899+
}else{
1900+
MsgLog(", ");
19011901
}
19021902

1903-
DBG(" (%X)", adr);
19041903
found = true;
19051904
if ( ToReplace.notEmpty() ) {
19061905
if ( Skip == 0 ) {
19071906
CopyMem(dsdt + BrdADR + adr, ToReplace.data(), ToReplace.size());
1907+
MsgLog("%X", adr);
1908+
nb_replaced += 1;
19081909
if (--count == 0) break;
19091910
} else {
1910-
MsgLog("Skip adr=%d ",adr);
1911+
MsgLog("Skip %X",adr);
19111912
Skip--;
19121913
}
19131914
}
1914-
k++;
19151915
}
19161916
}
19171917
}
1918-
DBG(" ]\n");
1918+
DBG("End ByBridge Rename Fix\n");
1919+
if ( nb_replaced > 0 ) {
1920+
MsgLog("]\n");
1921+
} else {
1922+
MsgLog(" bin not found / already patched!\n");
1923+
}
19191924
return len;
19201925
}
19211926

0 commit comments

Comments
 (0)