TianoCore EDK2
master
Loading...
Searching...
No Matches
Allocate.c
Go to the documentation of this file.
1
10
#include <
PiDxe.h
>
11
#include <
Library/HobLib.h
>
12
#include <
Library/UefiBootServicesTableLib.h
>
13
#include <
Library/DxeServicesLib.h
>
14
30
VOID *
31
EFIAPI
32
AllocatePeiAccessiblePages
(
33
IN
EFI_MEMORY_TYPE
MemoryType,
34
IN
UINTN
Pages
35
)
36
{
37
EFI_STATUS
Status;
38
EFI_ALLOCATE_TYPE
AllocType;
39
EFI_PHYSICAL_ADDRESS
Memory;
40
EFI_HOB_HANDOFF_INFO_TABLE
*PhitHob;
41
42
if
(Pages == 0) {
43
return
NULL
;
44
}
45
46
AllocType =
AllocateAnyPages
;
47
//
48
// A X64 build of DXE may be combined with a 32-bit build of PEI, and so we
49
// need to check the memory limit set by PEI, and allocate below 4 GB if the
50
// limit is set to 4 GB or lower.
51
//
52
PhitHob = (
EFI_HOB_HANDOFF_INFO_TABLE
*)
GetHobList
();
53
if
(PhitHob->
EfiFreeMemoryTop
<= MAX_UINT32) {
54
AllocType =
AllocateMaxAddress
;
55
Memory = MAX_UINT32;
56
}
57
58
Status =
gBS
->AllocatePages (AllocType, MemoryType, Pages, &Memory);
59
if
(EFI_ERROR (Status)) {
60
return
NULL
;
61
}
62
63
return
(VOID *)(
UINTN
)Memory;
64
}
UINTN
UINT64 UINTN
Definition:
ProcessorBind.h:112
AllocatePeiAccessiblePages
VOID *EFIAPI AllocatePeiAccessiblePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages)
Definition:
Allocate.c:31
GetHobList
VOID *EFIAPI GetHobList(VOID)
Definition:
HobLib.c:76
DxeServicesLib.h
HobLib.h
NULL
#define NULL
Definition:
Base.h:319
IN
#define IN
Definition:
Base.h:279
PiDxe.h
EFI_PHYSICAL_ADDRESS
UINT64 EFI_PHYSICAL_ADDRESS
Definition:
UefiBaseType.h:50
EFI_STATUS
RETURN_STATUS EFI_STATUS
Definition:
UefiBaseType.h:29
UefiBootServicesTableLib.h
gBS
EFI_BOOT_SERVICES * gBS
Definition:
UefiBootServicesTableLib.c:17
EFI_MEMORY_TYPE
EFI_MEMORY_TYPE
Definition:
UefiMultiPhase.h:38
EFI_ALLOCATE_TYPE
EFI_ALLOCATE_TYPE
Definition:
UefiSpec.h:29
AllocateMaxAddress
@ AllocateMaxAddress
Definition:
UefiSpec.h:38
AllocateAnyPages
@ AllocateAnyPages
Definition:
UefiSpec.h:33
EFI_HOB_HANDOFF_INFO_TABLE
Definition:
PiHob.h:60
EFI_HOB_HANDOFF_INFO_TABLE::EfiFreeMemoryTop
EFI_PHYSICAL_ADDRESS EfiFreeMemoryTop
Definition:
PiHob.h:88
MdePkg
Library
DxeServicesLib
X64
Allocate.c
Generated on Fri Nov 15 2024 18:01:17 for TianoCore EDK2 by
1.9.6