Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
OcAfterCompatLib: Added 11.0 support for AvoidRuntimeDefrag
  • Loading branch information
vit9696 committed Jun 24, 2020
1 parent bb12f5f commit 9f59339
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -17,6 +17,7 @@ OpenCore Changelog
- Fixed assertions caused by unaligned file path access in DEBUG builds
- Renamed `ConfigValidity` utility to `ocvalidate` for consistency
- Added `GlobalConnect` for APFS loading to workaround older firmware issues
- Added 11.0 support for `AvoidRuntimeDefrag` Booter quirk

#### v0.5.9
- Added full HiDPI support in OpenCanopy
Expand Down
17 changes: 9 additions & 8 deletions Include/Acidanthera/Library/OcBootManagementLib.h
Expand Up @@ -1035,14 +1035,15 @@ OcGetAppleBootLoadedImage (
by other libraries, so values are often pointers to original fields.
**/
typedef struct OC_BOOT_ARGUMENTS_ {
UINT32 *MemoryMap;
UINT32 *MemoryMapSize;
UINT32 *MemoryMapDescriptorSize;
UINT32 *MemoryMapDescriptorVersion;
CHAR8 *CommandLine;
UINT32 *DeviceTreeP;
UINT32 *DeviceTreeLength;
UINT32 *CsrActiveConfig;
UINT32 *MemoryMap;
UINT32 *MemoryMapSize;
UINT32 *MemoryMapDescriptorSize;
UINT32 *MemoryMapDescriptorVersion;
CHAR8 *CommandLine;
UINT32 *DeviceTreeP;
UINT32 *DeviceTreeLength;
UINT32 *CsrActiveConfig;
EFI_SYSTEM_TABLE *SystemTable;
} OC_BOOT_ARGUMENTS;

/**
Expand Down
4 changes: 4 additions & 0 deletions Library/OcAfterBootCompatLib/BootCompatInternal.h
Expand Up @@ -256,6 +256,10 @@ typedef struct KERNEL_SUPPORT_STATE_ {
///
UINTN SysTableRtAreaSize;
///
/// Physical configuration table location.
///
EFI_CONFIGURATION_TABLE *ConfigurationTable;
///
/// Virtual memory mapper context.
///
OC_VMEM_CONTEXT VmContext;
Expand Down
23 changes: 23 additions & 0 deletions Library/OcAfterBootCompatLib/KernelSupport.c
Expand Up @@ -381,6 +381,25 @@ AppleMapPrepareForBooting (
DescriptorSize,
MemoryMap
);

//
// On native Macs due to EfiBoot defragmentation it is guaranteed that
// VADDR % BASE_1GB == PADDR. macOS 11 started to rely on this in
// acpi_count_enabled_logical_processors, which needs to access MADT (APIC)
// ACPI table, and does that through ConfigurationTables.
//
// The simplest approach is to just copy the table, so that it is accessible
// at both actual mapping and 1:1 defragmented mapping. This should be safe,
// as the memory for 1:1 defragmented mapping is reserved by EfiBoot in the
// first place and is otherwise stolen anyway.
//
if (BootCompat->KernelState.ConfigurationTable != NULL) {
CopyMem (
(VOID*) ((UINTN) BA.SystemTable->ConfigurationTable & (BASE_1GB - 1)),
BootCompat->KernelState.ConfigurationTable,
sizeof (*BootCompat->KernelState.ConfigurationTable) * BA.SystemTable->NumberOfTableEntries
);
}
}
}

Expand Down Expand Up @@ -545,6 +564,10 @@ AppleMapPrepareBooterState (
gST,
gST->Hdr.HeaderSize
);
//
// Remember physical configuration table location.
//
BootCompat->KernelState.ConfigurationTable = gST->ConfigurationTable;
}

//
Expand Down
2 changes: 2 additions & 0 deletions Library/OcBootManagementLib/BootArguments.c
Expand Up @@ -45,6 +45,7 @@ OcParseBootArgs (

Arguments->DeviceTreeP = &BA1->deviceTreeP;
Arguments->DeviceTreeLength = &BA1->deviceTreeLength;
Arguments->SystemTable = (EFI_SYSTEM_TABLE*)(UINTN) BA1->efiSystemTable;
} else {
//
// Lion and newer
Expand All @@ -58,6 +59,7 @@ OcParseBootArgs (

Arguments->DeviceTreeP = &BA2->deviceTreeP;
Arguments->DeviceTreeLength = &BA2->deviceTreeLength;
Arguments->SystemTable = (EFI_SYSTEM_TABLE*)(UINTN) BA2->efiSystemTable;

if (BA2->flags & kBootArgsFlagCSRActiveConfig) {
Arguments->CsrActiveConfig = &BA2->csrActiveConfig;
Expand Down

0 comments on commit 9f59339

Please sign in to comment.