TianoCore EDK2 master
Loading...
Searching...
No Matches
CpuPageTable.h File Reference

Go to the source code of this file.

Data Structures

struct  PAGE_TABLE_LIB_PAGING_CONTEXT_IA32
 
struct  PAGE_TABLE_LIB_PAGING_CONTEXT_X64
 
union  PAGE_TABLE_LIB_PAGING_CONTEXT_DATA
 
struct  PAGE_TABLE_LIB_PAGING_CONTEXT
 
struct  PAGE_TABLE_POOL
 

Macros

#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PSE   BIT0
 
#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE   BIT1
 
#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAGE_1G_SUPPORT   BIT2
 
#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_5_LEVEL   BIT3
 
#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_WP_ENABLE   BIT30
 
#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED   BIT31
 
#define PAGE_TABLE_POOL_ALIGNMENT   BASE_2MB
 
#define PAGE_TABLE_POOL_UNIT_SIZE   SIZE_2MB
 
#define PAGE_TABLE_POOL_UNIT_PAGES   EFI_SIZE_TO_PAGES (PAGE_TABLE_POOL_UNIT_SIZE)
 
#define PAGE_TABLE_POOL_ALIGN_MASK    (~(EFI_PHYSICAL_ADDRESS)(PAGE_TABLE_POOL_ALIGNMENT - 1))
 

Typedefs

typedef VOID *(EFIAPI * PAGE_TABLE_LIB_ALLOCATE_PAGES) (IN UINTN Pages)
 

Functions

RETURN_STATUS EFIAPI AssignMemoryPageAttributes (IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext OPTIONAL, IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes, IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc OPTIONAL)
 
VOID InitializePageTableLib (VOID)
 
VOID *EFIAPI AllocatePageTableMemory (IN UINTN Pages)
 
VOID GetPagingDetails (IN PAGE_TABLE_LIB_PAGING_CONTEXT_DATA *PagingContextData, OUT UINTN **PageTableBase OPTIONAL, OUT UINT32 **Attributes OPTIONAL)
 

Detailed Description

Page table management header file.

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

Definition in file CpuPageTable.h.

Macro Definition Documentation

◆ PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_5_LEVEL

#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_5_LEVEL   BIT3

Definition at line 17 of file CpuPageTable.h.

◆ PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE

#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE   BIT1

Definition at line 15 of file CpuPageTable.h.

◆ PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAGE_1G_SUPPORT

#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAGE_1G_SUPPORT   BIT2

Definition at line 16 of file CpuPageTable.h.

◆ PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PSE

#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PSE   BIT0

Definition at line 14 of file CpuPageTable.h.

◆ PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_WP_ENABLE

#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_WP_ENABLE   BIT30

Definition at line 18 of file CpuPageTable.h.

◆ PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED

#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED   BIT31

Definition at line 19 of file CpuPageTable.h.

◆ PAGE_TABLE_POOL_ALIGN_MASK

#define PAGE_TABLE_POOL_ALIGN_MASK    (~(EFI_PHYSICAL_ADDRESS)(PAGE_TABLE_POOL_ALIGNMENT - 1))

Definition at line 51 of file CpuPageTable.h.

◆ PAGE_TABLE_POOL_ALIGNMENT

#define PAGE_TABLE_POOL_ALIGNMENT   BASE_2MB

Definition at line 48 of file CpuPageTable.h.

◆ PAGE_TABLE_POOL_UNIT_PAGES

#define PAGE_TABLE_POOL_UNIT_PAGES   EFI_SIZE_TO_PAGES (PAGE_TABLE_POOL_UNIT_SIZE)

Definition at line 50 of file CpuPageTable.h.

◆ PAGE_TABLE_POOL_UNIT_SIZE

#define PAGE_TABLE_POOL_UNIT_SIZE   SIZE_2MB

Definition at line 49 of file CpuPageTable.h.

Typedef Documentation

