TianoCore EDK2 master
Loading...
Searching...
No Matches
FileHandleWrappers.c
Go to the documentation of this file.
1
12#include "Shell.h"
13#include "FileHandleInternal.h"
14
15#define MEM_WRITE_REALLOC_OVERHEAD 1024
16
29EFIAPI
32 OUT EFI_FILE_PROTOCOL **NewHandle,
33 IN CHAR16 *FileName,
34 IN UINT64 OpenMode,
35 IN UINT64 Attributes
36 )
37{
38 return (EFI_NOT_FOUND);
39}
40
49EFIAPI
52 )
53{
54 return (EFI_SUCCESS);
55}
56
66EFIAPI
69 OUT UINT64 *Position
70 )
71{
72 return (EFI_UNSUPPORTED);
73}
74
84EFIAPI
87 IN UINT64 Position
88 )
89{
90 return (EFI_UNSUPPORTED);
91}
92
104EFIAPI
106 IN EFI_FILE_PROTOCOL *This,
107 IN EFI_GUID *InformationType,
108 IN OUT UINTN *BufferSize,
109 OUT VOID *Buffer
110 )
111{
112 return (EFI_UNSUPPORTED);
113}
114
126EFIAPI
128 IN EFI_FILE_PROTOCOL *This,
129 IN EFI_GUID *InformationType,
130 IN UINTN BufferSize,
131 IN VOID *Buffer
132 )
133{
134 return (EFI_UNSUPPORTED);
135}
136
150EFIAPI
152 IN EFI_FILE_PROTOCOL *This,
153 IN OUT UINTN *BufferSize,
154 IN VOID *Buffer
155 )
156{
157 if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
158 return (EFI_UNSUPPORTED);
159 }
160
161 if (*((CHAR16 *)Buffer) == gUnicodeFileTag) {
162 return (gST->ConOut->OutputString (gST->ConOut, (CHAR16 *)Buffer + 1));
163 }
164
165 return (gST->ConOut->OutputString (gST->ConOut, Buffer));
166}
167
178EFIAPI
180 IN EFI_FILE_PROTOCOL *This,
181 IN OUT UINTN *BufferSize,
182 IN VOID *Buffer
183 )
184{
185 return (EFI_UNSUPPORTED);
186}
187
200EFIAPI
202 IN EFI_FILE_PROTOCOL *This,
203 IN OUT UINTN *BufferSize,
204 IN VOID *Buffer
205 )
206{
207 return (gST->StdErr->OutputString (gST->StdErr, Buffer));
208}
209
220EFIAPI
222 IN EFI_FILE_PROTOCOL *This,
223 IN OUT UINTN *BufferSize,
224 OUT VOID *Buffer
225 )
226{
227 return (EFI_UNSUPPORTED);
228}
229
240EFIAPI
242 IN EFI_FILE_PROTOCOL *This,
243 IN OUT UINTN *BufferSize,
244 OUT VOID *Buffer
245 )
246{
247 return (EFI_UNSUPPORTED);
248}
249
260EFIAPI
262 IN EFI_FILE_PROTOCOL *This,
263 IN OUT UINTN *BufferSize,
264 OUT VOID *Buffer
265 )
266{
267 *BufferSize = 0;
268 return (EFI_SUCCESS);
269}
270
281EFIAPI
283 IN EFI_FILE_PROTOCOL *This,
284 IN OUT UINTN *BufferSize,
285 IN VOID *Buffer
286 )
287{
288 return (EFI_SUCCESS);
289}
290
302 IN CONST CHAR16 *InputString,
303 IN CONST UINTN StringLen,
304 IN CONST UINTN BufferSize,
305 IN OUT EFI_SHELL_FILE_INFO **TabCompletionList,
306 IN OUT UINTN *TabUpdatePos
307 )
308{
309 BOOLEAN InQuotation;
310 UINTN TabPos;
311 UINTN Index;
312 CONST CHAR16 *Cwd;
313 EFI_STATUS Status;
314 CHAR16 *TabStr;
315 EFI_SHELL_FILE_INFO *FileList;
317 EFI_SHELL_FILE_INFO *TempFileInfo;
318
319 //
320 // Allocate buffers
321 //
322 TabStr = AllocateZeroPool (BufferSize);
323 if (TabStr == NULL) {
324 return EFI_OUT_OF_RESOURCES;
325 }
326
327 //
328 // handle auto complete of file and directory names...
329 // E.g.: cd fs0:\EFI\Bo<TAB>
330 // ^ ^
331 // TabPos TabUpdatePos
332 //
333 TabPos = 0;
334 *TabUpdatePos = 0;
335 FileList = NULL;
336 InQuotation = FALSE;
337 for (Index = 0; Index < StringLen; Index++) {
338 switch (InputString[Index]) {
339 case L'\"':
340 InQuotation = (BOOLEAN)(!InQuotation);
341 break;
342
343 case L' ':
344 if (!InQuotation) {
345 TabPos = Index + 1;
346 *TabUpdatePos = TabPos;
347 }
348
349 break;
350
351 case L':':
352 //
353 // handle the case "fs0:<TAB>"
354 // Update the TabUpdatePos as well.
355 //
356 case L'\\':
357 *TabUpdatePos = Index + 1;
358 break;
359
360 default:
361 break;
362 }
363 }
364
365 if (StrStr (InputString + TabPos, L":") == NULL) {
366 //
367 // If file path doesn't contain ":", ...
368 //
369 Cwd = ShellInfoObject.NewEfiShellProtocol->GetCurDir (NULL);
370 if (Cwd != NULL) {
371 if (InputString[TabPos] != L'\\') {
372 //
373 // and it doesn't begin with "\\", it's a path relative to current directory.
374 // TabStr = "<cwd>\\"
375 //
376 StrnCpyS (TabStr, BufferSize / sizeof (CHAR16), Cwd, (BufferSize) / sizeof (CHAR16) - 1);
377 StrCatS (TabStr, (BufferSize) / sizeof (CHAR16), L"\\");
378 } else {
379 //
380 // and it begins with "\\", it's a path pointing to root directory of current map.
381 // TabStr = "fsx:"
382 //
383 Index = StrStr (Cwd, L":") - Cwd + 1;
384 StrnCpyS (TabStr, BufferSize / sizeof (CHAR16), Cwd, Index);
385 }
386 }
387 }
388
389 StrnCatS (TabStr, (BufferSize) / sizeof (CHAR16), InputString + TabPos, StringLen - TabPos);
390 StrnCatS (TabStr, (BufferSize) / sizeof (CHAR16), L"*", (BufferSize) / sizeof (CHAR16) - 1 - StrLen (TabStr));
391 Status = ShellInfoObject.NewEfiShellProtocol->FindFiles (TabStr, &FileList);
392
393 //
394 // Filter out the non-directory for "CD" command
395 // Filter "." and ".." for all
396 //
397 if (!EFI_ERROR (Status) && (FileList != NULL)) {
398 //
399 // Skip the spaces in the beginning
400 //
401 while (*InputString == L' ') {
402 InputString++;
403 }
404
405 for (FileInfo = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link); !IsNull (&FileList->Link, &FileInfo->Link); ) {
406 if (((StrCmp (FileInfo->FileName, L".") == 0) || (StrCmp (FileInfo->FileName, L"..") == 0)) ||
407 ((((InputString[0] == L'c') || (InputString[0] == L'C')) && ((InputString[1] == L'd') || (InputString[1] == L'D'))) &&
408 (ShellIsDirectory (FileInfo->FullName) != EFI_SUCCESS)))
409 {
410 TempFileInfo = FileInfo;
412 InternalFreeShellFileInfoNode (TempFileInfo);
413 } else {
414 FileInfo = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &FileInfo->Link);
415 }
416 }
417 }
418
419 if ((FileList != NULL) && !IsListEmpty (&FileList->Link)) {
420 Status = EFI_SUCCESS;
421 } else {
422 ShellInfoObject.NewEfiShellProtocol->FreeFileList (&FileList);
423 Status = EFI_NOT_FOUND;
424 }
425
426 FreePool (TabStr);
427
428 *TabCompletionList = FileList;
429 return Status;
430}
431
457EFIAPI
459 IN EFI_FILE_PROTOCOL *This,
460 IN OUT UINTN *BufferSize,
461 OUT VOID *Buffer
462 )
463{
464 CHAR16 *CurrentString;
465 BOOLEAN Done;
466 UINTN TabUpdatePos; // Start index of the string updated by TAB stroke
467 UINTN Column; // Column of current cursor
468 UINTN Row; // Row of current cursor
469 UINTN StartColumn; // Column at the beginning of the line
470 UINTN Update; // Line index for update
471 UINTN Delete; // Num of chars to delete from console after update
472 UINTN StringLen; // Total length of the line
473 UINTN StringCurPos; // Line index corresponding to the cursor
474 UINTN MaxStr; // Maximum possible line length
475 UINTN TotalColumn; // Num of columns in the console
476 UINTN TotalRow; // Num of rows in the console
477 UINTN SkipLength;
478 UINTN OutputLength; // Length of the update string
479 UINTN TailRow; // Row of end of line
480 UINTN TailColumn; // Column of end of line
481 EFI_INPUT_KEY Key;
482
483 BUFFER_LIST *LinePos;
484 BUFFER_LIST *NewPos;
485 BOOLEAN InScrolling;
486 EFI_STATUS Status;
487 BOOLEAN InTabScrolling; // Whether in TAB-completion state
488 EFI_SHELL_FILE_INFO *TabCompleteList;
489 EFI_SHELL_FILE_INFO *TabCurrent;
490 UINTN EventIndex;
491 CHAR16 *TabOutputStr;
492
493 //
494 // If buffer is not large enough to hold a CHAR16, return minimum buffer size
495 //
496 if (*BufferSize < sizeof (CHAR16) * 2) {
497 *BufferSize = sizeof (CHAR16) * 2;
498 return (EFI_BUFFER_TOO_SMALL);
499 }
500
501 Done = FALSE;
502 CurrentString = Buffer;
503 StringLen = 0;
504 StringCurPos = 0;
505 OutputLength = 0;
506 Update = 0;
507 Delete = 0;
508 LinePos = NewPos = (BUFFER_LIST *)(&ShellInfoObject.ViewingSettings.CommandHistory);
509 InScrolling = FALSE;
510 InTabScrolling = FALSE;
511 Status = EFI_SUCCESS;
512 TabOutputStr = NULL;
513 TabUpdatePos = 0;
514 TabCompleteList = NULL;
515 TabCurrent = NULL;
516
517 //
518 // Get the screen setting and the current cursor location
519 //
520 Column = StartColumn = gST->ConOut->Mode->CursorColumn;
521 Row = gST->ConOut->Mode->CursorRow;
522 gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &TotalColumn, &TotalRow);
523
524 //
525 // Limit the line length to the buffer size or the minimum size of the
526 // screen. (The smaller takes effect)
527 //
528 MaxStr = TotalColumn * (TotalRow - 1) - StartColumn;
529 if (MaxStr > *BufferSize / sizeof (CHAR16)) {
530 MaxStr = *BufferSize / sizeof (CHAR16);
531 }
532
533 ZeroMem (CurrentString, MaxStr * sizeof (CHAR16));
534 do {
535 //
536 // Read a key
537 //
538 gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
539 Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
540 if (EFI_ERROR (Status)) {
541 if (Status == EFI_NOT_READY) {
542 continue;
543 }
544
545 ZeroMem (CurrentString, MaxStr * sizeof (CHAR16));
546 StringLen = 0;
547 break;
548 }
549
550 //
551 // Press PageUp or PageDown to scroll the history screen up or down.
552 // Press any other key to quit scrolling.
553 //
554 if ((Key.UnicodeChar == 0) && ((Key.ScanCode == SCAN_PAGE_UP) || (Key.ScanCode == SCAN_PAGE_DOWN))) {
555 if (Key.ScanCode == SCAN_PAGE_UP) {
556 ConsoleLoggerDisplayHistory (FALSE, 0, ShellInfoObject.ConsoleInfo);
557 } else if (Key.ScanCode == SCAN_PAGE_DOWN) {
558 ConsoleLoggerDisplayHistory (TRUE, 0, ShellInfoObject.ConsoleInfo);
559 }
560
561 InScrolling = TRUE;
562 } else {
563 if (InScrolling) {
564 ConsoleLoggerStopHistory (ShellInfoObject.ConsoleInfo);
565 InScrolling = FALSE;
566 }
567 }
568
569 //
570 // If we are quitting TAB scrolling...
571 //
572 if (InTabScrolling && (Key.UnicodeChar != CHAR_TAB)) {
573 if (TabCompleteList != NULL) {
574 ShellInfoObject.NewEfiShellProtocol->FreeFileList (&TabCompleteList);
575 DEBUG_CODE (
576 TabCompleteList = NULL;
577 );
578 }
579
580 InTabScrolling = FALSE;
581 }
582
583 switch (Key.UnicodeChar) {
584 case CHAR_CARRIAGE_RETURN:
585 //
586 // All done, print a newline at the end of the string
587 //
588 TailRow = Row + (StringLen - StringCurPos + Column) / TotalColumn;
589 TailColumn = (StringLen - StringCurPos + Column) % TotalColumn;
590 ShellPrintEx ((INT32)TailColumn, (INT32)TailRow, L"%N\n");
591 Done = TRUE;
592 break;
593
594 case CHAR_BACKSPACE:
595 if (StringCurPos != 0) {
596 //
597 // If not move back beyond string beginning, move all characters behind
598 // the current position one character forward
599 //
600 StringCurPos--;
601 Update = StringCurPos;
602 Delete = 1;
603 CopyMem (CurrentString + StringCurPos, CurrentString + StringCurPos + 1, sizeof (CHAR16) * (StringLen - StringCurPos));
604
605 //
606 // Adjust the current column and row
607 //
608 MoveCursorBackward (TotalColumn, &Column, &Row);
609 }
610
611 break;
612
613 case CHAR_TAB:
614 if (!InTabScrolling) {
615 TabCurrent = NULL;
616 //
617 // Initialize a tab complete operation.
618 //
619 Status = CreateTabCompletionList (CurrentString, StringLen, *BufferSize, &TabCompleteList, &TabUpdatePos);
620 if (!EFI_ERROR (Status)) {
621 InTabScrolling = TRUE;
622 }
623
624 //
625 // We do not set up the replacement.
626 // The next section will do that.
627 //
628 }
629
630 if (InTabScrolling) {
631 //
632 // We are in a tab complete operation.
633 // set up the next replacement.
634 //
635 ASSERT (TabCompleteList != NULL);
636 if (TabCurrent == NULL) {
637 TabCurrent = (EFI_SHELL_FILE_INFO *)GetFirstNode (&TabCompleteList->Link);
638 } else {
639 TabCurrent = (EFI_SHELL_FILE_INFO *)GetNextNode (&TabCompleteList->Link, &TabCurrent->Link);
640 }
641
642 //
643 // Skip over the empty list beginning node
644 //
645 if (IsNull (&TabCompleteList->Link, &TabCurrent->Link)) {
646 TabCurrent = (EFI_SHELL_FILE_INFO *)GetNextNode (&TabCompleteList->Link, &TabCurrent->Link);
647 }
648 }
649
650 break;
651
652 default:
653 if (Key.UnicodeChar >= ' ') {
654 //
655 // If we are at the buffer's end, drop the key
656 //
657 if ((StringLen == MaxStr - 1) && (ShellInfoObject.ViewingSettings.InsertMode || (StringCurPos == StringLen))) {
658 break;
659 }
660
661 //
662 // If in insert mode, make space by moving each other character 1
663 // space higher in the array
664 //
665 if (ShellInfoObject.ViewingSettings.InsertMode) {
666 CopyMem (CurrentString + StringCurPos + 1, CurrentString + StringCurPos, (StringLen - StringCurPos)*sizeof (CurrentString[0]));
667 }
668
669 CurrentString[StringCurPos] = Key.UnicodeChar;
670 Update = StringCurPos;
671
672 StringCurPos += 1;
673 OutputLength = 1;
674 }
675
676 break;
677
678 case 0:
679 switch (Key.ScanCode) {
680 case SCAN_DELETE:
681 //
682 // Move characters behind current position one character forward
683 //
684 if (StringLen != 0) {
685 Update = StringCurPos;
686 Delete = 1;
687 CopyMem (CurrentString + StringCurPos, CurrentString + StringCurPos + 1, sizeof (CHAR16) * (StringLen - StringCurPos));
688 }
689
690 break;
691
692 case SCAN_UP:
693 //
694 // Prepare to print the previous command
695 //
696 NewPos = (BUFFER_LIST *)GetPreviousNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
697 if (IsNull (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link)) {
698 NewPos = (BUFFER_LIST *)GetPreviousNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
699 }
700
701 break;
702
703 case SCAN_DOWN:
704 //
705 // Prepare to print the next command
706 //
707 NewPos = (BUFFER_LIST *)GetNextNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
708 if (NewPos == (BUFFER_LIST *)(&ShellInfoObject.ViewingSettings.CommandHistory)) {
709 NewPos = (BUFFER_LIST *)GetNextNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
710 }
711
712 break;
713
714 case SCAN_LEFT:
715 //
716 // Adjust current cursor position
717 //
718 if (StringCurPos != 0) {
719 --StringCurPos;
720 MoveCursorBackward (TotalColumn, &Column, &Row);
721 }
722
723 break;
724
725 case SCAN_RIGHT:
726 //
727 // Adjust current cursor position
728 //
729 if (StringCurPos < StringLen) {
730 ++StringCurPos;
731 MoveCursorForward (TotalColumn, TotalRow, &Column, &Row);
732 }
733
734 break;
735
736 case SCAN_HOME:
737 //
738 // Move current cursor position to the beginning of the command line
739 //
740 Row -= (StringCurPos + StartColumn) / TotalColumn;
741 Column = StartColumn;
742 StringCurPos = 0;
743 break;
744
745 case SCAN_END:
746 //
747 // Move current cursor position to the end of the command line
748 //
749 TailRow = Row + (StringLen - StringCurPos + Column) / TotalColumn;
750 TailColumn = (StringLen - StringCurPos + Column) % TotalColumn;
751 Row = TailRow;
752 Column = TailColumn;
753 StringCurPos = StringLen;
754 break;
755
756 case SCAN_ESC:
757 //
758 // Prepare to clear the current command line
759 //
760 CurrentString[0] = 0;
761 Update = 0;
762 Delete = StringLen;
763 Row -= (StringCurPos + StartColumn) / TotalColumn;
764 Column = StartColumn;
765 OutputLength = 0;
766 break;
767
768 case SCAN_INSERT:
769 //
770 // Toggle the SEnvInsertMode flag
771 //
772 ShellInfoObject.ViewingSettings.InsertMode = (BOOLEAN) !ShellInfoObject.ViewingSettings.InsertMode;
773 break;
774
775 case SCAN_F7:
776 //
777 // Print command history
778 //
779 PrintCommandHistory (TotalColumn, TotalRow, 4);
780 *CurrentString = CHAR_NULL;
781 Done = TRUE;
782 break;
783 }
784 }
785
786 if (Done) {
787 break;
788 }
789
790 //
791 // If we are in auto-complete mode, we are preparing to print
792 // the next file or directory name
793 //
794 if (InTabScrolling) {
795 TabOutputStr = AllocateZeroPool (*BufferSize);
796 if (TabOutputStr == NULL) {
797 Status = EFI_OUT_OF_RESOURCES;
798 }
799 }
800
801 if (InTabScrolling && (TabOutputStr != NULL)) {
802 //
803 // Adjust the column and row to the start of TAB-completion string.
804 //
805 Column = (StartColumn + TabUpdatePos) % TotalColumn;
806 Row -= (StartColumn + StringCurPos) / TotalColumn - (StartColumn + TabUpdatePos) / TotalColumn;
807 OutputLength = StrLen (TabCurrent->FileName);
808 //
809 // if the output string contains blank space, quotation marks L'\"'
810 // should be added to the output.
811 //
812 if (StrStr (TabCurrent->FileName, L" ") != NULL) {
813 TabOutputStr[0] = L'\"';
814 CopyMem (TabOutputStr + 1, TabCurrent->FileName, OutputLength * sizeof (CHAR16));
815 TabOutputStr[OutputLength + 1] = L'\"';
816 TabOutputStr[OutputLength + 2] = CHAR_NULL;
817 } else {
818 CopyMem (TabOutputStr, TabCurrent->FileName, OutputLength * sizeof (CHAR16));
819 TabOutputStr[OutputLength] = CHAR_NULL;
820 }
821
822 OutputLength = StrLen (TabOutputStr) < MaxStr - 1 ? StrLen (TabOutputStr) : MaxStr - 1;
823 CopyMem (CurrentString + TabUpdatePos, TabOutputStr, OutputLength * sizeof (CHAR16));
824 CurrentString[TabUpdatePos + OutputLength] = CHAR_NULL;
825 StringCurPos = TabUpdatePos + OutputLength;
826 Update = TabUpdatePos;
827 if (StringLen > TabUpdatePos + OutputLength) {
828 Delete = StringLen - TabUpdatePos - OutputLength;
829 }
830
831 FreePool (TabOutputStr);
832 }
833
834 //
835 // If we have a new position, we are preparing to print a previous or
836 // next command.
837 //
838 if (NewPos != (BUFFER_LIST *)(&ShellInfoObject.ViewingSettings.CommandHistory)) {
839 Column = StartColumn;
840 Row -= (StringCurPos + StartColumn) / TotalColumn;
841
842 LinePos = NewPos;
843 NewPos = (BUFFER_LIST *)(&ShellInfoObject.ViewingSettings.CommandHistory);
844
845 OutputLength = StrLen (LinePos->Buffer) < MaxStr - 1 ? StrLen (LinePos->Buffer) : MaxStr - 1;
846 CopyMem (CurrentString, LinePos->Buffer, OutputLength * sizeof (CHAR16));
847 CurrentString[OutputLength] = CHAR_NULL;
848
849 StringCurPos = OutputLength;
850
851 //
852 // Draw new input string
853 //
854 Update = 0;
855 if (StringLen > OutputLength) {
856 //
857 // If old string was longer, blank its tail
858 //
859 Delete = StringLen - OutputLength;
860 }
861 }
862
863 //
864 // If we need to update the output do so now
865 //
866 if (Update != (UINTN)-1) {
867 ShellPrintEx ((INT32)Column, (INT32)Row, L"%s%.*s", CurrentString + Update, Delete, L"");
868 StringLen = StrLen (CurrentString);
869
870 if (Delete != 0) {
871 SetMem (CurrentString + StringLen, Delete * sizeof (CHAR16), CHAR_NULL);
872 }
873
874 if (StringCurPos > StringLen) {
875 StringCurPos = StringLen;
876 }
877
878 Update = (UINTN)-1;
879
880 //
881 // After using print to reflect newly updates, if we're not using
882 // BACKSPACE and DELETE, we need to move the cursor position forward,
883 // so adjust row and column here.
884 //
885 if ((Key.UnicodeChar != CHAR_BACKSPACE) && !((Key.UnicodeChar == 0) && (Key.ScanCode == SCAN_DELETE))) {
886 //
887 // Calculate row and column of the tail of current string
888 //
889 TailRow = Row + (StringLen - StringCurPos + Column + OutputLength) / TotalColumn;
890 TailColumn = (StringLen - StringCurPos + Column + OutputLength) % TotalColumn;
891
892 //
893 // If the tail of string reaches screen end, screen rolls up, so if
894 // Row does not equal TailRow, Row should be decremented
895 //
896 // (if we are recalling commands using UPPER and DOWN key, and if the
897 // old command is too long to fit the screen, TailColumn must be 79.
898 //
899 if ((TailColumn == 0) && (TailRow >= TotalRow) && (Row != TailRow)) {
900 Row--;
901 }
902
903 //
904 // Calculate the cursor position after current operation. If cursor
905 // reaches line end, update both row and column, otherwise, only
906 // column will be changed.
907 //
908 if (Column + OutputLength >= TotalColumn) {
909 SkipLength = OutputLength - (TotalColumn - Column);
910
911 Row += SkipLength / TotalColumn + 1;
912 if (Row > TotalRow - 1) {
913 Row = TotalRow - 1;
914 }
915
916 Column = SkipLength % TotalColumn;
917 } else {
918 Column += OutputLength;
919 }
920 }
921
922 Delete = 0;
923 }
924
925 //
926 // Set the cursor position for this key
927 //
928 gST->ConOut->SetCursorPosition (gST->ConOut, Column, Row);
929 } while (!Done);
930
931 if ((CurrentString != NULL) && (StrLen (CurrentString) > 0)) {
932 //
933 // add the line to the history buffer
934 //
935 AddLineToCommandHistory (CurrentString);
936 }
937
938 //
939 // Return the data to the caller
940 //
941 *BufferSize = StringLen * sizeof (CHAR16);
942
943 //
944 // if this was used it should be deallocated by now...
945 // prevent memory leaks...
946 //
947 if (TabCompleteList != NULL) {
948 ShellInfoObject.NewEfiShellProtocol->FreeFileList (&TabCompleteList);
949 }
950
951 ASSERT (TabCompleteList == NULL);
952
953 return Status;
954}
955
956//
957// FILE style interfaces for StdIn/StdOut/StdErr
958//
960 EFI_FILE_REVISION,
971};
972
974 EFI_FILE_REVISION,
985};
986
988 EFI_FILE_REVISION,
999};
1000
1002 EFI_FILE_REVISION,
1013};
1014
1015//
1016// This is identical to EFI_FILE_PROTOCOL except for the additional member
1017// for the name.
1018//
1019
1020typedef struct {
1021 UINT64 Revision;
1024 EFI_FILE_DELETE Delete;
1025 EFI_FILE_READ Read;
1026 EFI_FILE_WRITE Write;
1027 EFI_FILE_GET_POSITION GetPosition;
1028 EFI_FILE_SET_POSITION SetPosition;
1029 EFI_FILE_GET_INFO GetInfo;
1030 EFI_FILE_SET_INFO SetInfo;
1031 EFI_FILE_FLUSH Flush;
1032 CHAR16 Name[1];
1034// ANSI compliance helper to get size of the struct.
1035#define SIZE_OF_EFI_FILE_PROTOCOL_ENVIRONMENT EFI_FIELD_OFFSET (EFI_FILE_PROTOCOL_ENVIRONMENT, Name)
1036
1047EFIAPI
1049 IN EFI_FILE_PROTOCOL *This
1050 )
1051{
1052 VOID *NewBuffer;
1053 UINTN NewSize;
1054 EFI_STATUS Status;
1055 BOOLEAN Volatile;
1056 UINTN TotalSize;
1057
1058 //
1059 // Most if not all UEFI commands will have an '\r\n' at the end of any output.
1060 // Since the output was redirected to a variable, it does not make sense to
1061 // keep this. So, before closing, strip the trailing '\r\n' from the variable
1062 // if it exists.
1063 //
1064 NewBuffer = NULL;
1065 NewSize = 0;
1066 TotalSize = 0;
1067
1068 Status = IsVolatileEnv (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &Volatile);
1069 if (EFI_ERROR (Status)) {
1070 return Status;
1071 }
1072
1073 Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
1074 if (Status == EFI_BUFFER_TOO_SMALL) {
1075 TotalSize = NewSize + sizeof (CHAR16);
1076 NewBuffer = AllocateZeroPool (TotalSize);
1077 if (NewBuffer == NULL) {
1078 return EFI_OUT_OF_RESOURCES;
1079 }
1080
1081 Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
1082 }
1083
1084 if (!EFI_ERROR (Status) && (NewBuffer != NULL)) {
1085 if (TotalSize / sizeof (CHAR16) >= 3) {
1086 if ((((CHAR16 *)NewBuffer)[TotalSize / sizeof (CHAR16) - 2] == CHAR_LINEFEED) &&
1087 (((CHAR16 *)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] == CHAR_CARRIAGE_RETURN)
1088 )
1089 {
1090 ((CHAR16 *)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] = CHAR_NULL;
1091 //
1092 // If the NewBuffer end with \r\n\0, We will replace '\r' by '\0' and then update TotalSize.
1093 //
1094 TotalSize -= sizeof (CHAR16) * 2;
1095 }
1096
1097 if (Volatile) {
1099 ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
1100 TotalSize - sizeof (CHAR16),
1101 NewBuffer
1102 );
1103
1104 if (!EFI_ERROR (Status)) {
1105 Status = ShellAddEnvVarToList (
1106 ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
1107 NewBuffer,
1108 TotalSize,
1109 EFI_VARIABLE_BOOTSERVICE_ACCESS
1110 );
1111 }
1112 } else {
1114 ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
1115 TotalSize - sizeof (CHAR16),
1116 NewBuffer
1117 );
1118
1119 if (!EFI_ERROR (Status)) {
1120 Status = ShellAddEnvVarToList (
1121 ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
1122 NewBuffer,
1123 TotalSize,
1124 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS
1125 );
1126 }
1127 }
1128 }
1129 }
1130
1131 SHELL_FREE_NON_NULL (NewBuffer);
1133 return (Status);
1134}
1135
1144EFIAPI
1146 IN EFI_FILE_PROTOCOL *This
1147 )
1148{
1150 return (FileInterfaceEnvClose (This));
1151}
1152
1163EFIAPI
1165 IN EFI_FILE_PROTOCOL *This,
1166 IN OUT UINTN *BufferSize,
1167 OUT VOID *Buffer
1168 )
1169{
1170 EFI_STATUS Status;
1171
1172 *BufferSize = *BufferSize / sizeof (CHAR16) * sizeof (CHAR16);
1173 if (*BufferSize != 0) {
1174 //
1175 // Make sure the first unicode character is \xFEFF
1176 //
1177 *(CHAR16 *)Buffer = gUnicodeFileTag;
1178 Buffer = (CHAR16 *)Buffer + 1;
1179 *BufferSize -= sizeof (gUnicodeFileTag);
1180 }
1181
1183 ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
1184 BufferSize,
1185 Buffer
1186 );
1187 if (!EFI_ERROR (Status) || (Status == EFI_BUFFER_TOO_SMALL)) {
1188 //
1189 // BufferSize is valid and needs update when Status is Success or BufferTooSmall.
1190 //
1191 *BufferSize += sizeof (gUnicodeFileTag);
1192 }
1193
1194 return Status;
1195}
1196
1209EFIAPI
1211 IN EFI_FILE_PROTOCOL *This,
1212 IN OUT UINTN *BufferSize,
1213 IN VOID *Buffer
1214 )
1215{
1216 VOID *NewBuffer;
1217 UINTN NewSize;
1218 EFI_STATUS Status;
1219 UINTN TotalSize;
1220
1221 NewBuffer = NULL;
1222 NewSize = 0;
1223 TotalSize = 0;
1224
1225 Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
1226 if (Status == EFI_BUFFER_TOO_SMALL) {
1227 TotalSize = NewSize + *BufferSize + sizeof (CHAR16);
1228 } else if (Status == EFI_NOT_FOUND) {
1229 TotalSize = *BufferSize + sizeof (CHAR16);
1230 } else {
1231 return Status;
1232 }
1233
1234 NewBuffer = AllocateZeroPool (TotalSize);
1235 if (NewBuffer == NULL) {
1236 return EFI_OUT_OF_RESOURCES;
1237 }
1238
1239 if (Status == EFI_BUFFER_TOO_SMALL) {
1240 Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
1241 }
1242
1243 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
1244 FreePool (NewBuffer);
1245 return Status;
1246 }
1247
1248 CopyMem ((UINT8 *)NewBuffer + NewSize, Buffer, *BufferSize);
1249 Status = ShellAddEnvVarToList (
1250 ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
1251 NewBuffer,
1252 TotalSize,
1253 EFI_VARIABLE_BOOTSERVICE_ACCESS
1254 );
1255 if (EFI_ERROR (Status)) {
1256 FreePool (NewBuffer);
1257 return Status;
1258 }
1259
1261 ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
1262 TotalSize - sizeof (CHAR16),
1263 NewBuffer
1264 );
1265 if (EFI_ERROR (Status)) {
1267 }
1268
1269 FreePool (NewBuffer);
1270 return Status;
1271}
1272
1285EFIAPI
1287 IN EFI_FILE_PROTOCOL *This,
1288 IN OUT UINTN *BufferSize,
1289 IN VOID *Buffer
1290 )
1291{
1292 VOID *NewBuffer;
1293 UINTN NewSize;
1294 EFI_STATUS Status;
1295 UINTN TotalSize;
1296
1297 NewBuffer = NULL;
1298 NewSize = 0;
1299 TotalSize = 0;
1300
1301 Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
1302 if (Status == EFI_BUFFER_TOO_SMALL) {
1303 TotalSize = NewSize + *BufferSize + sizeof (CHAR16);
1304 } else if (Status == EFI_NOT_FOUND) {
1305 TotalSize = *BufferSize + sizeof (CHAR16);
1306 } else {
1307 return Status;
1308 }
1309
1310 NewBuffer = AllocateZeroPool (TotalSize);
1311 if (NewBuffer == NULL) {
1312 return EFI_OUT_OF_RESOURCES;
1313 }
1314
1315 if (Status == EFI_BUFFER_TOO_SMALL) {
1316 Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
1317 }
1318
1319 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
1320 FreePool (NewBuffer);
1321 return Status;
1322 }
1323
1324 CopyMem ((UINT8 *)NewBuffer + NewSize, Buffer, *BufferSize);
1325 Status = ShellAddEnvVarToList (
1326 ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
1327 NewBuffer,
1328 TotalSize,
1329 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS
1330 );
1331 if (EFI_ERROR (Status)) {
1332 FreePool (NewBuffer);
1333 return Status;
1334 }
1335
1337 ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
1338 TotalSize - sizeof (CHAR16),
1339 NewBuffer
1340 );
1341 if (EFI_ERROR (Status)) {
1343 }
1344
1345 FreePool (NewBuffer);
1346 return Status;
1347}
1348
1360 IN CONST CHAR16 *EnvName
1361 )
1362{
1363 EFI_STATUS Status;
1364 EFI_FILE_PROTOCOL_ENVIRONMENT *EnvFileInterface;
1365 UINTN EnvNameSize;
1366 BOOLEAN Volatile;
1367
1368 if (EnvName == NULL) {
1369 return (NULL);
1370 }
1371
1372 Status = IsVolatileEnv (EnvName, &Volatile);
1373 if (EFI_ERROR (Status)) {
1374 return NULL;
1375 }
1376
1377 //
1378 // Get some memory
1379 //
1380 EnvNameSize = StrSize (EnvName);
1381 EnvFileInterface = AllocateZeroPool (sizeof (EFI_FILE_PROTOCOL_ENVIRONMENT)+EnvNameSize);
1382 if (EnvFileInterface == NULL) {
1383 return (NULL);
1384 }
1385
1386 //
1387 // Assign the generic members
1388 //
1389 EnvFileInterface->Revision = EFI_FILE_REVISION;
1390 EnvFileInterface->Open = FileInterfaceOpenNotFound;
1391 EnvFileInterface->Close = FileInterfaceEnvClose;
1392 EnvFileInterface->GetPosition = FileInterfaceNopGetPosition;
1393 EnvFileInterface->SetPosition = FileInterfaceNopSetPosition;
1394 EnvFileInterface->GetInfo = FileInterfaceNopGetInfo;
1395 EnvFileInterface->SetInfo = FileInterfaceNopSetInfo;
1396 EnvFileInterface->Flush = FileInterfaceNopGeneric;
1397 EnvFileInterface->Delete = FileInterfaceEnvDelete;
1398 EnvFileInterface->Read = FileInterfaceEnvRead;
1399
1400 CopyMem (EnvFileInterface->Name, EnvName, EnvNameSize);
1401
1402 //
1403 // Assign the different members for Volatile and Non-Volatile variables
1404 //
1405 if (Volatile) {
1406 EnvFileInterface->Write = FileInterfaceEnvVolWrite;
1407 } else {
1408 EnvFileInterface->Write = FileInterfaceEnvNonVolWrite;
1409 }
1410
1411 return ((EFI_FILE_PROTOCOL *)EnvFileInterface);
1412}
1413
1421VOID
1423 IN UINTN LineLength,
1424 IN OUT UINTN *Column,
1425 IN OUT UINTN *Row
1426 )
1427{
1428 //
1429 // If current column is 0, move to the last column of the previous line,
1430 // otherwise, just decrement column.
1431 //
1432 if (*Column == 0) {
1433 *Column = LineLength - 1;
1434 if (*Row > 0) {
1435 (*Row)--;
1436 }
1437
1438 return;
1439 }
1440
1441 (*Column)--;
1442}
1443
1452VOID
1454 IN UINTN LineLength,
1455 IN UINTN TotalRow,
1456 IN OUT UINTN *Column,
1457 IN OUT UINTN *Row
1458 )
1459{
1460 //
1461 // Increment Column.
1462 // If this puts column past the end of the line, move to first column
1463 // of the next row.
1464 //
1465 (*Column)++;
1466 if (*Column >= LineLength) {
1467 (*Column) = 0;
1468 if ((*Row) < TotalRow - 1) {
1469 (*Row)++;
1470 }
1471 }
1472}
1473
1483VOID
1485 IN CONST UINTN TotalCols,
1486 IN CONST UINTN TotalRows,
1487 IN CONST UINTN StartColumn
1488 )
1489{
1490 BUFFER_LIST *Node;
1491 UINTN Index;
1492 UINTN LineNumber;
1493 UINTN LineCount;
1494
1495 ShellPrintEx (-1, -1, L"\n");
1496 Index = 0;
1497 LineNumber = 0;
1498 //
1499 // go through history list...
1500 //
1501 for ( Node = (BUFFER_LIST *)GetFirstNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link)
1502 ; !IsNull (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link)
1503 ; Node = (BUFFER_LIST *)GetNextNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link)
1504 )
1505 {
1506 Index++;
1507 LineCount = ((StrLen (Node->Buffer) + StartColumn + 1) / TotalCols) + 1;
1508
1509 if (LineNumber + LineCount >= TotalRows) {
1511 ShellPromptResponseTypeEnterContinue,
1512 STRING_TOKEN (STR_SHELL_ENTER_TO_CONT),
1513 ShellInfoObject.HiiHandle,
1514 NULL
1515 );
1516 LineNumber = 0;
1517 }
1518
1519 ShellPrintEx (-1, -1, L"%2d. %s\n", Index, Node->Buffer);
1520 LineNumber += LineCount;
1521 }
1522}
1523
1524//
1525// This is identical to EFI_FILE_PROTOCOL except for the additional members
1526// for the buffer, size, and position.
1527//
1528
1529typedef struct {
1530 UINT64 Revision;
1533 EFI_FILE_DELETE Delete;
1534 EFI_FILE_READ Read;
1535 EFI_FILE_WRITE Write;
1536 EFI_FILE_GET_POSITION GetPosition;
1537 EFI_FILE_SET_POSITION SetPosition;
1538 EFI_FILE_GET_INFO GetInfo;
1539 EFI_FILE_SET_INFO SetInfo;
1540 EFI_FILE_FLUSH Flush;
1541 VOID *Buffer;
1542 UINT64 Position;
1543 UINT64 BufferSize;
1544 BOOLEAN Unicode;
1545 UINT64 FileSize;
1547
1558EFIAPI
1560 IN EFI_FILE_PROTOCOL *This,
1561 OUT UINT64 Position
1562 )
1563{
1564 if (Position <= ((EFI_FILE_PROTOCOL_MEM *)This)->FileSize) {
1565 ((EFI_FILE_PROTOCOL_MEM *)This)->Position = Position;
1566 return (EFI_SUCCESS);
1567 } else {
1568 return (EFI_INVALID_PARAMETER);
1569 }
1570}
1571
1581EFIAPI
1583 IN EFI_FILE_PROTOCOL *This,
1584 OUT UINT64 *Position
1585 )
1586{
1587 *Position = ((EFI_FILE_PROTOCOL_MEM *)This)->Position;
1588 return (EFI_SUCCESS);
1589}
1590
1610EFIAPI
1612 IN EFI_FILE_PROTOCOL *This,
1613 IN EFI_GUID *InformationType,
1614 IN OUT UINTN *BufferSize,
1615 OUT VOID *Buffer
1616 )
1617{
1619
1620 if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {
1621 if (*BufferSize < sizeof (EFI_FILE_INFO)) {
1622 *BufferSize = sizeof (EFI_FILE_INFO);
1623 return EFI_BUFFER_TOO_SMALL;
1624 }
1625
1626 if (Buffer == NULL) {
1627 return EFI_INVALID_PARAMETER;
1628 }
1629
1630 FileInfo = (EFI_FILE_INFO *)Buffer;
1631 FileInfo->Size = sizeof (*FileInfo);
1632 ZeroMem (FileInfo, sizeof (*FileInfo));
1633 FileInfo->FileSize = ((EFI_FILE_PROTOCOL_MEM *)This)->FileSize;
1635 return EFI_SUCCESS;
1636 }
1637
1638 return EFI_UNSUPPORTED;
1639}
1640
1652EFIAPI
1654 IN EFI_FILE_PROTOCOL *This,
1655 IN OUT UINTN *BufferSize,
1656 IN VOID *Buffer
1657 )
1658{
1659 CHAR8 *AsciiBuffer;
1660 EFI_FILE_PROTOCOL_MEM *MemFile;
1661
1662 MemFile = (EFI_FILE_PROTOCOL_MEM *)This;
1663 if (MemFile->Unicode) {
1664 //
1665 // Unicode
1666 //
1667 if ((UINTN)(MemFile->Position + (*BufferSize)) > (UINTN)(MemFile->BufferSize)) {
1668 MemFile->Buffer = ReallocatePool ((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
1669 if (MemFile->Buffer == NULL) {
1670 return EFI_OUT_OF_RESOURCES;
1671 }
1672
1673 MemFile->BufferSize += (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD;
1674 }
1675
1676 CopyMem (((UINT8 *)MemFile->Buffer) + MemFile->Position, Buffer, *BufferSize);
1677 MemFile->Position += (*BufferSize);
1678 MemFile->FileSize = MemFile->Position;
1679 return (EFI_SUCCESS);
1680 } else {
1681 //
1682 // Ascii
1683 //
1684 AsciiBuffer = AllocateZeroPool (*BufferSize);
1685 if (AsciiBuffer == NULL) {
1686 return (EFI_OUT_OF_RESOURCES);
1687 }
1688
1689 AsciiSPrint (AsciiBuffer, *BufferSize, "%S", Buffer);
1690 if ((UINTN)(MemFile->Position + AsciiStrSize (AsciiBuffer)) > (UINTN)(MemFile->BufferSize)) {
1691 MemFile->Buffer = ReallocatePool ((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + AsciiStrSize (AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
1692 if (MemFile->Buffer == NULL) {
1693 FreePool (AsciiBuffer);
1694 return EFI_OUT_OF_RESOURCES;
1695 }
1696
1697 MemFile->BufferSize += AsciiStrSize (AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD;
1698 }
1699
1700 CopyMem (((UINT8 *)MemFile->Buffer) + MemFile->Position, AsciiBuffer, AsciiStrSize (AsciiBuffer));
1701 MemFile->Position += (*BufferSize / sizeof (CHAR16));
1702 MemFile->FileSize = MemFile->Position;
1703 FreePool (AsciiBuffer);
1704 return (EFI_SUCCESS);
1705 }
1706}
1707
1718EFIAPI
1720 IN EFI_FILE_PROTOCOL *This,
1721 IN OUT UINTN *BufferSize,
1722 IN VOID *Buffer
1723 )
1724{
1725 EFI_FILE_PROTOCOL_MEM *MemFile;
1726
1727 MemFile = (EFI_FILE_PROTOCOL_MEM *)This;
1728 if (*BufferSize > (UINTN)((MemFile->FileSize) - (UINTN)(MemFile->Position))) {
1729 (*BufferSize) = (UINTN)((MemFile->FileSize) - (UINTN)(MemFile->Position));
1730 }
1731
1732 CopyMem (Buffer, ((UINT8 *)MemFile->Buffer) + MemFile->Position, (*BufferSize));
1733 MemFile->Position = MemFile->Position + (*BufferSize);
1734 return (EFI_SUCCESS);
1735}
1736
1747EFIAPI
1749 IN EFI_FILE_PROTOCOL *This
1750 )
1751{
1752 SHELL_FREE_NON_NULL (((EFI_FILE_PROTOCOL_MEM *)This)->Buffer);
1753 SHELL_FREE_NON_NULL (This);
1754 return (EFI_SUCCESS);
1755}
1756
1768 IN CONST BOOLEAN Unicode
1769 )
1770{
1771 EFI_FILE_PROTOCOL_MEM *FileInterface;
1772
1773 //
1774 // Get some memory
1775 //
1776 FileInterface = AllocateZeroPool (sizeof (EFI_FILE_PROTOCOL_MEM));
1777 if (FileInterface == NULL) {
1778 return (NULL);
1779 }
1780
1781 //
1782 // Assign the generic members
1783 //
1784 FileInterface->Revision = EFI_FILE_REVISION;
1785 FileInterface->Open = FileInterfaceOpenNotFound;
1786 FileInterface->Close = FileInterfaceMemClose;
1787 FileInterface->GetPosition = FileInterfaceMemGetPosition;
1788 FileInterface->SetPosition = FileInterfaceMemSetPosition;
1789 FileInterface->GetInfo = FileInterfaceMemGetInfo;
1790 FileInterface->SetInfo = FileInterfaceNopSetInfo;
1791 FileInterface->Flush = FileInterfaceNopGeneric;
1792 FileInterface->Delete = FileInterfaceNopGeneric;
1793 FileInterface->Read = FileInterfaceMemRead;
1794 FileInterface->Write = FileInterfaceMemWrite;
1795 FileInterface->Unicode = Unicode;
1796
1797 ASSERT (FileInterface->Buffer == NULL);
1798 ASSERT (FileInterface->BufferSize == 0);
1799 ASSERT (FileInterface->Position == 0);
1800
1801 if (Unicode) {
1802 FileInterface->Buffer = AllocateZeroPool (sizeof (gUnicodeFileTag));
1803 if (FileInterface->Buffer == NULL) {
1804 FreePool (FileInterface);
1805 return NULL;
1806 }
1807
1808 *((CHAR16 *)(FileInterface->Buffer)) = EFI_UNICODE_BYTE_ORDER_MARK;
1809 FileInterface->BufferSize = 2;
1810 FileInterface->Position = 2;
1811 }
1812
1813 return ((EFI_FILE_PROTOCOL *)FileInterface);
1814}
1815
1816typedef struct {
1817 UINT64 Revision;
1820 EFI_FILE_DELETE Delete;
1821 EFI_FILE_READ Read;
1822 EFI_FILE_WRITE Write;
1823 EFI_FILE_GET_POSITION GetPosition;
1824 EFI_FILE_SET_POSITION SetPosition;
1825 EFI_FILE_GET_INFO GetInfo;
1826 EFI_FILE_SET_INFO SetInfo;
1827 EFI_FILE_FLUSH Flush;
1828 BOOLEAN Unicode;
1829 EFI_FILE_PROTOCOL *Orig;
1831
1843EFIAPI
1845 IN EFI_FILE_PROTOCOL *This,
1846 IN UINT64 Position
1847 )
1848{
1849 return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->SetPosition (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, Position);
1850}
1851
1863EFIAPI
1865 IN EFI_FILE_PROTOCOL *This,
1866 OUT UINT64 *Position
1867 )
1868{
1869 return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->GetPosition (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, Position);
1870}
1871
1891EFIAPI
1893 IN EFI_FILE_PROTOCOL *This,
1894 IN EFI_GUID *InformationType,
1895 IN OUT UINTN *BufferSize,
1896 OUT VOID *Buffer
1897 )
1898{
1899 return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->GetInfo (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, InformationType, BufferSize, Buffer);
1900}
1901
1920EFIAPI
1922 IN EFI_FILE_PROTOCOL *This,
1923 IN EFI_GUID *InformationType,
1924 IN UINTN BufferSize,
1925 IN VOID *Buffer
1926 )
1927{
1928 return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->SetInfo (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, InformationType, BufferSize, Buffer);
1929}
1930
1947EFIAPI
1949 IN EFI_FILE_PROTOCOL *This
1950 )
1951{
1952 return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Flush (((EFI_FILE_PROTOCOL_FILE *)This)->Orig);
1953}
1954
1970EFIAPI
1972 IN EFI_FILE_PROTOCOL *This,
1973 IN OUT UINTN *BufferSize,
1974 OUT VOID *Buffer
1975 )
1976{
1977 EFI_STATUS Status;
1978 UINT64 Position;
1979 CHAR8 *AsciiStrBuffer;
1980 CHAR16 *UscStrBuffer;
1981 UINTN Size;
1982
1983 if (((EFI_FILE_PROTOCOL_FILE *)This)->Unicode) {
1984 //
1985 // Unicode
1986 // There might be different file tag for the Unicode file. We cannot unconditionally insert the \xFEFF.
1987 // So we choose to leave the file content as is.
1988 //
1989 return (((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Read (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, BufferSize, Buffer));
1990 } else {
1991 //
1992 // Ascii
1993 //
1994 *BufferSize = *BufferSize / sizeof (CHAR16) * sizeof (CHAR16);
1995 if (*BufferSize == 0) {
1996 return EFI_SUCCESS;
1997 }
1998
1999 Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->GetPosition (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, &Position);
2000 if (EFI_ERROR (Status)) {
2001 return Status;
2002 }
2003
2004 if (Position == 0) {
2005 //
2006 // First two bytes in Buffer is for the Unicode file tag.
2007 //
2008 *(CHAR16 *)Buffer = gUnicodeFileTag;
2009 Buffer = (CHAR16 *)Buffer + 1;
2010 Size = *BufferSize / sizeof (CHAR16) - 1;
2011 } else {
2012 Size = *BufferSize / sizeof (CHAR16);
2013 }
2014
2015 AsciiStrBuffer = AllocateZeroPool (Size + 1);
2016 if (AsciiStrBuffer == NULL) {
2017 return EFI_OUT_OF_RESOURCES;
2018 }
2019
2020 UscStrBuffer = AllocateZeroPool ((Size + 1) * sizeof (CHAR16));
2021 if (UscStrBuffer == NULL) {
2022 SHELL_FREE_NON_NULL (AsciiStrBuffer);
2023 return EFI_OUT_OF_RESOURCES;
2024 }
2025
2026 Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Read (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, &Size, AsciiStrBuffer);
2027 if (!EFI_ERROR (Status)) {
2028 AsciiStrToUnicodeStrS (AsciiStrBuffer, UscStrBuffer, Size + 1);
2029 *BufferSize = Size * sizeof (CHAR16);
2030 CopyMem (Buffer, UscStrBuffer, *BufferSize);
2031 }
2032
2033 SHELL_FREE_NON_NULL (AsciiStrBuffer);
2034 SHELL_FREE_NON_NULL (UscStrBuffer);
2035 return Status;
2036 }
2037}
2038
2059EFIAPI
2061 IN EFI_FILE_PROTOCOL *This,
2062 OUT EFI_FILE_PROTOCOL **NewHandle,
2063 IN CHAR16 *FileName,
2064 IN UINT64 OpenMode,
2065 IN UINT64 Attributes
2066 )
2067{
2068 return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Open (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, NewHandle, FileName, OpenMode, Attributes);
2069}
2070
2081EFIAPI
2083 IN EFI_FILE_PROTOCOL *This
2084 )
2085{
2086 EFI_STATUS Status;
2087
2088 Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Delete (((EFI_FILE_PROTOCOL_FILE *)This)->Orig);
2089 FreePool (This);
2090 return (Status);
2091}
2092
2101EFIAPI
2103 IN EFI_FILE_PROTOCOL *This
2104 )
2105{
2106 EFI_STATUS Status;
2107
2108 Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Close (((EFI_FILE_PROTOCOL_FILE *)This)->Orig);
2109 FreePool (This);
2110 return (Status);
2111}
2112
2126EFIAPI
2128 IN EFI_FILE_PROTOCOL *This,
2129 IN OUT UINTN *BufferSize,
2130 IN VOID *Buffer
2131 )
2132{
2133 CHAR8 *AsciiBuffer;
2134 UINTN Size;
2135 EFI_STATUS Status;
2136
2137 if (((EFI_FILE_PROTOCOL_FILE *)This)->Unicode) {
2138 //
2139 // Unicode
2140 //
2141 return (((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Write (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, BufferSize, Buffer));
2142 } else {
2143 //
2144 // Ascii
2145 //
2146 AsciiBuffer = AllocateZeroPool (*BufferSize);
2147 if (AsciiBuffer == NULL) {
2148 return EFI_OUT_OF_RESOURCES;
2149 }
2150
2151 AsciiSPrint (AsciiBuffer, *BufferSize, "%S", Buffer);
2152 Size = AsciiStrSize (AsciiBuffer) - 1; // (we dont need the null terminator)
2153 Status = (((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Write (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, &Size, AsciiBuffer));
2154 FreePool (AsciiBuffer);
2155 return (Status);
2156 }
2157}
2158
2172 IN CONST EFI_FILE_PROTOCOL *Template,
2173 IN CONST BOOLEAN Unicode
2174 )
2175{
2176 EFI_FILE_PROTOCOL_FILE *NewOne;
2177
2178 NewOne = AllocateZeroPool (sizeof (EFI_FILE_PROTOCOL_FILE));
2179 if (NewOne == NULL) {
2180 return (NULL);
2181 }
2182
2183 CopyMem (NewOne, Template, sizeof (EFI_FILE_PROTOCOL_FILE));
2184 NewOne->Orig = (EFI_FILE_PROTOCOL *)Template;
2185 NewOne->Unicode = Unicode;
2186 NewOne->Open = FileInterfaceFileOpen;
2187 NewOne->Close = FileInterfaceFileClose;
2188 NewOne->Delete = FileInterfaceFileDelete;
2189 NewOne->Read = FileInterfaceFileRead;
2190 NewOne->Write = FileInterfaceFileWrite;
2191 NewOne->GetPosition = FileInterfaceFileGetPosition;
2192 NewOne->SetPosition = FileInterfaceFileSetPosition;
2193 NewOne->GetInfo = FileInterfaceFileGetInfo;
2194 NewOne->SetInfo = FileInterfaceFileSetInfo;
2195 NewOne->Flush = FileInterfaceFileFlush;
2196
2197 return ((EFI_FILE_PROTOCOL *)NewOne);
2198}
UINT64 UINTN
EFI_STATUS EFIAPI Open(IN VOID *Buffer, OUT EFI_ACPI_HANDLE *Handle)
Definition: AcpiSdt.c:593
EFI_STATUS EFIAPI Close(IN EFI_ACPI_HANDLE Handle)
Definition: AcpiSdt.c:628
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:443
LIST_ENTRY *EFIAPI GetPreviousNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:369
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
Definition: String.c:72
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
Definition: LinkedList.c:403
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:333
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
Definition: String.c:109
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
Definition: LinkedList.c:298
RETURN_STATUS EFIAPI StrCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
Definition: SafeString.c:405
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
RETURN_STATUS EFIAPI StrnCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
Definition: SafeString.c:507
RETURN_STATUS EFIAPI AsciiStrToUnicodeStrS(IN CONST CHAR8 *Source, OUT CHAR16 *Destination, IN UINTN DestMax)
Definition: SafeString.c:2873
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
Definition: String.c:681
RETURN_STATUS EFIAPI StrnCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
Definition: SafeString.c:310
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
Definition: String.c:30
CHAR16 *EFIAPI StrStr(IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
Definition: String.c:224
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
Definition: SetMemWrapper.c:38
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS ConsoleLoggerDisplayHistory(IN CONST BOOLEAN Forward, IN CONST UINTN Rows, IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo)
EFI_STATUS ConsoleLoggerStopHistory(IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
CONST UINT16 gUnicodeFileTag
EFI_FILE_PROTOCOL FileInterfaceStdIn
EFI_STATUS EFIAPI FileInterfaceFileFlush(IN EFI_FILE_PROTOCOL *This)
EFI_STATUS EFIAPI FileInterfaceEnvDelete(IN EFI_FILE_PROTOCOL *This)
EFI_STATUS EFIAPI FileInterfaceFileSetInfo(IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN UINTN BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceOpenNotFound(IN EFI_FILE_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes)
EFI_STATUS EFIAPI FileInterfaceStdOutRead(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceFileGetPosition(IN EFI_FILE_PROTOCOL *This, OUT UINT64 *Position)
VOID MoveCursorBackward(IN UINTN LineLength, IN OUT UINTN *Column, IN OUT UINTN *Row)
EFI_STATUS EFIAPI FileInterfaceMemClose(IN EFI_FILE_PROTOCOL *This)
EFI_STATUS EFIAPI FileInterfaceNopSetInfo(IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN UINTN BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceFileWrite(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceMemSetPosition(IN EFI_FILE_PROTOCOL *This, OUT UINT64 Position)
EFI_STATUS EFIAPI FileInterfaceMemGetInfo(IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceNulWrite(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceFileSetPosition(IN EFI_FILE_PROTOCOL *This, IN UINT64 Position)
EFI_FILE_PROTOCOL * CreateFileInterfaceMem(IN CONST BOOLEAN Unicode)
EFI_FILE_PROTOCOL FileInterfaceNulFile
EFI_STATUS EFIAPI FileInterfaceStdErrRead(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceStdInWrite(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceEnvVolWrite(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceFileClose(IN EFI_FILE_PROTOCOL *This)
EFI_STATUS EFIAPI FileInterfaceNulRead(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceMemGetPosition(IN EFI_FILE_PROTOCOL *This, OUT UINT64 *Position)
EFI_STATUS EFIAPI FileInterfaceMemWrite(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceNopGetInfo(IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceFileDelete(IN EFI_FILE_PROTOCOL *This)
EFI_STATUS EFIAPI FileInterfaceStdInRead(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceFileOpen(IN EFI_FILE_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes)
EFI_STATUS EFIAPI FileInterfaceNopGeneric(IN EFI_FILE_PROTOCOL *This)
EFI_STATUS EFIAPI FileInterfaceStdErrWrite(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
VOID MoveCursorForward(IN UINTN LineLength, IN UINTN TotalRow, IN OUT UINTN *Column, IN OUT UINTN *Row)
EFI_STATUS EFIAPI FileInterfaceFileRead(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_FILE_PROTOCOL * CreateFileInterfaceEnv(IN CONST CHAR16 *EnvName)
EFI_STATUS EFIAPI FileInterfaceEnvClose(IN EFI_FILE_PROTOCOL *This)
EFI_FILE_PROTOCOL FileInterfaceStdErr
EFI_STATUS EFIAPI FileInterfaceEnvRead(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_FILE_PROTOCOL FileInterfaceStdOut
EFI_STATUS EFIAPI FileInterfaceEnvNonVolWrite(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceNopGetPosition(IN EFI_FILE_PROTOCOL *This, OUT UINT64 *Position)
EFI_STATUS EFIAPI FileInterfaceMemRead(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI FileInterfaceNopSetPosition(IN EFI_FILE_PROTOCOL *This, IN UINT64 Position)
VOID PrintCommandHistory(IN CONST UINTN TotalCols, IN CONST UINTN TotalRows, IN CONST UINTN StartColumn)
EFI_FILE_PROTOCOL * CreateFileInterfaceFile(IN CONST EFI_FILE_PROTOCOL *Template, IN CONST BOOLEAN Unicode)
EFI_STATUS EFIAPI FileInterfaceFileGetInfo(IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS CreateTabCompletionList(IN CONST CHAR16 *InputString, IN CONST UINTN StringLen, IN CONST UINTN BufferSize, IN OUT EFI_SHELL_FILE_INFO **TabCompletionList, IN OUT UINTN *TabUpdatePos)
EFI_STATUS EFIAPI FileInterfaceStdOutWrite(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
UINTN EFIAPI AsciiSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...)
Definition: PrintLib.c:813
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG_CODE(Expression)
Definition: DebugLib.h:590
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
VOID AddLineToCommandHistory(IN CONST CHAR16 *Buffer)
Definition: Shell.c:1534
EFI_STATUS IsVolatileEnv(IN CONST CHAR16 *EnvVarName, OUT BOOLEAN *Volatile)
Definition: ShellEnvVar.c:29
EFI_STATUS ShellAddEnvVarToList(IN CONST CHAR16 *Key, IN CONST CHAR16 *Value, IN UINTN ValueSize, IN UINT32 Atts)
Definition: ShellEnvVar.c:472
EFI_STATUS ShellRemvoeEnvVarFromList(IN CONST CHAR16 *Key)
Definition: ShellEnvVar.c:543
#define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName, BufferSize, Buffer)
Definition: ShellEnvVar.h:75
#define SHELL_DELETE_ENVIRONMENT_VARIABLE(EnvVarName)
Definition: ShellEnvVar.h:55
#define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName, BufferSize, Buffer)
Definition: ShellEnvVar.h:136
#define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName, BufferSize, Buffer)
Definition: ShellEnvVar.h:95
EFI_STATUS EFIAPI ShellPromptForResponseHii(IN SHELL_PROMPT_REQUEST_TYPE Type, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle, IN OUT VOID **Response)
EFI_STATUS EFIAPI ShellIsDirectory(IN CONST CHAR16 *DirName)
EFI_STATUS EFIAPI ShellPrintEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR16 *Format,...)
VOID InternalFreeShellFileInfoNode(IN EFI_SHELL_FILE_INFO *FileListNode)
EFI_STATUS(EFIAPI * EFI_FILE_FLUSH)(IN EFI_FILE_PROTOCOL *This)
EFI_STATUS(EFIAPI * EFI_FILE_WRITE)(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS(EFIAPI * EFI_FILE_DELETE)(IN EFI_FILE_PROTOCOL *This)
EFI_STATUS(EFIAPI * EFI_FILE_SET_INFO)(IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN UINTN BufferSize, IN VOID *Buffer)
EFI_STATUS(EFIAPI * EFI_FILE_OPEN)(IN EFI_FILE_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes)
EFI_STATUS(EFIAPI * EFI_FILE_GET_INFO)(IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS(EFIAPI * EFI_FILE_GET_POSITION)(IN EFI_FILE_PROTOCOL *This, OUT UINT64 *Position)
EFI_STATUS(EFIAPI * EFI_FILE_CLOSE)(IN EFI_FILE_PROTOCOL *This)
EFI_STATUS(EFIAPI * EFI_FILE_READ)(IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS(EFIAPI * EFI_FILE_SET_POSITION)(IN EFI_FILE_PROTOCOL *This, IN UINT64 Position)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_SYSTEM_TABLE * gST
EFI_BOOT_SERVICES * gBS
#define STRING_TOKEN(t)
#define EFI_VARIABLE_NON_VOLATILE
#define EFI_UNICODE_BYTE_ORDER_MARK
EFI_SIMPLE_TEXT_OUTPUT_MODE * Mode
UINT64 PhysicalSize
Definition: FileInfo.h:31
UINT64 Size
Definition: FileInfo.h:23
CHAR16 FileName[1]
Definition: FileInfo.h:52
UINT64 FileSize
Definition: FileInfo.h:27
LIST_ENTRY Link
Linked list members.
Definition: Shell.h:153
CONST CHAR16 * FileName
name of this file.
Definition: Shell.h:156
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * StdErr
Definition: UefiSpec.h:2075
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
Definition: UefiSpec.h:2053
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
Definition: UefiSpec.h:2064
Definition: Base.h:213
UINT32 NoConsoleOut
Was "-noconsoleout" found on command line.
Definition: Shell.h:67
EFI_HII_HANDLE HiiHandle
Handle from HiiLib.
Definition: Shell.h:105
CONSOLE_LOGGER_PRIVATE_DATA * ConsoleInfo
Pointer for ConsoleInformation.
Definition: Shell.h:110
BOOLEAN InsertMode
Is the current typing mode insert (FALSE = overwrite).
Definition: Shell.h:94