]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/Mem/Imem.h
MdeModulePkg DxeCore: Return memory type from internal free pool/pages
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Mem / Imem.h
CommitLineData
23c98c94 1/** @file\r
504214c4 2 Data structure and functions to allocate and free memory space.\r
28a00297 3\r
2eb989bc 4Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 5This program and the accompanying materials\r
23c98c94 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
28a00297 9\r
23c98c94 10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
162ed594 12\r
13**/\r
28a00297 14\r
15#ifndef _IMEM_H_\r
16#define _IMEM_H_\r
17\r
8ee25f48
SZ
18//\r
19// +---------------------------------------------------+\r
20// | 0..(EfiMaxMemoryType - 1) - Normal memory type |\r
21// +---------------------------------------------------+\r
2eb989bc 22// | EfiMaxMemoryType..0x6FFFFFFF - Invalid |\r
8ee25f48
SZ
23// +---------------------------------------------------+\r
24// | 0x70000000..0x7FFFFFFF - OEM reserved |\r
25// +---------------------------------------------------+\r
26// | 0x80000000..0xFFFFFFFF - OS reserved |\r
27// +---------------------------------------------------+\r
28//\r
29#define MEMORY_TYPE_OS_RESERVED_MIN 0x80000000\r
30#define MEMORY_TYPE_OS_RESERVED_MAX 0xFFFFFFFF\r
31#define MEMORY_TYPE_OEM_RESERVED_MIN 0x70000000\r
32#define MEMORY_TYPE_OEM_RESERVED_MAX 0x7FFFFFFF\r
28a00297 33\r
34//\r
35// MEMORY_MAP_ENTRY\r
36//\r
37\r
f3f2e05d 38#define MEMORY_MAP_SIGNATURE SIGNATURE_32('m','m','a','p')\r
28a00297 39typedef struct {\r
40 UINTN Signature;\r
41 LIST_ENTRY Link;\r
42 BOOLEAN FromPages;\r
43\r
44 EFI_MEMORY_TYPE Type;\r
45 UINT64 Start;\r
46 UINT64 End;\r
47\r
48 UINT64 VirtualStart;\r
49 UINT64 Attribute;\r
50} MEMORY_MAP;\r
51\r
52//\r
53// Internal prototypes\r
54//\r
55\r
28a00297 56\r
162ed594 57/**\r
28a00297 58 Internal function. Used by the pool functions to allocate pages\r
59 to back pool allocation requests.\r
60\r
022c6d45 61 @param PoolType The type of memory for the new pool pages\r
62 @param NumberOfPages No of pages to allocate\r
63 @param Alignment Bits to align.\r
28a00297 64\r
162ed594 65 @return The allocated memory, or NULL\r
28a00297 66\r
162ed594 67**/\r
68VOID *\r
69CoreAllocatePoolPages (\r
23c98c94 70 IN EFI_MEMORY_TYPE PoolType,\r
71 IN UINTN NumberOfPages,\r
72 IN UINTN Alignment\r
73 );\r
28a00297 74\r
28a00297 75\r
28a00297 76\r
162ed594 77/**\r
78 Internal function. Frees pool pages allocated via AllocatePoolPages ()\r
28a00297 79\r
022c6d45 80 @param Memory The base address to free\r
162ed594 81 @param NumberOfPages The number of pages to free\r
28a00297 82\r
162ed594 83**/\r
28a00297 84VOID\r
85CoreFreePoolPages (\r
86 IN EFI_PHYSICAL_ADDRESS Memory,\r
87 IN UINTN NumberOfPages\r
23c98c94 88 );\r
28a00297 89\r
28a00297 90\r
28a00297 91\r
162ed594 92/**\r
93 Internal function to allocate pool of a particular type.\r
94 Caller must have the memory lock held\r
28a00297 95\r
022c6d45 96 @param PoolType Type of pool to allocate\r
97 @param Size The amount of pool to allocate\r
28a00297 98\r
162ed594 99 @return The allocate pool, or NULL\r
28a00297 100\r
162ed594 101**/\r
28a00297 102VOID *\r
103CoreAllocatePoolI (\r
104 IN EFI_MEMORY_TYPE PoolType,\r
105 IN UINTN Size\r
23c98c94 106 );\r
28a00297 107\r
28a00297 108\r
28a00297 109\r
162ed594 110/**\r
111 Internal function to free a pool entry.\r
28a00297 112 Caller must have the memory lock held\r
113\r
022c6d45 114 @param Buffer The allocated pool entry to free\r
925f0d1a 115 @param PoolType Pointer to pool type\r
28a00297 116\r
022c6d45 117 @retval EFI_INVALID_PARAMETER Buffer not valid\r
162ed594 118 @retval EFI_SUCCESS Buffer successfully freed.\r
28a00297 119\r
162ed594 120**/\r
28a00297 121EFI_STATUS\r
122CoreFreePoolI (\r
925f0d1a
SZ
123 IN VOID *Buffer,\r
124 OUT EFI_MEMORY_TYPE *PoolType OPTIONAL\r
23c98c94 125 );\r
28a00297 126\r
28a00297 127\r
28a00297 128\r
162ed594 129/**\r
130 Enter critical section by gaining lock on gMemoryLock.\r
28a00297 131\r
162ed594 132**/\r
28a00297 133VOID\r
134CoreAcquireMemoryLock (\r
135 VOID\r
23c98c94 136 );\r
28a00297 137\r
28a00297 138\r
162ed594 139/**\r
140 Exit critical section by releasing lock on gMemoryLock.\r
28a00297 141\r
162ed594 142**/\r
28a00297 143VOID\r
144CoreReleaseMemoryLock (\r
145 VOID\r
23c98c94 146 );\r
28a00297 147\r
148\r
149//\r
150// Internal Global data\r
151//\r
152\r
022c6d45 153extern EFI_LOCK gMemoryLock;\r
28a00297 154extern LIST_ENTRY gMemoryMap;\r
28a00297 155extern LIST_ENTRY mGcdMemorySpaceMap;\r
156#endif\r