jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 1 | /** @file
|
| 2 | Main file for Mode shell Debug1 function.
|
| 3 |
|
Tapan Shah | c011b6c | 2015-02-04 22:25:01 +0000 | [diff] [blame^] | 4 | (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
|
Jaben Carsey | c12383d | 2014-08-05 20:57:08 +0000 | [diff] [blame] | 5 | Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
|
lgao4 | d0cec2d | 2013-05-22 02:19:16 +0000 | [diff] [blame] | 6 | This program and the accompanying materials
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 7 | 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 Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 16 | //
|
| 17 | // Need full names for Standard-Format Output
|
| 18 | //
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 19 | STATIC CONST CHAR16 NameEfiReservedMemoryType[] = L"Reserved";
|
| 20 | STATIC CONST CHAR16 NameEfiLoaderCode[] = L"LoaderCode";
|
| 21 | STATIC CONST CHAR16 NameEfiLoaderData[] = L"LoaderData";
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 22 | STATIC CONST CHAR16 NameEfiBootServicesCode[] = L"BootServiceCode";
|
| 23 | STATIC CONST CHAR16 NameEfiBootServicesData[] = L"BootServiceData";
|
| 24 | STATIC CONST CHAR16 NameEfiRuntimeServicesCode[] = L"RuntimeCode";
|
| 25 | STATIC CONST CHAR16 NameEfiRuntimeServicesData[] = L"RuntimeData";
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 26 | STATIC CONST CHAR16 NameEfiConventionalMemory[] = L"Available";
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 27 | STATIC CONST CHAR16 NameEfiUnusableMemory[] = L"UnusableMemory";
|
| 28 | STATIC CONST CHAR16 NameEfiACPIReclaimMemory[] = L"ACPIReclaimMemory";
|
| 29 | STATIC CONST CHAR16 NameEfiACPIMemoryNVS[] = L"ACPIMemoryNVS";
|
| 30 | STATIC CONST CHAR16 NameEfiMemoryMappedIO[] = L"MemoryMappedIO";
|
| 31 | STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpace[] = L"MemoryMappedIOPortSpace";
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 32 | STATIC CONST CHAR16 NameEfiPalCode[] = L"PalCode";
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 33 |
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 34 | //
|
| 35 | // Need short names for some memory types
|
| 36 | //
|
| 37 | STATIC CONST CHAR16 NameEfiBootServicesCodeShort[] = L"BS_Code";
|
| 38 | STATIC CONST CHAR16 NameEfiBootServicesDataShort[] = L"BS_Data";
|
| 39 | STATIC CONST CHAR16 NameEfiRuntimeServicesCodeShort[] = L"RT_Code";
|
| 40 | STATIC CONST CHAR16 NameEfiRuntimeServicesDataShort[] = L"RT_Data";
|
| 41 | STATIC CONST CHAR16 NameEfiUnusableMemoryShort[] = L"Unusable";
|
| 42 | STATIC CONST CHAR16 NameEfiACPIReclaimMemoryShort[] = L"ACPI_Recl";
|
| 43 | STATIC CONST CHAR16 NameEfiACPIMemoryNVSShort[] = L"ACPI_NVS";
|
| 44 | STATIC CONST CHAR16 NameEfiMemoryMappedIOShort[] = L"MMIO";
|
| 45 | STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpaceShort[] = L"MMIO_Port";
|
| 46 |
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 47 | #include "UefiShellDebug1CommandsLib.h"
|
| 48 |
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 49 | /**
|
| 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 | **/
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 55 | SHELL_STATUS
|
| 56 | EFIAPI
|
| 57 | ShellCommandRunMemMap (
|
| 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;
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 90 | UINT64 AcpiReclaimPages;
|
| 91 | UINT64 AcpiNvsPages;
|
| 92 | UINT64 MmioSpacePages;
|
| 93 | UINT64 AcpiReclaimPagesSize;
|
| 94 | UINT64 AcpiNvsPagesSize;
|
| 95 | UINT64 MmioSpacePagesSize;
|
Jaben Carsey | c12383d | 2014-08-05 20:57:08 +0000 | [diff] [blame] | 96 | UINT64 MmioPortPages;
|
| 97 | UINT64 MmioPortPagesSize;
|
| 98 | UINT64 UnusableMemoryPages;
|
| 99 | UINT64 UnusableMemoryPagesSize;
|
| 100 | UINT64 PalCodePages;
|
| 101 | UINT64 PalCodePagesSize;
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 102 | BOOLEAN Sfo;
|
| 103 |
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 104 | AcpiReclaimPages = 0;
|
| 105 | AcpiNvsPages = 0;
|
| 106 | MmioSpacePages = 0;
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 107 | 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 Carsey | c12383d | 2014-08-05 20:57:08 +0000 | [diff] [blame] | 116 | MmioPortPages = 0;
|
| 117 | UnusableMemoryPages = 0;
|
| 118 | PalCodePages = 0;
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 119 | 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 Shah | 4092a8f | 2015-02-03 21:22:53 +0000 | [diff] [blame] | 139 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"memmap", ProblemParam);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 140 | FreePool(ProblemParam);
|
| 141 | ShellStatus = SHELL_INVALID_PARAMETER;
|
| 142 | } else {
|
| 143 | ASSERT(FALSE);
|
| 144 | }
|
| 145 | } else {
|
| 146 | if (ShellCommandLineGetCount(Package) > 1) {
|
Tapan Shah | 4092a8f | 2015-02-03 21:22:53 +0000 | [diff] [blame] | 147 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"memmap");
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 148 | 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;
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 153 | Buffer = AllocateZeroPool(Size);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 154 | Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version);
|
| 155 | }
|
| 156 | if (EFI_ERROR(Status)) {
|
Tapan Shah | 4092a8f | 2015-02-03 21:22:53 +0000 | [diff] [blame] | 157 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_GET_FAILED), gShellDebug1HiiHandle, L"memmap");
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 158 | ShellStatus = SHELL_ACCESS_DENIED;
|
| 159 | } else {
|
| 160 | ASSERT(Version == EFI_MEMORY_DESCRIPTOR_VERSION);
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 161 |
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 162 | Sfo = ShellCommandLineGetFlag(Package, L"-sfo");
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 163 | 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 |
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 169 | for (Walker = (UINT8*)Buffer; Walker < (((UINT8*)Buffer)+Size) && Walker != NULL; Walker += ItemSize){
|
| 170 | switch (((EFI_MEMORY_DESCRIPTOR*)Walker)->Type) {
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 171 | case EfiReservedMemoryType:
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 172 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 173 | ReservedPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 174 | break;
|
| 175 | case EfiLoaderCode:
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 176 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 177 | LoadCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 178 | TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 179 | break;
|
| 180 | case EfiLoaderData:
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 181 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 182 | LoadDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 183 | TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 184 | break;
|
| 185 | case EfiBootServicesCode:
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 186 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 187 | BSCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 188 | TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 189 | break;
|
| 190 | case EfiBootServicesData:
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 191 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 192 | BSDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 193 | TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 194 | break;
|
| 195 | case EfiRuntimeServicesCode:
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 196 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 197 | RTCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 198 | TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 199 | break;
|
| 200 | case EfiRuntimeServicesData:
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 201 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 202 | RTDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 203 | TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 204 | break;
|
| 205 | case EfiConventionalMemory:
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 206 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 207 | AvailPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 208 | TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
| 209 | break;
|
| 210 | case EfiUnusableMemory:
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 211 | 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 Carsey | c12383d | 2014-08-05 20:57:08 +0000 | [diff] [blame] | 212 | UnusableMemoryPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 213 | break;
|
| 214 | case EfiACPIReclaimMemory:
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 215 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 216 | TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 217 | AcpiReclaimPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 218 | break;
|
| 219 | case EfiACPIMemoryNVS:
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 220 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 221 | TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 222 | AcpiNvsPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 223 | break;
|
| 224 | case EfiMemoryMappedIO:
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 225 | 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);
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 226 | MmioSpacePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 227 | break;
|
| 228 | case EfiMemoryMappedIOPortSpace:
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 229 | 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 Carsey | c12383d | 2014-08-05 20:57:08 +0000 | [diff] [blame] | 230 | MmioPortPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 231 | break;
|
| 232 | case EfiPalCode:
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 233 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 234 | TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
Jaben Carsey | c12383d | 2014-08-05 20:57:08 +0000 | [diff] [blame] | 235 | PalCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages;
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 236 | break;
|
| 237 | default:
|
| 238 | ASSERT(FALSE);
|
| 239 | }
|
| 240 | }
|
| 241 | //
|
| 242 | // print the summary
|
| 243 | //
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 244 | 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);
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 259 | 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,
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 266 | RTCodePages, RTCodePagesSize,
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 267 | RTDataPages, RTDataPagesSize,
|
jcarsey | 3737ac2 | 2011-03-25 21:22:20 +0000 | [diff] [blame] | 268 | AcpiReclaimPages, AcpiReclaimPagesSize,
|
| 269 | AcpiNvsPages, AcpiNvsPagesSize,
|
| 270 | MmioSpacePages, MmioSpacePagesSize,
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 271 | MmioPortPages, MmioPortPagesSize,
|
| 272 | PalCodePages, PalCodePagesSize,
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 273 | AvailPages, AvailPagesSize,
|
| 274 | DivU64x32(MultU64x64(SIZE_4KB,TotalPages), SIZE_1MB), TotalPagesSize
|
| 275 | );
|
| 276 | } else {
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 277 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM_SFO), gShellDebug1HiiHandle,
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 278 | TotalPagesSize,
|
Chris Phillips | 7376808 | 2014-08-21 20:26:32 +0000 | [diff] [blame] | 279 | ReservedPagesSize,
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 280 | BSCodePagesSize,
|
| 281 | BSDataPagesSize,
|
| 282 | RTCodePagesSize,
|
| 283 | RTDataPagesSize,
|
| 284 | LoadCodePagesSize,
|
| 285 | LoadDataPagesSize,
|
Jaben Carsey | c12383d | 2014-08-05 20:57:08 +0000 | [diff] [blame] | 286 | AvailPagesSize,
|
| 287 | MmioSpacePagesSize,
|
| 288 | MmioPortPagesSize,
|
| 289 | UnusableMemoryPagesSize,
|
| 290 | AcpiReclaimPagesSize,
|
| 291 | AcpiNvsPagesSize,
|
| 292 | PalCodePagesSize
|
jcarsey | 5d73d92 | 2010-11-16 22:36:37 +0000 | [diff] [blame] | 293 | );
|
| 294 | }
|
| 295 | }
|
| 296 | }
|
| 297 | ShellCommandLineFreeVarList (Package);
|
| 298 | }
|
| 299 |
|
| 300 | if (Buffer != NULL) {
|
| 301 | FreePool(Buffer);
|
| 302 | }
|
| 303 |
|
| 304 | return (ShellStatus);
|
| 305 | }
|
| 306 |
|