1 /** @file
2 Main file for Mode shell Debug1 function.
3
4 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
5 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
6 Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which acModeanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 //
18 // Need full names for Standard-Format Output
19 //
20 STATIC CONST CHAR16 NameEfiReservedMemoryType[] = L"Reserved";
21 STATIC CONST CHAR16 NameEfiLoaderCode[] = L"LoaderCode";
22 STATIC CONST CHAR16 NameEfiLoaderData[] = L"LoaderData";
23 STATIC CONST CHAR16 NameEfiBootServicesCode[] = L"BootServiceCode";
24 STATIC CONST CHAR16 NameEfiBootServicesData[] = L"BootServiceData";
25 STATIC CONST CHAR16 NameEfiRuntimeServicesCode[] = L"RuntimeCode";
26 STATIC CONST CHAR16 NameEfiRuntimeServicesData[] = L"RuntimeData";
27 STATIC CONST CHAR16 NameEfiConventionalMemory[] = L"Available";
28 STATIC CONST CHAR16 NameEfiPersistentMemory[] = L"Persistent";
29 STATIC CONST CHAR16 NameEfiUnusableMemory[] = L"UnusableMemory";
30 STATIC CONST CHAR16 NameEfiACPIReclaimMemory[] = L"ACPIReclaimMemory";
31 STATIC CONST CHAR16 NameEfiACPIMemoryNVS[] = L"ACPIMemoryNVS";
32 STATIC CONST CHAR16 NameEfiMemoryMappedIO[] = L"MemoryMappedIO";
33 STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpace[] = L"MemoryMappedIOPortSpace";
34 STATIC CONST CHAR16 NameEfiPalCode[] = L"PalCode";
35
36 //
37 // Need short names for some memory types
38 //
39 STATIC CONST CHAR16 NameEfiBootServicesCodeShort[] = L"BS_Code";
40 STATIC CONST CHAR16 NameEfiBootServicesDataShort[] = L"BS_Data";
41 STATIC CONST CHAR16 NameEfiRuntimeServicesCodeShort[] = L"RT_Code";
42 STATIC CONST CHAR16 NameEfiRuntimeServicesDataShort[] = L"RT_Data";
43 STATIC CONST CHAR16 NameEfiUnusableMemoryShort[] = L"Unusable";
44 STATIC CONST CHAR16 NameEfiACPIReclaimMemoryShort[] = L"ACPI_Recl";
45 STATIC CONST CHAR16 NameEfiACPIMemoryNVSShort[] = L"ACPI_NVS";
46 STATIC CONST CHAR16 NameEfiMemoryMappedIOShort[] = L"MMIO";
47 STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpaceShort[] = L"MMIO_Port";
48
49 #include "UefiShellDebug1CommandsLib.h"
50
51 /**
52 Function for 'memmap' command.
53
54 @param[in] ImageHandle Handle to the Image (NULL if Internal).
55 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
56 **/
57 SHELL_STATUS
58 EFIAPI
ShellCommandRunMemMap(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)59 ShellCommandRunMemMap (
60 IN EFI_HANDLE ImageHandle,
61 IN EFI_SYSTEM_TABLE *SystemTable
62 )
63 {
64 EFI_STATUS Status;
65 LIST_ENTRY *Package;
66 CHAR16 *ProblemParam;
67 SHELL_STATUS ShellStatus;
68 UINTN Size;
69 EFI_MEMORY_DESCRIPTOR *Buffer;
70 UINTN MapKey;
71 UINTN ItemSize;
72 UINT32 Version;
73 UINT8 *Walker;
74 UINT64 ReservedPages;
75 UINT64 LoadCodePages;
76 UINT64 LoadDataPages;
77 UINT64 BSCodePages;
78 UINT64 BSDataPages;
79 UINT64 RTDataPages;
80 UINT64 RTCodePages;
81 UINT64 AvailPages;
82 UINT64 TotalPages;
83 UINT64 ReservedPagesSize;
84 UINT64 LoadCodePagesSize;
85 UINT64 LoadDataPagesSize;
86 UINT64 BSCodePagesSize;
87 UINT64 BSDataPagesSize;
88 UINT64 RTDataPagesSize;
89 UINT64 RTCodePagesSize;
90 UINT64 AvailPagesSize;
91 UINT64 TotalPagesSize;
92 UINT64 AcpiReclaimPages;
93 UINT64 AcpiNvsPages;
94 UINT64 MmioSpacePages;
95 UINT64 AcpiReclaimPagesSize;
96 UINT64 AcpiNvsPagesSize;
97 UINT64 MmioSpacePagesSize;
98 UINT64 MmioPortPages;
99 UINT64 MmioPortPagesSize;
100 UINT64 UnusableMemoryPages;
101 UINT64 UnusableMemoryPagesSize;
102 UINT64 PalCodePages;
103 UINT64 PalCodePagesSize;
104 UINT64 PersistentPages;
105 UINT64 PersistentPagesSize;
106 BOOLEAN Sfo;
107
108 AcpiReclaimPages = 0;
109 AcpiNvsPages = 0;
110 MmioSpacePages = 0;
111 TotalPages = 0;
112 ReservedPages = 0;
113 LoadCodePages = 0;
114 LoadDataPages = 0;
115 BSCodePages = 0;
116 BSDataPages = 0;
117 RTDataPages = 0;
118 RTCodePages = 0;
119 AvailPages = 0;
120 MmioPortPages = 0;
121 UnusableMemoryPages = 0;
122 PalCodePages = 0;
123 PersistentPages = 0;
124 Size = 0;
125 Buffer = NULL;
126 ShellStatus = SHELL_SUCCESS;
127 Status = EFI_SUCCESS;
128
129 //
130 // initialize the shell lib (we must be in non-auto-init...)
131 //
132 Status = ShellInitialize();
133 ASSERT_EFI_ERROR(Status);
134
135 Status = CommandInit();
136 ASSERT_EFI_ERROR(Status);
137
138 //
139 // parse the command line
140 //
141 Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE);
142 if (EFI_ERROR(Status)) {
143 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
144 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"memmap", ProblemParam);
145 FreePool(ProblemParam);
146 ShellStatus = SHELL_INVALID_PARAMETER;
147 } else {
148 ASSERT(FALSE);
149 }
150 } else {
151 if (ShellCommandLineGetCount(Package) > 1) {
152 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"memmap");
153 ShellStatus = SHELL_INVALID_PARAMETER;
154 } else {
155 Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version);
156 if (Status == EFI_BUFFER_TOO_SMALL){
157 Size += SIZE_1KB;
158 Buffer = AllocateZeroPool(Size);
159 Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version);
160 }
161 if (EFI_ERROR(Status)) {
162 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_GET_FAILED), gShellDebug1HiiHandle, L"memmap");
163 ShellStatus = SHELL_ACCESS_DENIED;
164 } else {
165 ASSERT(Version == EFI_MEMORY_DESCRIPTOR_VERSION);
166
167 Sfo = ShellCommandLineGetFlag(Package, L"-sfo");
168 if (!Sfo) {
169 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_HEAD), gShellDebug1HiiHandle);
170 } else {
171 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellDebug1HiiHandle, L"memmap");
172 }
173
174 for (Walker = (UINT8*)Buffer; Walker < (((UINT8*)Buffer)+Size) && Walker != NULL; Walker += ItemSize){
175 switch (((EFI_MEMORY_DESCRIPTOR*)Walker)->Type) {
176 case EfiReservedMemoryType:
177 ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiReservedMemoryType, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
178 ReservedPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
179 break;
180 case EfiLoaderCode:
181 ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
182 LoadCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
183 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
184 break;
185 case EfiLoaderData:
186 ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
187 LoadDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
188 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
189 break;
190 case EfiBootServicesCode:
191 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, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
192 BSCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
193 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
194 break;
195 case EfiBootServicesData:
196 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, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
197 BSDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
198 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
199 break;
200 case EfiRuntimeServicesCode:
201 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, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
202 RTCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
203 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
204 break;
205 case EfiRuntimeServicesData:
206 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, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
207 RTDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
208 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
209 break;
210 case EfiConventionalMemory:
211 ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiConventionalMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
212 AvailPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
213 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
214 break;
215 case EfiPersistentMemory:
216 ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiPersistentMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
217 PersistentPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
218 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
219 break;
220 case EfiUnusableMemory:
221 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, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
222 UnusableMemoryPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
223 break;
224 case EfiACPIReclaimMemory:
225 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, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
226 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
227 AcpiReclaimPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
228 break;
229 case EfiACPIMemoryNVS:
230 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, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
231 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
232 AcpiNvsPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
233 break;
234 case EfiMemoryMappedIO:
235 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, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
236 MmioSpacePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
237 break;
238 case EfiMemoryMappedIOPortSpace:
239 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, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
240 MmioPortPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
241 break;
242 case EfiPalCode:
243 ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiPalCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute);
244 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
245 PalCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
246 break;
247 default:
248 ASSERT(FALSE);
249 }
250 }
251 //
252 // print the summary
253 //
254 ReservedPagesSize = MultU64x64(SIZE_4KB,ReservedPages);
255 LoadCodePagesSize = MultU64x64(SIZE_4KB,LoadCodePages);
256 LoadDataPagesSize = MultU64x64(SIZE_4KB,LoadDataPages);
257 BSCodePagesSize = MultU64x64(SIZE_4KB,BSCodePages);
258 BSDataPagesSize = MultU64x64(SIZE_4KB,BSDataPages);
259 RTDataPagesSize = MultU64x64(SIZE_4KB,RTDataPages);
260 RTCodePagesSize = MultU64x64(SIZE_4KB,RTCodePages);
261 AvailPagesSize = MultU64x64(SIZE_4KB,AvailPages);
262 TotalPagesSize = MultU64x64(SIZE_4KB,TotalPages);
263 AcpiReclaimPagesSize = MultU64x64(SIZE_4KB,AcpiReclaimPages);
264 AcpiNvsPagesSize = MultU64x64(SIZE_4KB,AcpiNvsPages);
265 MmioSpacePagesSize = MultU64x64(SIZE_4KB,MmioSpacePages);
266 MmioPortPagesSize = MultU64x64(SIZE_4KB,MmioPortPages);
267 PalCodePagesSize = MultU64x64(SIZE_4KB,PalCodePages);
268 PersistentPagesSize = MultU64x64(SIZE_4KB,PersistentPages);
269 UnusableMemoryPagesSize = MultU64x64(SIZE_4KB,UnusableMemoryPages);
270 if (!Sfo) {
271 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM), gShellDebug1HiiHandle,
272 ReservedPages, ReservedPagesSize,
273 LoadCodePages, LoadCodePagesSize,
274 LoadDataPages, LoadDataPagesSize,
275 BSCodePages, BSCodePagesSize,
276 BSDataPages, BSDataPagesSize,
277 RTCodePages, RTCodePagesSize,
278 RTDataPages, RTDataPagesSize,
279 AcpiReclaimPages, AcpiReclaimPagesSize,
280 AcpiNvsPages, AcpiNvsPagesSize,
281 MmioSpacePages, MmioSpacePagesSize,
282 MmioPortPages, MmioPortPagesSize,
283 PalCodePages, PalCodePagesSize,
284 AvailPages, AvailPagesSize,
285 PersistentPages, PersistentPagesSize,
286 DivU64x32(MultU64x64(SIZE_4KB,TotalPages), SIZE_1MB), TotalPagesSize
287 );
288 } else {
289 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM_SFO), gShellDebug1HiiHandle,
290 TotalPagesSize,
291 ReservedPagesSize,
292 BSCodePagesSize,
293 BSDataPagesSize,
294 RTCodePagesSize,
295 RTDataPagesSize,
296 LoadCodePagesSize,
297 LoadDataPagesSize,
298 AvailPagesSize,
299 MmioSpacePagesSize,
300 MmioPortPagesSize,
301 UnusableMemoryPagesSize,
302 AcpiReclaimPagesSize,
303 AcpiNvsPagesSize,
304 PalCodePagesSize,
305 PersistentPagesSize
306 );
307 }
308 }
309 }
310 ShellCommandLineFreeVarList (Package);
311 }
312
313 if (Buffer != NULL) {
314 FreePool(Buffer);
315 }
316
317 return (ShellStatus);
318 }
319
320