OpenCore  1.0.4
OpenCore Bootloader
1.0.4
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
MemoryAttributes.c File Reference
#include <Uefi.h>
#include <Guid/MemoryAttributesTable.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>

Go to the source code of this file.

Functions

STATIC UINT32 OcRealMemoryType (IN EFI_MEMORY_DESCRIPTOR *MemoryAttribte)
 
STATIC EFI_STATUS OcSplitMemoryEntryByAttribute (IN OUT EFI_MEMORY_DESCRIPTOR **RetMemoryMapEntry, IN OUT UINTN *CurrentEntryIndex, IN OUT UINTN *CurrentEntryCount, IN UINTN TotalEntryCount, IN EFI_MEMORY_DESCRIPTOR *MemoryAttribute, IN UINTN DescriptorSize)
 
STATIC EFI_STATUS OcExpandAttributeWrite (IN OUT EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryAttributesEntry OPTIONAL, IN UINTN MaxDescriptors, IN EFI_MEMORY_DESCRIPTOR *MemoryMapEntry, IN EFI_PHYSICAL_ADDRESS CurrentMapAddress)
 
STATIC EFI_STATUS OcExpandAttributesByMap (IN OUT EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryAttributesEntry, IN UINTN MaxDescriptors, IN UINTN MemoryMapDescriptors, IN EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize)
 
EFI_MEMORY_ATTRIBUTES_TABLE * OcGetMemoryAttributes (OUT EFI_MEMORY_DESCRIPTOR **MemoryAttributesEntry OPTIONAL)
 
EFI_STATUS OcRebuildAttributes (IN EFI_PHYSICAL_ADDRESS Address, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL)
 
UINTN OcCountSplitDescriptors (VOID)
 
EFI_STATUS OcSplitMemoryMapByAttributes (IN UINTN MaxMemoryMapSize, IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize)
 

Detailed Description

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 MemoryAttributes.c.

Function Documentation

◆ OcCountSplitDescriptors()

UINTN OcCountSplitDescriptors ( VOID )

Count upper bound of split runtime descriptors.

Return values
amountof runtime descriptors.

Definition at line 541 of file MemoryAttributes.c.

◆ OcExpandAttributesByMap()

STATIC EFI_STATUS OcExpandAttributesByMap ( IN OUT EFI_MEMORY_ATTRIBUTES_TABLE * MemoryAttributesTable,
IN OUT EFI_MEMORY_DESCRIPTOR * MemoryAttributesEntry,
IN UINTN MaxDescriptors,
IN UINTN MemoryMapDescriptors,
IN EFI_MEMORY_DESCRIPTOR * MemoryMap,
IN UINTN DescriptorSize )

Expand attributes table by adding memory map runtime entries into it. Requires sorted memory map.

Parameters
[in,out]MemoryAttributesTableMemory attributes table.
[in,out]MemoryAttributesEntryMemory attributes descriptor.
[in]MaxDescriptorsMaximum amount of descriptors in the attributes table.
[in]MemoryMapDescriptorsMemory map descriptor count.
[in]MemoryMapMemory map.
[in]DescriptorSizeMemory map descriptor size.
Return values
EFI_SUCCESSon success.
EFI_NOT_FOUNDnothing to do.

Definition at line 261 of file MemoryAttributes.c.

◆ OcExpandAttributeWrite()

STATIC EFI_STATUS OcExpandAttributeWrite ( IN OUT EFI_MEMORY_ATTRIBUTES_TABLE * MemoryAttributesTable,
IN OUT EFI_MEMORY_DESCRIPTOR *MemoryAttributesEntry OPTIONAL,
IN UINTN MaxDescriptors,
IN EFI_MEMORY_DESCRIPTOR * MemoryMapEntry,
IN EFI_PHYSICAL_ADDRESS CurrentMapAddress )

Definition at line 169 of file MemoryAttributes.c.

◆ OcGetMemoryAttributes()

EFI_MEMORY_ATTRIBUTES_TABLE * OcGetMemoryAttributes ( OUT EFI_MEMORY_DESCRIPTOR **MemoryAttributesEntry OPTIONAL)

Obtain memory attributes table.

Parameters
[out]MemoryAttributesEntrymemory descriptor pointer, optional.
Return values
pointerto memory attributes table.
NULLif memory attributes table is unsupported.

Definition at line 409 of file MemoryAttributes.c.

◆ OcRealMemoryType()

STATIC UINT32 OcRealMemoryType ( IN EFI_MEMORY_DESCRIPTOR * MemoryAttribte)

Determine actual memory type from the attribute.

Parameters
[in]MemoryAttributeAttribute to inspect.

Definition at line 33 of file MemoryAttributes.c.

◆ OcRebuildAttributes()

EFI_STATUS OcRebuildAttributes ( IN EFI_PHYSICAL_ADDRESS Address,
IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL )

Refresh memory attributes entry containing the specified address.

Parameters
[in]AddressAddress contained in the updated entry.
[in]GetMemoryMap
Return values
EFI_SUCCESSon success.
EFI_NOT_FOUNDno entry contains the specified address.
EFI_UNSUPPORTEDmemory attributes are not supported by the platform.

Definition at line 431 of file MemoryAttributes.c.

◆ OcSplitMemoryEntryByAttribute()

STATIC EFI_STATUS OcSplitMemoryEntryByAttribute ( IN OUT EFI_MEMORY_DESCRIPTOR ** RetMemoryMapEntry,
IN OUT UINTN * CurrentEntryIndex,
IN OUT UINTN * CurrentEntryCount,
IN UINTN TotalEntryCount,
IN EFI_MEMORY_DESCRIPTOR * MemoryAttribute,
IN UINTN DescriptorSize )

Split memory map descriptor by attribute.

Parameters
[in,out]RetMemoryMapEntryPointer to descriptor in the memory map, updated to next proccessed.
[in,out]CurrentEntryIndexCurrent index of the descriptor in the memory map, updated on increase.
[in,out]CurrentEntryCountNumber of descriptors in the memory map, updated on increase.
[in]TotalEntryCountMax number of descriptors in the memory map.
[in]MemoryAttributeMemory attribute used for splitting.
[in]DescriptorSizeMemory map descriptor size.
Return values
EFI_SUCCESSon success.
EFI_OUT_OF_RESOURCESwhen there are not enough free descriptor slots.

Definition at line 77 of file MemoryAttributes.c.

◆ OcSplitMemoryMapByAttributes()

EFI_STATUS OcSplitMemoryMapByAttributes ( IN UINTN MaxMemoryMapSize,
IN OUT UINTN * MemoryMapSize,
IN OUT EFI_MEMORY_DESCRIPTOR * MemoryMap,
IN UINTN DescriptorSize )

Split memory map by memory attributes if available. Requires sorted memory map!

Parameters
[in]MaxMemoryMapSizeUpper memory map size bound for growth.
[in,out]MemoryMapSizeCurrent memory map size, updated on return.
[in,out]MemoryMapMemory map to split.
[in]DescriptorSizeMemory map descriptor size.

Note, the function is guaranteed to return valid memory map, though not necessarily split.

Return values
EFI_SUCCESSon success.
EFI_UNSUPPORTEDmemory attributes are not supported by the platform.
EFI_OUT_OF_RESOURCESnew memory map did not fit.

Definition at line 573 of file MemoryAttributes.c.