3 Data structure and functions to allocate and free memory space.
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #if defined (MDE_CPU_IPF)
22 // For Itanium machines make the default allocations 8K aligned
24 #define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2)
25 #define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)
29 // For genric EFI machines make the default allocations 4K aligned
31 #define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)
32 #define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
41 #define MEMORY_MAP_SIGNATURE EFI_SIGNATURE_32('m','m','a','p')
56 // Internal prototypes
61 Internal function. Used by the pool functions to allocate pages
62 to back pool allocation requests.
64 @param PoolType The type of memory for the new pool pages
65 @param NumberOfPages No of pages to allocate
66 @param Alignment Bits to align.
68 @return The allocated memory, or NULL
72 CoreAllocatePoolPages (
73 IN EFI_MEMORY_TYPE PoolType
,
74 IN UINTN NumberOfPages
,
82 Internal function. Frees pool pages allocated via AllocatePoolPages ()
84 @param Memory The base address to free
85 @param NumberOfPages The number of pages to free
90 IN EFI_PHYSICAL_ADDRESS Memory
,
91 IN UINTN NumberOfPages
98 Internal function to allocate pool of a particular type.
99 Caller must have the memory lock held
101 @param PoolType Type of pool to allocate
102 @param Size The amount of pool to allocate
104 @return The allocate pool, or NULL
109 IN EFI_MEMORY_TYPE PoolType
,
117 Internal function to free a pool entry.
118 Caller must have the memory lock held
120 @param Buffer The allocated pool entry to free
122 @retval EFI_INVALID_PARAMETER Buffer not valid
123 @retval EFI_SUCCESS Buffer successfully freed.
135 Enter critical section by gaining lock on gMemoryLock.
139 CoreAcquireMemoryLock (
146 Exit critical section by releasing lock on gMemoryLock.
150 CoreReleaseMemoryLock (
157 // Internal Global data
160 extern EFI_LOCK gMemoryLock
;
161 extern LIST_ENTRY gMemoryMap
;
162 extern MEMORY_MAP
*gMemoryLastConvert
;
163 extern LIST_ENTRY mGcdMemorySpaceMap
;