exclude unused variables, move globals into class

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2020-05-11 18:44:00 +03:00
parent 9fae59d10c
commit 56c4e4dd48
8 changed files with 87 additions and 79 deletions

View File

@ -2050,7 +2050,7 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, CHAR8 *OSVersion)
FixChecksum(&FadtPointer->Header);
}
}
dropDSM = 0xFFFF; //by default we drop all OEM _DSM. They have no sense for us.
// dropDSM = 0xFFFF; //by default we drop all OEM _DSM. They have no sense for us.
// if (defDSM) {
// dropDSM = gSettings.DropOEM_DSM; //if set by user
// }

View File

@ -107,8 +107,8 @@ RT_VARIABLES *RtVariables;
BOOLEAN gFirmwareClover = FALSE;
UINTN gEvent;
UINT16 gBacklightLevel;
BOOLEAN defDSM;
UINT16 dropDSM;
//BOOLEAN defDSM;
//UINT16 dropDSM;
BOOLEAN GetLegacyLanAddress;
BOOLEAN ResumeFromCoreStorage;

View File

@ -278,9 +278,9 @@ VOID GetCPUProperties (VOID)
gCPUStructure.CPUID[CPUID_87][EDX] & (UINT32)CPUID_EXTFEATURE_TSCI;
}
if ((bit(9) & gCPUStructure.CPUID[CPUID_1][ECX]) != 0) {
SSSE3 = TRUE;
}
// if ((bit(9) & gCPUStructure.CPUID[CPUID_1][ECX]) != 0) {
// SSSE3 = TRUE;
// }
gCPUStructure.Turbo = FALSE;
if (gCPUStructure.Vendor == CPU_VENDOR_INTEL) {
// Determine turbo boost support

View File

@ -35,39 +35,26 @@
//#define DBG_RT( ...) if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPDebug) { printf(__VA_ARGS__); }
EFI_PHYSICAL_ADDRESS KernelRelocBase = 0;
BootArgs1 *bootArgs1 = NULL;
BootArgs2 *bootArgs2 = NULL;
CHAR8 *dtRoot = NULL;
UINT32 *dtLength;
//EFI_PHYSICAL_ADDRESS KernelRelocBase = 0;
//BootArgs1 *bootArgs1 = NULL;
//BootArgs2 *bootArgs2 = NULL;
//CHAR8 *dtRoot = NULL;
//UINT32 *dtLength;
//UINT8 *KernelData = NULL;
UINT32 KernelSlide = 0;
BOOLEAN isKernelcache = FALSE;
BOOLEAN is64BitKernel = FALSE;
BOOLEAN SSSE3;
//UINT32 KernelSlide = 0;
//BOOLEAN isKernelcache = FALSE;
//BOOLEAN is64BitKernel = FALSE;
//BOOLEAN SSSE3;
BOOLEAN PatcherInited = FALSE;
BOOLEAN gSNBEAICPUFixRequire = FALSE; // SandyBridge-E AppleIntelCpuPowerManagement patch require or not
BOOLEAN gBDWEIOPCIFixRequire = FALSE; // Broadwell-E IOPCIFamily fix require or not
//BOOLEAN PatcherInited = FALSE;
//BOOLEAN gSNBEAICPUFixRequire = FALSE; // SandyBridge-E AppleIntelCpuPowerManagement patch require or not
//BOOLEAN gBDWEIOPCIFixRequire = FALSE; // Broadwell-E IOPCIFamily fix require or not
// notes:
// - 64bit segCmd64->vmaddr is 0xffffff80xxxxxxxx and we are taking
// only lower 32bit part into PrelinkTextAddr
// - PrelinkTextAddr is segCmd64->vmaddr + KernelRelocBase
UINT32 PrelinkTextLoadCmdAddr = 0;
UINT32 PrelinkTextAddr = 0;
UINT32 PrelinkTextSize = 0;
// notes:
// - 64bit sect->addr is 0xffffff80xxxxxxxx and we are taking
// only lower 32bit part into PrelinkInfoAddr
// - PrelinkInfoAddr is sect->addr + KernelRelocBase
UINT32 PrelinkInfoLoadCmdAddr = 0;
UINT32 PrelinkInfoAddr = 0;
UINT32 PrelinkInfoSize = 0;
VOID SetKernelRelocBase()
/*
* the driver OsxAptioFixDrv is old and mostly not used in favour of its successors.
* anyway we will keep it for new investigations.
*/
VOID LOADER_ENTRY::SetKernelRelocBase()
{
// EFI_STATUS Status;
UINTN DataSize = sizeof(KernelRelocBase);
@ -1915,7 +1902,7 @@ VOID LOADER_ENTRY::Get_PreLink()
PrelinkTextSize = (UINT32)segCmd64->vmsize;
PrelinkTextLoadCmdAddr = (UINT32)(UINTN)segCmd64;
}
DBG("at %p: vmaddr = 0x%llx, vmsize = 0x%llx\n", segCmd64, segCmd64->vmaddr, segCmd64->vmsize);
DBG("at %p: vmaddr = 0x%llx, vmsize = 0x%llx\n", segCmd64, segCmd64->vmaddr, segCmd64->vmsize);
DBG("PrelinkTextLoadCmdAddr = 0x%X, PrelinkTextAddr = 0x%X, PrelinkTextSize = 0x%X\n",
PrelinkTextLoadCmdAddr, PrelinkTextAddr, PrelinkTextSize);
//DBG("cmd = 0x%08X\n",segCmd64->cmd);
@ -1936,8 +1923,8 @@ VOID LOADER_ENTRY::Get_PreLink()
DBG("Found PRELINK_INFO, 64bit\n");
//DBG("cmd = 0x%08X\n",segCmd64->cmd);
//DBG("cmdsize = 0x%08X\n",segCmd64->cmdsize);
DBG("vmaddr = 0x%08llX\n",segCmd64->vmaddr);
DBG("vmsize = 0x%08llX\n",segCmd64->vmsize);
DBG("vmaddr = 0x%08llX\n",segCmd64->vmaddr);
DBG("vmsize = 0x%08llX\n",segCmd64->vmsize);
//DBG("fileoff = 0x%08X\n",segCmd64->fileoff);
//DBG("filesize = 0x%08X\n",segCmd64->filesize);
//DBG("maxprot = 0x%08X\n",segCmd64->maxprot);
@ -1958,7 +1945,7 @@ VOID LOADER_ENTRY::Get_PreLink()
PrelinkInfoAddr = (UINT32)(sect->addr ? sect->addr + KernelRelocBase : 0);
PrelinkInfoSize = (UINT32)sect->size;
}
DBG("__info found at %p: addr = 0x%llx, size = 0x%llx\n", sect, sect->addr, sect->size);
DBG("__info found at %p: addr = 0x%llx, size = 0x%llx\n", sect, sect->addr, sect->size);
DBG("PrelinkInfoLoadCmdAddr = 0x%X, PrelinkInfoAddr = 0x%X, PrelinkInfoSize = 0x%X\n",
PrelinkInfoLoadCmdAddr, PrelinkInfoAddr, PrelinkInfoSize);
}
@ -1979,7 +1966,7 @@ VOID LOADER_ENTRY::Get_PreLink()
PrelinkTextSize = (UINT32)segCmd->vmsize;
PrelinkTextLoadCmdAddr = (UINT32)(UINTN)segCmd;
}
DBG("at %p: vmaddr = 0x%x, vmsize = 0x%x\n", segCmd, segCmd->vmaddr, segCmd->vmsize);
DBG("at %p: vmaddr = 0x%x, vmsize = 0x%x\n", segCmd, segCmd->vmaddr, segCmd->vmsize);
DBG("PrelinkTextLoadCmdAddr = 0x%X, PrelinkTextAddr = 0x%X, PrelinkTextSize = 0x%X\n",
PrelinkTextLoadCmdAddr, PrelinkTextAddr, PrelinkTextSize);
//gBS->Stall(30*1000000);
@ -2012,7 +1999,7 @@ VOID LOADER_ENTRY::Get_PreLink()
PrelinkInfoAddr = (UINT32)(sect->addr ? sect->addr + KernelRelocBase : 0);
PrelinkInfoSize = (UINT32)sect->size;
}
DBG("__info found at %p: addr = 0x%x, size = 0x%x\n", sect, sect->addr, sect->size);
DBG("__info found at %p: addr = 0x%x, size = 0x%x\n", sect, sect->addr, sect->size);
DBG("PrelinkInfoLoadCmdAddr = 0x%X, PrelinkInfoAddr = 0x%X, PrelinkInfoSize = 0x%X\n",
PrelinkInfoLoadCmdAddr, PrelinkInfoAddr, PrelinkInfoSize);
//gBS->Stall(30*1000000);
@ -2057,13 +2044,13 @@ LOADER_ENTRY::FindBootArgs()
dtLength = &bootArgs2->deviceTreeLength;
KernelSlide = bootArgs2->kslide;
DBG_RT( "Found bootArgs2 at 0x%llX, DevTree at 0x%llX\n", (UINTN)ptr, (UINTN)bootArgs2->deviceTreeP);
DBG_RT( "Found bootArgs2 at 0x%llX, DevTree at 0x%llX\n", (UINTN)ptr, (UINTN)bootArgs2->deviceTreeP);
//DBG("bootArgs2->kaddr = 0x%08X and bootArgs2->ksize = 0x%08X\n", bootArgs2->kaddr, bootArgs2->ksize);
//DBG("bootArgs2->efiMode = 0x%02X\n", bootArgs2->efiMode);
DBG_RT( "bootArgs2->CommandLine = %s\n", bootArgs2->CommandLine);
DBG_RT( "bootArgs2->CommandLine = %s\n", bootArgs2->CommandLine);
DBG_RT( "bootArgs2->flags = 0x%hx\n", bootArgs2->flags);
DBG_RT( "bootArgs2->kslide = 0x%x\n", bootArgs2->kslide);
DBG_RT( "bootArgs2->bootMemStart = 0x%llx\n", bootArgs2->bootMemStart);
DBG_RT( "bootArgs2->bootMemStart = 0x%llx\n", bootArgs2->bootMemStart);
if (KernelAndKextPatches && KernelAndKextPatches->KPDebug)
gBS->Stall(2000000);
@ -2086,7 +2073,7 @@ LOADER_ENTRY::FindBootArgs()
dtRoot = (CHAR8*)(UINTN)bootArgs1->deviceTreeP;
dtLength = &bootArgs1->deviceTreeLength;
DBG_RT( "Found bootArgs1 at 0x%8s, DevTree at %p\n", ptr, dtRoot);
DBG_RT( "Found bootArgs1 at 0x%8s, DevTree at %p\n", ptr, dtRoot);
//DBG("bootArgs1->kaddr = 0x%08X and bootArgs1->ksize = 0x%08X\n", bootArgs1->kaddr, bootArgs1->ksize);
//DBG("bootArgs1->efiMode = 0x%02X\n", bootArgs1->efiMode);
@ -2294,9 +2281,12 @@ VOID
LOADER_ENTRY::KernelAndKextsPatcherStart()
{
BOOLEAN KextPatchesNeeded, patchedOk;
// it was intended for custom entries but not work if no suctom entries used
// so set common until better solution invented
/*
* it was intended for custom entries but not work if no custom entries used
* so set common until better solution invented
*/
KernelAndKextPatches = (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches));
// we will call KernelAndKextPatcherInit() only if needed
if (KernelAndKextPatches == NULL) return; //entry is not null as double check

