OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
MemoryAlloc.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

EFI_STATUS OcAllocatePagesFromTop (IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, IN OUT EFI_PHYSICAL_ADDRESS *Memory, IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL, IN EFI_ALLOCATE_PAGES AllocatePages OPTIONAL, IN CHECK_ALLOCATION_RANGE CheckRange OPTIONAL)
 
UINT64 OcCountRuntimePages (IN UINTN MemoryMapSize, IN EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN DescriptorSize, OUT UINTN *DescriptorCount OPTIONAL)
 
UINTN OcCountFreePages (OUT UINTN *LowerMemory OPTIONAL)
 

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

Function Documentation

◆ OcAllocatePagesFromTop()

EFI_STATUS OcAllocatePagesFromTop ( IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN OUT EFI_PHYSICAL_ADDRESS * Memory,
IN EFI_GET_MEMORY_MAP GetMemoryMap OPTIONAL,
IN EFI_ALLOCATE_PAGES AllocatePages OPTIONAL,
IN CHECK_ALLOCATION_RANGE CheckRange OPTIONAL )

Allocate pages from the top of physical memory up to address specified in Memory. Unlike AllocateMaxAddress, this method guarantees to choose top most address.

Parameters
[in]MemoryTypeAllocated memory type.
[in]PagesAmount of pages to allocate.
[in,out]MemoryTop address for input, allocated address for output.
[in]GetMemoryMapCustom GetMemoryMap implementation to use, optional.
[in]AllocatePagesCustom AllocatePages implementation to use, optional.
[in]CheckRangeHandler allowing to not allocate select ranges, optional.
Return values
EFI_SUCCESSon successful allocation.

Definition at line 27 of file MemoryAlloc.c.

◆ OcCountFreePages()

UINTN OcCountFreePages ( OUT UINTN *LowerMemory OPTIONAL)

Calculate number of free pages in the memory map.

Parameters
[out]LowerMemoryNumber of free pages below 4 GB, optional.
Return values
Numberof free pages.

Definition at line 148 of file MemoryAlloc.c.

◆ OcCountRuntimePages()

UINT64 OcCountRuntimePages ( IN UINTN MemoryMapSize,
IN EFI_MEMORY_DESCRIPTOR * MemoryMap,
IN UINTN DescriptorSize,
OUT UINTN *DescriptorCount OPTIONAL )

Calculate number of runtime pages in the memory map.

Parameters
[in]MemoryMapSizeMemory map size in bytes.
[in]MemoryMapMemory map to inspect.
[in]DescriptorSizeMemory map descriptor size in bytes.
[out]DescriptorCountNumber of relevant descriptors, optional.
Return values
Numberof runtime pages.

Definition at line 111 of file MemoryAlloc.c.