2 Data structure and functions to allocate and free memory space.
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #if defined (MDE_CPU_IPF)
20 /// For Itanium machines make the default allocations 8K aligned
22 #define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2)
23 #define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)
25 #elif defined (MDE_CPU_AARCH64)
27 /// 64-bit ARM systems allow the OS to execute with 64 KB page size,
28 /// so for improved interoperability with the firmware, align the
29 /// runtime regions to 64 KB as well
31 #define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (SIZE_64KB)
32 #define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
36 /// For genric EFI machines make the default allocations 4K aligned
38 #define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)
39 #define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
48 #define MEMORY_MAP_SIGNATURE SIGNATURE_32('m','m','a','p')
63 // Internal prototypes
68 Internal function. Used by the pool functions to allocate pages
69 to back pool allocation requests.
71 @param PoolType The type of memory for the new pool pages
72 @param NumberOfPages No of pages to allocate
73 @param Alignment Bits to align.
75 @return The allocated memory, or NULL
79 CoreAllocatePoolPages (
80 IN EFI_MEMORY_TYPE PoolType
,
81 IN UINTN NumberOfPages
,
88 Internal function. Frees pool pages allocated via AllocatePoolPages ()
90 @param Memory The base address to free
91 @param NumberOfPages The number of pages to free
96 IN EFI_PHYSICAL_ADDRESS Memory
,
97 IN UINTN NumberOfPages
103 Internal function to allocate pool of a particular type.
104 Caller must have the memory lock held
106 @param PoolType Type of pool to allocate
107 @param Size The amount of pool to allocate
109 @return The allocate pool, or NULL
114 IN EFI_MEMORY_TYPE PoolType
,
121 Internal function to free a pool entry.
122 Caller must have the memory lock held
124 @param Buffer The allocated pool entry to free
126 @retval EFI_INVALID_PARAMETER Buffer not valid
127 @retval EFI_SUCCESS Buffer successfully freed.
138 Enter critical section by gaining lock on gMemoryLock.
142 CoreAcquireMemoryLock (
148 Exit critical section by releasing lock on gMemoryLock.
152 CoreReleaseMemoryLock (
158 // Internal Global data
161 extern EFI_LOCK gMemoryLock
;
162 extern LIST_ENTRY gMemoryMap
;
163 extern LIST_ENTRY mGcdMemorySpaceMap
;