mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2025-02-02 22:51:28 +01:00
Move all OpenCore initialisation in StarLoader11.
This commit is contained in:
parent
9f93857fd3
commit
5f3adb976e
@ -462,7 +462,8 @@
|
|||||||
gEmuVariableControlProtocolGuid
|
gEmuVariableControlProtocolGuid
|
||||||
gEfiAudioIoProtocolGuid # CONSUMES
|
gEfiAudioIoProtocolGuid # CONSUMES
|
||||||
gOcQuirksProtocolGuid
|
gOcQuirksProtocolGuid
|
||||||
|
gAptioMemoryFixProtocolGuid
|
||||||
|
|
||||||
[FeaturePcd]
|
[FeaturePcd]
|
||||||
gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
|
gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
|
||||||
|
|
||||||
|
@ -1068,114 +1068,159 @@ VOID LOADER_ENTRY::StartLoader11()
|
|||||||
DbgHeader("StartLoader11");
|
DbgHeader("StartLoader11");
|
||||||
|
|
||||||
|
|
||||||
// if (Settings.notEmpty()) {
|
if (Settings.notEmpty()) {
|
||||||
// DBG(" Settings: %ls\n", Settings.wc_str());
|
DBG(" Settings: %ls\n", Settings.wc_str());
|
||||||
// Status = LoadUserSettings(SelfRootDir, Settings, &dict);
|
TagDict* dict;
|
||||||
// if (!EFI_ERROR(Status)) {
|
Status = LoadUserSettings(SelfRootDir, Settings, &dict);
|
||||||
// DBG(" - found custom settings for this entry: %ls\n", Settings.wc_str());
|
if (!EFI_ERROR(Status)) {
|
||||||
// gBootChanged = TRUE;
|
DBG(" - found custom settings for this entry: %ls\n", Settings.wc_str());
|
||||||
// Status = GetUserSettings(dict);
|
gBootChanged = TRUE;
|
||||||
// if (EFI_ERROR(Status)) {
|
Status = GetUserSettings(dict);
|
||||||
// DBG(" - ... but: %s\n", efiStrError(Status));
|
if (EFI_ERROR(Status)) {
|
||||||
// } else {
|
DBG(" - ... but: %s\n", efiStrError(Status));
|
||||||
// if ((gSettings.CpuFreqMHz > 100) && (gSettings.CpuFreqMHz < 20000)) {
|
} else {
|
||||||
// gCPUStructure.MaxSpeed = gSettings.CpuFreqMHz;
|
if ((gSettings.CpuFreqMHz > 100) && (gSettings.CpuFreqMHz < 20000)) {
|
||||||
// }
|
gCPUStructure.MaxSpeed = gSettings.CpuFreqMHz;
|
||||||
// //CopyMem(KernelAndKextPatches,
|
}
|
||||||
// // &gSettings.KernelAndKextPatches,
|
//CopyMem(KernelAndKextPatches,
|
||||||
// // sizeof(KERNEL_AND_KEXT_PATCHES));
|
// &gSettings.KernelAndKextPatches,
|
||||||
// //DBG("Custom KernelAndKextPatches copyed to started entry\n");
|
// sizeof(KERNEL_AND_KEXT_PATCHES));
|
||||||
// }
|
//DBG("Custom KernelAndKextPatches copyed to started entry\n");
|
||||||
// } else {
|
}
|
||||||
// DBG(" - [!] LoadUserSettings failed: %s\n", efiStrError(Status));
|
} else {
|
||||||
// }
|
DBG(" - [!] LoadUserSettings failed: %s\n", efiStrError(Status));
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DBG("Finally: ExternalClock=%lluMHz BusSpeed=%llukHz CPUFreq=%uMHz",
|
DBG("Finally: ExternalClock=%lluMHz BusSpeed=%llukHz CPUFreq=%uMHz",
|
||||||
// DivU64x32(gCPUStructure.ExternalClock + kilo - 1, kilo),
|
DivU64x32(gCPUStructure.ExternalClock + kilo - 1, kilo),
|
||||||
// DivU64x32(gCPUStructure.FSBFrequency + kilo - 1, kilo),
|
DivU64x32(gCPUStructure.FSBFrequency + kilo - 1, kilo),
|
||||||
// gCPUStructure.MaxSpeed);
|
gCPUStructure.MaxSpeed);
|
||||||
// if (gSettings.QPI) {
|
if (gSettings.QPI) {
|
||||||
// DBG(" QPI: hw.busfrequency=%lluHz\n", MultU64x32(gSettings.QPI, Mega));
|
DBG(" QPI: hw.busfrequency=%lluHz\n", MultU64x32(gSettings.QPI, Mega));
|
||||||
// } else {
|
} else {
|
||||||
// // to match the value of hw.busfrequency in the terminal
|
// to match the value of hw.busfrequency in the terminal
|
||||||
// DBG(" PIS: hw.busfrequency=%lluHz\n", MultU64x32(LShiftU64(DivU64x32(gCPUStructure.ExternalClock + kilo - 1, kilo), 2), Mega));
|
DBG(" PIS: hw.busfrequency=%lluHz\n", MultU64x32(LShiftU64(DivU64x32(gCPUStructure.ExternalClock + kilo - 1, kilo), 2), Mega));
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (OSVersion.notEmpty() && (AsciiOSVersionToUint64(OSVersion) >= AsciiOSVersionToUint64("10.11"_XS8))) {
|
||||||
|
if (OSFLAG_ISSET(Flags, OSFLAG_NOSIP)) {
|
||||||
|
gSettings.CsrActiveConfig = (UINT32)0xB7F;
|
||||||
|
gSettings.BooterConfig = 0x28;
|
||||||
|
}
|
||||||
|
// ReadSIPCfg();
|
||||||
|
}
|
||||||
|
|
||||||
|
FilterKextPatches();
|
||||||
|
FilterKernelPatches();
|
||||||
|
FilterBootPatches();
|
||||||
|
if (LoadedImage && !BooterPatch((UINT8*)LoadedImage->ImageBase, LoadedImage->ImageSize)) {
|
||||||
|
DBG("Will not patch boot.efi\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set boot argument for kernel if no caches, this should force kernel loading
|
||||||
|
if ( OSFLAG_ISSET(Flags, OSFLAG_NOCACHES) && !LoadOptions.containsStartWithIC("Kernel=") ) {
|
||||||
|
XString8 KernelLocation;
|
||||||
|
|
||||||
|
if (OSVersion.notEmpty() && AsciiOSVersionToUint64(OSVersion) <= AsciiOSVersionToUint64("10.9"_XS8)) {
|
||||||
|
KernelLocation.S8Printf("\"Kernel=/mach_kernel\"");
|
||||||
|
} else {
|
||||||
|
// used for 10.10, 10.11, and new version.
|
||||||
|
KernelLocation.S8Printf("\"Kernel=/System/Library/Kernels/kernel\"");
|
||||||
|
}
|
||||||
|
LoadOptions.AddID(KernelLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
//we are booting OSX - restore emulation if it's not installed before g boot.efi
|
||||||
|
if (gEmuVariableControl != NULL) {
|
||||||
|
gEmuVariableControl->InstallEmulation(gEmuVariableControl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// first patchACPI and find PCIROOT and RTC
|
||||||
|
// but before ACPI patch we need smbios patch
|
||||||
|
CheckEmptyFB();
|
||||||
|
PatchSmbios();
|
||||||
|
// DBG("PatchACPI\n");
|
||||||
|
PatchACPI(Volume, OSVersion);
|
||||||
|
|
||||||
|
// If KPDebug is true boot in verbose mode to see the debug messages
|
||||||
|
if (KernelAndKextPatches.KPDebug) {
|
||||||
|
LoadOptions.AddID("-v"_XS8);
|
||||||
|
}
|
||||||
|
|
||||||
|
DbgHeader("RestSetup macOS");
|
||||||
|
|
||||||
|
// DBG("SetDevices\n");
|
||||||
|
SetDevices(this);
|
||||||
|
// DBG("SetFSInjection\n");
|
||||||
|
SetFSInjection();
|
||||||
|
//PauseForKey(L"SetFSInjection");
|
||||||
|
// DBG("SetVariablesForOSX\n");
|
||||||
|
SetVariablesForOSX(this);
|
||||||
|
// DBG("SetVariablesForOSX\n");
|
||||||
|
EventsInitialize(this);
|
||||||
|
// DBG("FinalizeSmbios\n");
|
||||||
|
FinalizeSmbios();
|
||||||
|
|
||||||
|
SetCPUProperties();
|
||||||
|
|
||||||
|
if (OSFLAG_ISSET(Flags, OSFLAG_HIBERNATED)) {
|
||||||
|
DoHibernateWake = PrepareHibernation(Volume);
|
||||||
|
}
|
||||||
|
SetupDataForOSX(DoHibernateWake);
|
||||||
|
|
||||||
|
|
||||||
|
if ( gDriversFlags.AptioFixLoaded &&
|
||||||
|
!DoHibernateWake &&
|
||||||
|
!LoadOptions.containsStartWithIC("slide=") ) {
|
||||||
|
// Add slide=0 argument for ML+ if not present
|
||||||
|
LoadOptions.AddID("slide=0"_XS8);
|
||||||
|
}
|
||||||
|
|
||||||
|
// UINTN HandleCount = 0;
|
||||||
|
// EFI_HANDLE* HandleBuffer = NULL;
|
||||||
|
// EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo = NULL;
|
||||||
|
// UINTN OpenInfoCount;
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// if (OSVersion.notEmpty() && (AsciiOSVersionToUint64(OSVersion) >= AsciiOSVersionToUint64("10.11"_XS8))) {
|
// Status = gBS->LocateHandleBuffer (ByProtocol, &gAptioMemoryFixProtocolGuid, NULL, &HandleCount, &HandleBuffer);
|
||||||
// if (OSFLAG_ISSET(Flags, OSFLAG_NOSIP)) {
|
// if ( !EFI_ERROR(Status) )
|
||||||
// gSettings.CsrActiveConfig = (UINT32)0xB7F;
|
// {
|
||||||
// gSettings.BooterConfig = 0x28;
|
// for (UINTN HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
|
||||||
|
// EFI_HANDLE Interface = NULL;
|
||||||
|
// Status = gBS->HandleProtocol(HandleBuffer[HandleIndex], &gAptioMemoryFixProtocolGuid, &Interface);
|
||||||
|
// if ( !EFI_ERROR(Status) ) {
|
||||||
|
// Status = gBS->UninstallProtocolInterface(HandleBuffer[HandleIndex], &gAptioMemoryFixProtocolGuid, Interface);
|
||||||
|
// if (EFI_ERROR(Status)) panic("Cannot uninstall AptioMemoryFix protocol. Status=%s\n", efiStrError(Status));
|
||||||
|
// }else{
|
||||||
|
// if ( Status != EFI_UNSUPPORTED ) DBG("HandleProtocol status=%s\n", efiStrError(Status));
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
//// ReadSIPCfg();
|
// }else{
|
||||||
|
// DBG("LocateHandleBuffer status=%s\n", efiStrError(Status));
|
||||||
|
// // Assume no protocol AptioMemoryFix is installed.
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// FilterKextPatches();
|
|
||||||
// FilterKernelPatches();
|
|
||||||
// FilterBootPatches();
|
|
||||||
// if (LoadedImage && !BooterPatch((UINT8*)LoadedImage->ImageBase, LoadedImage->ImageSize)) {
|
|
||||||
// DBG("Will not patch boot.efi\n");
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// // Set boot argument for kernel if no caches, this should force kernel loading
|
EFI_LOADED_IMAGE* OcLoadedImage;
|
||||||
// if ( OSFLAG_ISSET(Flags, OSFLAG_NOCACHES) && !LoadOptions.containsStartWithIC("Kernel=") ) {
|
Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &OcLoadedImage);
|
||||||
// XString8 KernelLocation;
|
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* FileSystem = LocateFileSystem(OcLoadedImage->DeviceHandle, OcLoadedImage->FilePath);
|
||||||
//
|
Status = OcStorageInitFromFs(&mOpenCoreStorage, FileSystem, L"EFI\\CLOVER", NULL);
|
||||||
// if (OSVersion.notEmpty() && AsciiOSVersionToUint64(OSVersion) <= AsciiOSVersionToUint64("10.9"_XS8)) {
|
|
||||||
// KernelLocation.S8Printf("\"Kernel=/mach_kernel\"");
|
OcConfigureLogProtocol (
|
||||||
// } else {
|
127,
|
||||||
// // used for 10.10, 10.11, and new version.
|
0,
|
||||||
// KernelLocation.S8Printf("\"Kernel=/System/Library/Kernels/kernel\"");
|
2151678018,
|
||||||
// }
|
2147483648,
|
||||||
// LoadOptions.AddID(KernelLocation);
|
OPEN_CORE_LOG_PREFIX_PATH,
|
||||||
// }
|
mOpenCoreStorage.FileSystem
|
||||||
//
|
);
|
||||||
// //we are booting OSX - restore emulation if it's not installed before g boot.efi
|
DEBUG ((DEBUG_INFO, "OC: Log initialized...\n"));
|
||||||
// if (gEmuVariableControl != NULL) {
|
OcAppleDebugLogInstallProtocol(0);
|
||||||
// gEmuVariableControl->InstallEmulation(gEmuVariableControl);
|
OcLoadBooterUefiSupport(&mOpenCoreConfiguration);
|
||||||
// }
|
OcLoadKernelSupport(&mOpenCoreStorage, &mOpenCoreConfiguration, &mOpenCoreCpuInfo);
|
||||||
//
|
OcImageLoaderInit ();
|
||||||
// // first patchACPI and find PCIROOT and RTC
|
|
||||||
// // but before ACPI patch we need smbios patch
|
|
||||||
// CheckEmptyFB();
|
|
||||||
// PatchSmbios();
|
|
||||||
//// DBG("PatchACPI\n");
|
|
||||||
// PatchACPI(Volume, OSVersion);
|
|
||||||
//
|
|
||||||
// // If KPDebug is true boot in verbose mode to see the debug messages
|
|
||||||
// if (KernelAndKextPatches.KPDebug) {
|
|
||||||
// LoadOptions.AddID("-v"_XS8);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// DbgHeader("RestSetup macOS");
|
|
||||||
//
|
|
||||||
//// DBG("SetDevices\n");
|
|
||||||
// SetDevices(this);
|
|
||||||
//// DBG("SetFSInjection\n");
|
|
||||||
// SetFSInjection();
|
|
||||||
// //PauseForKey(L"SetFSInjection");
|
|
||||||
//// DBG("SetVariablesForOSX\n");
|
|
||||||
// SetVariablesForOSX(this);
|
|
||||||
//// DBG("SetVariablesForOSX\n");
|
|
||||||
// EventsInitialize(this);
|
|
||||||
//// DBG("FinalizeSmbios\n");
|
|
||||||
// FinalizeSmbios();
|
|
||||||
//
|
|
||||||
// SetCPUProperties();
|
|
||||||
//
|
|
||||||
// if (OSFLAG_ISSET(Flags, OSFLAG_HIBERNATED)) {
|
|
||||||
// DoHibernateWake = PrepareHibernation(Volume);
|
|
||||||
// }
|
|
||||||
// SetupDataForOSX(DoHibernateWake);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// if ( gDriversFlags.AptioFixLoaded &&
|
|
||||||
// !DoHibernateWake &&
|
|
||||||
// !LoadOptions.containsStartWithIC("slide=") ) {
|
|
||||||
// // Add slide=0 argument for ML+ if not present
|
|
||||||
// LoadOptions.AddID("slide=0"_XS8);
|
|
||||||
// }
|
|
||||||
|
|
||||||
XObjArray<SIDELOAD_KEXT> kextArray;
|
XObjArray<SIDELOAD_KEXT> kextArray;
|
||||||
if (!DoHibernateWake) {
|
if (!DoHibernateWake) {
|
||||||
@ -2472,7 +2517,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
|||||||
if ( !EFI_ERROR(Status) ) DBG("Clover : Image base = 0x%llX\n", (uintptr_t)LoadedImage->ImageBase); // do not change, it's used by grep to feed the debugger
|
if ( !EFI_ERROR(Status) ) DBG("Clover : Image base = 0x%llX\n", (uintptr_t)LoadedImage->ImageBase); // do not change, it's used by grep to feed the debugger
|
||||||
|
|
||||||
#ifdef JIEF_DEBUG
|
#ifdef JIEF_DEBUG
|
||||||
// gBS->Stall(3500000); // to give time to gdb to connect
|
gBS->Stall(3500000); // to give time to gdb to connect
|
||||||
// gBS->Stall(0500000); // to give time to gdb to connect
|
// gBS->Stall(0500000); // to give time to gdb to connect
|
||||||
// PauseForKey(L"press\n");
|
// PauseForKey(L"press\n");
|
||||||
#endif
|
#endif
|
||||||
@ -2481,24 +2526,22 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
|||||||
construct_globals_objects(gImageHandle); // do this after SelfLoadedImage is initialized
|
construct_globals_objects(gImageHandle); // do this after SelfLoadedImage is initialized
|
||||||
|
|
||||||
|
|
||||||
EFI_LOADED_IMAGE* OcLoadedImage;
|
// EFI_LOADED_IMAGE* OcLoadedImage;
|
||||||
Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &OcLoadedImage);
|
// Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &OcLoadedImage);
|
||||||
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* FileSystem = LocateFileSystem(OcLoadedImage->DeviceHandle, OcLoadedImage->FilePath);
|
// EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* FileSystem = LocateFileSystem(OcLoadedImage->DeviceHandle, OcLoadedImage->FilePath);
|
||||||
Status = OcStorageInitFromFs(&mOpenCoreStorage, FileSystem, L"EFI\\CLOVER", NULL);
|
// Status = OcStorageInitFromFs(&mOpenCoreStorage, FileSystem, L"EFI\\CLOVER", NULL);
|
||||||
|
//
|
||||||
OcConfigureLogProtocol (
|
// OcConfigureLogProtocol (
|
||||||
127,
|
// 127,
|
||||||
0,
|
// 0,
|
||||||
2151678018,
|
// 2151678018,
|
||||||
2147483648,
|
// 2147483648,
|
||||||
OPEN_CORE_LOG_PREFIX_PATH,
|
// OPEN_CORE_LOG_PREFIX_PATH,
|
||||||
mOpenCoreStorage.FileSystem
|
// mOpenCoreStorage.FileSystem
|
||||||
);
|
// );
|
||||||
DEBUG ((DEBUG_INFO, "OC: Log initialized...\n"));
|
// DEBUG ((DEBUG_INFO, "OC: Log initialized...\n"));
|
||||||
OcAppleDebugLogInstallProtocol(0);
|
// OcAppleDebugLogInstallProtocol(0);
|
||||||
OcLoadBooterUefiSupport(&mOpenCoreConfiguration);
|
// OcLoadBooterUefiSupport(&mOpenCoreConfiguration);
|
||||||
OcLoadKernelSupport(&mOpenCoreStorage, &mOpenCoreConfiguration, &mOpenCoreCpuInfo);
|
|
||||||
OcImageLoaderInit ();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user