TianoCore EDK2 master
Loading...
Searching...
No Matches
MemMap.c
Go to the documentation of this file.
1
11//
12// Need full names for Standard-Format Output
13//
14STATIC CONST CHAR16 NameEfiReservedMemoryType[] = L"Reserved";
15STATIC CONST CHAR16 NameEfiLoaderCode[] = L"LoaderCode";
16STATIC CONST CHAR16 NameEfiLoaderData[] = L"LoaderData";
17STATIC CONST CHAR16 NameEfiBootServicesCode[] = L"BootServiceCode";
18STATIC CONST CHAR16 NameEfiBootServicesData[] = L"BootServiceData";
19STATIC CONST CHAR16 NameEfiRuntimeServicesCode[] = L"RuntimeCode";
20STATIC CONST CHAR16 NameEfiRuntimeServicesData[] = L"RuntimeData";
21STATIC CONST CHAR16 NameEfiConventionalMemory[] = L"Available";
22STATIC CONST CHAR16 NameEfiPersistentMemory[] = L"Persistent";
23STATIC CONST CHAR16 NameEfiUnusableMemory[] = L"UnusableMemory";
24STATIC CONST CHAR16 NameEfiACPIReclaimMemory[] = L"ACPIReclaimMemory";
25STATIC CONST CHAR16 NameEfiACPIMemoryNVS[] = L"ACPIMemoryNVS";
26STATIC CONST CHAR16 NameEfiMemoryMappedIO[] = L"MemoryMappedIO";
27STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpace[] = L"MemoryMappedIOPortSpace";
28STATIC CONST CHAR16 NameEfiPalCode[] = L"PalCode";
29STATIC CONST CHAR16 NameEfiUnacceptedMemoryType[] = L"Unaccepted";
30
31//
32// Need short names for some memory types
33//
34STATIC CONST CHAR16 NameEfiBootServicesCodeShort[] = L"BS_Code";
35STATIC CONST CHAR16 NameEfiBootServicesDataShort[] = L"BS_Data";
36STATIC CONST CHAR16 NameEfiRuntimeServicesCodeShort[] = L"RT_Code";
37STATIC CONST CHAR16 NameEfiRuntimeServicesDataShort[] = L"RT_Data";
38STATIC CONST CHAR16 NameEfiUnusableMemoryShort[] = L"Unusable";
39STATIC CONST CHAR16 NameEfiACPIReclaimMemoryShort[] = L"ACPI_Recl";
40STATIC CONST CHAR16 NameEfiACPIMemoryNVSShort[] = L"ACPI_NVS";
41STATIC CONST CHAR16 NameEfiMemoryMappedIOShort[] = L"MMIO";
42STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpaceShort[] = L"MMIO_Port";
43
45
46typedef struct {
47 UINT32 Type;
48 UINT64 NumberOfPages;
49 LIST_ENTRY Link;
51
59VOID
61 LIST_ENTRY *List,
62 UINT32 Type,
63 UINT64 NumberOfPages
64 )
65{
67 MEMORY_LENGTH_ENTRY *NewEntry;
68 LIST_ENTRY *Link;
69
70 Entry = NULL;
71 for (Link = GetFirstNode (List); !IsNull (List, Link); Link = GetNextNode (List, Link)) {
72 Entry = BASE_CR (Link, MEMORY_LENGTH_ENTRY, Link);
73 if (Entry->Type >= Type) {
74 break;
75 }
76 }
77
78 if ((Entry != NULL) && (Entry->Type == Type)) {
79 //
80 // The Entry is the one we look for.
81 //
82 NewEntry = Entry;
83 } else {
84 //
85 // The search operation breaks due to:
86 // 1. Type of every entry < Type --> Insert to tail
87 // 2. Type of an entry > Type --> Insert to previous of this entry
88 //
89 NewEntry = AllocatePool (sizeof (*NewEntry));
90 if (NewEntry == NULL) {
91 return;
92 }
93
94 NewEntry->Type = Type;
95 NewEntry->NumberOfPages = 0;
96 InsertTailList (Link, &NewEntry->Link);
97 }
98
99 NewEntry->NumberOfPages += NumberOfPages;
100}
101
109EFIAPI
111 IN EFI_HANDLE ImageHandle,
112 IN EFI_SYSTEM_TABLE *SystemTable
113 )
114{
115 EFI_STATUS Status;
116 LIST_ENTRY *Package;
117 CHAR16 *ProblemParam;
118 SHELL_STATUS ShellStatus;
119 UINTN Size;
120 EFI_MEMORY_DESCRIPTOR *Descriptors;
121 UINTN MapKey;
122 UINTN ItemSize;
123 UINT32 Version;
124 EFI_MEMORY_DESCRIPTOR *Walker;
125 UINT64 ReservedPages;
126 UINT64 LoadCodePages;
127 UINT64 LoadDataPages;
128 UINT64 BSCodePages;
129 UINT64 BSDataPages;
130 UINT64 RTDataPages;
131 UINT64 RTCodePages;
132 UINT64 AvailPages;
133 UINT64 TotalPages;
134 UINT64 ReservedPagesSize;
135 UINT64 LoadCodePagesSize;
136 UINT64 LoadDataPagesSize;
137 UINT64 BSCodePagesSize;
138 UINT64 BSDataPagesSize;
139 UINT64 RTDataPagesSize;
140 UINT64 RTCodePagesSize;
141 UINT64 AvailPagesSize;
142 UINT64 TotalPagesSize;
143 UINT64 AcpiReclaimPages;
144 UINT64 AcpiNvsPages;
145 UINT64 MmioSpacePages;
146 UINT64 AcpiReclaimPagesSize;
147 UINT64 AcpiNvsPagesSize;
148 UINT64 MmioSpacePagesSize;
149 UINT64 MmioPortPages;
150 UINT64 MmioPortPagesSize;
151 UINT64 UnusableMemoryPages;
152 UINT64 UnusableMemoryPagesSize;
153 UINT64 PalCodePages;
154 UINT64 PalCodePagesSize;
155 UINT64 UnacceptedPages;
156 UINT64 UnacceptedPagesSize;
157 UINT64 PersistentPages;
158 UINT64 PersistentPagesSize;
159 BOOLEAN Sfo;
160 LIST_ENTRY MemoryList;
161 MEMORY_LENGTH_ENTRY *Entry;
162 LIST_ENTRY *Link;
163
164 AcpiReclaimPages = 0;
165 AcpiNvsPages = 0;
166 MmioSpacePages = 0;
167 TotalPages = 0;
168 ReservedPages = 0;
169 LoadCodePages = 0;
170 LoadDataPages = 0;
171 BSCodePages = 0;
172 BSDataPages = 0;
173 RTDataPages = 0;
174 RTCodePages = 0;
175 AvailPages = 0;
176 MmioPortPages = 0;
177 UnusableMemoryPages = 0;
178 PalCodePages = 0;
179 PersistentPages = 0;
180 Size = 0;
181 UnacceptedPages = 0;
182 Descriptors = NULL;
183 ShellStatus = SHELL_SUCCESS;
184 Status = EFI_SUCCESS;
185 InitializeListHead (&MemoryList);
186
187 //
188 // initialize the shell lib (we must be in non-auto-init...)
189 //
190 Status = ShellInitialize ();
191 ASSERT_EFI_ERROR (Status);
192
193 Status = CommandInit ();
194 ASSERT_EFI_ERROR (Status);
195
196 //
197 // parse the command line
198 //
199 Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE);
200 if (EFI_ERROR (Status)) {
201 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
202 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"memmap", ProblemParam);
203 FreePool (ProblemParam);
204 ShellStatus = SHELL_INVALID_PARAMETER;
205 } else {
206 ASSERT (FALSE);
207 }
208 } else {
209 if (ShellCommandLineGetCount (Package) > 1) {
210 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"memmap");
211 ShellStatus = SHELL_INVALID_PARAMETER;
212 } else {
213 Status = gBS->GetMemoryMap (&Size, Descriptors, &MapKey, &ItemSize, &Version);
214 if (Status == EFI_BUFFER_TOO_SMALL) {
215 Size += SIZE_1KB;
216 Descriptors = AllocateZeroPool (Size);
217 if (Descriptors == NULL) {
218 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"memmap");
221 }
222
223 Status = gBS->GetMemoryMap (&Size, Descriptors, &MapKey, &ItemSize, &Version);
224 }
225
226 if (EFI_ERROR (Status)) {
227 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_GET_FAILED), gShellDebug1HiiHandle, L"memmap");
228 ShellStatus = SHELL_ACCESS_DENIED;
229 } else {
230 ASSERT (Version == EFI_MEMORY_DESCRIPTOR_VERSION);
231
232 Sfo = ShellCommandLineGetFlag (Package, L"-sfo");
233 if (!Sfo) {
234 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_HEAD), gShellDebug1HiiHandle);
235 } else {
236 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellDebug1HiiHandle, L"memmap");
237 }
238
239 for ( Walker = Descriptors
240 ; (Walker < (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Descriptors + Size)) && (Walker != NULL)
241 ; Walker = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Walker + ItemSize)
242 )
243 {
244 switch (Walker->Type) {
246 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiReservedMemoryType, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
247 ReservedPages += Walker->NumberOfPages;
248 break;
249 case EfiLoaderCode:
250 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
251 LoadCodePages += Walker->NumberOfPages;
252 TotalPages += Walker->NumberOfPages;
253 break;
254 case EfiLoaderData:
255 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderData, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
256 LoadDataPages += Walker->NumberOfPages;
257 TotalPages += Walker->NumberOfPages;
258 break;
260 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiBootServicesCodeShort : NameEfiBootServicesCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
261 BSCodePages += Walker->NumberOfPages;
262 TotalPages += Walker->NumberOfPages;
263 break;
265 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiBootServicesDataShort : NameEfiBootServicesData, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
266 BSDataPages += Walker->NumberOfPages;
267 TotalPages += Walker->NumberOfPages;
268 break;
270 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiRuntimeServicesCodeShort : NameEfiRuntimeServicesCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
271 RTCodePages += Walker->NumberOfPages;
272 TotalPages += Walker->NumberOfPages;
273 break;
275 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiRuntimeServicesDataShort : NameEfiRuntimeServicesData, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
276 RTDataPages += Walker->NumberOfPages;
277 TotalPages += Walker->NumberOfPages;
278 break;
280 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiConventionalMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
281 AvailPages += Walker->NumberOfPages;
282 TotalPages += Walker->NumberOfPages;
283 break;
285 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiPersistentMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
286 PersistentPages += Walker->NumberOfPages;
287 TotalPages += Walker->NumberOfPages;
288 break;
290 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiUnusableMemoryShort : NameEfiUnusableMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
291 UnusableMemoryPages += Walker->NumberOfPages;
292 break;
294 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiACPIReclaimMemoryShort : NameEfiACPIReclaimMemory, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
295 TotalPages += Walker->NumberOfPages;
296 AcpiReclaimPages += Walker->NumberOfPages;
297 break;
298 case EfiACPIMemoryNVS:
299 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiACPIMemoryNVSShort : NameEfiACPIMemoryNVS, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
300 TotalPages += Walker->NumberOfPages;
301 AcpiNvsPages += Walker->NumberOfPages;
302 break;
304 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiMemoryMappedIOShort : NameEfiMemoryMappedIO, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
305 MmioSpacePages += Walker->NumberOfPages;
306 break;
308 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, !Sfo ? NameEfiMemoryMappedIOPortSpaceShort : NameEfiMemoryMappedIOPortSpace, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
309 MmioPortPages += Walker->NumberOfPages;
310 break;
311 case EfiPalCode:
312 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiPalCode, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
313 TotalPages += Walker->NumberOfPages;
314 PalCodePages += Walker->NumberOfPages;
315 break;
317 ShellPrintHiiEx (-1, -1, NULL, (EFI_STRING_ID)(!Sfo ? STRING_TOKEN (STR_MEMMAP_LIST_ITEM) : STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiUnacceptedMemoryType, Walker->PhysicalStart, Walker->PhysicalStart+MultU64x64 (SIZE_4KB, Walker->NumberOfPages)-1, Walker->NumberOfPages, Walker->Attribute);
318 TotalPages += Walker->NumberOfPages;
319 UnacceptedPages += Walker->NumberOfPages;
320 break;
321 default:
322 //
323 // Shell Spec defines the SFO format.
324 // Do not print the OEM/OS memory usage in the SFO format, to avoid conflict with Shell Spec.
325 //
326 if (!Sfo) {
327 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_ITEM_OTHER), gShellDebug1HiiHandle, Walker->Type, Walker->PhysicalStart, Walker->PhysicalStart + MultU64x64 (SIZE_4KB, Walker->NumberOfPages) - 1, Walker->NumberOfPages, Walker->Attribute);
328 }
329
330 TotalPages += Walker->NumberOfPages;
331 AddMemoryLength (&MemoryList, Walker->Type, Walker->NumberOfPages);
332 break;
333 }
334 }
335
336 //
337 // print the summary
338 //
339 ReservedPagesSize = MultU64x64 (SIZE_4KB, ReservedPages);
340 LoadCodePagesSize = MultU64x64 (SIZE_4KB, LoadCodePages);
341 LoadDataPagesSize = MultU64x64 (SIZE_4KB, LoadDataPages);
342 BSCodePagesSize = MultU64x64 (SIZE_4KB, BSCodePages);
343 BSDataPagesSize = MultU64x64 (SIZE_4KB, BSDataPages);
344 RTDataPagesSize = MultU64x64 (SIZE_4KB, RTDataPages);
345 RTCodePagesSize = MultU64x64 (SIZE_4KB, RTCodePages);
346 AvailPagesSize = MultU64x64 (SIZE_4KB, AvailPages);
347 TotalPagesSize = MultU64x64 (SIZE_4KB, TotalPages);
348 AcpiReclaimPagesSize = MultU64x64 (SIZE_4KB, AcpiReclaimPages);
349 AcpiNvsPagesSize = MultU64x64 (SIZE_4KB, AcpiNvsPages);
350 MmioSpacePagesSize = MultU64x64 (SIZE_4KB, MmioSpacePages);
351 MmioPortPagesSize = MultU64x64 (SIZE_4KB, MmioPortPages);
352 PalCodePagesSize = MultU64x64 (SIZE_4KB, PalCodePages);
353 UnacceptedPagesSize = MultU64x64 (SIZE_4KB, UnacceptedPages);
354 PersistentPagesSize = MultU64x64 (SIZE_4KB, PersistentPages);
355 UnusableMemoryPagesSize = MultU64x64 (SIZE_4KB, UnusableMemoryPages);
356 if (!Sfo) {
358 -1,
359 -1,
360 NULL,
361 STRING_TOKEN (STR_MEMMAP_LIST_SUMM),
362 gShellDebug1HiiHandle,
363 ReservedPages,
364 ReservedPagesSize,
365 LoadCodePages,
366 LoadCodePagesSize,
367 LoadDataPages,
368 LoadDataPagesSize,
369 BSCodePages,
370 BSCodePagesSize,
371 BSDataPages,
372 BSDataPagesSize,
373 RTCodePages,
374 RTCodePagesSize,
375 RTDataPages,
376 RTDataPagesSize,
377 AcpiReclaimPages,
378 AcpiReclaimPagesSize,
379 AcpiNvsPages,
380 AcpiNvsPagesSize,
381 MmioSpacePages,
382 MmioSpacePagesSize,
383 MmioPortPages,
384 MmioPortPagesSize,
385 PalCodePages,
386 PalCodePagesSize,
387 UnacceptedPages,
388 UnacceptedPagesSize,
389 AvailPages,
390 AvailPagesSize,
391 PersistentPages,
392 PersistentPagesSize
393 );
394
395 //
396 // Print out the total memory usage for OEM/OS types in the order of type.
397 //
398 for (Link = GetFirstNode (&MemoryList); !IsNull (&MemoryList, Link); Link = GetNextNode (&MemoryList, Link)) {
399 Entry = BASE_CR (Link, MEMORY_LENGTH_ENTRY, Link);
401 -1,
402 -1,
403 NULL,
404 STRING_TOKEN (STR_MEMMAP_LIST_SUMM_OTHER),
405 gShellDebug1HiiHandle,
406 Entry->Type,
407 Entry->NumberOfPages,
408 MultU64x64 (SIZE_4KB, Entry->NumberOfPages)
409 );
410 }
411
413 -1,
414 -1,
415 NULL,
416 STRING_TOKEN (STR_MEMMAP_LIST_SUMM2),
417 gShellDebug1HiiHandle,
418 DivU64x32 (MultU64x64 (SIZE_4KB, TotalPages), SIZE_1MB),
419 TotalPagesSize
420 );
421 } else {
423 -1,
424 -1,
425 NULL,
426 STRING_TOKEN (STR_MEMMAP_LIST_SUMM_SFO),
427 gShellDebug1HiiHandle,
428 TotalPagesSize,
429 ReservedPagesSize,
430 BSCodePagesSize,
431 BSDataPagesSize,
432 RTCodePagesSize,
433 RTDataPagesSize,
434 LoadCodePagesSize,
435 LoadDataPagesSize,
436 AvailPagesSize,
437 MmioSpacePagesSize,
438 MmioPortPagesSize,
439 UnusableMemoryPagesSize,
440 AcpiReclaimPagesSize,
441 AcpiNvsPagesSize,
442 PalCodePagesSize,
443 UnacceptedPagesSize,
444 PersistentPagesSize
445 );
446 }
447 }
448 }
449
451 }
452
453 if (Descriptors != NULL) {
454 FreePool (Descriptors);
455 }
456
457 //
458 // Free the memory list.
459 //
460 for (Link = GetFirstNode (&MemoryList); !IsNull (&MemoryList, Link); ) {
461 Link = RemoveEntryList (Link);
462 }
463
464 return (ShellStatus);
465}
UINT64 UINTN
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:443
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:333
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
Definition: DivU64x32.c:29
UINT64 EFIAPI MultU64x64(IN UINT64 Multiplicand, IN UINT64 Multiplier)
Definition: MultU64x64.c:27
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
Definition: LinkedList.c:298
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define BASE_CR(Record, TYPE, Field)
Definition: Base.h:891
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
SHELL_STATUS
Definition: Shell.h:21
@ SHELL_OUT_OF_RESOURCES
Definition: Shell.h:73
@ SHELL_ACCESS_DENIED
Definition: Shell.h:106
@ SHELL_SUCCESS
Definition: Shell.h:25
@ SHELL_INVALID_PARAMETER
Definition: Shell.h:35
SHELL_STATUS EFIAPI ShellCommandRunMemMap(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: MemMap.c:110
VOID AddMemoryLength(LIST_ENTRY *List, UINT32 Type, UINT64 NumberOfPages)
Definition: MemMap.c:60
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_STATUS EFIAPI CommandInit(VOID)
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
Definition: ShellLib.h:755
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
SHELL_PARAM_ITEM SfoParamList[]
Helper structure for -sfo only (besides -? and -b)
Definition: UefiShellLib.c:22
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellInitialize(VOID)
Definition: UefiShellLib.c:532
UINTN EFIAPI ShellCommandLineGetCount(IN CONST LIST_ENTRY *CheckPackage)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
#define STRING_TOKEN(t)
@ EfiUnusableMemory
@ EfiBootServicesData
@ EfiPersistentMemory
@ EfiReservedMemoryType
@ EfiBootServicesCode
@ EfiConventionalMemory
@ EfiLoaderData
@ EfiACPIMemoryNVS
@ EfiMemoryMappedIOPortSpace
@ EfiACPIReclaimMemory
@ EfiLoaderCode
@ EfiMemoryMappedIO
@ EfiUnacceptedMemoryType
@ EfiPalCode
@ EfiRuntimeServicesCode
@ EfiRuntimeServicesData
#define EFI_MEMORY_DESCRIPTOR_VERSION
Definition: UefiSpec.h:138
EFI_PHYSICAL_ADDRESS PhysicalStart
Definition: UefiSpec.h:155