2 Hardware IO based debug commands
4 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
6 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 Commands useful for debugging hardware. IO commands separated out as not all
17 processor architectures support the IO command.
28 Argv[0] - "ioread"[.#] # is optional width 1, 2, or 4. Default 1
29 Argv[1] - Hex IO address
31 ior.4 0x3f8 ;Do a 32-bit IO Read from 0x3f8
32 ior 0x3f8 ;Do a 8-bit IO Read from 0x3f8
34 @param Argc Number of command arguments in Argv
35 @param Argv Array of strings that represent the parsed command line.
36 Argv[0] is the command name
53 return EFI_INVALID_PARAMETER
;
56 Port
= AsciiStrHexToUintn (Argv
[1]);
57 Width
= WidthFromCommandName (Argv
[0], 1);
60 Data
= IoRead8 (Port
);
61 } else if (Width
== 2) {
62 Data
= IoRead16 (Port
);
63 } else if (Width
== 4) {
64 Data
= IoRead32 (Port
);
66 return EFI_INVALID_PARAMETER
;
69 AsciiPrint ("0x%04x = 0x%x", Port
, Data
);
78 Argv[0] - "iowrite"[.#] # is optional width 1, 2, or 4. Default 1
79 Argv[1] - Hex IO address
80 Argv[2] - Hex data to write
82 iow.4 0x3f8 af ;Do a 32-bit IO write of af to 0x3f8
83 iow 0x3f8 af ;Do an 8-bit IO write of af to 0x3f8
85 @param Argc Number of command arguments in Argv
86 @param Argv Array of strings that represent the parsed command line.
87 Argv[0] is the command name
104 return EFI_INVALID_PARAMETER
;
107 Port
= AsciiStrHexToUintn (Argv
[1]);
108 Data
= AsciiStrHexToUintn (Argv
[2]);
109 Width
= WidthFromCommandName (Argv
[0], 1);
112 IoWrite8 (Port
, (UINT8
)Data
);
113 } else if (Width
== 2) {
114 IoWrite16 (Port
, (UINT16
)Data
);
115 } else if (Width
== 4) {
116 IoWrite32 (Port
, (UINT32
)Data
);
118 return EFI_INVALID_PARAMETER
;
124 GLOBAL_REMOVE_IF_UNREFERENCED
const EBL_COMMAND_TABLE mCmdHwIoDebugTemplate
[] =
128 "[.{1|2|4}] Port ; IO read of width byte(s) from Port",
134 "[.{1|2|4}] Port Data ; IO write Data of width byte(s) to Port",
143 Initialize the commands in this in this file
146 EblInitializemdHwIoDebugCmds (
150 if (FeaturePcdGet (PcdEmbeddedIoEnable
)) {
151 EblAddCommands (mCmdHwIoDebugTemplate
, sizeof (mCmdHwIoDebugTemplate
)/sizeof (EBL_COMMAND_TABLE
));