the component of shellpkg
.inf
[Defines]
INF_VERSION = 0x00010006
BASE_NAME = ShellParamApp
FILE_GUID = 079E8E98-AE93-4b9a-8A71-1DC869F23E0A
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = ShellCEntryLib
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
#
[Sources]
ShellParamApp.c
[Packages]
MdePkg/MdePkg.dec
ShellPkg/ShellPkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
ShellCEntryLib
UefiLib
ShellLib
ShellCommandLib
.C file
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/DebugLib.h>
#include <Library/ShellCEntryLib.h>
#include <Library/ShellLib.h> //brnxxxx 20240429
#include <Library/ShellCommandLib.h> //brnxxxx 20240429
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-aa", TypeValue},
{L"-cc", TypeValue},
{NULL, TypeMax}
};
/**
UEFI application entry point which has an interface similar to a
standard C main function.
The ShellCEntryLib library instance wrappers the actual UEFI application
entry point and calls this ShellAppMain function.
@param Argc Argument count
@param Argv The parsed arguments
@retval 0 The application exited normally.
@retval Other An error occurred.
**/
INTN
EFIAPI
ShellAppMain(
IN UINTN Argc,
IN CHAR16** Argv
)
{
EFI_STATUS Status;
LIST_ENTRY* Package;
CHAR16* ProblemParam;
CONST CHAR16* ParamAA;
CONST CHAR16* ParamCC;
UINT16 intParamAA = 0;
UINT16 intParamCC = 0;
ProblemParam = NULL;
Status = ShellInitialize();
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_INFO, "[ZK] !!!ShellInitialize Fail!,Status :%r.\n", Status));
}
Status = CommandInit();
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_INFO, "[ZK] !!!CommandInit Fail!,Status :%r.\n", Status));
}
Status = ShellCommandLineParse(ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_INFO, "[ZK] !!!ShellCommandLineParse Fail!,Status :%r.\n", Status));
}
else {
if (ShellCommandLineGetFlag(Package, L"-aa")) { //-a
ParamAA = ShellCommandLineGetValue(Package, L"-aa");
if (ParamAA != NULL) {
DEBUG((EFI_D_INFO, "ParamAA = %s\n", ParamAA));
intParamAA = (UINT8)ShellStrToUintn(ParamAA);
}
}
if (ShellCommandLineGetFlag(Package, L"-cc")) { //-b
ParamCC = ShellCommandLineGetValue(Package, L"-cc");
if (ParamAA != NULL) {
DEBUG((EFI_D_INFO, "ParamCC = %s\n", ParamCC));
intParamCC = (UINT8)ShellStrToUintn(ParamCC);
}
}
// free the command line package
ShellCommandLineFreeVarList(Package);
}
Print(L"intParamAA = %d,intParamCC = %d\n", intParamAA, intParamCC);
Print(L"-----------------------------------\n");
return EFI_SUCCESS;
}