/** @file
Main file for Mm shell Debug1 function.
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellDebug1CommandsLib.h"
#include <Library/ShellLib.h>
#include <Protocol/PciRootBridgeIo.h>
#include <Protocol/DeviceIo.h>
typedef enum {
{L"-mmio", TypeFlag},
{L"-mem", TypeFlag},
{L"-io", TypeFlag},
{L"-pci", TypeFlag},
{L"-pcie", TypeFlag},
{L"-n", TypeFlag},
{L"-w", TypeValue},
};
/**
Read some data into a buffer from memory.
@param[in] Width The width of each read.
@param[in] Addresss The memory location to start reading at.
@param[in] Size The size of Buffer in Width sized units.
@param[out] Buffer The buffer to read into.
**/
ReadMem (
)
{
//
// This function is defective. This ASSERT prevents the defect from affecting anything.
//
do {
if (Width == EfiPciWidthUint8) {
Address -= 1;
} else if (Width == EfiPciWidthUint16) {
Address -= 2;
} else if (Width == EfiPciWidthUint32) {
Address -= 4;
} else if (Width == EfiPciWidthUint64) {
Address -= 8;
} else {
break;
}
Size--;
} while (Size > 0);
}
/**
Write some data to memory.
@param[in] Width The width of each write.
@param[in] Addresss The memory location to start writing at.
@param[in] Size The size of Buffer in Width sized units.
@param[in] Buffer The buffer to write from.
**/
WriteMem (
)
{
//
// This function is defective. This ASSERT prevents the defect from affecting anything.
//
do {
if (Width == EfiPciWidthUint8) {
Address += 1;
} else if (Width == EfiPciWidthUint16) {
Address += 2;
} else if (Width == EfiPciWidthUint32) {
Address += 4;
} else if (Width == EfiPciWidthUint64) {
Address += 8;
} else {
}
//
//
//
Size--;
} while (Size > 0);
}
/**
Convert a string to it's hex data.
@param[in] str The pointer to the string of hex data.
@param[out] data The pointer to the buffer to fill. Valid upon a TRUE return.
@retval TRUE The conversion was successful.
@retval FALSE The conversion failed.
**/
GetHex (
)
{
//
// convert hex digits
//
TempUint = 0;
}
if (TempChar == ' ') {
break;
}
} else {
return FALSE;
}
}
return Find;
}
/**
Get the PCI-E Address from a PCI address format 0x0000ssbbddffrrr
where ss is SEGMENT, bb is BUS, dd is DEVICE, ff is FUNCTION
and rrr is REGISTER (extension format for PCI-E).
@param[in] InputAddress PCI address format on input.
@param[out]PciEAddress PCI-E address extention format.
**/
)
{
}
/**
Function for 'mm' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
)
{
// CHAR16 *ValueStr;
Address = 0;
PciEAddress = 0;
HandleBuffer = NULL;
BufferSize = 0;
SegmentNumber = 0;
//
// Parse arguments
//
Size = 1;
AddressStr = NULL;
// ValueStr = NULL;
Interactive = TRUE;
goto Done;
} else {
}
} else {
goto Done;
goto Done;
} else if (ShellCommandLineGetFlag(Package, L"-w") && ShellCommandLineGetValue(Package, L"-w") == NULL) {
goto Done;
} else {
){
goto Done;
}
){
goto Done;
}
AccessType = EfiIo;
){
goto Done;
}
){
goto Done;
}
}
}
Interactive = FALSE;
}
switch (ItemValue) {
case 1:
Size = 1;
break;
case 2:
Size = 2;
break;
case 4:
Size = 4;
break;
case 8:
Size = 8;
break;
default:
goto Done;
}
}
if (!ShellIsHexOrDecimalNumber(Temp, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp, (UINT64*)&Address, TRUE, FALSE))) {
goto Done;
}
if (!ShellIsHexOrDecimalNumber(Temp, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp, &Value, TRUE, FALSE))) {
goto Done;
}
switch (Size) {
case 1:
if (Value > 0xFF) {
}
break;
case 2:
if (Value > 0xFFFF) {
}
break;
case 4:
if (Value > 0xFFFFFFFF) {
}
break;
default:
break;
}
if (ShellStatus != SHELL_SUCCESS) {
goto Done;
}
}
goto Done;
}
//
// locate DeviceIO protocol interface
//
if (AccessType != EfiMemory) {
NULL,
);
goto Done;
}
//
// In the case of PCI or PCIE
// Get segment number and mask the segment bits in Address
//
if (AccessType == EfiPciEConfig) {
Address &= 0xfffffffffULL;
} else {
if (AccessType == EfiPciConfig) {
Address &= 0xffffffff;
}
}
//
// Find the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL of the specified segment number
//
);
continue;
}
}
}
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_SEGMENT_NOT_FOUND), gShellDebug1HiiHandle, SegmentNumber);
goto Done;
}
}
goto Done;
}
if (AccessType == EfiPciEConfig) {
}
//
// Set value
//
if (AccessType == EFIMemoryMappedIo) {
} else if (AccessType == EfiIo) {
} else if (AccessType == EfiPciConfig) {
} else if (AccessType == EfiPciEConfig) {
} else {
}
goto Done;
}
//
// non-interactive mode
//
if (!Interactive) {
Buffer = 0;
if (AccessType == EFIMemoryMappedIo) {
} else if (AccessType == EfiIo) {
} else if (AccessType == EfiPciConfig) {
} else if (AccessType == EfiPciEConfig) {
} else {
}
if (Size == 1) {
} else if (Size == 2) {
} else if (Size == 4) {
} else if (Size == 8) {
}
goto Done;
}
//
// interactive mode
//
do {
break;
}
Buffer = 0;
if (AccessType == EFIMemoryMappedIo) {
} else if (AccessType == EfiIo) {
} else if (AccessType == EfiPciConfig) {
} else if (AccessType == EfiPciEConfig) {
} else {
}
if (Size == 1) {
} else if (Size == 2) {
} else if (Size == 4) {
} else if (Size == 8) {
}
//
// wait user input to modify
//
}
//
// skip space characters
//
//
// parse input string
//
if (InputStr != NULL && (InputStr[Index] == '.' || InputStr[Index] == 'q' || InputStr[Index] == 'Q')) {
//
// Continue to next address
//
if (AccessType == EFIMemoryMappedIo) {
} else if (AccessType == EfiIo) {
} else if (AccessType == EfiPciConfig) {
} else if (AccessType == EfiPciEConfig) {
} else {
}
} else {
continue;
// PrintToken (STRING_TOKEN (STR_IOMOD_ERROR), HiiHandle);
}
if (AccessType == EfiPciEConfig) {
}
// Print (L"\n");
} while (!Complete);
}
Done:
}
if (HandleBuffer != NULL) {
}
}
return ShellStatus;
}