TianoCore EDK2 master
Loading...
Searching...
No Matches
PeiDxeMemEncryptSevLibInternal.c
Go to the documentation of this file.
1
11#include <Library/BaseLib.h>
12#include <Library/DebugLib.h>
14#include <Library/PcdLib.h>
17#include <Uefi/UefiBaseType.h>
18
34RETURN_STATUS
35EFIAPI
37 OUT UINTN *BaseAddress,
38 OUT UINTN *NumberOfPages
39 )
40{
41 UINTN MapStart;
42 UINTN MapEnd;
43 UINTN MapPagesStart; // MapStart rounded down to page boundary
44 UINTN MapPagesEnd; // MapEnd rounded up to page boundary
45 UINTN MapPagesSize; // difference between MapPagesStart and MapPagesEnd
46
47 if (!FeaturePcdGet (PcdSmmSmramRequire)) {
48 return RETURN_UNSUPPORTED;
49 }
50
52 MapEnd = MapStart + sizeof (AMD_SMRAM_SAVE_STATE_MAP);
53 MapPagesStart = MapStart & ~(UINTN)EFI_PAGE_MASK;
54 MapPagesEnd = ALIGN_VALUE (MapEnd, EFI_PAGE_SIZE);
55 MapPagesSize = MapPagesEnd - MapPagesStart;
56
57 ASSERT ((MapPagesSize & EFI_PAGE_MASK) == 0);
58
59 *BaseAddress = MapPagesStart;
60 *NumberOfPages = MapPagesSize >> EFI_PAGE_SHIFT;
61
62 return RETURN_SUCCESS;
63}
UINT64 UINTN
#define RETURN_UNSUPPORTED
Definition: Base.h:1081
#define ALIGN_VALUE(Value, Alignment)
Definition: Base.h:948
#define RETURN_SUCCESS
Definition: Base.h:1066
#define OUT
Definition: Base.h:284
#define SMM_DEFAULT_SMBASE
#define SMRAM_SAVE_STATE_MAP_OFFSET
#define FeaturePcdGet(TokenName)
Definition: PcdLib.h:50
RETURN_STATUS EFIAPI MemEncryptSevLocateInitialSmramSaveStateMapPages(OUT UINTN *BaseAddress, OUT UINTN *NumberOfPages)