本文整理汇总了C++中ShellCommandLineGetRawValue函数的典型用法代码示例。如果您正苦于以下问题:C++ ShellCommandLineGetRawValue函数的具体用法?C++ ShellCommandLineGetRawValue怎么用?C++ ShellCommandLineGetRawValue使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ShellCommandLineGetRawValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Image
/**
Function for 'stall' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunStall (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
UINT64 Intermediate;
ShellStatus = SHELL_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Status = ShellConvertStringToUint64(ShellCommandLineGetRawValue(Package, 1), &Intermediate, FALSE, FALSE);
if (EFI_ERROR(Status) || ((UINT64)(UINTN)(Intermediate)) != Intermediate) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel1HiiHandle, ShellCommandLineGetRawValue(Package, 1));
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Status = gBS->Stall((UINTN)Intermediate);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_STALL_FAILED), gShellLevel1HiiHandle, Status);
ShellStatus = SHELL_DEVICE_ERROR;
}
}
}
ShellCommandLineFreeVarList (Package);
}
return (ShellStatus);
}
示例2: PrepareFirmwareImage
STATIC
EFI_STATUS
PrepareFirmwareImage (
IN LIST_ENTRY *CheckPackage,
IN OUT SHELL_FILE_HANDLE *FileHandle,
IN OUT UINTN **FileBuffer,
IN OUT UINT64 *FileSize
)
{
CONST CHAR16 *FileStr;
EFI_STATUS Status;
UINT64 OpenMode;
UINTN *Buffer;
// Parse string from commandline
FileStr = ShellCommandLineGetRawValue (CheckPackage, 1);
if (FileStr == NULL) {
Print (L"%s: No image specified\n", CMD_NAME_STRING);
return EFI_INVALID_PARAMETER;
} else {
Status = ShellIsFile (FileStr);
if (EFI_ERROR(Status)) {
Print (L"%s: File not found\n", CMD_NAME_STRING);
return EFI_INVALID_PARAMETER;
}
}
// Obtain file size
OpenMode = EFI_FILE_MODE_READ;
Status = ShellOpenFileByName (FileStr, FileHandle, OpenMode, 0);
if (EFI_ERROR (Status)) {
Print (L"%s: Cannot open Image file\n", CMD_NAME_STRING);
return EFI_DEVICE_ERROR;
}
Status = FileHandleGetSize (*FileHandle, FileSize);
if (EFI_ERROR (Status)) {
Print (L"%s: Cannot get Image file size\n", CMD_NAME_STRING);
}
// Read Image header into buffer
Buffer = AllocateZeroPool (*FileSize);
Status = FileHandleRead (*FileHandle, (UINTN *)FileSize, Buffer);
if (EFI_ERROR (Status)) {
Print (L"%s: Cannot read Image file header\n", CMD_NAME_STRING);
ShellCloseFile (FileHandle);
FreePool (Buffer);
return EFI_DEVICE_ERROR;
}
*FileBuffer = Buffer;
return EFI_SUCCESS;
}
示例3: Image
/**
Function for 'openinfo' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunOpenInfo (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
EFI_HANDLE TheHandle;
CONST CHAR16 *Param1;
UINT64 Intermediate;
ShellStatus = SHELL_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"openinfo", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) > 2){
//
// error for too many parameters
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"openinfo");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) == 0) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle, L"openinfo");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Param1 = ShellCommandLineGetRawValue(Package, 1);
Status = ShellConvertStringToUint64(Param1, &Intermediate, TRUE, FALSE);
if (EFI_ERROR(Status) || Param1 == NULL || ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"openinfo", Param1);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
TheHandle = ConvertHandleIndexToHandle((UINTN)Intermediate);
ASSERT(TheHandle != NULL);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_OPENINFO_HEADER_LINE), gShellDriver1HiiHandle, (UINTN)Intermediate, TheHandle);
Status = TraverseHandleDatabase (TheHandle);
if (!EFI_ERROR(Status)) {
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"openinfo", Param1);
ShellStatus = SHELL_NOT_FOUND;
}
}
}
}
return (ShellStatus);
}
示例4: Image
/**
Function for 'setsize' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunSetSize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Temp1;
UINTN NewSize;
UINTN LoopVar;
SHELL_FILE_HANDLE FileHandle;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"setsize", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) < 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"setsize");
ShellStatus = SHELL_INVALID_PARAMETER;
NewSize = 0;
} else {
Temp1 = ShellCommandLineGetRawValue(Package, 1);
if (!ShellIsHexOrDecimalNumber(Temp1, FALSE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SIZE_NOT_SPEC), gShellDebug1HiiHandle, L"setsize");
ShellStatus = SHELL_INVALID_PARAMETER;
NewSize = 0;
} else {
NewSize = ShellStrToUintn(Temp1);
}
}
for (LoopVar = 2 ; LoopVar < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS ; LoopVar++) {
Status = ShellOpenFileByName(ShellCommandLineGetRawValue(Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0);
if (EFI_ERROR(Status)) {
Status = ShellOpenFileByName(ShellCommandLineGetRawValue(Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
}
if (EFI_ERROR(Status) && LoopVar == 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle, L"setsize");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"setsize", ShellCommandLineGetRawValue(Package, LoopVar));
ShellStatus = SHELL_INVALID_PARAMETER;
break;
} else {
Status = FileHandleSetSize(FileHandle, NewSize);
if (Status == EFI_VOLUME_FULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_VOLUME_FULL), gShellDebug1HiiHandle, L"setsize");
ShellStatus = SHELL_VOLUME_FULL;
} else if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_FAIL), gShellDebug1HiiHandle, L"setsize", ShellCommandLineGetRawValue(Package, LoopVar));
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_DONE), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, LoopVar));
}
ShellCloseFile(&FileHandle);
}
}
ShellCommandLineFreeVarList (Package);
}
return (ShellStatus);
}
示例5: Image
/**
Function for 'time' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunTime (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
EFI_TIME TheTime;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
INT16 Tz;
UINT8 Daylight;
CONST CHAR16 *TempLocation;
UINTN TzMinutes;
//
// Initialize variables
//
ShellStatus = SHELL_SUCCESS;
ProblemParam = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
if (PcdGet8(PcdShellSupportLevel) == 2) {
Status = ShellCommandLineParseEx (TimeParamList2, &Package, &ProblemParam, TRUE, TRUE);
} else {
ASSERT(PcdGet8(PcdShellSupportLevel) == 3);
Status = ShellCommandLineParseEx (TimeParamList3, &Package, &ProblemParam, TRUE, TRUE);
}
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"time", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// check for "-?"
//
Status = gRT->GetTime(&TheTime, NULL);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", Status);
return (SHELL_DEVICE_ERROR);
}
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
} else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"time");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// If there are no parameters, then print the current time
//
if (ShellCommandLineGetRawValue(Package, 1) == NULL
&& !ShellCommandLineGetFlag(Package, L"-d")
&& !ShellCommandLineGetFlag(Package, L"-tz")) {
//
// ShellPrintEx the current time
//
if (TheTime.TimeZone == EFI_UNSPECIFIED_TIMEZONE) {
TzMinutes = 0;
} else {
TzMinutes = (ABS(TheTime.TimeZone)) % 60;
}
if (TheTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_TIME_FORMAT),
gShellLevel2HiiHandle,
TheTime.Hour,
TheTime.Minute,
TheTime.Second,
(TheTime.TimeZone > 0?L"-":L"+"),
((ABS(TheTime.TimeZone)) / 60),
TzMinutes
);
} else {
ShellPrintHiiEx (
-1,
//.........这里部分代码省略.........
示例6: Image
/**
Function for 'compress' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunEfiCompress (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
SHELL_FILE_HANDLE InShellFileHandle;
SHELL_FILE_HANDLE OutShellFileHandle;
UINT64 OutSize;
UINTN OutSize2;
VOID *OutBuffer;
UINT64 InSize;
UINTN InSize2;
VOID *InBuffer;
CHAR16 *InFileName;
CONST CHAR16 *OutFileName;
CONST CHAR16 *TempParam;
InFileName = NULL;
OutFileName = NULL;
OutSize = 0;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
OutBuffer = NULL;
InShellFileHandle = NULL;
OutShellFileHandle = NULL;
InBuffer = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"eficompress", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) > 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"eficompress");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) < 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"eficompress");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
TempParam = ShellCommandLineGetRawValue(Package, 1);
ASSERT(TempParam != NULL);
InFileName = ShellFindFilePath(TempParam);
OutFileName = ShellCommandLineGetRawValue(Package, 2);
if (InFileName == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, L"eficompress", TempParam);
ShellStatus = SHELL_NOT_FOUND;
} else {
if (ShellIsDirectory(InFileName) == EFI_SUCCESS){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", InFileName);
ShellStatus = SHELL_INVALID_PARAMETER;
}
if (ShellIsDirectory(OutFileName) == EFI_SUCCESS){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"eficompress", OutFileName);
ShellStatus = SHELL_INVALID_PARAMETER;
}
if (ShellStatus == SHELL_SUCCESS) {
Status = ShellOpenFileByName(InFileName, &InShellFileHandle, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue(Package, 1));
ShellStatus = SHELL_NOT_FOUND;
}
Status = ShellOpenFileByName(OutFileName, &OutShellFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"eficompress", ShellCommandLineGetRawValue(Package, 2));
ShellStatus = SHELL_NOT_FOUND;
}
}
if (ShellStatus == SHELL_SUCCESS) {
Status = gEfiShellProtocol->GetFileSize(InShellFileHandle, &InSize);
ASSERT_EFI_ERROR(Status);
InBuffer = AllocateZeroPool((UINTN)InSize);
//.........这里部分代码省略.........
示例7: Image
/**
Function for 'touch' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunTouch (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
CONST CHAR16 *Param;
SHELL_STATUS ShellStatus;
UINTN ParamCount;
EFI_SHELL_FILE_INFO *FileList;
EFI_SHELL_FILE_INFO *Node;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
ParamCount = 0;
FileList = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"touch", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
}
if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
//
// we insufficient parameters
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle, L"touch");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// get a list with each file specified by parameters
// if parameter is a directory then add all the files below it to the list
//
for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)
; Param != NULL
; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)
){
Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, &FileList);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"touch", (CHAR16*)Param);
ShellStatus = SHELL_NOT_FOUND;
break;
}
//
// make sure we completed the param parsing sucessfully...
// Also make sure that any previous action was sucessful
//
if (ShellStatus == SHELL_SUCCESS) {
//
// check that we have at least 1 file
//
if (FileList == NULL || IsListEmpty(&FileList->Link)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, L"touch", Param);
continue;
} else {
//
// loop through the list and make sure we are not aborting...
//
for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)
; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()
; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)
){
//
// make sure the file opened ok
//
if (EFI_ERROR(Node->Status)){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Node->FileName);
//.........这里部分代码省略.........
示例8: Image
/**
Function for 'dblk' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunDblk (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *BlockName;
CONST CHAR16 *LbaString;
CONST CHAR16 *BlockCountString;
UINT64 Lba;
UINT64 BlockCount;
EFI_DEVICE_PATH_PROTOCOL *DevPath;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) > 4) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) < 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// Parse the params
//
BlockName = ShellCommandLineGetRawValue(Package, 1);
LbaString = ShellCommandLineGetRawValue(Package, 2);
BlockCountString = ShellCommandLineGetRawValue(Package, 3);
if (LbaString == NULL) {
Lba = 0;
} else {
if (!ShellIsHexOrDecimalNumber(LbaString, TRUE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, LbaString);
ShellStatus = SHELL_INVALID_PARAMETER;
}
ShellConvertStringToUint64(LbaString, &Lba, TRUE, FALSE);
}
if (BlockCountString == NULL) {
BlockCount = 1;
} else {
if (!ShellIsHexOrDecimalNumber(BlockCountString, TRUE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, BlockCountString);
ShellStatus = SHELL_INVALID_PARAMETER;
}
ShellConvertStringToUint64(BlockCountString, &BlockCount, TRUE, FALSE);
if (BlockCount > 0x10) {
BlockCount = 0x10;
} else if (BlockCount == 0) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, BlockCountString);
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
if (ShellStatus == SHELL_SUCCESS) {
//
// do the work if we have a valid block identifier
//
if (gEfiShellProtocol->GetDevicePathFromMap(BlockName) == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, BlockName);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
DevPath = (EFI_DEVICE_PATH_PROTOCOL*)gEfiShellProtocol->GetDevicePathFromMap(BlockName);
if (gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &DevPath, NULL) == EFI_NOT_FOUND) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MAP_PROTOCOL), gShellDebug1HiiHandle, BlockName, L"BlockIo");
//.........这里部分代码省略.........
示例9: Image
/**
Function for 'date' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunDate (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
EFI_TIME TheTime;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Param1;
ShellStatus = SHELL_SUCCESS;
ProblemParam = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
} else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// If there are 0 value parameters, then print the current date
// else If there are any value paramerers, then print error
//
if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
//
// get the current date
//
Status = gRT->GetTime(&TheTime, NULL);
ASSERT_EFI_ERROR(Status);
//
// ShellPrintEx the date in SFO or regular format
//
if (ShellCommandLineGetFlag(Package, L"-sfo")) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DATE_SFO_FORMAT), gShellLevel2HiiHandle, TheTime.Month, TheTime.Day, TheTime.Year);
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DATE_FORMAT), gShellLevel2HiiHandle, TheTime.Month, TheTime.Day, TheTime.Year);
}
} else {
if (PcdGet8(PcdShellSupportLevel) == 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// perform level 3 operation here.
//
Param1 = ShellCommandLineGetRawValue(Package, 1);
if (Param1 == NULL) {
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ShellStatus = CheckAndSetDate(Param1);
}
if (ShellStatus != SHELL_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, Param1);
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
}
}
}
//
// free the command line package
//
ShellCommandLineFreeVarList (Package);
//
// return the status
//
//.........这里部分代码省略.........
示例10: Image
/**
Function for 'mode' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunMode (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
UINTN NewCol;
UINTN NewRow;
UINTN Col;
UINTN Row;
CONST CHAR16 *Temp;
BOOLEAN Done;
INT32 LoopVar;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) > 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) == 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) == 3) {
Temp = ShellCommandLineGetRawValue(Package, 1);
if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
}
NewCol = ShellStrToUintn(Temp);
Temp = ShellCommandLineGetRawValue(Package, 2);
if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
}
NewRow = ShellStrToUintn(Temp);
for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) {
Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row);
if (EFI_ERROR(Status)) {
continue;
}
if (Col == NewCol && Row == NewRow) {
Status = gST->ConOut->SetMode(gST->ConOut, LoopVar);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_SET_FAIL), gShellDebug1HiiHandle, Status);
ShellStatus = SHELL_DEVICE_ERROR;
} else {
// worked fine...
Done = TRUE;
}
break;
}
}
if (!Done) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_NO_MATCH), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
}
} else if (ShellCommandLineGetCount(Package) == 1) {
//
// print out valid
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_HEAD), gShellDebug1HiiHandle);
for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) {
Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row);
//.........这里部分代码省略.........
示例11: Image
//.........这里部分代码省略.........
L"tftp", ProblemParam
);
FreePool (ProblemParam);
} else {
ASSERT (FALSE);
}
goto Error;
}
//
// Check the number of parameters
//
ParamCount = ShellCommandLineGetCount (CheckPackage);
if (ParamCount > 4) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
gShellTftpHiiHandle, L"tftp"
);
goto Error;
}
if (ParamCount < 3) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW),
gShellTftpHiiHandle, L"tftp"
);
goto Error;
}
Mtftp4ConfigData = DefaultMtftp4ConfigData;
//
// Check the host IPv4 address
//
ValueStr = ShellCommandLineGetRawValue (CheckPackage, 1);
Status = NetLibStrToIp4 (ValueStr, &Mtftp4ConfigData.ServerIp);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
gShellTftpHiiHandle, L"tftp", ValueStr
);
goto Error;
}
RemoteFilePath = ShellCommandLineGetRawValue (CheckPackage, 2);
AsciiRemoteFilePath = AllocatePool (
(StrLen (RemoteFilePath) + 1) * sizeof (CHAR8)
);
if (AsciiRemoteFilePath == NULL) {
ShellStatus = SHELL_OUT_OF_RESOURCES;
goto Error;
}
UnicodeStrToAsciiStr (RemoteFilePath, AsciiRemoteFilePath);
if (ParamCount == 4) {
LocalFilePath = ShellCommandLineGetRawValue (CheckPackage, 3);
} else {
Walker = RemoteFilePath + StrLen (RemoteFilePath);
while ((--Walker) >= RemoteFilePath) {
if ((*Walker == L'\\') ||
(*Walker == L'/' ) ) {
break;
}
}
LocalFilePath = Walker + 1;
}
示例12: Image
/**
Function for 'hexedit' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunHexEdit (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
CHAR16 *Buffer;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
LIST_ENTRY *Package;
CHAR16 *NewName;
CONST CHAR16 *Name;
UINTN Offset;
UINTN Size;
EDIT_FILE_TYPE WhatToDo;
Buffer = NULL;
ShellStatus = SHELL_SUCCESS;
NewName = NULL;
Buffer = NULL;
Name = NULL;
Offset = 0;
Size = 0;
WhatToDo = FileTypeNone;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
// ASSERT_EFI_ERROR(Status);
Status = CommandInit();
// ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) {
return SHELL_UNSUPPORTED;
}
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"hexedit", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} /* else {
ASSERT(FALSE);
} */
} else {
//
// Check for -d
//
if (ShellCommandLineGetFlag(Package, L"-d")){
if (ShellCommandLineGetCount(Package) < 4) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) > 4) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
WhatToDo = FileTypeDiskBuffer;
Name = ShellCommandLineGetRawValue(Package, 1);
Offset = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 2));
Size = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 3));
}
if (Offset == (UINTN)-1 || Size == (UINTN)-1) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"hexedit", L"-d");
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
//
// check for -f
//
if (ShellCommandLineGetFlag(Package, L"-f") && (WhatToDo == FileTypeNone)){
if (ShellCommandLineGetCount(Package) < 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) > 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Name = ShellCommandLineGetRawValue(Package, 1);
if (Name == NULL || !IsValidFileName(Name)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"hexedit", Name);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
WhatToDo = FileTypeFileBuffer;
}
}
//.........这里部分代码省略.........
示例13: Image
/**
Function for 'disconnect' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunDisconnect (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Param1;
CONST CHAR16 *Param2;
CONST CHAR16 *Param3;
EFI_HANDLE Handle1;
EFI_HANDLE Handle2;
EFI_HANDLE Handle3;
UINT64 Intermediate1;
UINT64 Intermediate2;
UINT64 Intermediate3;
ShellStatus = SHELL_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
if (ShellCommandLineGetFlag(Package, L"-r")){
if (ShellCommandLineGetCount(Package) > 1){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) < 1) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Status = DisconnectAll();
}
} else {
if (ShellCommandLineGetCount(Package) > 4){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) < 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// must have between 1 and 3 handles passed in ...
//
Param1 = ShellCommandLineGetRawValue(Package, 1);
Param2 = ShellCommandLineGetRawValue(Package, 2);
Param3 = ShellCommandLineGetRawValue(Package, 3);
ShellConvertStringToUint64(Param1, &Intermediate1, TRUE, FALSE);
Handle1 = Param1!=NULL?ConvertHandleIndexToHandle((UINTN)Intermediate1):NULL;
ShellConvertStringToUint64(Param2, &Intermediate2, TRUE, FALSE);
Handle2 = Param2!=NULL?ConvertHandleIndexToHandle((UINTN)Intermediate2):NULL;
ShellConvertStringToUint64(Param3, &Intermediate3, TRUE, FALSE);
Handle3 = Param3!=NULL?ConvertHandleIndexToHandle((UINTN)Intermediate3):NULL;
if (Param1 != NULL && Handle1 == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param1);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (Param2 != NULL && Handle2 == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param2);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (Param3 != NULL && Handle3 == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param3);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiDevicePathProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
ASSERT(Param1 != NULL);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, ShellStrToUintn(Param1), L"controller handle");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (Handle2 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
ASSERT(Param2 != NULL);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, ShellStrToUintn(Param2), L"driver handle");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//.........这里部分代码省略.........
示例14: Image
/**
Function for 'devices' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunDevices (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CHAR8 *Language;
EFI_HANDLE *HandleList;
EFI_HANDLE *HandleListWalker;
CHAR16 Type;
BOOLEAN Cfg;
BOOLEAN Diag;
UINTN Parents;
UINTN Devices;
UINTN Children;
CHAR16 *Name;
CONST CHAR16 *Lang;
BOOLEAN SfoFlag;
ShellStatus = SHELL_SUCCESS;
Language = NULL;
SfoFlag = FALSE;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
// ASSERT_EFI_ERROR(Status);
Status = CommandInit();
// ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) {
return SHELL_UNSUPPORTED;
}
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"devices", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} /* else {
ASSERT(FALSE);
} */
} else {
//
// if more than 0 'value' parameters we have too many parameters
//
if (ShellCommandLineGetRawValue(Package, 1) != NULL){
//
// error for too many parameters
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"devices");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// get the language if necessary
//
Lang = ShellCommandLineGetValue(Package, L"-l");
if (Lang != NULL) {
Language = AllocateZeroPool(StrSize(Lang));
AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
} else if (!ShellCommandLineGetFlag(Package, L"-l")){
ASSERT(Language == NULL);
// Language = AllocateZeroPool(10);
// AsciiSPrint(Language, 10, "en-us");
} else {
ASSERT(Language == NULL);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"devices", L"-l");
ShellCommandLineFreeVarList (Package);
return (SHELL_INVALID_PARAMETER);
}
//
// Print Header
//
if (ShellCommandLineGetFlag (Package, L"-sfo")) {
ShellPrintHiiEx (-1, -1, Language, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellDriver1HiiHandle, L"devices");
SfoFlag = TRUE;
} else {
ShellPrintHiiEx (-1, -1, Language, STRING_TOKEN (STR_DEVICES_HEADER_LINES), gShellDriver1HiiHandle);
}
//.........这里部分代码省略.........
示例15: ShellCommandRotate
/**
* Function executed when the rotate command is entered
*
* @param ImageHandle Pointer to the Image handle of this driver
* @param SystemTable Pointer to the EFI_SYSTEM_TABLE
*
* @retval EFI_SUCCESS Command always returns success
**/
SHELL_STATUS EFIAPI ShellCommandRotate(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
CONST CHAR16 *Temp;
UINT64 Rotate = (UINTN)-1;
UINT64 HandleNumber = (UINT64)(-1);
GRAPHICS_OUTPUT_PROTOCOL_ROTATE_PROTOCOL *GopRotate = NULL;
EFI_HANDLE Handle = NULL;
Status = ShellCommandLineParse(ParamList, &Package, &ProblemParam, TRUE);
if(EFI_ERROR(Status))
{
Print(L"Problem Param! %s\n", ProblemParam);
gBS->FreePool(ProblemParam);
return SHELL_INVALID_PARAMETER;
}
if(ShellCommandLineGetCount(Package) == 1)
{
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_GEN_TOO_FEW), gGopRotateShellCommandHiiHandle, L"rotate");
return SHELL_INVALID_PARAMETER;
}
if(ShellCommandLineGetCount(Package) > 3)
{
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_GEN_TOO_MANY), gGopRotateShellCommandHiiHandle, L"rotate");
return SHELL_INVALID_PARAMETER;
}
Temp = ShellCommandLineGetRawValue(Package, 1);
if(Temp != NULL)
{
Status = ShellConvertStringToUint64(Temp, &HandleNumber, TRUE, TRUE);
}
Temp = ShellCommandLineGetRawValue(Package, 2);
if(Temp != NULL)
{
Status = ShellConvertStringToUint64(Temp, &Rotate, TRUE, TRUE);
}
Handle = ConvertHandleIndexToHandle((UINTN)HandleNumber);
Status = gBS->HandleProtocol(Handle, &gGraphicsOutputProtocolRotateProtocolGuid, (VOID**)&GopRotate);
if(EFI_ERROR(Status))
{
Print(L"No Gop Rotate Protocol found on device\n");
}
else
{
switch(Rotate)
{
case 0:
GopRotate->SetRotation(GopRotate, Rotate0);
break;
case 0x90:
GopRotate->SetRotation(GopRotate, Rotate90);
break;
case 0x180:
GopRotate->SetRotation(GopRotate, Rotate180);
break;
case 0x270:
GopRotate->SetRotation(GopRotate, Rotate270);
break;
default:
Print(L"Invalid paramter \"%s\" for rotate angle\n", Temp);
Print(L"Expected: 0, 90, 180 or 270\n");
break;
}
}
return EFI_SUCCESS;
}