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