X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ArmPkg%2FLibrary%2FSemihostLib%2FSemihostLib.c;fp=ArmPkg%2FLibrary%2FSemihostLib%2FSemihostLib.c;h=b1bbcbb392797c32be65ae14030e54db38435616;hp=f93d7991d298dbb9b71bae9c8d15d37df075df35;hb=5521b5cc73e21957023b634cb7f75e415bba0225;hpb=c20f8ec6619d6bd6717364e12211f03f5f499676 diff --git a/ArmPkg/Library/SemihostLib/SemihostLib.c b/ArmPkg/Library/SemihostLib/SemihostLib.c index f93d7991d2..b1bbcbb392 100644 --- a/ArmPkg/Library/SemihostLib/SemihostLib.c +++ b/ArmPkg/Library/SemihostLib/SemihostLib.c @@ -172,6 +172,46 @@ SemihostFileLength ( } } +/** + Get a temporary name for a file from the host running the debug agent. + + @param[out] Buffer Pointer to the buffer where the temporary name has to + be stored + @param[in] Identifier File name identifier (integer in the range 0 to 255) + @param[in] Length Length of the buffer to store the temporary name + + @retval RETURN_SUCCESS Temporary name returned + @retval RETURN_INVALID_PARAMETER Invalid buffer address + @retval RETURN_ABORTED Temporary name not returned + +**/ +RETURN_STATUS +SemihostFileTmpName( + OUT VOID *Buffer, + IN UINT8 Identifier, + IN UINTN Length + ) +{ + SEMIHOST_FILE_TMPNAME_BLOCK TmpNameBlock; + INT32 Result; + + if (Buffer == NULL) { + return RETURN_INVALID_PARAMETER; + } + + TmpNameBlock.Buffer = Buffer; + TmpNameBlock.Identifier = Identifier; + TmpNameBlock.Length = Length; + + Result = Semihost_SYS_TMPNAME (&TmpNameBlock); + + if (Result != 0) { + return RETURN_ABORTED; + } else { + return RETURN_SUCCESS; + } +} + RETURN_STATUS SemihostFileRemove ( IN CHAR8 *FileName @@ -197,6 +237,44 @@ SemihostFileRemove ( } } +/** + Rename a specified file. + + @param[in] FileName Name of the file to rename. + @param[in] NewFileName The new name of the file. + + @retval RETURN_SUCCESS File Renamed + @retval RETURN_INVALID_PARAMETER Either the current or the new name is not specified + @retval RETURN_ABORTED Rename failed + +**/ +RETURN_STATUS +SemihostFileRename( + IN CHAR8 *FileName, + IN CHAR8 *NewFileName + ) +{ + SEMIHOST_FILE_RENAME_BLOCK RenameBlock; + INT32 Result; + + if ((FileName == NULL) || (NewFileName == NULL)) { + return RETURN_INVALID_PARAMETER; + } + + RenameBlock.FileName = FileName; + RenameBlock.FileNameLength = AsciiStrLen (FileName); + RenameBlock.NewFileName = NewFileName; + RenameBlock.NewFileNameLength = AsciiStrLen (NewFileName); + + Result = Semihost_SYS_RENAME (&RenameBlock); + + if (Result != 0) { + return RETURN_ABORTED; + } else { + return RETURN_SUCCESS; + } +} + CHAR8 SemihostReadCharacter ( VOID