EmbeddedPkg: Add AllocateRuntimePages in PrePiMemoryAllocationLib
AllocateRuntimePages is used to allocate one or more 4KB pages of type EfiRuntimeServicesData. Cc: Leif Lindholm <quic_llindhol@quicinc.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Abner Chang <abner.chang@hpe.com> Cc: Daniel Schaefer <daniel.schaefer@hpe.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Ard Biesheuvel <ardb+tianocore@kernel.org> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Min Xu <min.m.xu@intel.com>
This commit is contained in:
parent
7cc7c52670
commit
fb008dbe01
|
@ -665,6 +665,25 @@ AllocatePages (
|
||||||
IN UINTN Pages
|
IN UINTN Pages
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Allocates one or more 4KB pages of type EfiRuntimeServicesData.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
@param Pages The number of 4 KB pages to allocate.
|
||||||
|
|
||||||
|
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID *
|
||||||
|
EFIAPI
|
||||||
|
AllocateRuntimePages (
|
||||||
|
IN UINTN Pages
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocates a buffer of type EfiBootServicesData.
|
Allocates a buffer of type EfiBootServicesData.
|
||||||
|
|
||||||
|
|
|
@ -14,23 +14,12 @@
|
||||||
#include <Library/PrePiLib.h>
|
#include <Library/PrePiLib.h>
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
|
|
||||||
/**
|
STATIC
|
||||||
Allocates one or more 4KB pages of type EfiBootServicesData.
|
|
||||||
|
|
||||||
Allocates the number of 4KB pages of MemoryType 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.
|
|
||||||
|
|
||||||
@param Pages The number of 4 KB pages to allocate.
|
|
||||||
|
|
||||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID *
|
VOID *
|
||||||
EFIAPI
|
EFIAPI
|
||||||
AllocatePages (
|
InternalAllocatePages (
|
||||||
IN UINTN Pages
|
IN UINTN Pages,
|
||||||
|
IN EFI_MEMORY_TYPE MemoryType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_PEI_HOB_POINTERS Hob;
|
EFI_PEI_HOB_POINTERS Hob;
|
||||||
|
@ -65,12 +54,56 @@ AllocatePages (
|
||||||
BuildMemoryAllocationHob (
|
BuildMemoryAllocationHob (
|
||||||
Hob.HandoffInformationTable->EfiFreeMemoryTop,
|
Hob.HandoffInformationTable->EfiFreeMemoryTop,
|
||||||
Pages * EFI_PAGE_SIZE,
|
Pages * EFI_PAGE_SIZE,
|
||||||
EfiBootServicesData
|
MemoryType
|
||||||
);
|
);
|
||||||
return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;
|
return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Allocates one or more 4KB pages of type EfiBootServicesData.
|
||||||
|
|
||||||
|
Allocates the number of 4KB pages of MemoryType 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.
|
||||||
|
|
||||||
|
@param Pages The number of 4 KB pages to allocate.
|
||||||
|
|
||||||
|
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID *
|
||||||
|
EFIAPI
|
||||||
|
AllocatePages (
|
||||||
|
IN UINTN Pages
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return InternalAllocatePages (Pages, EfiBootServicesData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Allocates one or more 4KB pages of type EfiRuntimeServicesData.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
@param Pages The number of 4 KB pages to allocate.
|
||||||
|
|
||||||
|
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID *
|
||||||
|
EFIAPI
|
||||||
|
AllocateRuntimePages (
|
||||||
|
IN UINTN Pages
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return InternalAllocatePages (Pages, EfiRuntimeServicesData);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
|
Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue