Quick hack to load OpneRuntime.efi.

UINTN to uintptr_t.
Conditionnal code in OpenCorePkg.
This commit is contained in:
jief666 2020-10-11 09:06:50 +03:00
parent 743b036202
commit 4d5ccc026f
8 changed files with 74 additions and 29 deletions

@ -1 +1 @@
Subproject commit 69c719f978f42cb65eed25c654fc04a76a635d10
Subproject commit b114709c9ae8f823951fda29a6d103523c1344a5

View File

@ -1018,7 +1018,7 @@ EFI_STATUS DumpTable(EFI_ACPI_DESCRIPTION_HEADER *TableEntry, CONST CHAR8 *Check
OemTableId[8] = 0;
stripTrailingSpaces(OemTableId);
DBG(" %llx: '%s', '%s', Rev: %d, Len: %d", (UINTN)TableEntry, Signature, OemTableId, TableEntry->Revision, TableEntry->Length);
DBG(" %llx: '%s', '%s', Rev: %d, Len: %d", (uintptr_t)TableEntry, Signature, OemTableId, TableEntry->Revision, TableEntry->Length);
//
// Additional checks
@ -1150,7 +1150,7 @@ EFI_STATUS DumpFadtTables(EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt, CONST
// Take Signature for printing
CopyMem(&Signature[0], &Facs->Signature, 4);
Signature[4] = 0;
DBG(" %llx: '%s', Ver: %d, Len: %d", (UINTN)Facs, Signature, Facs->Version, Facs->Length);
DBG(" %llx: '%s', Ver: %d, Len: %d", (uintptr_t)Facs, Signature, Facs->Version, Facs->Length);
// FACS checks
if (Facs->Signature != EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) {
@ -1208,7 +1208,7 @@ EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE* GetFadt()
RsdPtr = NULL;
/*Status = */EfiGetSystemConfigurationTable (&gEfiAcpi20TableGuid, (void**)&RsdPtr);
if (RsdPtr != NULL) {
DBG("Found UEFI Acpi 2.0 RSDP at %llx\n", (UINTN)RsdPtr);
DBG("Found UEFI Acpi 2.0 RSDP at %llx\n", (uintptr_t)RsdPtr);
Rsdt = (RSDT_TABLE*)(UINTN)(RsdPtr->RsdtAddress);
if (RsdPtr->Revision > 0) {
if (Rsdt == NULL || Rsdt->Header.Signature != EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {
@ -1251,13 +1251,13 @@ void DumpTables(void *RsdPtrVoid, CONST CHAR16 *DirName)
//
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER* RsdPtr = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER*)RsdPtrVoid;
if (DirName != NULL) {
DBG("Saving ACPI tables from RSDP %llx to %ls ...\n", (UINTN)RsdPtr, DirName);
DBG("Saving ACPI tables from RSDP %llx to %ls ...\n", (uintptr_t)RsdPtr, DirName);
} else {
DBG("Printing ACPI tables from RSDP %llx ...\n", (UINTN)RsdPtr);
DBG("Printing ACPI tables from RSDP %llx ...\n", (uintptr_t)RsdPtr);
}
if (RsdPtr->Signature != EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE) {
DBG(" RsdPrt at %llx has invaid signature 0x%llx - exiting.\n", (UINTN)RsdPtr, RsdPtr->Signature);
DBG(" RsdPrt at %llx has invaid signature 0x%llx - exiting.\n", (uintptr_t)RsdPtr, RsdPtr->Signature);
return;
}
@ -1270,7 +1270,7 @@ void DumpTables(void *RsdPtrVoid, CONST CHAR16 *DirName)
Rsdt = NULL;
Xsdt = NULL;
DBG(" %llx: '%s', Rev: %d", (UINTN)RsdPtr, Signature, RsdPtr->Revision);
DBG(" %llx: '%s', Rev: %d", (uintptr_t)RsdPtr, Signature, RsdPtr->Revision);
if (RsdPtr->Revision == 0) {
// Acpi 1.0
Length = sizeof(EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER);

View File

@ -183,7 +183,7 @@ CreateBootOptionDevicePath (
//
Status = gBS->HandleProtocol (FileDeviceHandle, &gEfiSimpleFileSystemProtocolGuid, (void**)&Volume);
if (EFI_ERROR(Status)) {
DBG("CreateBootOptionDevicePath: FileDeviceHandle %llx is not fs volume", (UINTN)FileDeviceHandle);
DBG("CreateBootOptionDevicePath: FileDeviceHandle %llx is not fs volume", (uintptr_t)FileDeviceHandle);
return EFI_INVALID_PARAMETER;
}
@ -756,7 +756,7 @@ FindBootOptionForFile (
UINTN SearchedDevicePathSize[2];
DBG("FindBootOptionForFile: %llx, %ls\n", (UINTN)FileDeviceHandle, FileName.wc_str());
DBG("FindBootOptionForFile: %llx, %ls\n", (uintptr_t)FileDeviceHandle, FileName.wc_str());
//
// Get BootOrder - we will search only options listed in BootOrder.
@ -1012,7 +1012,7 @@ AddBootOptionForFile (
DBG("\nAddBootOptionForFile: %llx, %ls, %ls\n %ls, %llu\n",
(UINTN)FileDeviceHandle, FileName.wc_str(),
(uintptr_t)FileDeviceHandle, FileName.wc_str(),
UseShortForm ? L"ShortDevPath" : L"FullDevPath",
Description, BootIndex);
@ -1111,7 +1111,7 @@ DeleteBootOptionForFile (
IN UINT16 BootNum;
DBG("\nDeleteBootOptionForFile: %llx, %ls\n", (UINTN)FileDeviceHandle, FileName.wc_str());
DBG("\nDeleteBootOptionForFile: %llx, %ls\n", (uintptr_t)FileDeviceHandle, FileName.wc_str());
do {
Status = FindBootOptionForFile (FileDeviceHandle, FileName, &BootNum, NULL);
if (!EFI_ERROR(Status)) {

View File

@ -68,7 +68,7 @@ InitializeBiosIntCaller (
mThunkContext->RealModeBuffer = (void*)(UINTN)LegacyRegionBase;
mThunkContext->RealModeBufferSize = LegacyRegionSize;
mThunkContext->ThunkAttributes = THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15;
DBG("mThunkContext->RealModeBuffer: %llx, mThunkContext->RealModeBufferSize: %d\n", (UINTN)(mThunkContext->RealModeBuffer), mThunkContext->RealModeBufferSize);
DBG("mThunkContext->RealModeBuffer: %llx, mThunkContext->RealModeBufferSize: %d\n", (uintptr_t)(mThunkContext->RealModeBuffer), mThunkContext->RealModeBufferSize);
AsmPrepareThunk16(mThunkContext);
return Status;
}

View File

@ -803,7 +803,7 @@ EFI_STATUS bootPBR(REFIT_VOLUME* volume, BOOLEAN SataReset)
//Status = LegacyBios->GetBbsInfo(LegacyBios, &HddCount, &HddInfo, &BbsCount, &BbsTable);
//DBG("GetBbsInfo = %s, HddCnt=%d, HddInfo=%p, BbsCount=%d, BbsTabl%p\n", efiStrError(Status), HddCount, HddInfo, BbsCount, BbsTable);
Status = LegacyBios->PrepareToBootEfi(LegacyBios, &BbsCount, &BbsTable);
DBG("PrepareToBootEfi = %s, BbsCount=%d, BbsTabl%llx\n", efiStrError(Status), BbsCount, (UINTN)BbsTable);
DBG("PrepareToBootEfi = %s, BbsCount=%d, BbsTabl%llx\n", efiStrError(Status), BbsCount, (uintptr_t)BbsTable);
//PauseForKey(L"continue ...\n");
//

View File

@ -3046,7 +3046,7 @@ GetEarlyUserSettings (
gSettings.KernelAndKextPatches.OcKernelCache = "Auto"_XS8;
}
}else{
MsgLog("MALFORMED PLIST : KernelAndKextPatches/KernelCache must be a string");
MsgLog("MALFORMED PLIST : Quirks/KernelCache must be a string");
gSettings.KernelAndKextPatches.OcKernelCache = "Auto"_XS8;
}
}

View File

@ -120,6 +120,8 @@ BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
if (!EFI_ERROR(Status))
return FALSE;
MsgLog("Fatal Error: %s %ls\n", efiStrError(Status), where);
// StatusToString(ErrorName, Status);
gST->ConOut->SetAttribute (gST->ConOut, EFI_RED | EFI_BACKGROUND_BLACK);
printf("Fatal Error: %s %ls\n", efiStrError(Status), where);
@ -138,6 +140,8 @@ BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
if (!EFI_ERROR(Status))
return FALSE;
MsgLog("Fatal Error: %s %ls\n", efiStrError(Status), where);
// StatusToString(ErrorName, Status);
gST->ConOut->SetAttribute (gST->ConOut, EFI_RED | EFI_BACKGROUND_BLACK);
printf("Error: %s %ls\n", efiStrError(Status), where);

View File

@ -385,7 +385,7 @@ void DumpKernelAndKextPatches(KERNEL_AND_KEXT_PATCHES *Patches)
DBG("Kernel and Kext Patches null pointer\n");
return;
}
DBG("Kernel and Kext Patches at %llx:\n", (UINTN)Patches);
DBG("Kernel and Kext Patches at %llx:\n", (uintptr_t)Patches);
DBG("\tAllowed: %c\n", gSettings.KextPatchesAllowed ? 'y' : 'n');
DBG("\tDebug: %c\n", Patches->KPDebug ? 'y' : 'n');
// DBG("\tKernelCpu: %c\n", Patches->KPKernelCpu ? 'y' : 'n');
@ -397,23 +397,23 @@ void DumpKernelAndKextPatches(KERNEL_AND_KEXT_PATCHES *Patches)
// Dell smbios truncate fix
DBG("\tDellSMBIOSPatch: %c\n", Patches->KPDELLSMBIOS ? 'y' : 'n');
DBG("\tFakeCPUID: 0x%X\n", Patches->FakeCPUID);
DBG("\tATIController: %s\n", (Patches->KPATIConnectorsController == NULL) ? "(null)": Patches->KPATIConnectorsController);
DBG("\tATIDataLength: %d\n", Patches->KPATIConnectorsDataLen);
DBG("\t%d Kexts to load\n", Patches->ForceKexts.size());
if (Patches->ForceKexts) {
INTN i = 0;
DBG("\tATIController: %s\n", Patches->KPATIConnectorsController.isEmpty() ? "(null)": Patches->KPATIConnectorsController.c_str());
DBG("\tATIDataLength: %zu\n", Patches->KPATIConnectorsData.size());
DBG("\t%zu Kexts to load\n", Patches->ForceKexts.size());
if (Patches->ForceKexts.size()) {
size_t i = 0;
for (; i < Patches->ForceKexts.size(); ++i) {
DBG("\t KextToLoad[%d]: %ls\n", i, Patches->ForceKexts[i]);
DBG("\t KextToLoad[%zu]: %ls\n", i, Patches->ForceKexts[i].wc_str());
}
}
DBG("\t%d Kexts to patch\n", Patches->KextPatches.size());
if (Patches->KextPatches) {
INTN i = 0;
DBG("\t%zu Kexts to patch\n", Patches->KextPatches.size());
if (Patches->KextPatches.size()) {
size_t i = 0;
for (; i < Patches->KextPatches.size(); ++i) {
if (Patches->KextPatches[i].IsPlistPatch) {
DBG("\t KextPatchPlist[%d]: %d bytes, %s\n", i, Patches->KextPatches[i].DataLen, Patches->KextPatches[i].Name);
DBG("\t KextPatchPlist[%zu]: %zu bytes, %s\n", i, Patches->KextPatches[i].Data.size(), Patches->KextPatches[i].Name.c_str());
} else {
DBG("\t KextPatch[%d]: %d bytes, %s\n", i, Patches->KextPatches[i].DataLen, Patches->KextPatches[i].Name);
DBG("\t KextPatch[%zu]: %zu bytes, %s\n", i, Patches->KextPatches[i].Data.size(), Patches->KextPatches[i].Name.c_str());
}
}
}
@ -687,6 +687,26 @@ size_t setKextAtPos(XObjArray<SIDELOAD_KEXT>* kextArrayPtr, const XString8& kext
return pos;
}
static XStringW getDriversPath()
{
#if defined(MDE_CPU_X64)
if (gFirmwareClover) {
if (FileExists(&self.getCloverDir(), L"drivers\\BIOS")) {
return L"drivers\\BIOS"_XSW;
} else {
return L"drivers64"_XSW;
}
} else
if (FileExists(&self.getCloverDir(), L"drivers\\UEFI")) {
return L"drivers\\UEFI"_XSW;
} else {
return L"drivers64UEFI"_XSW;
}
#else
return L"drivers32"_XSW;
#endif
}
void debugStartImageWithOC()
{
MsgLog("debugStartImageWithOC\n");
@ -959,10 +979,12 @@ DBG("Beginning OC\n");
#endif
}
#ifndef USE_OC_SECTION_Misc
OC_STRING_ASSIGN(mOpenCoreConfiguration.Misc.Security.SecureBootModel, "Disabled");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Misc.Security.Vault, "Optional");
#endif
#ifdef USE_OC_SECTION_Nvram
mOpenCoreConfiguration.Nvram.WriteFlash = true;
#ifdef JIEF_DEBUG
#endif
#ifndef USE_OC_SECTION_Booter
@ -1144,7 +1166,26 @@ DBG("Beginning OC\n");
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* FileSystem = LocateFileSystem(OcLoadedImage->DeviceHandle, OcLoadedImage->FilePath);
Status = OcStorageInitFromFs(&mOpenCoreStorage, FileSystem, self.getCloverDirPathAsXStringW().wc_str(), NULL);
XStringW FileName = SWPrintf("%ls\\%ls\\%s", self.getCloverDirPathAsXStringW().wc_str(), getDriversPath().wc_str(), "OpenRuntime.efi");
EFI_HANDLE DriverHandle;
Status = gBS->LoadImage(false, gImageHandle, FileDevicePath(self.getSelfLoadedImage().DeviceHandle, FileName), NULL, 0, &DriverHandle);
DBG("Load OpenRuntime.efi : Status %s\n", efiStrError(Status));
Status = gBS->StartImage(DriverHandle, 0, 0);
DBG("Start OpenRuntime.efi : Status %s\n", efiStrError(Status));
OcMain(&mOpenCoreStorage, NULL);
// {
// gCurrentConfig = &gMainConfig;
// RedirectRuntimeServices();
// EFI_HANDLE Handle = NULL;
// Status = gBS->InstallMultipleProtocolInterfaces (
// &Handle,
// &gOcFirmwareRuntimeProtocolGuid,
// &mOcFirmwareRuntimeProtocol,
// NULL
// );
// DBG("Install gOcFirmwareRuntimeProtocolGuid : Status %s\n", efiStrError(Status));
// }
CHAR16* UnicodeDevicePath = NULL; (void)UnicodeDevicePath;
UnicodeDevicePath = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
@ -1851,7 +1892,7 @@ void DisconnectInvalidDiskIoChildDrivers(void)
Found = TRUE;
Status = gBS->DisconnectController (Handles[Index], OpenInfo[OpenInfoIndex].AgentHandle, NULL);
//DBG(" BY_DRIVER Agent: %p, Disconnect: %s", OpenInfo[OpenInfoIndex].AgentHandle, efiStrError(Status));
DBG(" - Handle %llx with DiskIo, is Partition, no Fs, BY_DRIVER Agent: %llx, Disconnect: %s\n", (UINTN)Handles[Index], (UINTN)(OpenInfo[OpenInfoIndex].AgentHandle), efiStrError(Status));
DBG(" - Handle %llx with DiskIo, is Partition, no Fs, BY_DRIVER Agent: %llx, Disconnect: %s\n", (uintptr_t)Handles[Index], (uintptr_t)(OpenInfo[OpenInfoIndex].AgentHandle), efiStrError(Status));
}
}
FreePool(OpenInfo);