View File

@ -103,38 +103,23 @@ typedef struct SEGMENT {
} SEGMENT;
extern EFI_PHYSICAL_ADDRESS KernelRelocBase;
extern BootArgs1 *bootArgs1;
extern BootArgs2 *bootArgs2;
extern CHAR8 *dtRoot;
extern UINT32 *dtLength;
extern UINT8 *KernelData;
extern UINT32 KernelSlide;
extern BOOLEAN isKernelcache;
extern BOOLEAN is64BitKernel;
extern BOOLEAN gSNBEAICPUFixRequire; // SandyBridge-E AppleIntelCpuPowerManagement patch require or not
extern BOOLEAN gBDWEIOPCIFixRequire; // Broadwell-E IOPCIFamily fix require or not
//extern EFI_PHYSICAL_ADDRESS KernelRelocBase;
//extern BootArgs1 *bootArgs1;
//extern BootArgs2 *bootArgs2;
//extern CHAR8 *dtRoot;
//extern UINT32 *dtLength;
//extern UINT8 *KernelData;
//extern UINT32 KernelSlide;
//extern BOOLEAN isKernelcache;
//extern BOOLEAN is64BitKernel;
//extern BOOLEAN gSNBEAICPUFixRequire; // SandyBridge-E AppleIntelCpuPowerManagement patch require or not
//extern BOOLEAN gBDWEIOPCIFixRequire; // Broadwell-E IOPCIFamily fix require or not
// notes:
// - 64bit segCmd64->vmaddr is 0xffffff80xxxxxxxx and we are taking
// only lower 32bit part into PrelinkTextAddr
// - PrelinkTextAddr is segCmd64->vmaddr + KernelRelocBase
extern UINT32 PrelinkTextLoadCmdAddr;
extern UINT32 PrelinkTextAddr;
extern UINT32 PrelinkTextSize;
// notes:
// - 64bit sect->addr is 0xffffff80xxxxxxxx and we are taking
// only lower 32bit part into PrelinkInfoAddr
// - PrelinkInfoAddr is sect->addr + KernelRelocBase
extern UINT32 PrelinkInfoLoadCmdAddr;
extern UINT32 PrelinkInfoAddr;
extern UINT32 PrelinkInfoSize;
extern UINT32 DisplayVendor[];
//extern UINT32 DisplayVendor[];
//VOID findCPUfamily();
extern BOOLEAN SSSE3;
//extern BOOLEAN SSSE3;
//UINT64 kernelsize;

