]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/imem.h
Add comments and DoxyGen format for these files.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / imem.h
CommitLineData
504214c4
LG
1/** @file \r
2 \r
3 Data structure and functions to allocate and free memory space.\r
28a00297 4\r
504214c4 5Copyright (c) 2006 - 2008, Intel Corporation \r
28a00297 6All rights reserved. This program and the accompanying materials \r
7are licensed and made available under the terms and conditions of the BSD License \r
8which accompanies this distribution. The full text of the license may be found at \r
9http://opensource.org/licenses/bsd-license.php \r
10 \r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
13\r
28a00297 14--*/\r
15\r
16#ifndef _IMEM_H_\r
17#define _IMEM_H_\r
18\r
19#if defined (MDE_CPU_IPF)\r
20//\r
21// For Itanium machines make the default allocations 8K aligned\r
22//\r
23#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2)\r
24#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)\r
25\r
26#else\r
27//\r
28// For genric EFI machines make the default allocations 4K aligned\r
29//\r
30#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)\r
31#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)\r
32\r
33#endif\r
34\r
35\r
36//\r
37// MEMORY_MAP_ENTRY\r
38//\r
39\r
40#define MEMORY_MAP_SIGNATURE EFI_SIGNATURE_32('m','m','a','p')\r
41typedef struct {\r
42 UINTN Signature;\r
43 LIST_ENTRY Link;\r
44 BOOLEAN FromPages;\r
45\r
46 EFI_MEMORY_TYPE Type;\r
47 UINT64 Start;\r
48 UINT64 End;\r
49\r
50 UINT64 VirtualStart;\r
51 UINT64 Attribute;\r
52} MEMORY_MAP;\r
53\r
54//\r
55// Internal prototypes\r
56//\r
57\r
58VOID *\r
59CoreAllocatePoolPages (\r
60 IN EFI_MEMORY_TYPE PoolType,\r
61 IN UINTN NumberOfPages,\r
62 IN UINTN Alignment\r
63 )\r
64/*++\r
65\r
66Routine Description:\r
67\r
68 Internal function. Used by the pool functions to allocate pages\r
69 to back pool allocation requests.\r
70\r
71Arguments:\r
72\r
73 PoolType - The type of memory for the new pool pages\r
74\r
75 NumberOfPages - No of pages to allocate\r
76 \r
77 Alignment - Bits to align.\r
78\r
79Returns:\r
80\r
81 The allocated memory, or NULL\r
82\r
83--*/\r
84;\r
85\r
86\r
87VOID\r
88CoreFreePoolPages (\r
89 IN EFI_PHYSICAL_ADDRESS Memory,\r
90 IN UINTN NumberOfPages\r
91 )\r
92/*++\r
93\r
94Routine Description:\r
95\r
96 Internal function. Frees pool pages allocated via AllocatePoolPages ()\r
97\r
98Arguments:\r
99\r
100 Memory - The base address to free\r
101\r
102 NumberOfPages - The number of pages to free\r
103\r
104Returns:\r
105\r
106 None\r
107\r
108--*/\r
109;\r
110\r
111\r
112VOID *\r
113CoreAllocatePoolI (\r
114 IN EFI_MEMORY_TYPE PoolType,\r
115 IN UINTN Size\r
116 )\r
117/*++\r
118\r
119Routine Description:\r
120\r
121 Internal function to allocate pool of a particular type.\r
122\r
123 Caller must have the memory lock held\r
124\r
125\r
126Arguments:\r
127\r
128 PoolType - Type of pool to allocate\r
129\r
130 Size - The amount of pool to allocate\r
131\r
132Returns:\r
133\r
134 The allocate pool, or NULL\r
135\r
136--*/\r
137;\r
138\r
139\r
140EFI_STATUS\r
141CoreFreePoolI (\r
142 IN VOID *Buffer\r
143 )\r
144/*++\r
145\r
146Routine Description:\r
147\r
148 Internal function to free a pool entry.\r
149\r
150 Caller must have the memory lock held\r
151\r
152\r
153Arguments:\r
154\r
155 Buffer - The allocated pool entry to free\r
156\r
157Returns:\r
158\r
159 EFI_INVALID_PARAMETER - Buffer not valid\r
160 \r
161 EFI_SUCCESS - Buffer successfully freed.\r
162\r
163--*/\r
164;\r
165\r
166\r
167VOID\r
168CoreAcquireMemoryLock (\r
169 VOID\r
170 )\r
171/*++\r
172\r
173Routine Description:\r
174\r
175 Enter critical section by gaining lock on gMemoryLock\r
176\r
177Arguments:\r
178\r
179 None\r
180\r
181Returns:\r
182\r
183 None\r
184\r
185--*/\r
186;\r
187\r
188VOID\r
189CoreReleaseMemoryLock (\r
190 VOID\r
191 )\r
192/*++\r
193\r
194Routine Description:\r
195\r
196 Exit critical section by releasing lock on gMemoryLock\r
197\r
198Arguments:\r
199\r
200 None\r
201\r
202Returns:\r
203\r
204 None\r
205\r
206--*/\r
207;\r
208\r
209\r
210//\r
211// Internal Global data\r
212//\r
213\r
214extern EFI_LOCK gMemoryLock; \r
215extern LIST_ENTRY gMemoryMap;\r
216extern MEMORY_MAP *gMemoryLastConvert;\r
217extern LIST_ENTRY mGcdMemorySpaceMap;\r
218#endif\r