TianoCore EDK2 master
Loading...
Searching...
No Matches
RuntimeMemAllocation.c File Reference

Go to the source code of this file.

Data Structures

struct  RT_MEMORY_PAGE_ENTRY
 
struct  RT_MEMORY_PAGE_TABLE
 

Macros

#define RT_PAGE_SIZE   0x200
 
#define RT_PAGE_MASK   0x1FF
 
#define RT_PAGE_SHIFT   9
 
#define RT_SIZE_TO_PAGES(a)   (((a) >> RT_PAGE_SHIFT) + (((a) & RT_PAGE_MASK) ? 1 : 0))
 
#define RT_PAGES_TO_SIZE(a)   ((a) << RT_PAGE_SHIFT)
 
#define RT_PAGE_FREE   0x00000000
 
#define RT_PAGE_USED   0x00000001
 
#define MIN_REQUIRED_BLOCKS   1100
 

Functions

EFI_STATUS InitializeScratchMemory (IN OUT UINT8 *ScratchBuffer, IN UINTN ScratchBufferSize)
 
UINTN LookupFreeMemRegion (IN UINTN AllocationSize)
 
VOID * RuntimeAllocateMem (IN UINTN AllocationSize)
 
VOID RuntimeFreeMem (IN VOID *Buffer)
 
VOID EFIAPI RuntimeCryptLibAddressChangeEvent (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI RuntimeCryptLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
void * malloc (size_t size)
 
void * realloc (void *ptr, size_t size)
 
void free (void *ptr)
 

Variables

RT_MEMORY_PAGE_TABLEmRTPageTable = NULL
 
STATIC EFI_EVENT mVirtualAddressChangeEvent
 

Detailed Description

Light-weight Memory Management Routines for OpenSSL-based Crypto Library at Runtime Phase.

Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file RuntimeMemAllocation.c.

Macro Definition Documentation

◆ MIN_REQUIRED_BLOCKS

#define MIN_REQUIRED_BLOCKS   1100

Definition at line 36 of file RuntimeMemAllocation.c.

◆ RT_PAGE_FREE

#define RT_PAGE_FREE   0x00000000

Definition at line 33 of file RuntimeMemAllocation.c.

◆ RT_PAGE_MASK

#define RT_PAGE_MASK   0x1FF

Definition at line 24 of file RuntimeMemAllocation.c.

◆ RT_PAGE_SHIFT

#define RT_PAGE_SHIFT   9

Definition at line 25 of file RuntimeMemAllocation.c.

◆ RT_PAGE_SIZE

#define RT_PAGE_SIZE   0x200

Definition at line 23 of file RuntimeMemAllocation.c.

◆ RT_PAGE_USED

#define RT_PAGE_USED   0x00000001

Definition at line 34 of file RuntimeMemAllocation.c.

◆ RT_PAGES_TO_SIZE

#define RT_PAGES_TO_SIZE (   a)    ((a) << RT_PAGE_SHIFT)

Definition at line 28 of file RuntimeMemAllocation.c.

◆ RT_SIZE_TO_PAGES

#define RT_SIZE_TO_PAGES (   a)    (((a) >> RT_PAGE_SHIFT) + (((a) & RT_PAGE_MASK) ? 1 : 0))

Definition at line 27 of file RuntimeMemAllocation.c.

Function Documentation

◆ free()

void free ( void *  ptr)

Definition at line 451 of file RuntimeMemAllocation.c.

◆ InitializeScratchMemory()

EFI_STATUS InitializeScratchMemory ( IN OUT UINT8 *  ScratchBuffer,
IN UINTN  ScratchBufferSize 
)

Initializes pre-allocated memory pointed by ScratchBuffer for subsequent runtime use.

Parameters
[in,out]ScratchBufferPointer to user-supplied memory buffer.
[in]ScratchBufferSizeSize of supplied buffer in bytes.
Return values
EFI_SUCCESSSuccessful initialization.

Definition at line 75 of file RuntimeMemAllocation.c.

◆ LookupFreeMemRegion()

UINTN LookupFreeMemRegion ( IN UINTN  AllocationSize)

Look-up Free memory Region for object allocation.

Parameters
[in]AllocationSizeBytes to be allocated.
Returns
Return available page offset for object allocation.

Definition at line 125 of file RuntimeMemAllocation.c.

◆ malloc()

void * malloc ( size_t  size)

Definition at line 390 of file RuntimeMemAllocation.c.

◆ realloc()

void * realloc ( void *  ptr,
size_t  size 
)

Definition at line 399 of file RuntimeMemAllocation.c.

◆ RuntimeAllocateMem()

VOID * RuntimeAllocateMem ( IN UINTN  AllocationSize)

Allocates a buffer at runtime phase.

Parameters
[in]AllocationSizeBytes to be allocated.
Returns
A pointer to the allocated buffer or NULL if allocation fails.

Definition at line 228 of file RuntimeMemAllocation.c.

◆ RuntimeCryptLibAddressChangeEvent()

VOID EFIAPI RuntimeCryptLibAddressChangeEvent ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.

This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event. It converts a pointer to a new virtual address.

Parameters
[in]EventThe event whose notification function is being invoked.
[in]ContextThe pointer to the notification function's context.

Definition at line 325 of file RuntimeMemAllocation.c.

◆ RuntimeCryptLibConstructor()

EFI_STATUS EFIAPI RuntimeCryptLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Constructor routine for runtime crypt library instance.

The constructor function pre-allocates space for runtime cryptographic operation.

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe construction succeeded.
EFI_OUT_OF_RESOURCEFailed to allocate memory.

Definition at line 351 of file RuntimeMemAllocation.c.

◆ RuntimeFreeMem()

VOID RuntimeFreeMem ( IN VOID *  Buffer)

Frees a buffer that was previously allocated at runtime phase.

Parameters
[in]BufferPointer to the buffer to free.

Definition at line 283 of file RuntimeMemAllocation.c.

Variable Documentation

◆ mRTPageTable

RT_MEMORY_PAGE_TABLE* mRTPageTable = NULL

Definition at line 57 of file RuntimeMemAllocation.c.

◆ mVirtualAddressChangeEvent

STATIC EFI_EVENT mVirtualAddressChangeEvent

Definition at line 62 of file RuntimeMemAllocation.c.