]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Dxe/Mem/Imem.h
MdeModulePkg DxeCore: Fix issue to print GUID value %g without pointer
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Mem / Imem.h
... / ...
CommitLineData
1/** @file\r
2 Data structure and functions to allocate and free memory space.\r
3\r
4Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
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
9\r
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
12\r
13**/\r
14\r
15#ifndef _IMEM_H_\r
16#define _IMEM_H_\r
17\r
18//\r
19// +---------------------------------------------------+\r
20// | 0..(EfiMaxMemoryType - 1) - Normal memory type |\r
21// +---------------------------------------------------+\r
22// | EfiMaxMemoryType..0x6FFFFFFF - Invalid |\r
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
33\r
34//\r
35// MEMORY_MAP_ENTRY\r
36//\r
37\r
38#define MEMORY_MAP_SIGNATURE SIGNATURE_32('m','m','a','p')\r
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
56\r
57/**\r
58 Internal function. Used by the pool functions to allocate pages\r
59 to back pool allocation requests.\r
60\r
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
64\r
65 @return The allocated memory, or NULL\r
66\r
67**/\r
68VOID *\r
69CoreAllocatePoolPages (\r
70 IN EFI_MEMORY_TYPE PoolType,\r
71 IN UINTN NumberOfPages,\r
72 IN UINTN Alignment\r
73 );\r
74\r
75\r
76\r
77/**\r
78 Internal function. Frees pool pages allocated via AllocatePoolPages ()\r
79\r
80 @param Memory The base address to free\r
81 @param NumberOfPages The number of pages to free\r
82\r
83**/\r
84VOID\r
85CoreFreePoolPages (\r
86 IN EFI_PHYSICAL_ADDRESS Memory,\r
87 IN UINTN NumberOfPages\r
88 );\r
89\r
90\r
91\r
92/**\r
93 Internal function to allocate pool of a particular type.\r
94 Caller must have the memory lock held\r
95\r
96 @param PoolType Type of pool to allocate\r
97 @param Size The amount of pool to allocate\r
98\r
99 @return The allocate pool, or NULL\r
100\r
101**/\r
102VOID *\r
103CoreAllocatePoolI (\r
104 IN EFI_MEMORY_TYPE PoolType,\r
105 IN UINTN Size\r
106 );\r
107\r
108\r
109\r
110/**\r
111 Internal function to free a pool entry.\r
112 Caller must have the memory lock held\r
113\r
114 @param Buffer The allocated pool entry to free\r
115 @param PoolType Pointer to pool type\r
116\r
117 @retval EFI_INVALID_PARAMETER Buffer not valid\r
118 @retval EFI_SUCCESS Buffer successfully freed.\r
119\r
120**/\r
121EFI_STATUS\r
122CoreFreePoolI (\r
123 IN VOID *Buffer,\r
124 OUT EFI_MEMORY_TYPE *PoolType OPTIONAL\r
125 );\r
126\r
127\r
128\r
129/**\r
130 Enter critical section by gaining lock on gMemoryLock.\r
131\r
132**/\r
133VOID\r
134CoreAcquireMemoryLock (\r
135 VOID\r
136 );\r
137\r
138\r
139/**\r
140 Exit critical section by releasing lock on gMemoryLock.\r
141\r
142**/\r
143VOID\r
144CoreReleaseMemoryLock (\r
145 VOID\r
146 );\r
147\r
148\r
149//\r
150// Internal Global data\r
151//\r
152\r
153extern EFI_LOCK gMemoryLock;\r
154extern LIST_ENTRY gMemoryMap;\r
155extern LIST_ENTRY mGcdMemorySpaceMap;\r
156#endif\r