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

Go to the source code of this file.

Data Structures

union  IA32_MAP_ATTRIBUTE
 
struct  IA32_MAP_ENTRY
 

Macros

#define IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK   0xFFFFFFFFFF000ull
 
#define IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS(pa)   ((pa)->Uint64 & IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK)
 
#define IA32_MAP_ATTRIBUTE_ATTRIBUTES(pa)   ((pa)->Uint64 & ~IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK)
 

Enumerations

enum  PAGING_MODE {
  Paging32bit , PagingPae4KB = 0x0301 , PagingPae2MB = 0x0302 , PagingPae = 0x0302 ,
  Paging4Level4KB = 0x0401 , Paging4Level2MB = 0x0402 , Paging4Level = 0x0402 , Paging4Level1GB = 0x0403 ,
  Paging5Level4KB = 0x0501 , Paging5Level2MB = 0x0502 , Paging5Level = 0x0502 , Paging5Level1GB = 0x0503 ,
  PagingModeMax
}
 

Functions

RETURN_STATUS EFIAPI PageTableMap (IN OUT UINTN *PageTable OPTIONAL, IN PAGING_MODE PagingMode, IN VOID *Buffer, IN OUT UINTN *BufferSize, IN UINT64 LinearAddress, IN UINT64 Length, IN IA32_MAP_ATTRIBUTE *Attribute, IN IA32_MAP_ATTRIBUTE *Mask, OUT BOOLEAN *IsModified OPTIONAL)
 
RETURN_STATUS EFIAPI PageTableParse (IN UINTN PageTable, IN PAGING_MODE PagingMode, IN IA32_MAP_ENTRY *Map, IN OUT UINTN *MapCount)
 

Detailed Description

Public include file for PageTableLib library.

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

Definition in file CpuPageTableLib.h.

Macro Definition Documentation

◆ IA32_MAP_ATTRIBUTE_ATTRIBUTES

#define IA32_MAP_ATTRIBUTE_ATTRIBUTES (   pa)    ((pa)->Uint64 & ~IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK)

Definition at line 36 of file CpuPageTableLib.h.

◆ IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS

#define IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS (   pa)    ((pa)->Uint64 & IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK)

Definition at line 35 of file CpuPageTableLib.h.

◆ IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK

#define IA32_MAP_ATTRIBUTE_PAGE_TABLE_BASE_ADDRESS_MASK   0xFFFFFFFFFF000ull

Definition at line 34 of file CpuPageTableLib.h.

Enumeration Type Documentation

◆ PAGING_MODE

enum PAGING_MODE

Definition at line 42 of file CpuPageTableLib.h.

Function Documentation

◆ PageTableMap()

RETURN_STATUS EFIAPI PageTableMap ( IN OUT UINTN *PageTable  OPTIONAL,
IN PAGING_MODE  PagingMode,
IN VOID *  Buffer,
IN OUT UINTN BufferSize,
IN UINT64  LinearAddress,
IN UINT64  Length,
IN IA32_MAP_ATTRIBUTE Attribute,
IN IA32_MAP_ATTRIBUTE Mask,
OUT BOOLEAN *IsModified  OPTIONAL 
)

Create or update page table to map [LinearAddress, LinearAddress + Length) with specified attribute.

Parameters
[in,out]PageTableThe pointer to the page table to update, or pointer to NULL if a new page table is to be created. If not pointer to NULL, the value it points to won't be changed in this function.
[in]PagingModeThe paging mode.
[in]BufferThe free buffer to be used for page table creation/updating.
[in,out]BufferSizeThe buffer size. On return, the remaining buffer size. The free buffer is used from the end so caller can supply the same Buffer pointer with an updated BufferSize in the second call to this API.
[in]LinearAddressThe start of the linear address range.
[in]LengthThe length of the linear address range.
[in]AttributeThe attribute of the linear address range. All non-reserved fields in IA32_MAP_ATTRIBUTE are supported to set in the page table. Page table entries that map the linear address range are reset to 0 before set to the new attribute when a new physical base address is set.
[in]MaskThe mask used for attribute. The corresponding field in Attribute is ignored if that in Mask is 0.
[out]IsModifiedTRUE means page table is modified by software or hardware. FALSE means page table is not modified by software. If the output IsModified is FALSE, there is possibility that the page table is changed by hardware. It is ok because page table can be changed by hardware anytime, and caller don't need to Flush TLB.
Return values
RETURN_UNSUPPORTEDPagingMode is not supported.
RETURN_INVALID_PARAMETERPageTable, BufferSize, Attribute or Mask is NULL.
RETURN_INVALID_PARAMETERFor non-present range, Mask->Bits.Present is 0 but some other attributes are provided.
RETURN_INVALID_PARAMETERFor non-present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 1 but some other attributes are not provided.
RETURN_INVALID_PARAMETERFor non-present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 0 but some other attributes are provided.
RETURN_INVALID_PARAMETERFor present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 0 but some other attributes are provided.
RETURN_INVALID_PARAMETER*BufferSize is not multiple of 4KB.
RETURN_BUFFER_TOO_SMALLThe buffer is too small for page table creation/updating. BufferSize is updated to indicate the expected buffer size. Caller may still get RETURN_BUFFER_TOO_SMALL with the new BufferSize.
RETURN_SUCCESSPageTable is created/updated successfully or the input Length is 0.

Definition at line 686 of file CpuPageTableMap.c.

◆ PageTableParse()

RETURN_STATUS EFIAPI PageTableParse ( IN UINTN  PageTable,
IN PAGING_MODE  PagingMode,
IN IA32_MAP_ENTRY Map,
IN OUT UINTN MapCount 
)

Parse page table.

Parameters
[in]PageTablePointer to the page table.
[in]PagingModeThe paging mode.
[out]MapReturn an array that describes multiple linear address ranges.
[in,out]MapCountOn input, the maximum number of entries that Map can hold. On output, the number of entries in Map.
Return values
RETURN_UNSUPPORTEDPageLevel is not 5 or 4.
RETURN_INVALID_PARAMETERMapCount is NULL.
RETURN_INVALID_PARAMETER*MapCount is not 0 but Map is NULL.
RETURN_BUFFER_TOO_SMALL*MapCount is too small.
RETURN_SUCCESSPage table is parsed successfully.