2 Data structure and functions to allocate and free memory space.
4 Copyright (c) 2006 - 2015, 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)
44 // +---------------------------------------------------+
45 // | 0..(EfiMaxMemoryType - 1) - Normal memory type |
46 // +---------------------------------------------------+
47 // | EfiMaxMemoryType..0x6FFFFFFF - Ilegal |
48 // +---------------------------------------------------+
49 // | 0x70000000..0x7FFFFFFF - OEM reserved |
50 // +---------------------------------------------------+
51 // | 0x80000000..0xFFFFFFFF - OS reserved |
52 // +---------------------------------------------------+
54 #define MEMORY_TYPE_OS_RESERVED_MIN 0x80000000
55 #define MEMORY_TYPE_OS_RESERVED_MAX 0xFFFFFFFF
56 #define MEMORY_TYPE_OEM_RESERVED_MIN 0x70000000
57 #define MEMORY_TYPE_OEM_RESERVED_MAX 0x7FFFFFFF
63 #define MEMORY_MAP_SIGNATURE SIGNATURE_32('m','m','a','p')
78 // Internal prototypes
83 Internal function. Used by the pool functions to allocate pages
84 to back pool allocation requests.
86 @param PoolType The type of memory for the new pool pages
87 @param NumberOfPages No of pages to allocate
88 @param Alignment Bits to align.
90 @return The allocated memory, or NULL
94 CoreAllocatePoolPages (
95 IN EFI_MEMORY_TYPE PoolType
,
96 IN UINTN NumberOfPages
,
103 Internal function. Frees pool pages allocated via AllocatePoolPages ()
105 @param Memory The base address to free
106 @param NumberOfPages The number of pages to free
111 IN EFI_PHYSICAL_ADDRESS Memory
,
112 IN UINTN NumberOfPages
118 Internal function to allocate pool of a particular type.
119 Caller must have the memory lock held
121 @param PoolType Type of pool to allocate
122 @param Size The amount of pool to allocate
124 @return The allocate pool, or NULL
129 IN EFI_MEMORY_TYPE PoolType
,
136 Internal function to free a pool entry.
137 Caller must have the memory lock held
139 @param Buffer The allocated pool entry to free
141 @retval EFI_INVALID_PARAMETER Buffer not valid
142 @retval EFI_SUCCESS Buffer successfully freed.
153 Enter critical section by gaining lock on gMemoryLock.
157 CoreAcquireMemoryLock (
163 Exit critical section by releasing lock on gMemoryLock.
167 CoreReleaseMemoryLock (
173 // Internal Global data
176 extern EFI_LOCK gMemoryLock
;
177 extern LIST_ENTRY gMemoryMap
;
178 extern LIST_ENTRY mGcdMemorySpaceMap
;