* [PATCH v2 0/2] SortLib for UEFI SEC
@ 2018-11-08 17:09 Jeff Brasen
2018-11-08 17:09 ` [PATCH v2 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() Jeff Brasen
2018-11-08 17:09 ` [PATCH v2 2/2] MdeModulePkg/BaseSortLib: Enable for all module types Jeff Brasen
0 siblings, 2 replies; 4+ messages in thread
From: Jeff Brasen @ 2018-11-08 17:09 UTC (permalink / raw)
To: edk2-devel; +Cc: ard.biesheuvel, leif.lindholm, Jeff Brasen
This patch series enables support for BaseSortLib in UEFI SEC Phase.
This requires the addition of the AllocateZeroPool which is implemented
in the PrePiMemoryAllocationLib.
Changelog:
v1 - Initial version
v2 - Update order of NULL check in MemoryAllocationLib
Jeff Brasen (2):
EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()
MdeModulePkg/BaseSortLib: Enable for all module types
.../PrePiMemoryAllocationLib/MemoryAllocationLib.c | 32 ++++++++++++++++++++++
MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf | 4 +--
2 files changed, 34 insertions(+), 2 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()
2018-11-08 17:09 [PATCH v2 0/2] SortLib for UEFI SEC Jeff Brasen
@ 2018-11-08 17:09 ` Jeff Brasen
2018-11-08 17:49 ` Laszlo Ersek
2018-11-08 17:09 ` [PATCH v2 2/2] MdeModulePkg/BaseSortLib: Enable for all module types Jeff Brasen
1 sibling, 1 reply; 4+ messages in thread
From: Jeff Brasen @ 2018-11-08 17:09 UTC (permalink / raw)
To: edk2-devel; +Cc: ard.biesheuvel, leif.lindholm, Jeff Brasen
This function is exposed by the MemoryAllocationLib header.
An AllocateZeroPool() function has been added to fix modules depending on
this library and this function.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
---
.../PrePiMemoryAllocationLib/MemoryAllocationLib.c | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
index 0e75e23..c39d140 100644
--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
@@ -16,6 +16,7 @@
#include <PiPei.h>
#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/PrePiLib.h>
#include <Library/DebugLib.h>
@@ -195,6 +196,37 @@ AllocatePool (
}
/**
+ Allocates and zeros a buffer of type EfiBootServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
+ request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateZeroPool (
+ IN UINTN AllocationSize
+ )
+{
+ VOID *Buffer;
+
+ Buffer = AllocatePool (AllocationSize);
+ if (Buffer == NULL) {
+ return NULL;
+ }
+
+ SetMem (Buffer, AllocationSize, 0);
+
+ return Buffer;
+}
+
+/**
Frees a buffer that was previously allocated with one of the pool allocation functions in the
Memory Allocation Library.
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] MdeModulePkg/BaseSortLib: Enable for all module types
2018-11-08 17:09 [PATCH v2 0/2] SortLib for UEFI SEC Jeff Brasen
2018-11-08 17:09 ` [PATCH v2 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() Jeff Brasen
@ 2018-11-08 17:09 ` Jeff Brasen
1 sibling, 0 replies; 4+ messages in thread
From: Jeff Brasen @ 2018-11-08 17:09 UTC (permalink / raw)
To: edk2-devel; +Cc: ard.biesheuvel, leif.lindholm, Jeff Brasen
Expose BaseSortLib for use in SEC and PEI phases.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
---
MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf b/MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
index f807cd7..5bd1aa1 100644
--- a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
+++ b/MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
@@ -18,9 +18,9 @@
BASE_NAME = BaseSortLib
MODULE_UNI_FILE = BaseSortLib.uni
FILE_GUID = 03F3331B-F12D-494f-BF37-E55A657F2497
- MODULE_TYPE = UEFI_DRIVER
+ MODULE_TYPE = BASE
VERSION_STRING = 1.0
- LIBRARY_CLASS = SortLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
+ LIBRARY_CLASS = SortLib
#
# VALID_ARCHITECTURES = IA32 X64 EBC
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()
2018-11-08 17:09 ` [PATCH v2 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() Jeff Brasen
@ 2018-11-08 17:49 ` Laszlo Ersek
0 siblings, 0 replies; 4+ messages in thread
From: Laszlo Ersek @ 2018-11-08 17:49 UTC (permalink / raw)
To: Jeff Brasen, edk2-devel
On 11/08/18 18:09, Jeff Brasen wrote:
> This function is exposed by the MemoryAllocationLib header.
> An AllocateZeroPool() function has been added to fix modules depending on
> this library and this function.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> ---
> .../PrePiMemoryAllocationLib/MemoryAllocationLib.c | 32 ++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> index 0e75e23..c39d140 100644
> --- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> +++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> @@ -16,6 +16,7 @@
> #include <PiPei.h>
>
> #include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> #include <Library/PrePiLib.h>
> #include <Library/DebugLib.h>
>
> @@ -195,6 +196,37 @@ AllocatePool (
> }
>
> /**
> + Allocates and zeros a buffer of type EfiBootServicesData.
> +
> + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
> + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
> + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
> + request, then NULL is returned.
> +
> + @param AllocationSize The number of bytes to allocate and zero.
> +
> + @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateZeroPool (
> + IN UINTN AllocationSize
> + )
> +{
> + VOID *Buffer;
> +
> + Buffer = AllocatePool (AllocationSize);
> + if (Buffer == NULL) {
> + return NULL;
> + }
> +
> + SetMem (Buffer, AllocationSize, 0);
> +
> + return Buffer;
> +}
> +
> +/**
> Frees a buffer that was previously allocated with one of the pool allocation functions in the
> Memory Allocation Library.
>
>
Drive-by comment: can you use ZeroMem()? It's a tiny bit more idiomatic.
Thanks
Laszlo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-11-08 17:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-08 17:09 [PATCH v2 0/2] SortLib for UEFI SEC Jeff Brasen
2018-11-08 17:09 ` [PATCH v2 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() Jeff Brasen
2018-11-08 17:49 ` Laszlo Ersek
2018-11-08 17:09 ` [PATCH v2 2/2] MdeModulePkg/BaseSortLib: Enable for all module types Jeff Brasen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox