OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
KernelSupport.c File Reference
#include "BootCompatInternal.h"
#include <Guid/OcVariable.h>
#include <IndustryStandard/AppleHibernate.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcDeviceTreeLib.h>
#include <Library/OcMachoLib.h>
#include <Library/OcMemoryLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcStringLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>

Go to the source code of this file.

Functions

STATIC VOID ProtectRtMemoryFromRelocation (IN OUT RT_RELOC_PROTECT_DATA *RtReloc, IN UINTN MemoryMapSize, IN UINTN DescriptorSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN EFI_PHYSICAL_ADDRESS SysTableArea, IN UINTN SysTableAreaSize)
 
STATIC EFI_STATUS PerformRtMemoryVirtualMapping (IN OUT KERNEL_SUPPORT_STATE *KernelState, IN UINTN MemoryMapSize, IN UINTN DescriptorSize, IN UINT32 DescriptorVersion, IN EFI_MEMORY_DESCRIPTOR *MemoryMap)
 
STATIC VOID RestoreProtectedRtMemoryTypes (IN RT_RELOC_PROTECT_DATA *RtReloc, IN UINTN MemoryMapSize, IN UINTN DescriptorSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap)
 
VOID AppleMapPrepareForBooting (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN OUT VOID *BootArgs)
 
VOID AppleMapPrepareForHibernateWake (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN UINTN ImageHeaderPage)
 
VOID AppleMapPrepareMemoryPool (IN OUT BOOT_COMPAT_CONTEXT *BootCompat)
 
VOID AppleMapPrepareBooterState (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN OUT EFI_LOADED_IMAGE *LoadedImage, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL)
 
EFI_STATUS AppleMapPrepareMemState (IN OUT BOOT_COMPAT_CONTEXT *BootCompat, IN UINTN MemoryMapSize, IN UINTN DescriptorSize, IN UINT32 DescriptorVersion, IN EFI_MEMORY_DESCRIPTOR *MemoryMap)
 

Detailed Description

Copyright (C) 2013, dmazar. All rights reserved. Copyright (C) 2019, vit9696. All rights reserved.

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file KernelSupport.c.

Function Documentation

◆ AppleMapPrepareBooterState()

VOID AppleMapPrepareBooterState ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN OUT EFI_LOADED_IMAGE * LoadedImage,
IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL )

Prepare environment for Apple UEFI bootloader. See more details inside.

Parameters
[in,out]BootCompatBoot compatibility context.
[in,out]LoadedImageUEFI loaded image protocol instance.
[in]GetMemoryMapUnmodified GetMemoryMap pointer, optional.

Definition at line 542 of file KernelSupport.c.

◆ AppleMapPrepareForBooting()

VOID AppleMapPrepareForBooting ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN OUT VOID * BootArgs )

Prepare environment for normal booting. Called when boot.efi jumps to kernel.

Parameters
[in,out]BootCompatBoot compatibility context.
[in,out]BootArgsApple kernel boot arguments.

Definition at line 325 of file KernelSupport.c.

◆ AppleMapPrepareForHibernateWake()

VOID AppleMapPrepareForHibernateWake ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN UINTN ImageHeaderPage )

Prepare environment for hibernate wake. Called when boot.efi jumps to kernel.

Parameters
[in,out]BootCompatBoot compatibility context.
[in,out]ImageHeaderPageApple hibernate image page number.

Definition at line 436 of file KernelSupport.c.

◆ AppleMapPrepareMemoryPool()

VOID AppleMapPrepareMemoryPool ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat)

Prepare virtual memory management environment for later usage.

Parameters
[in,out]BootCompatBoot compatibility context.

Definition at line 518 of file KernelSupport.c.

◆ AppleMapPrepareMemState()

EFI_STATUS AppleMapPrepareMemState ( IN OUT BOOT_COMPAT_CONTEXT * BootCompat,
IN UINTN MemoryMapSize,
IN UINTN DescriptorSize,
IN UINT32 DescriptorVersion,
IN EFI_MEMORY_DESCRIPTOR * MemoryMap )

Prepare memory state and perform virtual address translation.

Parameters
[in,out]BootCompatBoot compatibility context.
[in]MemoryMapSizeSetVirtualAddresses memory map size argument.
[in]DescriptorSizeSetVirtualAddresses descriptor size argument.
[in]DescriptorVersionSetVirtualAddresses descriptor version argument.
[in]MemoryMapSetVirtualAddresses memory map argument.

Definition at line 608 of file KernelSupport.c.

◆ PerformRtMemoryVirtualMapping()

STATIC EFI_STATUS PerformRtMemoryVirtualMapping ( IN OUT KERNEL_SUPPORT_STATE * KernelState,
IN UINTN MemoryMapSize,
IN UINTN DescriptorSize,
IN UINT32 DescriptorVersion,
IN EFI_MEMORY_DESCRIPTOR * MemoryMap )

Copy RT flagged areas to separate memmap, define virtual to physical address mapping, and call SetVirtualAddressMap() only with that partial memmap.

Parameters
[in,out]KernelStateKernel support state.
[in]MemoryMapSizeMemory map size.
[in]DescriptorSizeMemory map descriptor size.
[in]DescriptorVersionMemor map descriptor version.
[in,out]MemoryMapComplete memory map with all entries.
Return values
EFI_SUCCESSon success.

Definition at line 143 of file KernelSupport.c.

◆ ProtectRtMemoryFromRelocation()

STATIC VOID ProtectRtMemoryFromRelocation ( IN OUT RT_RELOC_PROTECT_DATA * RtReloc,
IN UINTN MemoryMapSize,
IN UINTN DescriptorSize,
IN OUT EFI_MEMORY_DESCRIPTOR * MemoryMap,
IN EFI_PHYSICAL_ADDRESS SysTableArea,
IN UINTN SysTableAreaSize )

Protect RT data from boot.efi relocation by marking them MemMapIO. See more details in the function definition.

Parameters
[in,out]RtRelocRelocation entry list to store entry types.
[in]MemoryMapSizeMemory map size.
[in]DescriptorSizeMemory map descriptor size.
[in,out]MemoryMapMemoryMap to protect entries in.
[in]SysTableAreaSpecial address that should not be protected.

Definition at line 47 of file KernelSupport.c.

◆ RestoreProtectedRtMemoryTypes()

STATIC VOID RestoreProtectedRtMemoryTypes ( IN RT_RELOC_PROTECT_DATA * RtReloc,
IN UINTN MemoryMapSize,
IN UINTN DescriptorSize,
IN OUT EFI_MEMORY_DESCRIPTOR * MemoryMap )

Revert RT data protected types to let XNU kernel kernel properly map data.

Parameters
[in]RtRelocRelocated entry list with entry types.
[in]MemoryMapSizeMemory map size.
[in]DescriptorSizeMemory map descriptor size.
[in,out]MemoryMapMemoryMap to restore protected entries in.

Definition at line 270 of file KernelSupport.c.