summaryrefslogtreecommitdiff
path: root/EmbeddedPkg/Library
diff options
context:
space:
mode:
Diffstat (limited to 'EmbeddedPkg/Library')
-rw-r--r--EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c189
1 files changed, 82 insertions, 107 deletions
diff --git a/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c b/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c
index 8ef0790a81..1db7d7d035 100644
--- a/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c
+++ b/EmbeddedPkg/Library/EfiFileLib/EfiFileLib.c
@@ -100,8 +100,8 @@ Internal worker function to validate a File handle.
**/
BOOLEAN
FileHandleValid (
- IN EFI_OPEN_FILE *File
- )
+ IN EFI_OPEN_FILE *File
+ )
{
EFI_OPEN_FILE_GUARD *GuardFile;
@@ -123,8 +123,8 @@ Internal worker function. If Buffer is not NULL free it.
**/
VOID
EblFreePool (
- IN VOID *Buffer
- )
+ IN VOID *Buffer
+ )
{
if (Buffer != NULL) {
FreePool (Buffer);
@@ -137,45 +137,20 @@ Update Device List Global Variables
**/
VOID
EblUpdateDeviceLists (
- VOID
- )
+ VOID
+ )
{
EFI_STATUS Status;
UINTN Size;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
EFI_FILE_HANDLE Root;
UINTN Index;
- BOOLEAN Update;
if (mBlkIo != NULL) {
FreePool (mBlkIo);
}
gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &mBlkIoCount, &mBlkIo);
- //
- // This is a trick to trigger the gBS->ReinstallProtocolInterface () in a removable media
- // device to make a filesystem layer on. Probing devices will detect if media has been
- // inserted and create
- //
- for (Index =0, Update = FALSE; Index < mBlkIoCount; Index++) {
- Status = gBS->HandleProtocol (mBlkIo[Index], &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo);
- if (!EFI_ERROR (Status)) {
- if (BlkIo->Media->RemovableMedia) {
- gBS->DisconnectController (mBlkIo[Index], NULL, NULL);
- gBS->ConnectController (mBlkIo[Index], NULL, NULL, TRUE);
- Update = TRUE;
- }
- }
- }
-
- if (Update) {
- // In case we caused media to be detected that contains a partition (SD Card, ...) rescan
- if (mBlkIo != NULL) {
- FreePool (mBlkIo);
- }
- gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &mBlkIoCount, &mBlkIo);
- }
if (mFv != NULL) {
@@ -248,10 +223,10 @@ and it can be used with mFs[] to find the handle that needs to be opened
**/
BOOLEAN
EblMatchVolumeName (
- IN CHAR8 *PathName,
- IN UINTN FileStart,
- OUT UINTN *MatchIndex
- )
+ IN CHAR8 *PathName,
+ IN UINTN FileStart,
+ OUT UINTN *MatchIndex
+ )
{
UINTN Index;
UINTN Compare;
@@ -297,8 +272,8 @@ Return the number of devices of the current type active in the system
**/
UINTN
EfiGetDeviceCounts (
- IN EFI_OPEN_FILE_TYPE DeviceType
- )
+ IN EFI_OPEN_FILE_TYPE DeviceType
+ )
{
switch (DeviceType) {
case EfiOpenLoadFile:
@@ -316,9 +291,9 @@ EfiGetDeviceCounts (
EFI_STATUS
ConvertIpStringToEfiIp (
- IN CHAR8 *PathName,
- OUT EFI_IP_ADDRESS *ServerIp
- )
+ IN CHAR8 *PathName,
+ OUT EFI_IP_ADDRESS *ServerIp
+ )
{
CHAR8 *Str;
@@ -362,8 +337,8 @@ text. Easy way to extract numbers from strings like blk7:.
**/
UINTN
EblConvertDevStringToNumber (
- IN CHAR8 *Str
- )
+ IN CHAR8 *Str
+ )
{
UINTN Max;
UINTN Index;
@@ -392,10 +367,10 @@ Internal work function to fill in EFI_OPEN_FILE information for the Fs and BlkIo
**/
EFI_STATUS
EblFileDevicePath (
- IN OUT EFI_OPEN_FILE *File,
- IN CHAR8 *FileName,
- IN CONST UINT64 OpenMode
- )
+ IN OUT EFI_OPEN_FILE *File,
+ IN CHAR8 *FileName,
+ IN CONST UINT64 OpenMode
+ )
{
EFI_STATUS Status;
UINTN Size;
@@ -481,9 +456,9 @@ EblFileDevicePath (
EFI_STATUS
CompareGuidToString (
- IN EFI_GUID *Guid,
- IN CHAR8 *String
- )
+ IN EFI_GUID *Guid,
+ IN CHAR8 *String
+ )
{
CHAR8 AsciiGuid[64];
CHAR8 *StringPtr;
@@ -528,10 +503,10 @@ Internal work function to fill in EFI_OPEN_FILE information for the FV
**/
EFI_STATUS
EblFvFileDevicePath (
- IN OUT EFI_OPEN_FILE *File,
- IN CHAR8 *FileName,
- IN CONST UINT64 OpenMode
- )
+ IN OUT EFI_OPEN_FILE *File,
+ IN CHAR8 *FileName,
+ IN CONST UINT64 OpenMode
+ )
{
EFI_STATUS Status;
EFI_STATUS GetNextFileStatus;
@@ -678,10 +653,10 @@ For any file that is opened with EfiOpen() must be closed with EfiClose().
**/
EFI_OPEN_FILE *
EfiOpen (
- IN CHAR8 *PathName,
- IN CONST UINT64 OpenMode,
- IN CONST EFI_SECTION_TYPE SectionType
- )
+ IN CHAR8 *PathName,
+ IN CONST UINT64 OpenMode,
+ IN CONST EFI_SECTION_TYPE SectionType
+ )
{
EFI_STATUS Status;
EFI_OPEN_FILE *File;
@@ -937,9 +912,9 @@ ErrorExit:
EFI_STATUS
EfiCopyFile (
- IN CHAR8 *DestinationFile,
- IN CHAR8 *SourceFile
- )
+ IN CHAR8 *DestinationFile,
+ IN CHAR8 *SourceFile
+ )
{
EFI_OPEN_FILE *Source = NULL;
EFI_OPEN_FILE *Destination = NULL;
@@ -976,13 +951,13 @@ EfiCopyFile (
Status = EfiRead(Source, Buffer, &Chunk);
if (EFI_ERROR(Status)) {
- AsciiPrint("Read file error\n");
+ AsciiPrint("Read file error %r\n", Status);
goto Exit;
}
Status = EfiWrite(Destination, Buffer, &Chunk);
if (EFI_ERROR(Status)) {
- AsciiPrint("Write file error\n");
+ AsciiPrint("Write file error %r\n", Status);
goto Exit;
}
}
@@ -1038,9 +1013,9 @@ Use DeviceType and Index to form a valid PathName and try and open it.
**/
EFI_OPEN_FILE *
EfiDeviceOpenByType (
- IN EFI_OPEN_FILE_TYPE DeviceType,
- IN UINTN Index
- )
+ IN EFI_OPEN_FILE_TYPE DeviceType,
+ IN UINTN Index
+ )
{
CHAR8 *DevStr;
CHAR8 Path[MAX_CMD_LINE];
@@ -1083,8 +1058,8 @@ EfiOpen().
**/
EFI_STATUS
EfiClose (
- IN EFI_OPEN_FILE *File
- )
+ IN EFI_OPEN_FILE *File
+ )
{
EFI_STATUS Status;
UINT64 TftpBufferSize;
@@ -1117,21 +1092,21 @@ EfiClose (
if ((File->Type == EfiOpenLoadFile) ||
((File->Type == EfiOpenTftp) && (File->IsBufferValid == TRUE)) ||
((File->Type == EfiOpenFirmwareVolume) && (File->IsBufferValid == TRUE))) {
- EblFreePool(File->Buffer);
- }
+ EblFreePool(File->Buffer);
+ }
- EblFreePool (File->DevicePath);
- EblFreePool (File->DeviceName);
- EblFreePool (File->FsFileInfo);
- EblFreePool (File->FsInfo);
+ EblFreePool (File->DevicePath);
+ EblFreePool (File->DeviceName);
+ EblFreePool (File->FsFileInfo);
+ EblFreePool (File->FsInfo);
- if (File->FsFileHandle != NULL) {
- File->FsFileHandle->Close (File->FsFileHandle);
- }
+ if (File->FsFileHandle != NULL) {
+ File->FsFileHandle->Close (File->FsFileHandle);
+ }
- // Need to free File and it's Guard structures
- EblFreePool (BASE_CR (File, EFI_OPEN_FILE_GUARD, File));
- return EFI_SUCCESS;
+ // Need to free File and it's Guard structures
+ EblFreePool (BASE_CR (File, EFI_OPEN_FILE_GUARD, File));
+ return EFI_SUCCESS;
}
@@ -1147,9 +1122,9 @@ LoadFile is an exception as a load file size is set to zero.
**/
UINTN
EfiTell (
- IN EFI_OPEN_FILE *File,
- OUT EFI_LBA *CurrentPosition OPTIONAL
- )
+ IN EFI_OPEN_FILE *File,
+ OUT EFI_LBA *CurrentPosition OPTIONAL
+ )
{
EFI_STATUS Status;
UINT64 BufferSize = 0;
@@ -1221,10 +1196,10 @@ EfiSeekEnd : Only supported if Offset is zero to seek to end of file.
**/
EFI_STATUS
EfiSeek (
- IN EFI_OPEN_FILE *File,
- IN EFI_LBA Offset,
- IN EFI_SEEK_TYPE SeekType
- )
+ IN EFI_OPEN_FILE *File,
+ IN EFI_LBA Offset,
+ IN EFI_SEEK_TYPE SeekType
+ )
{
EFI_STATUS Status;
UINT64 CurrentPosition;
@@ -1280,8 +1255,8 @@ EfiSeek (
EFI_STATUS
CacheTftpFile (
- IN OUT EFI_OPEN_FILE *File
- )
+ IN OUT EFI_OPEN_FILE *File
+ )
{
EFI_STATUS Status;
UINT64 TftpBufferSize;
@@ -1341,10 +1316,10 @@ FV, and TFTP case you must read the entire file.
**/
EFI_STATUS
EfiRead (
- IN EFI_OPEN_FILE *File,
- OUT VOID *Buffer,
- OUT UINTN *BufferSize
- )
+ IN EFI_OPEN_FILE *File,
+ OUT VOID *Buffer,
+ OUT UINTN *BufferSize
+ )
{
EFI_STATUS Status;
UINT32 AuthenticationStatus;
@@ -1472,10 +1447,10 @@ must be.
**/
EFI_STATUS
EfiReadAllocatePool (
- IN EFI_OPEN_FILE *File,
- OUT VOID **Buffer,
- OUT UINTN *BufferSize
- )
+ IN EFI_OPEN_FILE *File,
+ OUT VOID **Buffer,
+ OUT UINTN *BufferSize
+ )
{
if (!FileHandleValid (File)) {
return EFI_INVALID_PARAMETER;
@@ -1511,10 +1486,10 @@ Write data back to the file. For TFTP case you must write the entire file.
**/
EFI_STATUS
EfiWrite (
- IN EFI_OPEN_FILE *File,
- OUT VOID *Buffer,
- OUT UINTN *BufferSize
- )
+ IN EFI_OPEN_FILE *File,
+ OUT VOID *Buffer,
+ OUT UINTN *BufferSize
+ )
{
EFI_STATUS Status;
EFI_FV_WRITE_FILE_DATA FileData;
@@ -1628,9 +1603,9 @@ directory names.
**/
CHAR8 *
ExpandPath (
- IN CHAR8 *Cwd,
- IN CHAR8 *Path
- )
+ IN CHAR8 *Cwd,
+ IN CHAR8 *Path
+ )
{
CHAR8 *NewPath;
CHAR8 *Work, *Start, *End;
@@ -1705,8 +1680,8 @@ the path does not contain a device name, The CWD is prepended to the path.
**/
EFI_STATUS
EfiSetCwd (
- IN CHAR8 *Cwd
- )
+ IN CHAR8 *Cwd
+ )
{
EFI_OPEN_FILE *File;
UINTN Len;
@@ -1781,8 +1756,8 @@ this funciton.
**/
CHAR8 *
EfiGetCwd (
- VOID
- )
+ VOID
+ )
{
if (gCwd == NULL) {
return "";