22 IN OC_GLOBAL_CONFIG *Config
28 BOOLEAN IsMmioWhitelistEnabled;
29 BOOLEAN ShouldEnableDevirtualiseMmio;
30 BOOLEAN IsDevirtualiseMmioEnabled;
33 IsDevirtualiseMmioEnabled = Config->Booter.Quirks.DevirtualiseMmio;
35 IsMmioWhitelistEnabled = FALSE;
36 ShouldEnableDevirtualiseMmio = FALSE;
37 for (Index = 0; Index < Config->Booter.MmioWhitelist.Count; ++Index) {
38 Comment =
OC_BLOB_GET (&Config->Booter.MmioWhitelist.Values[Index]->Comment);
39 IsMmioWhitelistEnabled = Config->Booter.MmioWhitelist.Values[Index]->Enabled;
43 ShouldEnableDevirtualiseMmio = IsMmioWhitelistEnabled;
49 DEBUG ((DEBUG_WARN,
"Booter->MmioWhitelist[%u]->Comment contains illegal character!\n", Index));
54 if (ShouldEnableDevirtualiseMmio && !IsDevirtualiseMmioEnabled) {
55 DEBUG ((DEBUG_WARN,
"There are enabled entries under Booter->MmioWhitelist, but DevirtualiseMmio is not enabled!\n"));
64 IN OC_GLOBAL_CONFIG *Config
71 CONST CHAR8 *Identifier;
78 CONST UINT8 *ReplaceMask;
79 UINT32 ReplaceMaskSize;
83 for (Index = 0; Index < Config->Booter.Patch.Count; ++Index) {
84 Comment =
OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Comment);
85 Arch =
OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Arch);
86 Identifier =
OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Identifier);
87 Find =
OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Find);
88 FindSize = Config->Booter.Patch.Values[Index]->Find.Size;
89 Replace =
OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Replace);
90 ReplaceSize = Config->Booter.Patch.Values[Index]->Replace.Size;
91 Mask =
OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->Mask);
92 MaskSize = Config->Booter.Patch.Values[Index]->Mask.Size;
93 ReplaceMask =
OC_BLOB_GET (&Config->Booter.Patch.Values[Index]->ReplaceMask);
94 ReplaceMaskSize = Config->Booter.Patch.Values[Index]->ReplaceMask.Size;
100 DEBUG ((DEBUG_WARN,
"Booter->Patch[%u]->Comment contains illegal character!\n", Index));
105 DEBUG ((DEBUG_WARN,
"Booter->Patch[%u]->Arch is borked (Can only be Any, i386, and x86_64)!\n", Index));
110 DEBUG ((DEBUG_WARN,
"Booter->Patch[%u]->Identifier contains illegal character!\n", Index));
138 IN OC_GLOBAL_CONFIG *Config
143 OC_UEFI_DRIVER_ENTRY *DriverEntry;
146 BOOLEAN IsAllowRelocationBlockEnabled;
147 BOOLEAN IsProvideCustomSlideEnabled;
148 BOOLEAN IsEnableSafeModeSlideEnabled;
149 BOOLEAN IsDisableVariableWriteEnabled;
150 BOOLEAN IsEnableWriteUnprotectorEnabled;
151 BOOLEAN IsClearTaskSwitchBitEnabled;
152 BOOLEAN HasOpenRuntimeEfiDriver;
153 INT8 ResizeAppleGpuBars;
156 IsAllowRelocationBlockEnabled = Config->Booter.Quirks.AllowRelocationBlock;
157 IsProvideCustomSlideEnabled = Config->Booter.Quirks.ProvideCustomSlide;
158 IsEnableSafeModeSlideEnabled = Config->Booter.Quirks.EnableSafeModeSlide;
159 IsDisableVariableWriteEnabled = Config->Booter.Quirks.DisableVariableWrite;
160 IsEnableWriteUnprotectorEnabled = Config->Booter.Quirks.EnableWriteUnprotector;
161 IsClearTaskSwitchBitEnabled = Config->Booter.Quirks.ClearTaskSwitchBit;
162 HasOpenRuntimeEfiDriver = FALSE;
163 MaxSlide = Config->Booter.Quirks.ProvideMaxSlide;
164 ResizeAppleGpuBars = Config->Booter.Quirks.ResizeAppleGpuBars;
166 for (Index = 0; Index < Config->Uefi.Drivers.Count; ++Index) {
167 DriverEntry = Config->Uefi.Drivers.Values[Index];
173 if (DriverEntry->Enabled && (AsciiStrCmp (Driver,
"OpenRuntime.efi") == 0)) {
174 HasOpenRuntimeEfiDriver = TRUE;
178 if (!HasOpenRuntimeEfiDriver) {
179 if (IsProvideCustomSlideEnabled) {
180 DEBUG ((DEBUG_WARN,
"Booter->Quirks->ProvideCustomSlide is enabled, but OpenRuntime.efi is not loaded at UEFI->Drivers!\n"));
184 if (IsDisableVariableWriteEnabled) {
185 DEBUG ((DEBUG_WARN,
"Booter->Quirks->DisableVariableWrite is enabled, but OpenRuntime.efi is not loaded at UEFI->Drivers!\n"));
189 if (IsEnableWriteUnprotectorEnabled) {
190 DEBUG ((DEBUG_WARN,
"Booter->Quirks->EnableWriteUnprotector is enabled, but OpenRuntime.efi is not loaded at UEFI->Drivers!\n"));
194 if (IsClearTaskSwitchBitEnabled) {
195 DEBUG ((DEBUG_WARN,
"Booter->Quirks->ClearTaskSwitchBit is enabled, but OpenRuntime.efi is not loaded at UEFI->Drivers!\n"));
200 if (!IsProvideCustomSlideEnabled) {
201 if (IsAllowRelocationBlockEnabled) {
202 DEBUG ((DEBUG_WARN,
"Booter->Quirks->AllowRelocationBlock is enabled, but ProvideCustomSlide is not enabled altogether!\n"));
206 if (IsEnableSafeModeSlideEnabled) {
207 DEBUG ((DEBUG_WARN,
"Booter->Quirks->EnableSafeModeSlide is enabled, but ProvideCustomSlide is not enabled altogether!\n"));
212 DEBUG ((DEBUG_WARN,
"Booter->Quirks->ProvideMaxSlide is set to %u, but ProvideCustomSlide is not enabled altogether!\n", MaxSlide));
217 if (ResizeAppleGpuBars > 10) {
218 DEBUG ((DEBUG_WARN,
"Booter->Quirks->ResizeAppleGpuBars is set to %d, which is unsupported by macOS!\n", Config->Booter.Quirks.ResizeAppleGpuBars));
220 }
else if (ResizeAppleGpuBars > 8) {
221 DEBUG ((DEBUG_WARN,
"Booter->Quirks->ResizeAppleGpuBars is set to %d, which is unstable with macOS sleep-wake!\n", Config->Booter.Quirks.ResizeAppleGpuBars));
223 }
else if (ResizeAppleGpuBars > 0) {
224 DEBUG ((DEBUG_WARN,
"Booter->Quirks->ResizeAppleGpuBars is set to %d, which is not useful for macOS!\n", Config->Booter.Quirks.ResizeAppleGpuBars));
UINT32 ValidatePatch(IN CONST CHAR8 *PatchSection, IN UINT32 PatchIndex, IN BOOLEAN FindSizeCanBeZero, IN CONST UINT8 *Find, IN UINT32 FindSize, IN CONST UINT8 *Replace, IN UINT32 ReplaceSize, IN CONST UINT8 *Mask, IN UINT32 MaskSize, IN CONST UINT8 *ReplaceMask, IN UINT32 ReplaceMaskSize)