2009-12-06 02:57:05 +01:00
|
|
|
/** @file
|
|
|
|
Hardware IO based debug commands
|
|
|
|
|
2010-04-29 14:40:51 +02:00
|
|
|
Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
|
|
|
|
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
2015-10-29 13:59:06 +01:00
|
|
|
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
|
2009-12-06 02:57:05 +01:00
|
|
|
|
2010-04-29 14:40:51 +02:00
|
|
|
This program and the accompanying materials
|
2009-12-06 02:57:05 +01:00
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
2011-08-08 20:29:14 +02:00
|
|
|
Commands useful for debugging hardware. IO commands separated out as not all
|
2009-12-06 02:57:05 +01:00
|
|
|
processor architectures support the IO command.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "Ebl.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Read from IO space
|
|
|
|
|
2011-08-08 20:29:14 +02:00
|
|
|
Argv[0] - "ioread"[.#] # is optional width 1, 2, or 4. Default 1
|
2009-12-06 02:57:05 +01:00
|
|
|
Argv[1] - Hex IO address
|
|
|
|
|
2010-02-11 00:48:46 +01:00
|
|
|
ior.4 0x3f8 ;Do a 32-bit IO Read from 0x3f8
|
|
|
|
ior 0x3f8 ;Do a 8-bit IO Read from 0x3f8
|
2009-12-06 02:57:05 +01:00
|
|
|
|
|
|
|
@param Argc Number of command arguments in Argv
|
2014-08-19 15:29:52 +02:00
|
|
|
@param Argv Array of strings that represent the parsed command line.
|
2011-08-08 20:29:14 +02:00
|
|
|
Argv[0] is the command name
|
2009-12-06 02:57:05 +01:00
|
|
|
|
|
|
|
@return EFI_SUCCESS
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2015-10-29 13:59:06 +01:00
|
|
|
EFIAPI
|
2009-12-06 02:57:05 +01:00
|
|
|
EblIoReadCmd (
|
|
|
|
IN UINTN Argc,
|
|
|
|
IN CHAR8 **Argv
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Width;
|
|
|
|
UINTN Port;
|
|
|
|
UINTN Data;
|
|
|
|
|
|
|
|
if (Argc < 2) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
Port = AsciiStrHexToUintn (Argv[1]);
|
2010-02-11 00:48:46 +01:00
|
|
|
Width = WidthFromCommandName (Argv[0], 1);
|
2009-12-06 02:57:05 +01:00
|
|
|
|
|
|
|
if (Width == 1) {
|
|
|
|
Data = IoRead8 (Port);
|
|
|
|
} else if (Width == 2) {
|
|
|
|
Data = IoRead16 (Port);
|
|
|
|
} else if (Width == 4) {
|
|
|
|
Data = IoRead32 (Port);
|
|
|
|
} else {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
AsciiPrint ("0x%04x = 0x%x", Port, Data);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Write to IO space
|
|
|
|
|
2011-08-08 20:29:14 +02:00
|
|
|
Argv[0] - "iowrite"[.#] # is optional width 1, 2, or 4. Default 1
|
2009-12-06 02:57:05 +01:00
|
|
|
Argv[1] - Hex IO address
|
|
|
|
Argv[2] - Hex data to write
|
|
|
|
|
2010-02-11 00:48:46 +01:00
|
|
|
iow.4 0x3f8 af ;Do a 32-bit IO write of af to 0x3f8
|
|
|
|
iow 0x3f8 af ;Do an 8-bit IO write of af to 0x3f8
|
2009-12-06 02:57:05 +01:00
|
|
|
|
|
|
|
@param Argc Number of command arguments in Argv
|
2014-08-19 15:29:52 +02:00
|
|
|
@param Argv Array of strings that represent the parsed command line.
|
2011-08-08 20:29:14 +02:00
|
|
|
Argv[0] is the command name
|
2009-12-06 02:57:05 +01:00
|
|
|
|
|
|
|
@return EFI_SUCCESS
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2015-10-29 13:59:06 +01:00
|
|
|
EFIAPI
|
2009-12-06 02:57:05 +01:00
|
|
|
EblIoWriteCmd (
|
|
|
|
IN UINTN Argc,
|
|
|
|
IN CHAR8 **Argv
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Width;
|
|
|
|
UINTN Port;
|
|
|
|
UINTN Data;
|
|
|
|
|
|
|
|
if (Argc < 3) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
Port = AsciiStrHexToUintn (Argv[1]);
|
|
|
|
Data = AsciiStrHexToUintn (Argv[2]);
|
2010-02-11 00:48:46 +01:00
|
|
|
Width = WidthFromCommandName (Argv[0], 1);
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2009-12-06 02:57:05 +01:00
|
|
|
if (Width == 1) {
|
|
|
|
IoWrite8 (Port, (UINT8)Data);
|
|
|
|
} else if (Width == 2) {
|
|
|
|
IoWrite16 (Port, (UINT16)Data);
|
|
|
|
} else if (Width == 4) {
|
|
|
|
IoWrite32 (Port, (UINT32)Data);
|
|
|
|
} else {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHwIoDebugTemplate[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"ioread",
|
2010-02-11 00:48:46 +01:00
|
|
|
"[.{1|2|4}] Port ; IO read of width byte(s) from Port",
|
2009-12-06 02:57:05 +01:00
|
|
|
NULL,
|
|
|
|
EblIoReadCmd
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"iowrite",
|
2010-02-11 00:48:46 +01:00
|
|
|
"[.{1|2|4}] Port Data ; IO write Data of width byte(s) to Port",
|
2009-12-06 02:57:05 +01:00
|
|
|
NULL,
|
|
|
|
EblIoWriteCmd
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Initialize the commands in this in this file
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EblInitializemdHwIoDebugCmds (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (FeaturePcdGet (PcdEmbeddedIoEnable)) {
|
|
|
|
EblAddCommands (mCmdHwIoDebugTemplate, sizeof (mCmdHwIoDebugTemplate)/sizeof (EBL_COMMAND_TABLE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|