public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/2] SortLib for UEFI SEC
@ 2018-10-30 21:30 Jeff Brasen
  2018-10-30 21:30 ` [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() Jeff Brasen
  2018-10-30 21:30 ` [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types Jeff Brasen
  0 siblings, 2 replies; 13+ messages in thread
From: Jeff Brasen @ 2018-10-30 21:30 UTC (permalink / raw)
  To: edk2-devel; +Cc: 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.

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] 13+ messages in thread

* [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()
  2018-10-30 21:30 [PATCH 0/2] SortLib for UEFI SEC Jeff Brasen
@ 2018-10-30 21:30 ` Jeff Brasen
  2018-10-30 22:57   ` Carsey, Jaben
                     ` (2 more replies)
  2018-10-30 21:30 ` [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types Jeff Brasen
  1 sibling, 3 replies; 13+ messages in thread
From: Jeff Brasen @ 2018-10-30 21:30 UTC (permalink / raw)
  To: edk2-devel; +Cc: 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..f93f9cf 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 (NULL == Buffer) {
+    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] 13+ messages in thread

* [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types
  2018-10-30 21:30 [PATCH 0/2] SortLib for UEFI SEC Jeff Brasen
  2018-10-30 21:30 ` [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() Jeff Brasen
@ 2018-10-30 21:30 ` Jeff Brasen
  2018-10-30 22:57   ` Carsey, Jaben
  2018-10-31  8:56   ` Ni, Ruiyu
  1 sibling, 2 replies; 13+ messages in thread
From: Jeff Brasen @ 2018-10-30 21:30 UTC (permalink / raw)
  To: edk2-devel; +Cc: 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] 13+ messages in thread

* Re: [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()
  2018-10-30 21:30 ` [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() Jeff Brasen
@ 2018-10-30 22:57   ` Carsey, Jaben
  2018-11-08  0:29   ` Gao, Liming
  2018-11-08 11:13   ` Ard Biesheuvel
  2 siblings, 0 replies; 13+ messages in thread
From: Carsey, Jaben @ 2018-10-30 22:57 UTC (permalink / raw)
  To: Jeff Brasen, edk2-devel@lists.01.org

Code looks good.
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Jeff Brasen
> Sent: Tuesday, October 30, 2018 2:31 PM
> To: edk2-devel@lists.01.org
> Cc: Jeff Brasen <jbrasen@nvidia.com>
> Subject: [edk2] [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib:
> Added AllocateZeroPool()
> 
> 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..f93f9cf 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 (NULL == Buffer) {
> +    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
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types
  2018-10-30 21:30 ` [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types Jeff Brasen
@ 2018-10-30 22:57   ` Carsey, Jaben
  2018-10-31  8:56   ` Ni, Ruiyu
  1 sibling, 0 replies; 13+ messages in thread
From: Carsey, Jaben @ 2018-10-30 22:57 UTC (permalink / raw)
  To: Jeff Brasen, edk2-devel@lists.01.org

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Jeff Brasen
> Sent: Tuesday, October 30, 2018 2:31 PM
> To: edk2-devel@lists.01.org
> Cc: Jeff Brasen <jbrasen@nvidia.com>
> Subject: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all
> module types
> 
> 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
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types
  2018-10-30 21:30 ` [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types Jeff Brasen
  2018-10-30 22:57   ` Carsey, Jaben
@ 2018-10-31  8:56   ` Ni, Ruiyu
  2018-11-01  6:25     ` Jeff Brasen
  1 sibling, 1 reply; 13+ messages in thread
From: Ni, Ruiyu @ 2018-10-31  8:56 UTC (permalink / raw)
  To: Jeff Brasen, edk2-devel@lists.01.org; +Cc: Gao, Liming, Kinney, Michael D

SortLib depends on MemoryAllocationLib.
How can it be a BASE type library?

Can we do it in two options?
1. Change the SortLib API to accept a temporary buffer from caller. So the MemoryAllocationlIb dependency can be removed.
2. Do not change SortLibAPI but uses a fixed-size temporary buffer internally. E.g.: UINT8 Buffer[MAX_ELEMENT_SIZE];


Thanks/Ray

> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Jeff
> Brasen
> Sent: Wednesday, October 31, 2018 5:31 AM
> To: edk2-devel@lists.01.org
> Cc: Jeff Brasen <jbrasen@nvidia.com>
> Subject: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all
> module types
> 
> 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
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types
  2018-10-31  8:56   ` Ni, Ruiyu
@ 2018-11-01  6:25     ` Jeff Brasen
  2018-11-01 13:31       ` Gao, Liming
  0 siblings, 1 reply; 13+ messages in thread
From: Jeff Brasen @ 2018-11-01  6:25 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Gao, Liming, Kinney, Michael D

For defining it as a BASE type i changed that to that as there is a MemoryAllocationLib defined for the various phases. For example, SEC uses EmbeddedPkg/Library/PrePiMemoryAllocationLib (other patch in this series implements the AllocateZeroPool that is needed for this).


I am not opposed to an allocation-less SortLib but was trying to enable this capability without impact to other users of this library.


Thanks,

Jeff

________________________________
From: Ni, Ruiyu <ruiyu.ni@intel.com>
Sent: Wednesday, October 31, 2018 2:56:42 AM
To: Jeff Brasen; edk2-devel@lists.01.org
Cc: Gao, Liming; Kinney, Michael D
Subject: RE: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types

SortLib depends on MemoryAllocationLib.
How can it be a BASE type library?

Can we do it in two options?
1. Change the SortLib API to accept a temporary buffer from caller. So the MemoryAllocationlIb dependency can be removed.
2. Do not change SortLibAPI but uses a fixed-size temporary buffer internally. E.g.: UINT8 Buffer[MAX_ELEMENT_SIZE];


Thanks/Ray

> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Jeff
> Brasen
> Sent: Wednesday, October 31, 2018 5:31 AM
> To: edk2-devel@lists.01.org
> Cc: Jeff Brasen <jbrasen@nvidia.com>
> Subject: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all
> module types
>
> 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
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types
  2018-11-01  6:25     ` Jeff Brasen
@ 2018-11-01 13:31       ` Gao, Liming
  2018-11-02  4:59         ` Zeng, Star
  0 siblings, 1 reply; 13+ messages in thread
From: Gao, Liming @ 2018-11-01 13:31 UTC (permalink / raw)
  To: Jeff Brasen, Ni, Ruiyu, edk2-devel@lists.01.org
  Cc: Kinney, Michael D, Gao, Liming

Jeff:
  Thanks for your case. PrePiMemoryAllocationLib is a MemoryAllocationLib implementation that doesn't depend on PEI or DXE service. So, MemoryAllocationLib may be used in BASE type. And, I find MdeModulePkg\Library\BaseBmpSupportLib\BaseBmpSupportLib.inf is BASE type and consumes MemoryAllocationLib. So, I think your change is OK. Reviewed-by: Liming Gao <liming.gao@intel.com>

Thanks
Liming
From: Jeff Brasen [mailto:jbrasen@nvidia.com]
Sent: Thursday, November 1, 2018 2:25 PM
To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types


For defining it as a BASE type i changed that to that as there is a MemoryAllocationLib defined for the various phases. For example, SEC uses EmbeddedPkg/Library/PrePiMemoryAllocationLib (other patch in this series implements the AllocateZeroPool that is needed for this).



I am not opposed to an allocation-less SortLib but was trying to enable this capability without impact to other users of this library.



Thanks,

Jeff

________________________________
From: Ni, Ruiyu <ruiyu.ni@intel.com<mailto:ruiyu.ni@intel.com>>
Sent: Wednesday, October 31, 2018 2:56:42 AM
To: Jeff Brasen; edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Cc: Gao, Liming; Kinney, Michael D
Subject: RE: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types

SortLib depends on MemoryAllocationLib.
How can it be a BASE type library?

Can we do it in two options?
1. Change the SortLib API to accept a temporary buffer from caller. So the MemoryAllocationlIb dependency can be removed.
2. Do not change SortLibAPI but uses a fixed-size temporary buffer internally. E.g.: UINT8 Buffer[MAX_ELEMENT_SIZE];


Thanks/Ray

> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org<mailto:edk2-devel-bounces@lists.01.org>> On Behalf Of Jeff
> Brasen
> Sent: Wednesday, October 31, 2018 5:31 AM
> To: edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> Cc: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
> Subject: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all
> module types
>
> Expose BaseSortLib for use in SEC and PEI phases.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com<mailto: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
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> https://lists.01.org/mailman/listinfo/edk2-devel
________________________________
This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types
  2018-11-01 13:31       ` Gao, Liming
@ 2018-11-02  4:59         ` Zeng, Star
  2018-11-02  7:45           ` Gao, Liming
  0 siblings, 1 reply; 13+ messages in thread
From: Zeng, Star @ 2018-11-02  4:59 UTC (permalink / raw)
  To: Gao, Liming, Jeff Brasen, Ni, Ruiyu, edk2-devel@lists.01.org
  Cc: Kinney, Michael D, Gao, Liming, Zeng, Star

Liming,

Will you help push the patch series?


Thanks,
Star

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Gao, Liming
Sent: Thursday, November 1, 2018 9:31 PM
To: Jeff Brasen <jbrasen@nvidia.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org
Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types

Jeff:
  Thanks for your case. PrePiMemoryAllocationLib is a MemoryAllocationLib implementation that doesn't depend on PEI or DXE service. So, MemoryAllocationLib may be used in BASE type. And, I find MdeModulePkg\Library\BaseBmpSupportLib\BaseBmpSupportLib.inf is BASE type and consumes MemoryAllocationLib. So, I think your change is OK. Reviewed-by: Liming Gao <liming.gao@intel.com>

Thanks
Liming
From: Jeff Brasen [mailto:jbrasen@nvidia.com]
Sent: Thursday, November 1, 2018 2:25 PM
To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types


For defining it as a BASE type i changed that to that as there is a MemoryAllocationLib defined for the various phases. For example, SEC uses EmbeddedPkg/Library/PrePiMemoryAllocationLib (other patch in this series implements the AllocateZeroPool that is needed for this).



I am not opposed to an allocation-less SortLib but was trying to enable this capability without impact to other users of this library.



Thanks,

Jeff

________________________________
From: Ni, Ruiyu <ruiyu.ni@intel.com<mailto:ruiyu.ni@intel.com>>
Sent: Wednesday, October 31, 2018 2:56:42 AM
To: Jeff Brasen; edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Cc: Gao, Liming; Kinney, Michael D
Subject: RE: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types

SortLib depends on MemoryAllocationLib.
How can it be a BASE type library?

Can we do it in two options?
1. Change the SortLib API to accept a temporary buffer from caller. So the MemoryAllocationlIb dependency can be removed.
2. Do not change SortLibAPI but uses a fixed-size temporary buffer internally. E.g.: UINT8 Buffer[MAX_ELEMENT_SIZE];


Thanks/Ray

> -----Original Message-----
> From: edk2-devel 
> <edk2-devel-bounces@lists.01.org<mailto:edk2-devel-bounces@lists.01.or
> g>> On Behalf Of Jeff Brasen
> Sent: Wednesday, October 31, 2018 5:31 AM
> To: edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> Cc: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
> Subject: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all 
> module types
>
> Expose BaseSortLib for use in SEC and PEI phases.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jeff Brasen 
> <jbrasen@nvidia.com<mailto: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
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> https://lists.01.org/mailman/listinfo/edk2-devel
________________________________
This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types
  2018-11-02  4:59         ` Zeng, Star
@ 2018-11-02  7:45           ` Gao, Liming
  0 siblings, 0 replies; 13+ messages in thread
From: Gao, Liming @ 2018-11-02  7:45 UTC (permalink / raw)
  To: Zeng, Star, Jeff Brasen, Ni, Ruiyu, edk2-devel@lists.01.org
  Cc: Kinney, Michael D

Yes. I will wait for another patch in this patch set to be reviewed. 

>-----Original Message-----
>From: Zeng, Star
>Sent: Friday, November 02, 2018 1:00 PM
>To: Gao, Liming <liming.gao@intel.com>; Jeff Brasen <jbrasen@nvidia.com>;
>Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org
>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
><liming.gao@intel.com>; Zeng, Star <star.zeng@intel.com>
>Subject: RE: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all
>module types
>
>Liming,
>
>Will you help push the patch series?
>
>
>Thanks,
>Star
>
>-----Original Message-----
>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Gao,
>Liming
>Sent: Thursday, November 1, 2018 9:31 PM
>To: Jeff Brasen <jbrasen@nvidia.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-
>devel@lists.01.org
>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
><liming.gao@intel.com>
>Subject: Re: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all
>module types
>
>Jeff:
>  Thanks for your case. PrePiMemoryAllocationLib is a MemoryAllocationLib
>implementation that doesn't depend on PEI or DXE service. So,
>MemoryAllocationLib may be used in BASE type. And, I find
>MdeModulePkg\Library\BaseBmpSupportLib\BaseBmpSupportLib.inf is BASE
>type and consumes MemoryAllocationLib. So, I think your change is OK.
>Reviewed-by: Liming Gao <liming.gao@intel.com>
>
>Thanks
>Liming
>From: Jeff Brasen [mailto:jbrasen@nvidia.com]
>Sent: Thursday, November 1, 2018 2:25 PM
>To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>; Kinney, Michael D
><michael.d.kinney@intel.com>
>Subject: Re: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all
>module types
>
>
>For defining it as a BASE type i changed that to that as there is a
>MemoryAllocationLib defined for the various phases. For example, SEC uses
>EmbeddedPkg/Library/PrePiMemoryAllocationLib (other patch in this series
>implements the AllocateZeroPool that is needed for this).
>
>
>
>I am not opposed to an allocation-less SortLib but was trying to enable this
>capability without impact to other users of this library.
>
>
>
>Thanks,
>
>Jeff
>
>________________________________
>From: Ni, Ruiyu <ruiyu.ni@intel.com<mailto:ruiyu.ni@intel.com>>
>Sent: Wednesday, October 31, 2018 2:56:42 AM
>To: Jeff Brasen; edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
>Cc: Gao, Liming; Kinney, Michael D
>Subject: RE: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all
>module types
>
>SortLib depends on MemoryAllocationLib.
>How can it be a BASE type library?
>
>Can we do it in two options?
>1. Change the SortLib API to accept a temporary buffer from caller. So the
>MemoryAllocationlIb dependency can be removed.
>2. Do not change SortLibAPI but uses a fixed-size temporary buffer internally.
>E.g.: UINT8 Buffer[MAX_ELEMENT_SIZE];
>
>
>Thanks/Ray
>
>> -----Original Message-----
>> From: edk2-devel
>> <edk2-devel-bounces@lists.01.org<mailto:edk2-devel-bounces@lists.01.or
>> g>> On Behalf Of Jeff Brasen
>> Sent: Wednesday, October 31, 2018 5:31 AM
>> To: edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
>> Cc: Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
>> Subject: [edk2] [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all
>> module types
>>
>> Expose BaseSortLib for use in SEC and PEI phases.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Jeff Brasen
>> <jbrasen@nvidia.com<mailto: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
>>
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
>> https://lists.01.org/mailman/listinfo/edk2-devel
>________________________________
>This email message is for the sole use of the intended recipient(s) and may
>contain confidential information.  Any unauthorized review, use, disclosure or
>distribution is prohibited.  If you are not the intended recipient, please contact
>the sender by reply email and destroy all copies of the original message.
>________________________________
>_______________________________________________
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()
  2018-10-30 21:30 ` [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() Jeff Brasen
  2018-10-30 22:57   ` Carsey, Jaben
@ 2018-11-08  0:29   ` Gao, Liming
  2018-11-08 11:13   ` Ard Biesheuvel
  2 siblings, 0 replies; 13+ messages in thread
From: Gao, Liming @ 2018-11-08  0:29 UTC (permalink / raw)
  To: Jeff Brasen, edk2-devel@lists.01.org

Cc to the package maintainers. 

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jeff Brasen
> Sent: Wednesday, October 31, 2018 5:31 AM
> To: edk2-devel@lists.01.org
> Cc: Jeff Brasen <jbrasen@nvidia.com>
> Subject: [edk2] [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()
> 
> 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..f93f9cf 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 (NULL == Buffer) {
> +    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
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()
  2018-10-30 21:30 ` [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() Jeff Brasen
  2018-10-30 22:57   ` Carsey, Jaben
  2018-11-08  0:29   ` Gao, Liming
@ 2018-11-08 11:13   ` Ard Biesheuvel
  2018-11-08 16:52     ` Jeff Brasen
  2 siblings, 1 reply; 13+ messages in thread
From: Ard Biesheuvel @ 2018-11-08 11:13 UTC (permalink / raw)
  To: Jeff Brasen, Leif Lindholm; +Cc: edk2-devel@lists.01.org

On 30 October 2018 at 22:30, Jeff Brasen <jbrasen@nvidia.com> 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..f93f9cf 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.

I guess this is just boilerplate, but what on earth is 'a valid buffer
of 0 size'?

>  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 (NULL == Buffer) {

Please don't use Yoda speak

> +    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
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()
  2018-11-08 11:13   ` Ard Biesheuvel
@ 2018-11-08 16:52     ` Jeff Brasen
  0 siblings, 0 replies; 13+ messages in thread
From: Jeff Brasen @ 2018-11-08 16:52 UTC (permalink / raw)
  To: Ard Biesheuvel, Leif Lindholm; +Cc: edk2-devel@lists.01.org




________________________________
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Sent: Thursday, November 8, 2018 4:13 AM
To: Jeff Brasen; Leif Lindholm
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool()

On 30 October 2018 at 22:30, Jeff Brasen <jbrasen@nvidia.com> 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..f93f9cf 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.

I guess this is just boilerplate, but what on earth is 'a valid buffer
of 0 size'?

[JB] Copied this from the MemoryAllocationLib but allocate with create creates a free-able buffer is created with a unique pointer but you can't read/write to it (as it has no .

>  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 (NULL == Buffer) {

Please don't use Yoda speak

[JB] Will update, habit of mine from before compilers would generally report a warning for assignments in if statements.

> +    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
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


Thanks,

Jeff


Thanks,

Jeff

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-11-08 16:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-30 21:30 [PATCH 0/2] SortLib for UEFI SEC Jeff Brasen
2018-10-30 21:30 ` [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() Jeff Brasen
2018-10-30 22:57   ` Carsey, Jaben
2018-11-08  0:29   ` Gao, Liming
2018-11-08 11:13   ` Ard Biesheuvel
2018-11-08 16:52     ` Jeff Brasen
2018-10-30 21:30 ` [PATCH 2/2] MdeModulePkg/BaseSortLib: Enable for all module types Jeff Brasen
2018-10-30 22:57   ` Carsey, Jaben
2018-10-31  8:56   ` Ni, Ruiyu
2018-11-01  6:25     ` Jeff Brasen
2018-11-01 13:31       ` Gao, Liming
2018-11-02  4:59         ` Zeng, Star
2018-11-02  7:45           ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox