OUT UINTN *Length\r
);\r
\r
+/**\r
+ Get a temporary name for a file from the host running the debug agent.\r
+\r
+ @param[out] Buffer Pointer to the buffer where the temporary name has to\r
+ be stored\r
+ @param[in] Identifier File name identifier (integer in the range 0 to 255)\r
+ @param[in] Length Length of the buffer to store the temporary name\r
+\r
+ @retval RETURN_SUCCESS Temporary name returned\r
+ @retval RETURN_INVALID_PARAMETER Invalid buffer address\r
+ @retval RETURN_ABORTED Temporary name not returned\r
+\r
+**/\r
+RETURN_STATUS\r
+SemihostFileTmpName(\r
+ OUT VOID *Buffer,\r
+ IN UINT8 Identifier,\r
+ IN UINTN Length\r
+ );\r
+\r
RETURN_STATUS\r
SemihostFileRemove (\r
IN CHAR8 *FileName\r
);\r
\r
+/**\r
+ Rename a specified file.\r
+\r
+ @param[in] FileName Name of the file to rename.\r
+ @param[in] NewFileName The new name of the file.\r
+\r
+ @retval RETURN_SUCCESS File Renamed\r
+ @retval RETURN_INVALID_PARAMETER Either the current or the new name is not specified\r
+ @retval RETURN_ABORTED Rename failed\r
+\r
+**/\r
+RETURN_STATUS\r
+SemihostFileRename(\r
+ IN CHAR8 *FileName,\r
+ IN CHAR8 *NewFileName\r
+ );\r
+\r
CHAR8\r
SemihostReadCharacter (\r
VOID\r
}\r
}\r
\r
+/**\r
+ Get a temporary name for a file from the host running the debug agent.\r
+\r
+ @param[out] Buffer Pointer to the buffer where the temporary name has to\r
+ be stored\r
+ @param[in] Identifier File name identifier (integer in the range 0 to 255)\r
+ @param[in] Length Length of the buffer to store the temporary name\r
+\r
+ @retval RETURN_SUCCESS Temporary name returned\r
+ @retval RETURN_INVALID_PARAMETER Invalid buffer address\r
+ @retval RETURN_ABORTED Temporary name not returned\r
+\r
+**/\r
+RETURN_STATUS\r
+SemihostFileTmpName(\r
+ OUT VOID *Buffer,\r
+ IN UINT8 Identifier,\r
+ IN UINTN Length\r
+ )\r
+{\r
+ SEMIHOST_FILE_TMPNAME_BLOCK TmpNameBlock;\r
+ INT32 Result;\r
+\r
+ if (Buffer == NULL) {\r
+ return RETURN_INVALID_PARAMETER;\r
+ }\r
+\r
+ TmpNameBlock.Buffer = Buffer;\r
+ TmpNameBlock.Identifier = Identifier;\r
+ TmpNameBlock.Length = Length;\r
+\r
+ Result = Semihost_SYS_TMPNAME (&TmpNameBlock);\r
+\r
+ if (Result != 0) {\r
+ return RETURN_ABORTED;\r
+ } else {\r
+ return RETURN_SUCCESS;\r
+ }\r
+}\r
+\r
RETURN_STATUS\r
SemihostFileRemove (\r
IN CHAR8 *FileName\r
}\r
}\r
\r
+/**\r
+ Rename a specified file.\r
+\r
+ @param[in] FileName Name of the file to rename.\r
+ @param[in] NewFileName The new name of the file.\r
+\r
+ @retval RETURN_SUCCESS File Renamed\r
+ @retval RETURN_INVALID_PARAMETER Either the current or the new name is not specified\r
+ @retval RETURN_ABORTED Rename failed\r
+\r
+**/\r
+RETURN_STATUS\r
+SemihostFileRename(\r
+ IN CHAR8 *FileName,\r
+ IN CHAR8 *NewFileName\r
+ )\r
+{\r
+ SEMIHOST_FILE_RENAME_BLOCK RenameBlock;\r
+ INT32 Result;\r
+\r
+ if ((FileName == NULL) || (NewFileName == NULL)) {\r
+ return RETURN_INVALID_PARAMETER;\r
+ }\r
+\r
+ RenameBlock.FileName = FileName;\r
+ RenameBlock.FileNameLength = AsciiStrLen (FileName);\r
+ RenameBlock.NewFileName = NewFileName;\r
+ RenameBlock.NewFileNameLength = AsciiStrLen (NewFileName);\r
+\r
+ Result = Semihost_SYS_RENAME (&RenameBlock);\r
+\r
+ if (Result != 0) {\r
+ return RETURN_ABORTED;\r
+ } else {\r
+ return RETURN_SUCCESS;\r
+ }\r
+}\r
+\r
CHAR8\r
SemihostReadCharacter (\r
VOID\r
UINTN Location;\r
} SEMIHOST_FILE_SEEK_BLOCK;\r
\r
+typedef struct {\r
+ VOID *Buffer;\r
+ UINTN Identifier;\r
+ UINTN Length;\r
+} SEMIHOST_FILE_TMPNAME_BLOCK;\r
+\r
typedef struct {\r
CHAR8 *FileName;\r
UINTN NameLength;\r
} SEMIHOST_FILE_REMOVE_BLOCK;\r
\r
+typedef struct {\r
+ CHAR8 *FileName;\r
+ UINTN FileNameLength;\r
+ CHAR8 *NewFileName;\r
+ UINTN NewFileNameLength;\r
+} SEMIHOST_FILE_RENAME_BLOCK;\r
+\r
typedef struct {\r
CHAR8 *CommandLine;\r
UINTN CommandLength;\r
IN UINT32 *Handle\r
);\r
\r
+__swi(SWI)\r
+UINT32\r
+_Semihost_SYS_TMPNAME(\r
+ IN UINTN SWI_0x0D,\r
+ IN SEMIHOST_FILE_TMPNAME_BLOCK *TmpNameBlock\r
+ );\r
+\r
__swi(SWI)\r
UINT32\r
_Semihost_SYS_REMOVE(\r
IN SEMIHOST_FILE_REMOVE_BLOCK *RemoveBlock\r
);\r
\r
+__swi(SWI)\r
+UINT32\r
+_Semihost_SYS_RENAME(\r
+ IN UINTN SWI_0x0F,\r
+ IN SEMIHOST_FILE_RENAME_BLOCK *RenameBlock\r
+ );\r
+\r
__swi(SWI)\r
UINT32\r
_Semihost_SYS_SYSTEM(\r
#define Semihost_SYS_READC() _Semihost_SYS_READC(0x07, 0)\r
#define Semihost_SYS_SEEK(SeekBlock) _Semihost_SYS_SEEK(0x0A, SeekBlock)\r
#define Semihost_SYS_FLEN(Handle) _Semihost_SYS_FLEN(0x0C, Handle)\r
+#define Semihost_SYS_TMPNAME(TmpNameBlock) _Semihost_SYS_TMPNAME(0x0D, TmpNameBlock)\r
#define Semihost_SYS_REMOVE(RemoveBlock) _Semihost_SYS_REMOVE(0x0E, RemoveBlock)\r
+#define Semihost_SYS_RENAME(RenameBlock) _Semihost_SYS_RENAME(0x0F, RenameBlock)\r
#define Semihost_SYS_SYSTEM(SystemBlock) _Semihost_SYS_SYSTEM(0x12, SystemBlock)\r
\r
#elif defined(__GNUC__) // __CC_ARM\r
#define Semihost_SYS_READC() GccSemihostCall(0x07, (UINTN)(0))\r
#define Semihost_SYS_SEEK(SeekBlock) GccSemihostCall(0x0A, (UINTN)(SeekBlock))\r
#define Semihost_SYS_FLEN(Handle) GccSemihostCall(0x0C, (UINTN)(Handle))\r
+#define Semihost_SYS_TMPNAME(TmpNameBlock) GccSemihostCall(0x0D, (UINTN)(TmpNameBlock))\r
#define Semihost_SYS_REMOVE(RemoveBlock) GccSemihostCall(0x0E, (UINTN)(RemoveBlock))\r
+#define Semihost_SYS_RENAME(RenameBlock) GccSemihostCall(0x0F, (UINTN)(RenameBlock))\r
#define Semihost_SYS_SYSTEM(SystemBlock) GccSemihostCall(0x12, (UINTN)(SystemBlock))\r
\r
#else // __CC_ARM\r
#define Semihost_SYS_READC() ('x')\r
#define Semihost_SYS_SEEK(SeekBlock) (-1)\r
#define Semihost_SYS_FLEN(Handle) (-1)\r
+#define Semihost_SYS_TMPNAME(TmpNameBlock) (-1)\r
#define Semihost_SYS_REMOVE(RemoveBlock) (-1)\r
+#define Semihost_SYS_RENAME(RenameBlock) (-1)\r
#define Semihost_SYS_SYSTEM(SystemBlock) (-1)\r
\r
#endif // __CC_ARM\r