blob: 598c04a2e7ed235f1abb17e9fae18e1c5a615bec [file] [log] [blame]
jcarsey5d73d922010-11-16 22:36:37 +00001/** @file
2 Main file for Mode shell Debug1 function.
3
Tapan Shahc011b6c2015-02-04 22:25:01 +00004 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
Jaben Carseyc12383d2014-08-05 20:57:08 +00005 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
lgao4d0cec2d2013-05-22 02:19:16 +00006 This program and the accompanying materials
jcarsey5d73d922010-11-16 22:36:37 +00007 are licensed and made available under the terms and conditions of the BSD License
8 which acModeanies 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
Chris Phillips73768082014-08-21 20:26:32 +000016//
17// Need full names for Standard-Format Output
18//
jcarsey3737ac22011-03-25 21:22:20 +000019STATIC CONST CHAR16 NameEfiReservedMemoryType[] = L"Reserved";
20STATIC CONST CHAR16 NameEfiLoaderCode[] = L"LoaderCode";
21STATIC CONST CHAR16 NameEfiLoaderData[] = L"LoaderData";
Chris Phillips73768082014-08-21 20:26:32 +000022STATIC CONST CHAR16 NameEfiBootServicesCode[] = L"BootServiceCode";
23STATIC CONST CHAR16 NameEfiBootServicesData[] = L"BootServiceData";
24STATIC CONST CHAR16 NameEfiRuntimeServicesCode[] = L"RuntimeCode";
25STATIC CONST CHAR16 NameEfiRuntimeServicesData[] = L"RuntimeData";
jcarsey3737ac22011-03-25 21:22:20 +000026STATIC CONST CHAR16 NameEfiConventionalMemory[] = L"Available";
Chris Phillips73768082014-08-21 20:26:32 +000027STATIC CONST CHAR16 NameEfiUnusableMemory[] = L"UnusableMemory";
28STATIC CONST CHAR16 NameEfiACPIReclaimMemory[] = L"ACPIReclaimMemory";
29STATIC CONST CHAR16 NameEfiACPIMemoryNVS[] = L"ACPIMemoryNVS";
30STATIC CONST CHAR16 NameEfiMemoryMappedIO[] = L"MemoryMappedIO";
31STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpace[] = L"MemoryMappedIOPortSpace";
jcarsey3737ac22011-03-25 21:22:20 +000032STATIC CONST CHAR16 NameEfiPalCode[] = L"PalCode";
jcarsey5d73d922010-11-16 22:36:37 +000033
Chris Phillips73768082014-08-21 20:26:32 +000034//
35// Need short names for some memory types
36//
37STATIC CONST CHAR16 NameEfiBootServicesCodeShort[] = L"BS_Code";
38STATIC CONST CHAR16 NameEfiBootServicesDataShort[] = L"BS_Data";
39STATIC CONST CHAR16 NameEfiRuntimeServicesCodeShort[] = L"RT_Code";
40STATIC CONST CHAR16 NameEfiRuntimeServicesDataShort[] = L"RT_Data";
41STATIC CONST CHAR16 NameEfiUnusableMemoryShort[] = L"Unusable";
42STATIC CONST CHAR16 NameEfiACPIReclaimMemoryShort[] = L"ACPI_Recl";
43STATIC CONST CHAR16 NameEfiACPIMemoryNVSShort[] = L"ACPI_NVS";
44STATIC CONST CHAR16 NameEfiMemoryMappedIOShort[] = L"MMIO";
45STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpaceShort[] = L"MMIO_Port";
46
jcarsey5d73d922010-11-16 22:36:37 +000047#include "UefiShellDebug1CommandsLib.h"
48
jcarsey3737ac22011-03-25 21:22:20 +000049/**
50 Function for 'memmap' command.
51
52 @param[in] ImageHandle Handle to the Image (NULL if Internal).
53 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
54**/
jcarsey5d73d922010-11-16 22:36:37 +000055SHELL_STATUS
56EFIAPI
57ShellCommandRunMemMap (
58 IN EFI_HANDLE ImageHandle,
59 IN EFI_SYSTEM_TABLE *SystemTable
60 )
61{
62 EFI_STATUS Status;
63 LIST_ENTRY *Package;
64 CHAR16 *ProblemParam;
65 SHELL_STATUS ShellStatus;
66 UINTN Size;
67 EFI_MEMORY_DESCRIPTOR *Buffer;
68 UINTN MapKey;
69 UINTN ItemSize;
70 UINT32 Version;
71 UINT8 *Walker;
72 UINT64 ReservedPages;
73 UINT64 LoadCodePages;
74 UINT64 LoadDataPages;
75 UINT64 BSCodePages;
76 UINT64 BSDataPages;
77 UINT64 RTDataPages;
78 UINT64 RTCodePages;
79 UINT64 AvailPages;
80 UINT64 TotalPages;
81 UINT64 ReservedPagesSize;
82 UINT64 LoadCodePagesSize;
83 UINT64 LoadDataPagesSize;
84 UINT64 BSCodePagesSize;
85 UINT64 BSDataPagesSize;
86 UINT64 RTDataPagesSize;
87 UINT64 RTCodePagesSize;
88 UINT64 AvailPagesSize;
89 UINT64 TotalPagesSize;
jcarsey3737ac22011-03-25 21:22:20 +000090 UINT64 AcpiReclaimPages;
91 UINT64 AcpiNvsPages;
92 UINT64 MmioSpacePages;
93 UINT64 AcpiReclaimPagesSize;
94 UINT64 AcpiNvsPagesSize;
95 UINT64 MmioSpacePagesSize;
Jaben Carseyc12383d2014-08-05 20:57:08 +000096 UINT64 MmioPortPages;
97 UINT64 MmioPortPagesSize;
98 UINT64 UnusableMemoryPages;
99 UINT64 UnusableMemoryPagesSize;
100 UINT64 PalCodePages;
101 UINT64 PalCodePagesSize;
jcarsey5d73d922010-11-16 22:36:37 +0000102 BOOLEAN Sfo;
103
jcarsey3737ac22011-03-25 21:22:20 +0000104 AcpiReclaimPages = 0;
105 AcpiNvsPages = 0;
106 MmioSpacePages = 0;
jcarsey5d73d922010-11-16 22:36:37 +0000107 TotalPages = 0;
108 ReservedPages = 0;
109 LoadCodePages = 0;
110 LoadDataPages = 0;
111 BSCodePages = 0;
112 BSDataPages = 0;
113 RTDataPages = 0;
114 RTCodePages = 0;
115 AvailPages = 0;
Jaben Carseyc12383d2014-08-05 20:57:08 +0000116 MmioPortPages = 0;
117 UnusableMemoryPages = 0;
118 PalCodePages = 0;
jcarsey5d73d922010-11-16 22:36:37 +0000119 Size = 0;
120 Buffer = NULL;
121 ShellStatus = SHELL_SUCCESS;
122 Status = EFI_SUCCESS;
123
124 //
125 // initialize the shell lib (we must be in non-auto-init...)
126 //
127 Status = ShellInitialize();
128 ASSERT_EFI_ERROR(Status);
129
130 Status = CommandInit();
131 ASSERT_EFI_ERROR(Status);
132
133 //
134 // parse the command line
135 //
136 Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE);
137 if (EFI_ERROR(Status)) {
138 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
Tapan Shah4092a8f2015-02-03 21:22:53 +0000139 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"memmap", ProblemParam);
jcarsey5d73d922010-11-16 22:36:37 +0000140 FreePool(ProblemParam);
141 ShellStatus = SHELL_INVALID_PARAMETER;
142 } else {
143 ASSERT(FALSE);
144 }
145 } else {
146 if (ShellCommandLineGetCount(Package) > 1) {
Tapan Shah4092a8f2015-02-03 21:22:53 +0000147 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"memmap");
jcarsey5d73d922010-11-16 22:36:37 +0000148 ShellStatus = SHELL_INVALID_PARAMETER;
149 } else {
150 Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version);
151 if (Status == EFI_BUFFER_TOO_SMALL){
152 Size += SIZE_1KB;
jcarsey3737ac22011-03-25 21:22:20 +0000153 Buffer = AllocateZeroPool(Size);
jcarsey5d73d922010-11-16 22:36:37 +0000154 Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version);
155 }
156 if (EFI_ERROR(Status)) {
Tapan Shah4092a8f2015-02-03 21:22:53 +0000157 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_GET_FAILED), gShellDebug1HiiHandle, L"memmap");
jcarsey5d73d922010-11-16 22:36:37 +0000158 ShellStatus = SHELL_ACCESS_DENIED;
159 } else {
160 ASSERT(Version == EFI_MEMORY_DESCRIPTOR_VERSION);
Chris Phillips73768082014-08-21 20:26:32 +0000161
jcarsey5d73d922010-11-16 22:36:37 +0000162 Sfo = ShellCommandLineGetFlag(Package, L"-sfo");
Chris Phillips73768082014-08-21 20:26:32 +0000163 if (!Sfo) {
164 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_HEAD), gShellDebug1HiiHandle);
165 } else {
166 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellDebug1HiiHandle, L"memmap");
167 }
168
jcarsey5d73d922010-11-16 22:36:37 +0000169 for (Walker = (UINT8*)Buffer; Walker < (((UINT8*)Buffer)+Size) && Walker != NULL; Walker += ItemSize){
170 switch (((EFI_MEMORY_DESCRIPTOR*)Walker)->Type) {
jcarsey5d73d922010-11-16 22:36:37 +0000171 case EfiReservedMemoryType:
jcarsey3737ac22011-03-25 21:22:20 +0000172 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);
jcarsey5d73d922010-11-16 22:36:37 +0000173 ReservedPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
jcarsey5d73d922010-11-16 22:36:37 +0000174 break;
175 case EfiLoaderCode:
jcarsey3737ac22011-03-25 21:22:20 +0000176 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);
jcarsey5d73d922010-11-16 22:36:37 +0000177 LoadCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
178 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
179 break;
180 case EfiLoaderData:
jcarsey3737ac22011-03-25 21:22:20 +0000181 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);
jcarsey5d73d922010-11-16 22:36:37 +0000182 LoadDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
183 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
184 break;
185 case EfiBootServicesCode:
Chris Phillips73768082014-08-21 20:26:32 +0000186 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);
jcarsey5d73d922010-11-16 22:36:37 +0000187 BSCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
188 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
189 break;
190 case EfiBootServicesData:
Chris Phillips73768082014-08-21 20:26:32 +0000191 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);
jcarsey5d73d922010-11-16 22:36:37 +0000192 BSDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
193 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
194 break;
195 case EfiRuntimeServicesCode:
Chris Phillips73768082014-08-21 20:26:32 +0000196 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);
jcarsey5d73d922010-11-16 22:36:37 +0000197 RTCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
198 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
199 break;
200 case EfiRuntimeServicesData:
Chris Phillips73768082014-08-21 20:26:32 +0000201 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);
jcarsey5d73d922010-11-16 22:36:37 +0000202 RTDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
203 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
204 break;
205 case EfiConventionalMemory:
jcarsey3737ac22011-03-25 21:22:20 +0000206 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);
jcarsey5d73d922010-11-16 22:36:37 +0000207 AvailPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
208 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
209 break;
210 case EfiUnusableMemory:
Chris Phillips73768082014-08-21 20:26:32 +0000211 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);
Jaben Carseyc12383d2014-08-05 20:57:08 +0000212 UnusableMemoryPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
jcarsey5d73d922010-11-16 22:36:37 +0000213 break;
214 case EfiACPIReclaimMemory:
Chris Phillips73768082014-08-21 20:26:32 +0000215 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);
jcarsey5d73d922010-11-16 22:36:37 +0000216 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
jcarsey3737ac22011-03-25 21:22:20 +0000217 AcpiReclaimPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
jcarsey5d73d922010-11-16 22:36:37 +0000218 break;
219 case EfiACPIMemoryNVS:
Chris Phillips73768082014-08-21 20:26:32 +0000220 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);
jcarsey5d73d922010-11-16 22:36:37 +0000221 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
jcarsey3737ac22011-03-25 21:22:20 +0000222 AcpiNvsPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
jcarsey5d73d922010-11-16 22:36:37 +0000223 break;
224 case EfiMemoryMappedIO:
Chris Phillips73768082014-08-21 20:26:32 +0000225 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);
jcarsey3737ac22011-03-25 21:22:20 +0000226 MmioSpacePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
jcarsey5d73d922010-11-16 22:36:37 +0000227 break;
228 case EfiMemoryMappedIOPortSpace:
Chris Phillips73768082014-08-21 20:26:32 +0000229 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);
Jaben Carseyc12383d2014-08-05 20:57:08 +0000230 MmioPortPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
jcarsey5d73d922010-11-16 22:36:37 +0000231 break;
232 case EfiPalCode:
jcarsey3737ac22011-03-25 21:22:20 +0000233 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);
jcarsey5d73d922010-11-16 22:36:37 +0000234 TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
Jaben Carseyc12383d2014-08-05 20:57:08 +0000235 PalCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
jcarsey5d73d922010-11-16 22:36:37 +0000236 break;
237 default:
238 ASSERT(FALSE);
239 }
240 }
241 //
242 // print the summary
243 //
Chris Phillips73768082014-08-21 20:26:32 +0000244 ReservedPagesSize = MultU64x64(SIZE_4KB,ReservedPages);
245 LoadCodePagesSize = MultU64x64(SIZE_4KB,LoadCodePages);
246 LoadDataPagesSize = MultU64x64(SIZE_4KB,LoadDataPages);
247 BSCodePagesSize = MultU64x64(SIZE_4KB,BSCodePages);
248 BSDataPagesSize = MultU64x64(SIZE_4KB,BSDataPages);
249 RTDataPagesSize = MultU64x64(SIZE_4KB,RTDataPages);
250 RTCodePagesSize = MultU64x64(SIZE_4KB,RTCodePages);
251 AvailPagesSize = MultU64x64(SIZE_4KB,AvailPages);
252 TotalPagesSize = MultU64x64(SIZE_4KB,TotalPages);
253 AcpiReclaimPagesSize = MultU64x64(SIZE_4KB,AcpiReclaimPages);
254 AcpiNvsPagesSize = MultU64x64(SIZE_4KB,AcpiNvsPages);
255 MmioSpacePagesSize = MultU64x64(SIZE_4KB,MmioSpacePages);
256 MmioPortPagesSize = MultU64x64(SIZE_4KB,MmioPortPages);
257 PalCodePagesSize = MultU64x64(SIZE_4KB,PalCodePages);
258 UnusableMemoryPagesSize = MultU64x64(SIZE_4KB,UnusableMemoryPages);
jcarsey5d73d922010-11-16 22:36:37 +0000259 if (!Sfo) {
260 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM), gShellDebug1HiiHandle,
261 ReservedPages, ReservedPagesSize,
262 LoadCodePages, LoadCodePagesSize,
263 LoadDataPages, LoadDataPagesSize,
264 BSCodePages, BSCodePagesSize,
265 BSDataPages, BSDataPagesSize,
jcarsey3737ac22011-03-25 21:22:20 +0000266 RTCodePages, RTCodePagesSize,
jcarsey5d73d922010-11-16 22:36:37 +0000267 RTDataPages, RTDataPagesSize,
jcarsey3737ac22011-03-25 21:22:20 +0000268 AcpiReclaimPages, AcpiReclaimPagesSize,
269 AcpiNvsPages, AcpiNvsPagesSize,
270 MmioSpacePages, MmioSpacePagesSize,
Chris Phillips73768082014-08-21 20:26:32 +0000271 MmioPortPages, MmioPortPagesSize,
272 PalCodePages, PalCodePagesSize,
jcarsey5d73d922010-11-16 22:36:37 +0000273 AvailPages, AvailPagesSize,
274 DivU64x32(MultU64x64(SIZE_4KB,TotalPages), SIZE_1MB), TotalPagesSize
275 );
276 } else {
Chris Phillips73768082014-08-21 20:26:32 +0000277 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM_SFO), gShellDebug1HiiHandle,
jcarsey5d73d922010-11-16 22:36:37 +0000278 TotalPagesSize,
Chris Phillips73768082014-08-21 20:26:32 +0000279 ReservedPagesSize,
jcarsey5d73d922010-11-16 22:36:37 +0000280 BSCodePagesSize,
281 BSDataPagesSize,
282 RTCodePagesSize,
283 RTDataPagesSize,
284 LoadCodePagesSize,
285 LoadDataPagesSize,
Jaben Carseyc12383d2014-08-05 20:57:08 +0000286 AvailPagesSize,
287 MmioSpacePagesSize,
288 MmioPortPagesSize,
289 UnusableMemoryPagesSize,
290 AcpiReclaimPagesSize,
291 AcpiNvsPagesSize,
292 PalCodePagesSize
jcarsey5d73d922010-11-16 22:36:37 +0000293 );
294 }
295 }
296 }
297 ShellCommandLineFreeVarList (Package);
298 }
299
300 if (Buffer != NULL) {
301 FreePool(Buffer);
302 }
303
304 return (ShellStatus);
305}
306