2 Data structure and functions to allocate and free memory space.
4 Copyright (c) 2006 - 2016, 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.
19 // +---------------------------------------------------+
20 // | 0..(EfiMaxMemoryType - 1) - Normal memory type |
21 // +---------------------------------------------------+
22 // | EfiMaxMemoryType..0x6FFFFFFF - Invalid |
23 // +---------------------------------------------------+
24 // | 0x70000000..0x7FFFFFFF - OEM reserved |
25 // +---------------------------------------------------+
26 // | 0x80000000..0xFFFFFFFF - OS reserved |
27 // +---------------------------------------------------+
29 #define MEMORY_TYPE_OS_RESERVED_MIN 0x80000000
30 #define MEMORY_TYPE_OS_RESERVED_MAX 0xFFFFFFFF
31 #define MEMORY_TYPE_OEM_RESERVED_MIN 0x70000000
32 #define MEMORY_TYPE_OEM_RESERVED_MAX 0x7FFFFFFF
38 #define MEMORY_MAP_SIGNATURE SIGNATURE_32('m','m','a','p')
53 // Internal prototypes
58 Internal function. Used by the pool functions to allocate pages
59 to back pool allocation requests.
61 @param PoolType The type of memory for the new pool pages
62 @param NumberOfPages No of pages to allocate
63 @param Alignment Bits to align.
65 @return The allocated memory, or NULL
69 CoreAllocatePoolPages (
70 IN EFI_MEMORY_TYPE PoolType
,
71 IN UINTN NumberOfPages
,
78 Internal function. Frees pool pages allocated via AllocatePoolPages ()
80 @param Memory The base address to free
81 @param NumberOfPages The number of pages to free
86 IN EFI_PHYSICAL_ADDRESS Memory
,
87 IN UINTN NumberOfPages
93 Internal function to allocate pool of a particular type.
94 Caller must have the memory lock held
96 @param PoolType Type of pool to allocate
97 @param Size The amount of pool to allocate
99 @return The allocate pool, or NULL
104 IN EFI_MEMORY_TYPE PoolType
,
111 Internal function to free a pool entry.
112 Caller must have the memory lock held
114 @param Buffer The allocated pool entry to free
115 @param PoolType Pointer to pool type
117 @retval EFI_INVALID_PARAMETER Buffer not valid
118 @retval EFI_SUCCESS Buffer successfully freed.
124 OUT EFI_MEMORY_TYPE
*PoolType OPTIONAL
130 Enter critical section by gaining lock on gMemoryLock.
134 CoreAcquireMemoryLock (
140 Exit critical section by releasing lock on gMemoryLock.
144 CoreReleaseMemoryLock (
150 // Internal Global data
153 extern EFI_LOCK gMemoryLock
;
154 extern LIST_ENTRY gMemoryMap
;
155 extern LIST_ENTRY mGcdMemorySpaceMap
;