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 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
7 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
8 |
|
---|
9 | **/
|
---|
10 |
|
---|
11 | //
|
---|
12 | // Need full names for Standard-Format Output
|
---|
13 | //
|
---|
14 | STATIC CONST CHAR16 NameEfiReservedMemoryType[] = L"Reserved";
|
---|
15 | STATIC CONST CHAR16 NameEfiLoaderCode[] = L"LoaderCode";
|
---|
16 | STATIC CONST CHAR16 NameEfiLoaderData[] = L"LoaderData";
|
---|
17 | STATIC CONST CHAR16 NameEfiBootServicesCode[] = L"BootServiceCode";
|
---|
18 | STATIC CONST CHAR16 NameEfiBootServicesData[] = L"BootServiceData";
|
---|
19 | STATIC CONST CHAR16 NameEfiRuntimeServicesCode[] = L"RuntimeCode";
|
---|
20 | STATIC CONST CHAR16 NameEfiRuntimeServicesData[] = L"RuntimeData";
|
---|
21 | STATIC CONST CHAR16 NameEfiConventionalMemory[] = L"Available";
|
---|
22 | STATIC CONST CHAR16 NameEfiPersistentMemory[] = L"Persistent";
|
---|
23 | STATIC CONST CHAR16 NameEfiUnusableMemory[] = L"UnusableMemory";
|
---|
24 | STATIC CONST CHAR16 NameEfiACPIReclaimMemory[] = L"ACPIReclaimMemory";
|
---|
25 | STATIC CONST CHAR16 NameEfiACPIMemoryNVS[] = L"ACPIMemoryNVS";
|
---|
26 | STATIC CONST CHAR16 NameEfiMemoryMappedIO[] = L"MemoryMappedIO";
|
---|
27 | STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpace[] = L"MemoryMappedIOPortSpace";
|
---|
28 | STATIC CONST CHAR16 NameEfiPalCode[] = L"PalCode";
|
---|
29 |
|
---|
30 | //
|
---|
31 | // Need short names for some memory types
|
---|
32 | //
|
---|
33 | STATIC CONST CHAR16 NameEfiBootServicesCodeShort[] = L"BS_Code";
|
---|
34 | STATIC CONST CHAR16 NameEfiBootServicesDataShort[] = L"BS_Data";
|
---|
35 | STATIC CONST CHAR16 NameEfiRuntimeServicesCodeShort[] = L"RT_Code";
|
---|
36 | STATIC CONST CHAR16 NameEfiRuntimeServicesDataShort[] = L"RT_Data";
|
---|
37 | STATIC CONST CHAR16 NameEfiUnusableMemoryShort[] = L"Unusable";
|
---|
38 | STATIC CONST CHAR16 NameEfiACPIReclaimMemoryShort[] = L"ACPI_Recl";
|
---|
39 | STATIC CONST CHAR16 NameEfiACPIMemoryNVSShort[] = L"ACPI_NVS";
|
---|
40 | STATIC CONST CHAR16 NameEfiMemoryMappedIOShort[] = L"MMIO";
|
---|
41 | STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpaceShort[] = L"MMIO_Port";
|
---|
42 |
|
---|
43 | #include "UefiShellDebug1CommandsLib.h"
|
---|
44 |
|
---|
45 | typedef struct {
|
---|
46 | UINT32 Type;
|
---|
47 | UINT64 NumberOfPages;
|
---|
48 | LIST_ENTRY Link;
|
---|
49 | } MEMORY_LENGTH_ENTRY;
|
---|
50 |
|
---|
51 | /**
|
---|
52 | Add the length of the specified type to List.
|
---|
53 |
|
---|
54 | @param List A list to hold all pairs of <Type, NumberOfPages>.
|
---|
55 | @param Type Memory type.
|
---|
56 | @param NumberOfPages Number of pages.
|
---|
57 | **/
|
---|
58 | VOID
|
---|
59 | AddMemoryLength (
|
---|
60 | LIST_ENTRY *List,
|
---|
61 | UINT32 Type,
|
---|
62 | UINT64 NumberOfPages
|
---|
63 | )
|
---|
64 | {
|
---|
65 | MEMORY_LENGTH_ENTRY *Entry;
|
---|
66 | MEMORY_LENGTH_ENTRY *NewEntry;
|
---|
67 | LIST_ENTRY *Link;
|
---|
68 |
|
---|
69 | Entry = NULL;
|
---|
70 | for (Link = GetFirstNode (List); !IsNull (List, Link); Link = GetNextNode (List, Link)) {
|
---|
71 | Entry = BASE_CR (Link, MEMORY_LENGTH_ENTRY, Link);
|
---|
72 | if (Entry->Type >= Type) {
|
---|
73 | break;
|
---|
74 | }
|
---|
75 | }
|
---|
76 |
|
---|
77 | if ((Entry != NULL) && (Entry->Type == Type)) {
|
---|
78 | //
|
---|
79 | // The Entry is the one we look for.
|
---|
80 | //
|
---|
81 | NewEntry = Entry;
|
---|
82 | } else {
|
---|
83 | //
|
---|
84 | // The search operation breaks due to:
|
---|
85 | // 1. Type of every entry < Type --> Insert to tail
|
---|
86 | // 2. Type of an entry > Type --> Insert to previous of this entry
|
---|
87 | //
|
---|
88 | NewEntry = AllocatePool (sizeof (*NewEntry));
|
---|
89 | if (NewEntry == NULL) {
|
---|
90 | return;
|
---|
91 | }
|
---|
92 | NewEntry->Type = Type;
|
---|
93 | NewEntry->NumberOfPages = 0;
|
---|
94 | InsertTailList (Link, &NewEntry->Link);
|
---|
95 | }
|
---|
96 |
|
---|
97 | NewEntry->NumberOfPages += NumberOfPages;
|
---|
98 | }
|
---|
99 |
|
---|
100 | /**
|
---|
101 | Function for 'memmap' command.
|
---|
102 |
|
---|
103 | @param[in] ImageHandle Handle to the Image (NULL if Internal).
|
---|
104 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
---|
105 | **/
|
---|
106 | SHELL_STATUS
|
---|
107 | EFIAPI
|
---|
108 | ShellCommandRunMemMap (
|
---|
109 | IN EFI_HANDLE ImageHandle,
|
---|
110 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
111 | )
|
---|
112 | {
|
---|
113 | EFI_STATUS Status;
|
---|
114 | LIST_ENTRY *Package;
|
---|
115 | CHAR16 *ProblemParam;
|
---|
116 | SHELL_STATUS ShellStatus;
|
---|
117 | UINTN Size;
|
---|
118 | EFI_MEMORY_DESCRIPTOR *Descriptors;
|
---|
119 | UINTN MapKey;
|
---|
120 | UINTN ItemSize;
|
---|
121 | UINT32 Version;
|
---|
122 | EFI_MEMORY_DESCRIPTOR *Walker;
|
---|
123 | UINT64 ReservedPages;
|
---|
124 | UINT64 LoadCodePages;
|
---|
125 | UINT64 LoadDataPages;
|
---|
126 | UINT64 BSCodePages;
|
---|
127 | UINT64 BSDataPages;
|
---|
128 | UINT64 RTDataPages;
|
---|
129 | UINT64 RTCodePages;
|
---|
130 | UINT64 AvailPages;
|
---|
131 | UINT64 TotalPages;
|
---|
132 | UINT64 ReservedPagesSize;
|
---|
133 | UINT64 LoadCodePagesSize;
|
---|
134 | UINT64 LoadDataPagesSize;
|
---|
135 | UINT64 BSCodePagesSize;
|
---|
136 | UINT64 BSDataPagesSize;
|
---|
137 | UINT64 RTDataPagesSize;
|
---|
138 | UINT64 RTCodePagesSize;
|
---|
139 | UINT64 AvailPagesSize;
|
---|
140 | UINT64 TotalPagesSize;
|
---|
141 | UINT64 AcpiReclaimPages;
|
---|
142 | UINT64 AcpiNvsPages;
|
---|
143 | UINT64 MmioSpacePages;
|
---|
144 | UINT64 AcpiReclaimPagesSize;
|
---|
145 | UINT64 AcpiNvsPagesSize;
|
---|
146 | UINT64 MmioSpacePagesSize;
|
---|
147 | UINT64 MmioPortPages;
|
---|
148 | UINT64 MmioPortPagesSize;
|
---|
149 | UINT64 UnusableMemoryPages;
|
---|
150 | UINT64 UnusableMemoryPagesSize;
|
---|
151 | UINT64 PalCodePages;
|
---|
152 | UINT64 PalCodePagesSize;
|
---|
153 | UINT64 PersistentPages;
|
---|
154 | UINT64 PersistentPagesSize;
|
---|
155 | BOOLEAN Sfo;
|
---|
156 | LIST_ENTRY MemoryList;
|
---|
157 | MEMORY_LENGTH_ENTRY *Entry;
|
---|
158 | LIST_ENTRY *Link;
|
---|
159 |
|
---|
160 | AcpiReclaimPages = 0;
|
---|
161 | AcpiNvsPages = 0;
|
---|
162 | MmioSpacePages = 0;
|
---|
163 | TotalPages = 0;
|
---|
164 | ReservedPages = 0;
|
---|
165 | LoadCodePages = 0;
|
---|
166 | LoadDataPages = 0;
|
---|
167 | BSCodePages = 0;
|
---|
168 | BSDataPages = 0;
|
---|
169 | RTDataPages = 0;
|
---|
170 | RTCodePages = 0;
|
---|
171 | AvailPages = 0;
|
---|
172 | MmioPortPages = 0;
|
---|
173 | UnusableMemoryPages = 0;
|
---|
174 | PalCodePages = 0;
|
---|
175 | PersistentPages = 0;
|
---|
176 | Size = 0;
|
---|
177 | Descriptors = NULL;
|
---|
178 | ShellStatus = SHELL_SUCCESS;
|
---|
179 | Status = EFI_SUCCESS;
|
---|
180 | InitializeListHead (&MemoryList);
|
---|
181 |
|
---|
182 | //
|
---|
183 | // initialize the shell lib (we must be in non-auto-init...)
|
---|
184 | //
|
---|
185 | Status = ShellInitialize();
|
---|
186 | ASSERT_EFI_ERROR(Status);
|
---|
187 |
|
---|
188 | Status = CommandInit();
|
---|
189 | ASSERT_EFI_ERROR(Status);
|
---|
190 |
|
---|
191 | //
|
---|
192 | // parse the command line
|
---|
193 | //
|
---|
194 | Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE);
|
---|
195 | if (EFI_ERROR(Status)) {
|
---|
196 | if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
---|
197 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"memmap", ProblemParam);
|
---|
198 | FreePool(ProblemParam);
|
---|
199 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
200 | } else {
|
---|
201 | ASSERT(FALSE);
|
---|
202 | }
|
---|
203 | } else {
|
---|
204 | if (ShellCommandLineGetCount(Package) > 1) {
|
---|
205 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"memmap");
|
---|
206 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
207 | } else {
|
---|
208 | Status = gBS->GetMemoryMap(&Size, Descriptors, &MapKey, &ItemSize, &Version);
|
---|
209 | if (Status == EFI_BUFFER_TOO_SMALL){
|
---|
210 | Size += SIZE_1KB;
|
---|
211 | Descriptors = AllocateZeroPool(Size);
|
---|
212 | Status = gBS->GetMemoryMap(&Size, Descriptors, &MapKey, &ItemSize, &Version);
|
---|
213 | }
|
---|
214 | if (EFI_ERROR(Status)) {
|
---|
215 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_GET_FAILED), gShellDebug1HiiHandle, L"memmap");
|
---|
216 | ShellStatus = SHELL_ACCESS_DENIED;
|
---|
217 | } else {
|
---|
218 | ASSERT(Version == EFI_MEMORY_DESCRIPTOR_VERSION);
|
---|
219 |
|
---|
220 | Sfo = ShellCommandLineGetFlag(Package, L"-sfo");
|
---|
221 | if (!Sfo) {
|
---|
222 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_HEAD), gShellDebug1HiiHandle);
|
---|
223 | } else {
|
---|
224 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellDebug1HiiHandle, L"memmap");
|
---|
225 | }
|
---|
226 |
|
---|
227 | for ( Walker = Descriptors
|
---|
228 | ; (Walker < (EFI_MEMORY_DESCRIPTOR *) ((UINT8*)Descriptors + Size)) && (Walker != NULL)
|
---|
229 | ; Walker = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *)Walker + ItemSize)
|
---|
230 | ){
|
---|
231 | switch (Walker->Type) {
|
---|
232 | case EfiReservedMemoryType:
|
---|
233 | 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);
|
---|
234 | ReservedPages += Walker->NumberOfPages;
|
---|
235 | break;
|
---|
236 | case EfiLoaderCode:
|
---|
237 | 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);
|
---|
238 | LoadCodePages += Walker->NumberOfPages;
|
---|
239 | TotalPages += Walker->NumberOfPages;
|
---|
240 | break;
|
---|
241 | case EfiLoaderData:
|
---|
242 | 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);
|
---|
243 | LoadDataPages += Walker->NumberOfPages;
|
---|
244 | TotalPages += Walker->NumberOfPages;
|
---|
245 | break;
|
---|
246 | case EfiBootServicesCode:
|
---|
247 | 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);
|
---|
248 | BSCodePages += Walker->NumberOfPages;
|
---|
249 | TotalPages += Walker->NumberOfPages;
|
---|
250 | break;
|
---|
251 | case EfiBootServicesData:
|
---|
252 | 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);
|
---|
253 | BSDataPages += Walker->NumberOfPages;
|
---|
254 | TotalPages += Walker->NumberOfPages;
|
---|
255 | break;
|
---|
256 | case EfiRuntimeServicesCode:
|
---|
257 | 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);
|
---|
258 | RTCodePages += Walker->NumberOfPages;
|
---|
259 | TotalPages += Walker->NumberOfPages;
|
---|
260 | break;
|
---|
261 | case EfiRuntimeServicesData:
|
---|
262 | 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);
|
---|
263 | RTDataPages += Walker->NumberOfPages;
|
---|
264 | TotalPages += Walker->NumberOfPages;
|
---|
265 | break;
|
---|
266 | case EfiConventionalMemory:
|
---|
267 | 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);
|
---|
268 | AvailPages += Walker->NumberOfPages;
|
---|
269 | TotalPages += Walker->NumberOfPages;
|
---|
270 | break;
|
---|
271 | case EfiPersistentMemory:
|
---|
272 | 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);
|
---|
273 | PersistentPages += Walker->NumberOfPages;
|
---|
274 | TotalPages += Walker->NumberOfPages;
|
---|
275 | break;
|
---|
276 | case EfiUnusableMemory:
|
---|
277 | 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);
|
---|
278 | UnusableMemoryPages += Walker->NumberOfPages;
|
---|
279 | break;
|
---|
280 | case EfiACPIReclaimMemory:
|
---|
281 | 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);
|
---|
282 | TotalPages += Walker->NumberOfPages;
|
---|
283 | AcpiReclaimPages += Walker->NumberOfPages;
|
---|
284 | break;
|
---|
285 | case EfiACPIMemoryNVS:
|
---|
286 | 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);
|
---|
287 | TotalPages += Walker->NumberOfPages;
|
---|
288 | AcpiNvsPages += Walker->NumberOfPages;
|
---|
289 | break;
|
---|
290 | case EfiMemoryMappedIO:
|
---|
291 | 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);
|
---|
292 | MmioSpacePages += Walker->NumberOfPages;
|
---|
293 | break;
|
---|
294 | case EfiMemoryMappedIOPortSpace:
|
---|
295 | 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);
|
---|
296 | MmioPortPages += Walker->NumberOfPages;
|
---|
297 | break;
|
---|
298 | case EfiPalCode:
|
---|
299 | 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);
|
---|
300 | TotalPages += Walker->NumberOfPages;
|
---|
301 | PalCodePages += Walker->NumberOfPages;
|
---|
302 | break;
|
---|
303 | default:
|
---|
304 | //
|
---|
305 | // Shell Spec defines the SFO format.
|
---|
306 | // Do not print the OEM/OS memory usage in the SFO format, to avoid conflict with Shell Spec.
|
---|
307 | //
|
---|
308 | if (!Sfo) {
|
---|
309 | 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);
|
---|
310 | }
|
---|
311 | TotalPages += Walker->NumberOfPages;
|
---|
312 | AddMemoryLength (&MemoryList, Walker->Type, Walker->NumberOfPages);
|
---|
313 | break;
|
---|
314 | }
|
---|
315 | }
|
---|
316 | //
|
---|
317 | // print the summary
|
---|
318 | //
|
---|
319 | ReservedPagesSize = MultU64x64(SIZE_4KB,ReservedPages);
|
---|
320 | LoadCodePagesSize = MultU64x64(SIZE_4KB,LoadCodePages);
|
---|
321 | LoadDataPagesSize = MultU64x64(SIZE_4KB,LoadDataPages);
|
---|
322 | BSCodePagesSize = MultU64x64(SIZE_4KB,BSCodePages);
|
---|
323 | BSDataPagesSize = MultU64x64(SIZE_4KB,BSDataPages);
|
---|
324 | RTDataPagesSize = MultU64x64(SIZE_4KB,RTDataPages);
|
---|
325 | RTCodePagesSize = MultU64x64(SIZE_4KB,RTCodePages);
|
---|
326 | AvailPagesSize = MultU64x64(SIZE_4KB,AvailPages);
|
---|
327 | TotalPagesSize = MultU64x64(SIZE_4KB,TotalPages);
|
---|
328 | AcpiReclaimPagesSize = MultU64x64(SIZE_4KB,AcpiReclaimPages);
|
---|
329 | AcpiNvsPagesSize = MultU64x64(SIZE_4KB,AcpiNvsPages);
|
---|
330 | MmioSpacePagesSize = MultU64x64(SIZE_4KB,MmioSpacePages);
|
---|
331 | MmioPortPagesSize = MultU64x64(SIZE_4KB,MmioPortPages);
|
---|
332 | PalCodePagesSize = MultU64x64(SIZE_4KB,PalCodePages);
|
---|
333 | PersistentPagesSize = MultU64x64(SIZE_4KB,PersistentPages);
|
---|
334 | UnusableMemoryPagesSize = MultU64x64(SIZE_4KB,UnusableMemoryPages);
|
---|
335 | if (!Sfo) {
|
---|
336 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM), gShellDebug1HiiHandle,
|
---|
337 | ReservedPages, ReservedPagesSize,
|
---|
338 | LoadCodePages, LoadCodePagesSize,
|
---|
339 | LoadDataPages, LoadDataPagesSize,
|
---|
340 | BSCodePages, BSCodePagesSize,
|
---|
341 | BSDataPages, BSDataPagesSize,
|
---|
342 | RTCodePages, RTCodePagesSize,
|
---|
343 | RTDataPages, RTDataPagesSize,
|
---|
344 | AcpiReclaimPages, AcpiReclaimPagesSize,
|
---|
345 | AcpiNvsPages, AcpiNvsPagesSize,
|
---|
346 | MmioSpacePages, MmioSpacePagesSize,
|
---|
347 | MmioPortPages, MmioPortPagesSize,
|
---|
348 | PalCodePages, PalCodePagesSize,
|
---|
349 | AvailPages, AvailPagesSize,
|
---|
350 | PersistentPages, PersistentPagesSize
|
---|
351 | );
|
---|
352 |
|
---|
353 | //
|
---|
354 | // Print out the total memory usage for OEM/OS types in the order of type.
|
---|
355 | //
|
---|
356 | for (Link = GetFirstNode (&MemoryList); !IsNull (&MemoryList, Link); Link = GetNextNode (&MemoryList, Link)) {
|
---|
357 | Entry = BASE_CR (Link, MEMORY_LENGTH_ENTRY, Link);
|
---|
358 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM_OTHER), gShellDebug1HiiHandle,
|
---|
359 | Entry->Type, Entry->NumberOfPages, MultU64x64 (SIZE_4KB, Entry->NumberOfPages)
|
---|
360 | );
|
---|
361 | }
|
---|
362 |
|
---|
363 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM2), gShellDebug1HiiHandle,
|
---|
364 | DivU64x32(MultU64x64(SIZE_4KB,TotalPages), SIZE_1MB), TotalPagesSize
|
---|
365 | );
|
---|
366 | } else {
|
---|
367 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM_SFO), gShellDebug1HiiHandle,
|
---|
368 | TotalPagesSize,
|
---|
369 | ReservedPagesSize,
|
---|
370 | BSCodePagesSize,
|
---|
371 | BSDataPagesSize,
|
---|
372 | RTCodePagesSize,
|
---|
373 | RTDataPagesSize,
|
---|
374 | LoadCodePagesSize,
|
---|
375 | LoadDataPagesSize,
|
---|
376 | AvailPagesSize,
|
---|
377 | MmioSpacePagesSize,
|
---|
378 | MmioPortPagesSize,
|
---|
379 | UnusableMemoryPagesSize,
|
---|
380 | AcpiReclaimPagesSize,
|
---|
381 | AcpiNvsPagesSize,
|
---|
382 | PalCodePagesSize,
|
---|
383 | PersistentPagesSize
|
---|
384 | );
|
---|
385 | }
|
---|
386 | }
|
---|
387 | }
|
---|
388 | ShellCommandLineFreeVarList (Package);
|
---|
389 | }
|
---|
390 |
|
---|
391 | if (Descriptors != NULL) {
|
---|
392 | FreePool(Descriptors);
|
---|
393 | }
|
---|
394 |
|
---|
395 | //
|
---|
396 | // Free the memory list.
|
---|
397 | //
|
---|
398 | for (Link = GetFirstNode (&MemoryList); !IsNull (&MemoryList, Link); ) {
|
---|
399 | Link = RemoveEntryList (Link);
|
---|
400 | }
|
---|
401 |
|
---|
402 | return (ShellStatus);
|
---|
403 | }
|
---|
404 |
|
---|