summaryrefslogtreecommitdiff
path: root/ArmPkg/Library
diff options
context:
space:
mode:
authorRonald Cron <ronald.cron@arm.com>2014-10-27 10:38:18 +0000
committeroliviermartin <oliviermartin@Edk2>2014-10-27 10:38:18 +0000
commit5521b5cc73e21957023b634cb7f75e415bba0225 (patch)
treeaf76c114b00289672a156402ce120ed89a4b2feb /ArmPkg/Library
parentc20f8ec6619d6bd6717364e12211f03f5f499676 (diff)
downloadedk2-platforms-5521b5cc73e21957023b634cb7f75e415bba0225.tar.xz
ArmPkg/SemihostLib: Add library functions
Add library functions to rename a file and get a temporary name for a file through the semi-hosting interface. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ronald Cron <ronald.cron@arm.com> Reviewed-By: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16238 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg/Library')
-rw-r--r--ArmPkg/Library/SemihostLib/SemihostLib.c78
-rw-r--r--ArmPkg/Library/SemihostLib/SemihostPrivate.h33
2 files changed, 111 insertions, 0 deletions
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
diff --git a/ArmPkg/Library/SemihostLib/SemihostPrivate.h b/ArmPkg/Library/SemihostLib/SemihostPrivate.h
index bb0a026d4e..afc53274b0 100644
--- a/ArmPkg/Library/SemihostLib/SemihostPrivate.h
+++ b/ArmPkg/Library/SemihostLib/SemihostPrivate.h
@@ -34,11 +34,24 @@ typedef struct {
} SEMIHOST_FILE_SEEK_BLOCK;
typedef struct {
+ VOID *Buffer;
+ UINTN Identifier;
+ UINTN Length;
+} SEMIHOST_FILE_TMPNAME_BLOCK;
+
+typedef struct {
CHAR8 *FileName;
UINTN NameLength;
} SEMIHOST_FILE_REMOVE_BLOCK;
typedef struct {
+ CHAR8 *FileName;
+ UINTN FileNameLength;
+ CHAR8 *NewFileName;
+ UINTN NewFileNameLength;
+} SEMIHOST_FILE_RENAME_BLOCK;
+
+typedef struct {
CHAR8 *CommandLine;
UINTN CommandLength;
} SEMIHOST_SYSTEM_BLOCK;
@@ -118,6 +131,13 @@ _Semihost_SYS_FLEN(
__swi(SWI)
UINT32
+_Semihost_SYS_TMPNAME(
+ IN UINTN SWI_0x0D,
+ IN SEMIHOST_FILE_TMPNAME_BLOCK *TmpNameBlock
+ );
+
+__swi(SWI)
+UINT32
_Semihost_SYS_REMOVE(
IN UINTN SWI_0x0E,
IN SEMIHOST_FILE_REMOVE_BLOCK *RemoveBlock
@@ -125,6 +145,13 @@ _Semihost_SYS_REMOVE(
__swi(SWI)
UINT32
+_Semihost_SYS_RENAME(
+ IN UINTN SWI_0x0F,
+ IN SEMIHOST_FILE_RENAME_BLOCK *RenameBlock
+ );
+
+__swi(SWI)
+UINT32
_Semihost_SYS_SYSTEM(
IN UINTN SWI_0x12,
IN SEMIHOST_SYSTEM_BLOCK *SystemBlock
@@ -139,7 +166,9 @@ _Semihost_SYS_SYSTEM(
#define Semihost_SYS_READC() _Semihost_SYS_READC(0x07, 0)
#define Semihost_SYS_SEEK(SeekBlock) _Semihost_SYS_SEEK(0x0A, SeekBlock)
#define Semihost_SYS_FLEN(Handle) _Semihost_SYS_FLEN(0x0C, Handle)
+#define Semihost_SYS_TMPNAME(TmpNameBlock) _Semihost_SYS_TMPNAME(0x0D, TmpNameBlock)
#define Semihost_SYS_REMOVE(RemoveBlock) _Semihost_SYS_REMOVE(0x0E, RemoveBlock)
+#define Semihost_SYS_RENAME(RenameBlock) _Semihost_SYS_RENAME(0x0F, RenameBlock)
#define Semihost_SYS_SYSTEM(SystemBlock) _Semihost_SYS_SYSTEM(0x12, SystemBlock)
#elif defined(__GNUC__) // __CC_ARM
@@ -161,7 +190,9 @@ GccSemihostCall (
#define Semihost_SYS_READC() GccSemihostCall(0x07, (UINTN)(0))
#define Semihost_SYS_SEEK(SeekBlock) GccSemihostCall(0x0A, (UINTN)(SeekBlock))
#define Semihost_SYS_FLEN(Handle) GccSemihostCall(0x0C, (UINTN)(Handle))
+#define Semihost_SYS_TMPNAME(TmpNameBlock) GccSemihostCall(0x0D, (UINTN)(TmpNameBlock))
#define Semihost_SYS_REMOVE(RemoveBlock) GccSemihostCall(0x0E, (UINTN)(RemoveBlock))
+#define Semihost_SYS_RENAME(RenameBlock) GccSemihostCall(0x0F, (UINTN)(RenameBlock))
#define Semihost_SYS_SYSTEM(SystemBlock) GccSemihostCall(0x12, (UINTN)(SystemBlock))
#else // __CC_ARM
@@ -177,7 +208,9 @@ GccSemihostCall (
#define Semihost_SYS_READC() ('x')
#define Semihost_SYS_SEEK(SeekBlock) (-1)
#define Semihost_SYS_FLEN(Handle) (-1)
+#define Semihost_SYS_TMPNAME(TmpNameBlock) (-1)
#define Semihost_SYS_REMOVE(RemoveBlock) (-1)
+#define Semihost_SYS_RENAME(RenameBlock) (-1)
#define Semihost_SYS_SYSTEM(SystemBlock) (-1)
#endif // __CC_ARM