这里介绍如何获得Shell下的命令行参数。关键代码很简单,如下:
EFI_STATUS EFIAPI ShellAppMain ( IN UINTN Argc, IN CHAR16 **Argv ) { UINTN i; Print (L"Total %d args\n",Argc); for (i=0;i<Argc;i++) { Print (L"Arg[%d]= %s \n",i,*(Argv+i)); } return EFI_SUCCESS; }
完整的代码 HelloWorld2
then how to obtain shell parameters without using ShellPkg? exp. using gnu-efi , or using entry "UefiMain" in edk2?
The parameters is just for Shell Application. It's not a feature of UEFI. I don't think there will be a way to get parameters without thses protocols.
In edk2 , ShellPkg use EFI_SHELL_PARAMETERS_PROTOCOL (or EfiShellParametersProtocol) to transfer parameters to ShellCEntryLib.
anyway I can just do what ShellCEntryLib do to get shell parameters.