View File

@ -920,7 +920,7 @@ VOID EFIAPI LOADER_ENTRY::KernelBooterExtensionsPatch()
UINTN NumSnow_X64_EXT = 0;
UINTN NumLion_i386_EXT = 0;
UINTN NumLion_X64_EXT = 0;
UINT32 patchLocation2 = 0, patchLocation3 = 0;
UINTN patchLocation2 = 0, patchLocation3 = 0;
DBG_RT("\nPatching kernel for injected kexts...\n");

View File

@ -39,6 +39,7 @@
#include "../../libeg/libeg.h"
#include "../../refit/lib.h"
#include "../../Platform/LoaderUefi.h"
#include "../../Platform/boot.h"
#include "../../cpp_foundation/XObjArray.h"
#include "../../cpp_foundation/XStringArray.h"
@ -363,14 +364,46 @@ class REFIT_ABSTRACT_MENU_ENTRY
UINT32 NamesTable;
INT32 SegVAddr;
INT32 shift;
BOOLEAN PatcherInited;
BOOLEAN gSNBEAICPUFixRequire; // SandyBridge-E AppleIntelCpuPowerManagement patch require or not
BOOLEAN gBDWEIOPCIFixRequire; // Broadwell-E IOPCIFamily fix require or not
BOOLEAN isKernelcache;
BOOLEAN is64BitKernel;
UINT32 KernelSlide;
// notes:
// - 64bit segCmd64->vmaddr is 0xffffff80xxxxxxxx and we are taking
// only lower 32bit part into PrelinkTextAddr
// - PrelinkTextAddr is segCmd64->vmaddr + KernelRelocBase
UINT32 PrelinkTextLoadCmdAddr;
UINT32 PrelinkTextAddr;
UINT32 PrelinkTextSize;
// notes:
// - 64bit sect->addr is 0xffffff80xxxxxxxx and we are taking
// only lower 32bit part into PrelinkInfoAddr
// - PrelinkInfoAddr is sect->addr + KernelRelocBase
UINT32 PrelinkInfoLoadCmdAddr;
UINT32 PrelinkInfoAddr;
UINT32 PrelinkInfoSize;
EFI_PHYSICAL_ADDRESS KernelRelocBase;
BootArgs1 *bootArgs1;
BootArgs2 *bootArgs2;
CHAR8 *dtRoot;
UINT32 *dtLength;
LOADER_ENTRY()
: REFIT_MENU_ITEM_BOOTNUM(), VolName(0), DevicePath(0), Flags(0), LoaderType(0), OSVersion(0), BuildVersion(0),
BootBgColor({0,0,0,0}),
CustomBoot(0), KernelAndKextPatches(0), Settings(0), KernelData(0),
AddrVtable(0), SizeVtable(0), NamesTable(0), shift(0)
AddrVtable(0), SizeVtable(0), NamesTable(0), shift(0),
PatcherInited(false), gSNBEAICPUFixRequire(false), gBDWEIOPCIFixRequire(false), isKernelcache(false), is64BitKernel(false),
KernelSlide(0), PrelinkTextLoadCmdAddr(0), PrelinkTextAddr(0), PrelinkTextSize(0),
PrelinkInfoLoadCmdAddr(0), PrelinkInfoAddr(0), PrelinkInfoSize(0),
KernelRelocBase(0), bootArgs1(0), bootArgs2(0), dtRoot(0), dtLength(0)
{};
VOID SetKernelRelocBase();
VOID FindBootArgs();
EFI_STATUS getVTable();
VOID Get_PreLink();

View File

@ -518,7 +518,7 @@ VOID FillInputs(BOOLEAN New)
}
snwprintf(InputItems[InputItemsCount++].SValue, 26, "0x%08X", gSettings.FakeXHCI);
InputItems[InputItemsCount].ItemType = CheckBit; //101 - vacant
InputItems[InputItemsCount++].IValue = dropDSM;
InputItems[InputItemsCount++].IValue = 0; //dropDSM;
InputItems[InputItemsCount].ItemType = BoolValue; //102
InputItems[InputItemsCount++].BValue = gSettings.DebugDSDT;