2 Main file for Dmem shell Debug1 function.
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiShellDebug1CommandsLib.h"
16 #include <Protocol/PciRootBridgeIo.h>
23 if ((Char
< 0x20 && Char
> 0)||(Char
> 126)) {
32 IN CONST VOID
*Address
,
36 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRbIo
;
39 SHELL_STATUS ShellStatus
;
41 ShellStatus
= SHELL_SUCCESS
;
43 Status
= gBS
->LocateProtocol(&gEfiPciRootBridgeIoProtocolGuid
, NULL
, (VOID
**)&PciRbIo
);
44 if (EFI_ERROR(Status
)) {
45 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PCIRBIO_NF
), gShellDebug1HiiHandle
);
46 return (SHELL_NOT_FOUND
);
48 Buffer
= AllocateZeroPool(Size
);
49 ASSERT(Buffer
!= NULL
);
51 Status
= PciRbIo
->Mem
.Read(PciRbIo
, EfiPciWidthUint8
, (UINT64
)Address
, Size
, Buffer
);
52 if (EFI_ERROR(Status
)) {
53 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PCIRBIO_ER
), gShellDebug1HiiHandle
, Status
);
54 ShellStatus
= SHELL_NOT_FOUND
;
56 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_DMEM_MMIO_HEADER_ROW
), gShellDebug1HiiHandle
, (UINT64
)Address
, Size
);
57 DumpHex(2,0,Size
,Buffer
);
64 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
72 IN EFI_HANDLE ImageHandle
,
73 IN EFI_SYSTEM_TABLE
*SystemTable
79 SHELL_STATUS ShellStatus
;
84 ShellStatus
= SHELL_SUCCESS
;
90 // initialize the shell lib (we must be in non-auto-init...)
92 Status
= ShellInitialize();
93 ASSERT_EFI_ERROR(Status
);
95 Status
= CommandInit();
96 ASSERT_EFI_ERROR(Status
);
99 // parse the command line
101 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
102 if (EFI_ERROR(Status
)) {
103 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
104 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, ProblemParam
);
105 FreePool(ProblemParam
);
106 ShellStatus
= SHELL_INVALID_PARAMETER
;
111 Temp1
= ShellCommandLineGetRawValue(Package
, 1);
116 if (!ShellIsHexOrDecimalNumber(Temp1
, TRUE
, FALSE
)) {
117 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp1
);
118 ShellStatus
= SHELL_INVALID_PARAMETER
;
120 Address
= (VOID
*)StrHexToUintn(Temp1
);
122 Temp1
= ShellCommandLineGetRawValue(Package
, 2);
126 if (!ShellIsHexOrDecimalNumber(Temp1
, FALSE
, FALSE
)) {
127 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp1
);
128 ShellStatus
= SHELL_INVALID_PARAMETER
;
130 Size
= ShellStrToUintn(Temp1
);
135 if (ShellStatus
== SHELL_SUCCESS
) {
136 if (!ShellCommandLineGetFlag(Package
, L
"-mmio")) {
137 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_DMEM_HEADER_ROW
), gShellDebug1HiiHandle
, (UINT64
)Address
, Size
);
138 DumpHex(2,0,Size
,Address
);
140 ShellStatus
= DisplayMmioMemory(Address
, Size
);
145 ShellCommandLineFreeVarList (Package
);
148 return (ShellStatus
);