12#define SHELL_MAN_HII_GUID \
14 0xf62ccd0c, 0x2449, 0x453c, { 0x8a, 0xcb, 0x8c, 0xc5, 0x7c, 0xf0, 0x2a, 0x97 } \
34 END_ENTIRE_DEVICE_PATH_SUBTYPE,
36 (UINT8)(END_DEVICE_PATH_LENGTH),
37 (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
60 if (NameString ==
NULL) {
80 (
StrSize (NameString) +
StrLen (L
".efi")*
sizeof (CHAR16))/
sizeof (CHAR16),
86 (
StrSize (NameString) +
StrLen (L
".efi")*
sizeof (CHAR16))/
sizeof (CHAR16),
114 if (ManFileName ==
NULL) {
121 if (
StrnCmp (ManFileName+
StrLen (ManFileName)-4, L
".man", 4) == 0) {
125 if (Buffer !=
NULL) {
128 (
StrSize (ManFileName) + 4*
sizeof (CHAR16))/
sizeof (CHAR16),
134 (
StrSize (ManFileName) + 4*
sizeof (CHAR16))/
sizeof (CHAR16),
161 OUT SHELL_FILE_HANDLE *Handle
164 CHAR16 *FullFileName;
167 if ( (FileName ==
NULL)
169 || (
StrLen (FileName) == 0)
172 return (EFI_INVALID_PARAMETER);
176 if (FullFileName ==
NULL) {
177 return (EFI_NOT_FOUND);
209 IN SHELL_FILE_HANDLE Handle,
211 OUT CHAR16 **HelpText,
219 BOOLEAN CurrentlyReading;
224 if ( (Handle ==
NULL)
225 || (HelpText ==
NULL)
226 || (HelpSize ==
NULL)
229 return (EFI_INVALID_PARAMETER);
233 CurrentlyReading =
FALSE;
238 if (ReadLine ==
NULL) {
239 return (EFI_OUT_OF_RESOURCES);
244 if (ReadLine[0] == L
'#') {
254 if (Status == EFI_BUFFER_TOO_SMALL) {
258 if (EFI_ERROR (Status)) {
260 }
else if (
StrnCmp (ReadLine, L
".TH", 3) == 0) {
265 }
else if (
StrnCmp (ReadLine, L
".SH", 3) == 0) {
266 if (Sections ==
NULL) {
267 CurrentlyReading =
TRUE;
274 if (CurrentlyReading) {
275 CurrentlyReading =
FALSE;
281 for ( SectionName = ReadLine + 3
282 ; *SectionName == L
' '
287 SectionLen =
StrLen (SectionName);
288 SectionName =
StrStr (Sections, SectionName);
289 if (SectionName ==
NULL) {
293 if ((*(SectionName + SectionLen) == CHAR_NULL) || (*(SectionName + SectionLen) == L
',')) {
294 CurrentlyReading =
TRUE;
296 }
else if (CurrentlyReading) {
301 ASSERT ((*HelpText ==
NULL && *HelpSize == 0) || (*HelpText !=
NULL));
308 if (!Found && !EFI_ERROR (Status)) {
309 return (EFI_NOT_FOUND);
340 OUT CHAR16 **BriefDesc OPTIONAL,
348 LookForThMacro, LookForCommandName, CompareCommands, GetBriefDescription, Final
359 State = LookForThMacro;
362 if (*Line == L
'\0') {
372 if ((
StrnCmp (L
".TH ", Line, 4) == 0) || (
StrnCmp (L
".TH\t", Line, 4) == 0)) {
374 State = LookForCommandName;
375 }
else if ((*Line == L
' ') || (*Line == L
'\t')) {
387 case LookForCommandName:
388 if ((*Line == L
' ') || (*Line == L
'\t')) {
392 State = CompareCommands;
403 case CompareCommands:
404 if ((*Line == L
' ') || (*Line == L
'\t')) {
406 State = (BriefDesc ==
NULL) ? Final : GetBriefDescription;
417 case GetBriefDescription:
418 if ((*Line != L
' ') && (*Line != L
'\t') && (*Line != L
'0') && (*Line != L
'1')) {
421 if (*BriefDesc !=
NULL) {
422 StrCpyS (*BriefDesc, (*BriefSize)/
sizeof (CHAR16), Line);
434 }
while (State < Final);
436 *Found = ReturnFound;
462 IN SHELL_FILE_HANDLE Handle,
464 OUT CHAR16 **BriefDesc OPTIONAL,
466 IN OUT BOOLEAN *Ascii
475 if ( (Handle ==
NULL)
477 || ((BriefDesc !=
NULL) && (BriefSize ==
NULL))
480 return (EFI_INVALID_PARAMETER);
488 if (ReadLine ==
NULL) {
489 return (EFI_OUT_OF_RESOURCES);
497 && (*(Command + Start - 1) != L
'\\')
498 && (*(Command + Start - 1) != L
'/')
499 && (*(Command + Start - 1) != L
':'))
509 if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
513 Status = EFI_NOT_FOUND;
514 if (
IsTitleHeader (Command+Start, ReadLine, BriefDesc, BriefSize, &Found)) {
559 IN CONST CHAR16 *Sections OPTIONAL,
560 OUT CHAR16 **BriefDesc OPTIONAL,
561 OUT CHAR16 **HelpText
565 SHELL_FILE_HANDLE FileHandle;
570 UINTN StringIdWalker;
573 CHAR16 *CmdFilePathName;
578 if ( (ManFileName ==
NULL)
580 || (HelpText ==
NULL)
583 return (EFI_INVALID_PARAMETER);
592 CmdFilePathName =
NULL;
593 CmdFileImgHandle =
NULL;
594 PackageListHeader =
NULL;
602 if (TempString !=
NULL) {
604 if (FileHandle ==
NULL) {
605 Status = EFI_OUT_OF_RESOURCES;
609 HelpSize =
StrLen (TempString) *
sizeof (CHAR16);
615 if (!EFI_ERROR (Status) && (HelpText !=
NULL)) {
626 if (TempString ==
NULL) {
627 return (EFI_INVALID_PARAMETER);
631 if (EFI_ERROR (Status)) {
633 if (FileDevPath ==
NULL) {
634 Status = EFI_OUT_OF_RESOURCES;
639 if (DevPath ==
NULL) {
640 Status = EFI_OUT_OF_RESOURCES;
645 SHELL_FREE_NON_NULL (FileDevPath);
646 SHELL_FREE_NON_NULL (DevPath);
649 if (!EFI_ERROR (Status)) {
653 if (!EFI_ERROR (Status) && (HelpText !=
NULL)) {
657 ShellInfoObject.NewEfiShellProtocol->CloseFile (FileHandle);
658 if (!EFI_ERROR (Status)) {
670 if (CmdFileName ==
NULL) {
671 Status = EFI_OUT_OF_RESOURCES;
680 if (CmdFilePathName ==
NULL) {
681 Status = EFI_NOT_FOUND;
685 DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath (CmdFilePathName);
687 if (EFI_ERROR (Status)) {
694 if (Status == EFI_SECURITY_VIOLATION) {
695 gBS->UnloadImage (CmdFileImgHandle);
702 Status =
gBS->OpenProtocol (
704 &gEfiHiiPackageListProtocolGuid,
705 (VOID **)&PackageListHeader,
708 EFI_OPEN_PROTOCOL_GET_PROTOCOL
710 if (EFI_ERROR (Status)) {
718 Status =
gBS->InstallProtocolInterface (
719 &mShellManDriverHandle,
720 &gEfiDevicePathProtocolGuid,
722 &mShellManHiiDevicePath
724 if (EFI_ERROR (Status)) {
731 mShellManDriverHandle,
734 if (EFI_ERROR (Status)) {
740 SHELL_FREE_NON_NULL (TempString);
741 if (BriefDesc !=
NULL) {
742 SHELL_FREE_NON_NULL (*BriefDesc);
745 TempString =
HiiGetString (mShellManHiiHandle, (EFI_STRING_ID)StringIdWalker,
NULL);
746 if (TempString ==
NULL) {
747 Status = EFI_NOT_FOUND;
752 if (FileHandle ==
NULL) {
753 Status = EFI_OUT_OF_RESOURCES;
757 HelpSize =
StrLen (TempString) *
sizeof (CHAR16);
763 if (!EFI_ERROR (Status) && (HelpText !=
NULL)) {
768 if (!EFI_ERROR (Status)) {
776 }
while (StringIdWalker < 0xFFFF && TempString !=
NULL);
780 if (mShellManDriverHandle !=
NULL) {
781 gBS->UninstallProtocolInterface (
782 mShellManDriverHandle,
783 &gEfiDevicePathProtocolGuid,
784 &mShellManHiiDevicePath
786 mShellManDriverHandle =
NULL;
789 if (mShellManHiiHandle !=
NULL) {
791 mShellManHiiHandle =
NULL;
794 if (CmdFileImgHandle !=
NULL) {
795 Status =
gBS->UnloadImage (CmdFileImgHandle);
798 SHELL_FREE_NON_NULL (TempString);
799 SHELL_FREE_NON_NULL (CmdFileName);
800 SHELL_FREE_NON_NULL (CmdFilePathName);
801 SHELL_FREE_NON_NULL (FileDevPath);
802 SHELL_FREE_NON_NULL (DevPath);
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
CHAR16 EFIAPI CharToUpper(IN CHAR16 Char)
INTN EFIAPI StrnCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString, IN UINTN Length)
RETURN_STATUS EFIAPI StrnCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
RETURN_STATUS EFIAPI StrnCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
CHAR16 *EFIAPI StrStr(IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
#define HARDWARE_DEVICE_PATH
EFI_DEVICE_PATH_PROTOCOL *EFIAPI FileDevicePath(IN EFI_HANDLE Device OPTIONAL, IN CONST CHAR16 *FileName)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePath(IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_FILE_PROTOCOL * CreateFileInterfaceMem(IN CONST BOOLEAN Unicode)
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
SHELL_FILE_HANDLE EFIAPI ConvertEfiFileProtocolToShellHandle(IN CONST EFI_FILE_PROTOCOL *Handle, IN CONST CHAR16 *Path)
BOOLEAN EFIAPI ShellFileHandleEof(IN SHELL_FILE_HANDLE Handle)
CHAR16 *EFIAPI ShellCommandGetCommandHelp(IN CONST CHAR16 *CommandString)
CHAR16 *EFIAPI StrnCatGrow(IN OUT CHAR16 **Destination, IN OUT UINTN *CurrentSize, IN CONST CHAR16 *Source, IN UINTN Count)
EFI_STATUS EFIAPI ShellFileHandleReadLine(IN SHELL_FILE_HANDLE Handle, IN OUT CHAR16 *Buffer, IN OUT UINTN *Size, IN BOOLEAN Truncate, IN OUT BOOLEAN *Ascii)
EFI_STATUS EFIAPI ShellSetFilePosition(IN SHELL_FILE_HANDLE FileHandle, IN UINT64 Position)
CHAR16 *EFIAPI ShellFindFilePath(IN CONST CHAR16 *FileName)
EFI_STATUS EFIAPI ShellWriteFile(IN SHELL_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI ShellCloseFile(IN SHELL_FILE_HANDLE *FileHandle)
CHAR16 * GetExecuatableFileName(IN CONST CHAR16 *NameString)
EFI_STATUS ManFileFindSections(IN SHELL_FILE_HANDLE Handle, IN CONST CHAR16 *Sections, OUT CHAR16 **HelpText, OUT UINTN *HelpSize, IN BOOLEAN Ascii)
CHAR16 * GetManFileName(IN CONST CHAR16 *ManFileName)
EFI_STATUS ProcessManFile(IN CONST CHAR16 *ManFileName, IN CONST CHAR16 *Command, IN CONST CHAR16 *Sections OPTIONAL, OUT CHAR16 **BriefDesc OPTIONAL, OUT CHAR16 **HelpText)
EFI_STATUS SearchPathForFile(IN CONST CHAR16 *FileName, OUT SHELL_FILE_HANDLE *Handle)
BOOLEAN IsTitleHeader(IN CONST CHAR16 *Command, IN CHAR16 *Line, OUT CHAR16 **BriefDesc OPTIONAL, OUT UINTN *BriefSize OPTIONAL, OUT BOOLEAN *Found)
EFI_STATUS ManFileFindTitleSection(IN SHELL_FILE_HANDLE Handle, IN CONST CHAR16 *Command, OUT CHAR16 **BriefDesc OPTIONAL, OUT UINTN *BriefSize OPTIONAL, IN OUT BOOLEAN *Ascii)
EFI_STATUS InternalOpenFileDevicePath(IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT SHELL_FILE_HANDLE *FileHandle, IN UINT64 OpenMode, IN UINT64 Attributes OPTIONAL)
EFI_STATUS EFIAPI EfiShellOpenFileByName(IN CONST CHAR16 *FileName, OUT SHELL_FILE_HANDLE *FileHandle, IN UINT64 OpenMode)
EFI_HII_DATABASE_PROTOCOL * gHiiDatabase
EFI_DEVICE_PATH_PROTOCOL * ImageDevPath
DevicePath for ourselves.