/** @file
Main file for NULL named library for debug1 profile shell command functions.
Copyright (c) 2010 - 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"
/**
Gets the debug file name. This will be used if HII is not working.
@retval NULL No file is available.
@return The NULL-terminated filename to get help from.
**/
)
{
return (mFileName);
}
/**
Constructor for the Shell Debug1 Commands library.
@param ImageHandle the image handle of the process
@param SystemTable the EFI System Table pointer
@retval EFI_SUCCESS the shell command handlers were installed sucessfully
@retval EFI_UNSUPPORTED the shell level required was not found.
**/
)
{
//
// check our bit of the profiles mask
//
return (EFI_SUCCESS);
}
//
// install the HII stuff.
//
gShellDebug1HiiHandle = HiiAddPackages (&gShellDebug1HiiGuid, gImageHandle, UefiShellDebug1CommandsLibStrings, NULL);
if (gShellDebug1HiiHandle == NULL) {
return (EFI_DEVICE_ERROR);
}
//
// install our shell command handlers that are always installed
//
ShellCommandRegisterCommandName(L"setsize", ShellCommandRunSetSize , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETSIZE) );
ShellCommandRegisterCommandName(L"comp", ShellCommandRunComp , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_COMP) );
ShellCommandRegisterCommandName(L"mode", ShellCommandRunMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MODE) );
ShellCommandRegisterCommandName(L"memmap", ShellCommandRunMemMap , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MEMMAP) );
ShellCommandRegisterCommandName(L"eficompress", ShellCommandRunEfiCompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFICOMPRESS) );
ShellCommandRegisterCommandName(L"efidecompress", ShellCommandRunEfiDecompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFIDCOMPRESS) );
ShellCommandRegisterCommandName(L"dmem", ShellCommandRunDmem , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMEM) );
ShellCommandRegisterCommandName(L"loadpcirom", ShellCommandRunLoadPciRom , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_LOAD_PCI_ROM) );
ShellCommandRegisterCommandName(L"mm", ShellCommandRunMm , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MM) );
ShellCommandRegisterCommandName(L"setvar", ShellCommandRunSetVar , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETVAR) );
ShellCommandRegisterCommandName(L"sermode", ShellCommandRunSerMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SERMODE) );
ShellCommandRegisterCommandName(L"pci", ShellCommandRunPci , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_PCI) );
ShellCommandRegisterCommandName(L"smbiosview", ShellCommandRunSmbiosView , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SMBIOSVIEW) );
ShellCommandRegisterCommandName(L"dmpstore", ShellCommandRunDmpStore , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMPSTORE) );
ShellCommandRegisterCommandName(L"dblk", ShellCommandRunDblk , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DBLK) );
ShellCommandRegisterCommandName(L"edit", ShellCommandRunEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EDIT) );
ShellCommandRegisterCommandName(L"hexedit", ShellCommandRunHexEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_HEXEDIT) );
//
// check install profile bit of the profiles mask is set
//
ShellCommandRegisterCommandName(L"bcfg", ShellCommandRunBcfg , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_BCFG) );
}
return (EFI_SUCCESS);
}
/**
Destructor for the library. free any resources.
@param ImageHandle The image handle of the process.
@param SystemTable The EFI System Table pointer.
**/
)
{
if (gShellDebug1HiiHandle != NULL) {
}
return (EFI_SUCCESS);
}
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F'
};
/**
Dump some hexadecimal data to the screen.
@param[in] Indent How many spaces to indent the output.
@param[in] Offset The offset of the printing.
@param[in] DataSize The size in bytes of UserData.
@param[in] UserData The data to print out.
**/
DumpHex (
)
{
while (DataSize != 0) {
Size = 16;
}
}
}
}
/**
Convert a Unicode character to upper case only if
it maps to a valid small-case ASCII character.
This internal function only deal with Unicode character
which maps to a valid small-case ASCII character, i.e.
L'a' to L'z'. For other Unicode character, the input character
is returned directly.
@param Char The character to convert.
@retval LowerCharacter If the Char is with range L'a' to L'z'.
@retval Unchanged Otherwise.
//Stolen from MdePkg Baselib
**/
)
{
}
return Char;
}
/**
Function returns a system configuration table that is stored in the
EFI System Table based on the provided GUID.
@param[in] TableGuid A pointer to the table's GUID type.
@param[in, out] Table On exit, a pointer to a system configuration table.
@retval EFI_SUCCESS A configuration table matching TableGuid was found.
@retval EFI_NOT_FOUND A configuration table matching TableGuid was not found.
**/
)
{
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}
/**
Convert a Unicode character to numerical value.
This internal function only deal with Unicode character
which maps to a valid hexadecimal ASII character, i.e.
L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other
Unicode character, the value returned does not make sense.
@param Char The character to convert.
@return The numerical value converted.
**/
)
{
return Char - L'0';
}
}
/**
Convert a string representation of a guid to a Guid value.
@param[in] StringGuid The pointer to the string of a guid.
@param[in, out] Guid The pointer to the GUID structure to populate.
@retval EFI_INVALID_PARAMETER A parameter was invalid.
@retval EFI_SUCCESS The conversion was successful.
**/
)
{
if (StringGuid == NULL) {
return (EFI_INVALID_PARAMETER);
return (EFI_INVALID_PARAMETER);
}
return (EFI_OUT_OF_RESOURCES);
}
}
return (Status);
}
Walker += 9;
}
return (Status);
}
Walker += 5;
}
return (Status);
}
Walker += 5;
Walker += 2;
Walker += 3;
Walker += 2;
Walker += 2;
Walker += 2;
Walker += 2;
Walker += 2;
return (EFI_SUCCESS);
}
/**
Clear the line at the specified Row.
@param[in] Row The row number to be cleared ( start from 1 )
@param[in] LastCol The last printable column.
@param[in] LastRow The last printable row.
**/
)
{
if (Row == 0) {
Row = 1;
}
//
// prepare a blank line
//
//
// if CHAR_NULL is still at position 80, it will cause first line error
//
} else {
}
//
// print out the blank line
//
}
/**
Determine if the character is valid for a filename.
@param[in] Ch The character to test.
@retval TRUE The character is valid.
@retval FALSE The character is not valid.
**/
)
{
//
// See if there are any illegal characters within the name
//
if (Ch < 0x20 || Ch == L'\"' || Ch == L'*' || Ch == L'/' || Ch == L'<' || Ch == L'>' || Ch == L'?' || Ch == L'|') {
return FALSE;
}
return TRUE;
}
/**
Check if file name has illegal characters.
@param Name The filename to check.
@retval TRUE The filename is ok.
@retval FALSE The filename is not ok.
**/
)
{
//
// check the length of Name
//
break;
}
}
return FALSE;
}
//
// check whether any char in Name not appears in valid file name char
//
return FALSE;
}
}
return TRUE;
}
/**
Find a filename that is valid (not taken) with the given extension.
@param[in] Extension The file extension.
@retval NULL Something went wrong.
@return the valid filename.
**/
CHAR16 *
)
{
Suffix = 0;
do {
//
// after that filename changed to path
//
if (Status == EFI_NOT_FOUND) {
return FileNameTmp;
}
FileNameTmp = NULL;
Suffix++;
} while (Suffix != 0);
return NULL;
}
/**
Read a file into an allocated buffer. The buffer is the responsibility
of the caller to free.
@param[in] FileName The filename of the file to open.
@param[out] Buffer Upon successful return, the pointer to the
address of the allocated buffer.
@param[out] BufferSize If not NULL, then the pointer to the size
of the allocated buffer.
@param[out] ReadOnly Upon successful return TRUE if the file is
read only. FALSE otherwise.
@retval EFI_NOT_FOUND The filename did not represent a file in the
file system.
@retval EFI_SUCCESS The file was read into the buffer.
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.
@retval EFI_LOAD_ERROR The file read operation failed.
@retval EFI_INVALID_PARAMETER A parameter was invalid.
@retval EFI_INVALID_PARAMETER FileName was NULL.
@retval EFI_INVALID_PARAMETER FileName was a directory.
**/
)
{
FileSize = 0;
FileHandle = NULL;
CreateFile = FALSE;
return (EFI_INVALID_PARAMETER);
}
//
// try to open the file
//
if (FileHandle == NULL) {
return EFI_LOAD_ERROR;
}
return EFI_INVALID_PARAMETER;
}
} else {
}
//
// get file size
//
} else if (Status == EFI_NOT_FOUND) {
//
// file not exists. add create and try again
//
Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
return Status;
} else {
//
// it worked. now delete it and move on with the name (now validated)
//
if (Status == EFI_WARN_DELETE_FAILURE) {
}
return Status;
}
}
//
// file doesn't exist, so set CreateFile to TRUE and can't be read-only
//
CreateFile = TRUE;
}
//
// the file exists
//
if (!CreateFile) {
//
// allocate buffer to read file
//
if (InternalBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// read file into InternalBuffer
//
FileHandle = NULL;
return EFI_LOAD_ERROR;
}
}
*Buffer = InternalBuffer;
if (BufferSize != NULL) {
*BufferSize = FileSize;
}
return (EFI_SUCCESS);
}