Fix TgtBridge.

This commit is contained in:
jief666 2020-10-07 12:15:21 +03:00
parent 648f5c3d3b
commit 64c6c10fdf
4 changed files with 27 additions and 15 deletions

View File

@ -1289,13 +1289,8 @@ BOOLEAN CmpPNP (UINT8 *dsdt, UINT32 j, UINT16 PNP)
(dsdt[j + 9] == ((PNP & 0x00ff) >> 0))); (dsdt[j + 9] == ((PNP & 0x00ff) >> 0)));
} }
template <typename T, enable_if( is___String(T) )> INT32 CmpDev(UINT8 *dsdt, UINT32 i, const char Name[4])
INT32 CmpDev(UINT8 *dsdt, UINT32 i, const T& Name)
{ {
if ( Name.length() != 4 ) {
MsgLog("ATTENTION : CmpDev called with a %s with length() != 4 %ld\n", Name.data(), Name.length());
return 0;
}
if ((dsdt[i+0] == Name[0]) && (dsdt[i+1] == Name[1]) && if ((dsdt[i+0] == Name[0]) && (dsdt[i+1] == Name[1]) &&
(dsdt[i+2] == Name[2]) && (dsdt[i+3] == Name[3]) && (dsdt[i+2] == Name[2]) && (dsdt[i+3] == Name[3]) &&
(((dsdt[i-2] == 0x82) && (dsdt[i-3] == 0x5B) && (dsdt[i-1] < 0x40)) || (((dsdt[i-2] == 0x82) && (dsdt[i-3] == 0x5B) && (dsdt[i-1] < 0x40)) ||
@ -1313,13 +1308,23 @@ INT32 CmpDev(UINT8 *dsdt, UINT32 i, const T& Name)
return 0; return 0;
} }
INT32 CmpDev(UINT8 *dsdt, UINT32 i, CONST CHAR8* Name) //template <typename T, enable_if( is___String(T) )>
INT32 CmpDev(UINT8 *dsdt, UINT32 i, const XString8& Name)
{ {
if ( !Name ) { if ( Name.length() != 4 ) {
MsgLog("ATTENTION : CmpDev called with a name == NULL\n"); MsgLog("ATTENTION : CmpDev called with a %s with length() != 4 %ld\n", Name.data(), Name.length());
return 0; return 0;
} }
return CmpDev(dsdt, i, LString8(Name)); return CmpDev(dsdt, i, Name.c_str());
}
INT32 CmpDev(UINT8 *dsdt, UINT32 i, const XBuffer<UINT8>& Name)
{
if ( Name.size() != 4 ) {
MsgLog("ATTENTION : CmpDev called with a name whose size() != 4\n");
return 0;
}
return CmpDev(dsdt, i, Name.CData());
} }
//the procedure can find BIN array UNSIGNED CHAR8 sizeof N inside part of large array "dsdt" size of len //the procedure can find BIN array UNSIGNED CHAR8 sizeof N inside part of large array "dsdt" size of len
@ -1811,7 +1816,7 @@ UINT32 FixAny (UINT8* dsdt, UINT32 len, const XBuffer<UINT8> ToFind, const XBuff
} }
//new method. by goodwin_c //new method. by goodwin_c
UINT32 FixRenameByBridge2 (UINT8* dsdt, UINT32 len, const XString8& TgtBrgName, const XBuffer<UINT8>& ToFind, const XBuffer<UINT8>& ToReplace) UINT32 FixRenameByBridge2 (UINT8* dsdt, UINT32 len, const XBuffer<UINT8>& TgtBrgName, const XBuffer<UINT8>& ToFind, const XBuffer<UINT8>& ToReplace)
{ {
INT32 adr; INT32 adr;
BOOLEAN found = FALSE; BOOLEAN found = FALSE;

View File

@ -84,7 +84,7 @@ INT32 FindBin (UINT8 *dsdt, size_t len, const XBuffer<UINT8>& bin);
UINT32 FixAny (UINT8* dsdt, UINT32 len, const XBuffer<UINT8> ToFind, const XBuffer<UINT8> ToReplace); UINT32 FixAny (UINT8* dsdt, UINT32 len, const XBuffer<UINT8> ToFind, const XBuffer<UINT8> ToReplace);
UINT32 FixRenameByBridge2 (UINT8* dsdt, UINT32 len, const XString8& TgtBrgName, const XBuffer<UINT8>& ToFind, const XBuffer<UINT8>& ToReplace); UINT32 FixRenameByBridge2 (UINT8* dsdt, UINT32 len, const XBuffer<UINT8>& TgtBrgName, const XBuffer<UINT8>& ToFind, const XBuffer<UINT8>& ToReplace);

View File

@ -4468,8 +4468,15 @@ static void getACPISettings(const TagDict *CfgDict)
dsdtPatch.PatchDsdtReplace.stealValueFrom(data, Size); dsdtPatch.PatchDsdtReplace.stealValueFrom(data, Size);
DBG(", lenToReplace: %zu", dsdtPatch.PatchDsdtReplace.size()); DBG(", lenToReplace: %zu", dsdtPatch.PatchDsdtReplace.size());
data = GetDataSetting (Prop2, "TgtBridge", &Size); data = GetDataSetting (Prop2, "TgtBridge", &Size);
dsdtPatch.PatchDsdtTgt.stealValueFrom((char*)data); if ( Size != 0 ) {
DBG(", Target Bridge: %s\n", dsdtPatch.PatchDsdtTgt.c_str()); if ( Size != 4 ) {
DBG("\n TgtBridge must 4 bytes. It's %llu byte(s). Ignored\n", Size);
}else{
dsdtPatch.PatchDsdtTgt.stealValueFrom(data, Size);
DBG(", Target Bridge: %c%c%c%c", dsdtPatch.PatchDsdtTgt[0], dsdtPatch.PatchDsdtTgt[1], dsdtPatch.PatchDsdtTgt[2], dsdtPatch.PatchDsdtTgt[3]);
}
}
DBG("\n");
if (!dsdtPatch.PatchDsdtMenuItem.BValue) { if (!dsdtPatch.PatchDsdtMenuItem.BValue) {
DBG(" patch disabled at config\n"); DBG(" patch disabled at config\n");
} }

View File

@ -216,7 +216,7 @@ public :
XBuffer<UINT8> PatchDsdtFind; XBuffer<UINT8> PatchDsdtFind;
XBuffer<UINT8> PatchDsdtReplace; XBuffer<UINT8> PatchDsdtReplace;
XString8 PatchDsdtLabel; XString8 PatchDsdtLabel;
XString8 PatchDsdtTgt; XBuffer<UINT8> PatchDsdtTgt;
INPUT_ITEM PatchDsdtMenuItem; INPUT_ITEM PatchDsdtMenuItem;
DSDT_Patch() : PatchDsdtFind(), PatchDsdtReplace(), PatchDsdtLabel(), PatchDsdtTgt(), PatchDsdtMenuItem() { } DSDT_Patch() : PatchDsdtFind(), PatchDsdtReplace(), PatchDsdtLabel(), PatchDsdtTgt(), PatchDsdtMenuItem() { }