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>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 Commands useful for debugging hardware. IO commands seperated out as not all
16 processor architectures support the IO command.
27 Argv[0] - "ioread"[.#] # is optiona width 1, 2, or 4. Default 1
28 Argv[1] - Hex IO address
30 ior.4 0x3f8 ;Do a 32-bit IO Read from 0x3f8
31 ior 0x3f8 ;Do a 8-bit IO Read from 0x3f8
33 @param Argc Number of command arguments in Argv
34 @param Argv Array of strings that represent the parsed command line.
35 Argv[0] is the comamnd name
51 return EFI_INVALID_PARAMETER
;
54 Port
= AsciiStrHexToUintn (Argv
[1]);
55 Width
= WidthFromCommandName (Argv
[0], 1);
58 Data
= IoRead8 (Port
);
59 } else if (Width
== 2) {
60 Data
= IoRead16 (Port
);
61 } else if (Width
== 4) {
62 Data
= IoRead32 (Port
);
64 return EFI_INVALID_PARAMETER
;
67 AsciiPrint ("0x%04x = 0x%x", Port
, Data
);
76 Argv[0] - "iowrite"[.#] # is optiona width 1, 2, or 4. Default 1
77 Argv[1] - Hex IO address
78 Argv[2] - Hex data to write
80 iow.4 0x3f8 af ;Do a 32-bit IO write of af to 0x3f8
81 iow 0x3f8 af ;Do an 8-bit IO write of af to 0x3f8
83 @param Argc Number of command arguments in Argv
84 @param Argv Array of strings that represent the parsed command line.
85 Argv[0] is the comamnd name
101 return EFI_INVALID_PARAMETER
;
104 Port
= AsciiStrHexToUintn (Argv
[1]);
105 Data
= AsciiStrHexToUintn (Argv
[2]);
106 Width
= WidthFromCommandName (Argv
[0], 1);
109 IoWrite8 (Port
, (UINT8
)Data
);
110 } else if (Width
== 2) {
111 IoWrite16 (Port
, (UINT16
)Data
);
112 } else if (Width
== 4) {
113 IoWrite32 (Port
, (UINT32
)Data
);
115 return EFI_INVALID_PARAMETER
;
121 GLOBAL_REMOVE_IF_UNREFERENCED
const EBL_COMMAND_TABLE mCmdHwIoDebugTemplate
[] =
125 "[.{1|2|4}] Port ; IO read of width byte(s) from Port",
131 "[.{1|2|4}] Port Data ; IO write Data of width byte(s) to Port",
140 Initialize the commands in this in this file
143 EblInitializemdHwIoDebugCmds (
147 if (FeaturePcdGet (PcdEmbeddedIoEnable
)) {
148 EblAddCommands (mCmdHwIoDebugTemplate
, sizeof (mCmdHwIoDebugTemplate
)/sizeof (EBL_COMMAND_TABLE
));