◆ PAGE_TABLE_LIB_ALLOCATE_PAGES

typedef VOID *(EFIAPI * PAGE_TABLE_LIB_ALLOCATE_PAGES) (IN UINTN Pages)

Allocates one or more 4KB pages for page table.

Parameters
PagesThe number of 4 KB pages to allocate.
Returns
A pointer to the allocated buffer or NULL if allocation fails.

Definition at line 69 of file CpuPageTable.h.

Function Documentation

◆ AllocatePageTableMemory()

VOID *EFIAPI AllocatePageTableMemory ( IN UINTN  Pages)

This API provides a way to allocate memory for page table.

This API can be called more once to allocate memory for page tables.

Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.

Parameters
PagesThe number of 4 KB pages to allocate.
Returns
A pointer to the allocated buffer or NULL if allocation fails.

This API provides a way to allocate memory for page table.

This API can be called more than once to allocate memory for page tables.

Allocates the number of 4KB pages and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary.

If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.

Parameters
PagesThe number of 4 KB pages to allocate.
Returns
A pointer to the allocated buffer or NULL if allocation fails.

This API provides a way to allocate memory for page table.

Parameters
PagesThe number of 4 KB pages to allocate.
Returns
A pointer to the allocated buffer or NULL if allocation fails.

Definition at line 314 of file VirtualMemory.c.

◆ AssignMemoryPageAttributes()

RETURN_STATUS EFIAPI AssignMemoryPageAttributes ( IN PAGE_TABLE_LIB_PAGING_CONTEXT *PagingContext  OPTIONAL,
IN PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN UINT64  Attributes,
IN PAGE_TABLE_LIB_ALLOCATE_PAGES AllocatePagesFunc  OPTIONAL 
)

This function assigns the page attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Caller should make sure BaseAddress and Length is at page boundary.

Caller need guarantee the TPL <= TPL_NOTIFY, if there is split page request.

Parameters
PagingContextThe paging context. NULL means get page table from current CPU context.
BaseAddressThe physical address that is the start address of a memory region.
LengthThe size in bytes of the memory region.
AttributesThe bit mask of attributes to set for the memory region.
AllocatePagesFuncIf page split is needed, this function is used to allocate more pages. NULL mean page split is unsupported.
Return values
RETURN_SUCCESSThe attributes were cleared for the memory region.
RETURN_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
RETURN_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be set together.
RETURN_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
RETURN_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not support for the memory resource range specified by BaseAddress and Length.

This function assigns the page attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Caller should make sure BaseAddress and Length is at page boundary.

Caller need guarantee the TPL <= TPL_NOTIFY, if there is split page request.

Parameters
[in]PagingContextThe paging context. NULL means get page table from current CPU context.
[in]BaseAddressThe physical address that is the start address of a memory region.
[in]LengthThe size in bytes of the memory region.
[in]AttributesThe bit mask of attributes to set for the memory region.
[in]AllocatePagesFuncIf page split is needed, this function is used to allocate more pages. NULL mean page split is unsupported.
Return values
RETURN_SUCCESSThe attributes were cleared for the memory region.
RETURN_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
RETURN_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be set together.
RETURN_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
RETURN_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not support for the memory resource range specified by BaseAddress and Length.

Definition at line 912 of file CpuPageTable.c.

◆ GetPagingDetails()

VOID GetPagingDetails ( IN PAGE_TABLE_LIB_PAGING_CONTEXT_DATA PagingContextData,
OUT UINTN **PageTableBase  OPTIONAL,
OUT UINT32 **Attributes  OPTIONAL 
)

Get paging details.

Parameters
PagingContextDataThe paging context.
PageTableBaseReturn PageTableBase field.
AttributesReturn Attributes field.

Definition at line 20 of file PagingAttribute.c.

◆ InitializePageTableLib()

VOID InitializePageTableLib ( VOID  )

Initialize the Page Table lib.

Definition at line 1401 of file CpuPageTable.c.