2 Hardware IO based debug commands
4 Copyright (c) 2007, Intel Corporation<BR>
5 Portions copyright (c) 2008-2009, Apple Inc. All rights reserved.
7 All rights reserved. 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.
28 Argv[1] - Hex IO address
29 Argv[2] - IO Width [1|2|4] with a default of 1
31 ior 0x3f8 4 ;Do a 32-bit IO Read from 0x3f8
32 ior 0x3f8 1 ;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 comamnd name
52 return EFI_INVALID_PARAMETER
;
55 Port
= AsciiStrHexToUintn (Argv
[1]);
56 Width
= (Argc
> 2) ? AsciiStrHexToUintn (Argv
[2]) : 1;
59 Data
= IoRead8 (Port
);
60 } else if (Width
== 2) {
61 Data
= IoRead16 (Port
);
62 } else if (Width
== 4) {
63 Data
= IoRead32 (Port
);
65 return EFI_INVALID_PARAMETER
;
68 AsciiPrint ("0x%04x = 0x%x", Port
, Data
);
78 Argv[1] - Hex IO address
79 Argv[2] - Hex data to write
80 Argv[3] - IO Width [1|2|4] with a default of 1
82 iow 0x3f8 af 4 ;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 comamnd name
103 return EFI_INVALID_PARAMETER
;
106 Port
= AsciiStrHexToUintn (Argv
[1]);
107 Data
= AsciiStrHexToUintn (Argv
[2]);
108 Width
= (Argc
> 3) ? AsciiStrHexToUintn (Argv
[3]) : 1;
111 IoWrite8 (Port
, (UINT8
)Data
);
112 } else if (Width
== 2) {
113 IoWrite16 (Port
, (UINT16
)Data
);
114 } else if (Width
== 4) {
115 IoWrite32 (Port
, (UINT32
)Data
);
117 return EFI_INVALID_PARAMETER
;
123 GLOBAL_REMOVE_IF_UNREFERENCED
const EBL_COMMAND_TABLE mCmdHwIoDebugTemplate
[] =
127 " Port [1|2|4]; IO read of width[1] byte(s) from Port",
133 " Port Data [1|2|4]; IO write Data of width[1] byte(s) to Port",
142 Initialize the commands in this in this file
145 EblInitializemdHwIoDebugCmds (
149 if (FeaturePcdGet (PcdEmbeddedIoEnable
)) {
150 EblAddCommands (mCmdHwIoDebugTemplate
, sizeof (mCmdHwIoDebugTemplate
)/sizeof (EBL_COMMAND_TABLE
));