]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmulatorPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c
EmulatorPkg: Remove all trailing whitespace
[mirror_edk2.git] / EmulatorPkg / Library / GuardUefiMemoryAllocationLib / MemoryAllocationLib.c
index c457e7c213134df49e7041877c3569af3521682e..d6e20d6f74e6afea884dd86f5c322411f5fe5a6c 100644 (file)
@@ -1,23 +1,23 @@
 /** @file\r
-  Support routines for memory allocation routines based \r
+  Support routines for memory allocation routines based\r
   on boot services for Dxe phase drivers using OS malloc.\r
-  \r
-  OS malloc is used so OS based malloc debugging tools can be used. \r
-  If a single driver links against this lib protocols from other \r
-  drivers, or EFI boot services can return a buffer that needs to \r
-  freed using the EFI scheme. This is why the gEmuThunk->Free () \r
+\r
+  OS malloc is used so OS based malloc debugging tools can be used.\r
+  If a single driver links against this lib protocols from other\r
+  drivers, or EFI boot services can return a buffer that needs to\r
+  freed using the EFI scheme. This is why the gEmuThunk->Free ()\r
   can detect if the memory rang is for EFI so the right free can be\r
   called.\r
 \r
   Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-  This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php.                                            \r
+  Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
 \r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
 \r
 **/\r
 VOID *\r
 InternalAllocatePages (\r
-  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN EFI_MEMORY_TYPE  MemoryType,\r
   IN UINTN            Pages\r
   )\r
 {\r
   EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  Memory; \r
+  EFI_PHYSICAL_ADDRESS  Memory;\r
 \r
   if (Pages == 0) {\r
     return NULL;\r
@@ -134,11 +134,11 @@ AllocateReservedPages (
   must have been allocated on a previous call to the page allocation services of the Memory\r
   Allocation Library.  If it is not possible to free allocated pages, then this function will\r
   perform no actions.\r
-  \r
+\r
   If Buffer was not allocated with a page allocation function in the Memory Allocation Library,\r
   then ASSERT().\r
   If Pages is zero, then ASSERT().\r
\r
+\r
   @param  Buffer                The pointer to the buffer of pages to free.\r
   @param  Pages                 The number of 4 KB pages to free.\r
 \r
@@ -155,7 +155,7 @@ FreePages (
   ASSERT (Pages != 0);\r
   if (!gEmuThunk->Free (Buffer)) {\r
     // The Free thunk will not free memory allocated in emulated EFI memory.\r
-    // The assmuption is this was allocated directly by EFI. We need this as some \r
+    // The assmuption is this was allocated directly by EFI. We need this as some\r
     // times protocols or EFI BootServices can return dynamically allocated buffers.\r
     Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
     ASSERT_EFI_ERROR (Status);\r
@@ -181,7 +181,7 @@ FreePages (
 **/\r
 VOID *\r
 InternalAllocateAlignedPages (\r
-  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN EFI_MEMORY_TYPE  MemoryType,\r
   IN UINTN            Pages,\r
   IN UINTN            Alignment\r
   )\r
@@ -197,7 +197,7 @@ InternalAllocateAlignedPages (
   // Alignment must be a power of two or zero.\r
   //\r
   ASSERT ((Alignment & (Alignment - 1)) == 0);\r
\r
+\r
   if (Pages == 0) {\r
     return NULL;\r
   }\r
@@ -211,7 +211,7 @@ InternalAllocateAlignedPages (
     // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.\r
     //\r
     ASSERT (RealPages > Pages);\r
\r
+\r
     Memory = gEmuThunk->Valloc (Pages * EFI_PAGE_SIZE);\r
     if (Memory != NULL) {\r
       return NULL;\r
@@ -252,7 +252,7 @@ InternalAllocateAlignedPages (
   alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
   returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
   request, then NULL is returned.\r
-  \r
+\r
   If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
 \r
   @param  Pages                 The number of 4 KB pages to allocate.\r
@@ -279,7 +279,7 @@ AllocateAlignedPages (
   alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
   returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
   request, then NULL is returned.\r
-  \r
+\r
   If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
 \r
   @param  Pages                 The number of 4 KB pages to allocate.\r
@@ -306,7 +306,7 @@ AllocateAlignedRuntimePages (
   alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
   returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
   request, then NULL is returned.\r
-  \r
+\r
   If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
 \r
   @param  Pages                 The number of 4 KB pages to allocate.\r
@@ -332,13 +332,13 @@ AllocateAlignedReservedPages (
 \r
   Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer\r
   must have been allocated on a previous call to the aligned page allocation services of the Memory\r
-  Allocation Library.  If it is not possible to free allocated pages, then this function will \r
+  Allocation Library.  If it is not possible to free allocated pages, then this function will\r
   perform no actions.\r
-  \r
+\r
   If Buffer was not allocated with an aligned page allocation function in the Memory Allocation\r
   Library, then ASSERT().\r
   If Pages is zero, then ASSERT().\r
-  \r
+\r
   @param  Buffer                The pointer to the buffer of pages to free.\r
   @param  Pages                 The number of 4 KB pages to free.\r
 \r
@@ -368,7 +368,7 @@ FreeAlignedPages (
 **/\r
 VOID *\r
 InternalAllocatePool (\r
-  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN EFI_MEMORY_TYPE  MemoryType,\r
   IN UINTN            AllocationSize\r
   )\r
 {\r
@@ -454,9 +454,9 @@ AllocateReservedPool (
 **/\r
 VOID *\r
 InternalAllocateZeroPool (\r
-  IN EFI_MEMORY_TYPE  PoolType,  \r
+  IN EFI_MEMORY_TYPE  PoolType,\r
   IN UINTN            AllocationSize\r
-  ) \r
+  )\r
 {\r
   VOID  *Memory;\r
 \r
@@ -541,7 +541,7 @@ AllocateReservedZeroPool (
   allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
   is not enough memory remaining to satisfy the request, then NULL is returned.\r
   If Buffer is NULL, then ASSERT().\r
-  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
   @param  PoolType              The type of pool to allocate.\r
   @param  AllocationSize        The number of bytes to allocate and zero.\r
@@ -552,10 +552,10 @@ AllocateReservedZeroPool (
 **/\r
 VOID *\r
 InternalAllocateCopyPool (\r
-  IN EFI_MEMORY_TYPE  PoolType,  \r
+  IN EFI_MEMORY_TYPE  PoolType,\r
   IN UINTN            AllocationSize,\r
   IN CONST VOID       *Buffer\r
-  ) \r
+  )\r
 {\r
   VOID  *Memory;\r
 \r
@@ -567,7 +567,7 @@ InternalAllocateCopyPool (
      Memory = CopyMem (Memory, Buffer, AllocationSize);\r
   }\r
   return Memory;\r
-} \r
+}\r
 \r
 /**\r
   Copies a buffer to an allocated buffer of type EfiBootServicesData.\r
@@ -576,9 +576,9 @@ InternalAllocateCopyPool (
   AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
   allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
   is not enough memory remaining to satisfy the request, then NULL is returned.\r
-  \r
+\r
   If Buffer is NULL, then ASSERT().\r
-  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
   @param  AllocationSize        The number of bytes to allocate and zero.\r
   @param  Buffer                The buffer to copy to the allocated buffer.\r
@@ -603,9 +603,9 @@ AllocateCopyPool (
   AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
   allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
   is not enough memory remaining to satisfy the request, then NULL is returned.\r
-  \r
+\r
   If Buffer is NULL, then ASSERT().\r
-  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
   @param  AllocationSize        The number of bytes to allocate and zero.\r
   @param  Buffer                The buffer to copy to the allocated buffer.\r
@@ -630,9 +630,9 @@ AllocateRuntimeCopyPool (
   AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
   allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
   is not enough memory remaining to satisfy the request, then NULL is returned.\r
-  \r
+\r
   If Buffer is NULL, then ASSERT().\r
-  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
 \r
   @param  AllocationSize        The number of bytes to allocate and zero.\r
   @param  Buffer                The buffer to copy to the allocated buffer.\r
@@ -654,19 +654,19 @@ AllocateReservedCopyPool (
   Reallocates a buffer of a specified memory type.\r
 \r
   Allocates and zeros the number bytes specified by NewSize from memory of the type\r
-  specified by PoolType.  If OldBuffer is not NULL, then the smaller of OldSize and \r
-  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
-  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
-  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
+  specified by PoolType.  If OldBuffer is not NULL, then the smaller of OldSize and\r
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and\r
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.\r
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not\r
   enough memory remaining to satisfy the request, then NULL is returned.\r
-  \r
+\r
   If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
   is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().\r
 \r
   @param  PoolType       The type of pool to allocate.\r
   @param  OldSize        The size, in bytes, of OldBuffer.\r
   @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
-  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional\r
                          parameter that may be NULL.\r
 \r
   @return A pointer to the allocated buffer or NULL if allocation fails.\r
@@ -674,7 +674,7 @@ AllocateReservedCopyPool (
 **/\r
 VOID *\r
 InternalReallocatePool (\r
-  IN EFI_MEMORY_TYPE  PoolType,  \r
+  IN EFI_MEMORY_TYPE  PoolType,\r
   IN UINTN            OldSize,\r
   IN UINTN            NewSize,\r
   IN VOID             *OldBuffer  OPTIONAL\r
@@ -694,18 +694,18 @@ InternalReallocatePool (
   Reallocates a buffer of type EfiBootServicesData.\r
 \r
   Allocates and zeros the number bytes specified by NewSize from memory of type\r
-  EfiBootServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and \r
-  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
-  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
-  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
+  EfiBootServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and\r
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and\r
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.\r
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not\r
   enough memory remaining to satisfy the request, then NULL is returned.\r
-  \r
+\r
   If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
   is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().\r
 \r
   @param  OldSize        The size, in bytes, of OldBuffer.\r
   @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
-  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional\r
                          parameter that may be NULL.\r
 \r
   @return A pointer to the allocated buffer or NULL if allocation fails.\r
@@ -726,10 +726,10 @@ ReallocatePool (
   Reallocates a buffer of type EfiRuntimeServicesData.\r
 \r
   Allocates and zeros the number bytes specified by NewSize from memory of type\r
-  EfiRuntimeServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and \r
-  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
-  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
-  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
+  EfiRuntimeServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and\r
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and\r
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.\r
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not\r
   enough memory remaining to satisfy the request, then NULL is returned.\r
 \r
   If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
@@ -737,7 +737,7 @@ ReallocatePool (
 \r
   @param  OldSize        The size, in bytes, of OldBuffer.\r
   @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
-  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional\r
                          parameter that may be NULL.\r
 \r
   @return A pointer to the allocated buffer or NULL if allocation fails.\r
@@ -758,10 +758,10 @@ ReallocateRuntimePool (
   Reallocates a buffer of type EfiReservedMemoryType.\r
 \r
   Allocates and zeros the number bytes specified by NewSize from memory of type\r
-  EfiReservedMemoryType.  If OldBuffer is not NULL, then the smaller of OldSize and \r
-  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
-  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
-  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
+  EfiReservedMemoryType.  If OldBuffer is not NULL, then the smaller of OldSize and\r
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and\r
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.\r
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not\r
   enough memory remaining to satisfy the request, then NULL is returned.\r
 \r
   If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
@@ -769,7 +769,7 @@ ReallocateRuntimePool (
 \r
   @param  OldSize        The size, in bytes, of OldBuffer.\r
   @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
-  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional\r
                          parameter that may be NULL.\r
 \r
   @return A pointer to the allocated buffer or NULL if allocation fails.\r
@@ -793,7 +793,7 @@ ReallocateReservedPool (
   Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the\r
   pool allocation services of the Memory Allocation Library.  If it is not possible to free pool\r
   resources, then this function will perform no actions.\r
-  \r
+\r
   If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,\r
   then ASSERT().\r
 \r
@@ -810,7 +810,7 @@ FreePool (
 \r
   if (!gEmuThunk->Free (Buffer)) {\r
     // The Free thunk will not free memory allocated in emulated EFI memory.\r
-    // The assmuption is this was allocated directly by EFI. We need this as some \r
+    // The assmuption is this was allocated directly by EFI. We need this as some\r
     // times protocols or EFI BootServices can return dynamically allocated buffers.\r
     Status = gBS->FreePool (Buffer);\r
     ASSERT_EFI_ERROR (Status);\r