Support a Semi Host file system over a debuggers JTAG\r
\r
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>\r
+ Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid) != 0) {\r
//Status = SetFilesystemInfo (Fcb, BufferSize, Buffer);\r
} else if (CompareGuid (InformationType, &gEfiFileInfoGuid) != 0) {\r
- //Status = SetFileInfo (Fcb, BufferSize, Buffer);\r
+ // Semihosting does not give us access to setting file info, but\r
+ // if we fail here we cannot create new files.\r
+ Status = EFI_SUCCESS;\r
} else if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid) != 0) {\r
if (StrSize (Buffer) > 0) {\r
FreePool (mSemihostFsLabel);\r
/** @file\r
\r
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- \r
+ Copyright (c) 2013 - 2014, ARM Ltd. All rights reserved.<BR>\r
+\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
Result = Semihost_SYS_SEEK(&SeekBlock);\r
\r
- if (Result == 0) {\r
- return RETURN_SUCCESS;\r
- } else {\r
+ // Semihosting does not behave as documented. It returns the offset on\r
+ // success.\r
+ if (Result < 0) {\r
return RETURN_ABORTED;\r
+ } else {\r
+ return RETURN_SUCCESS;\r
}\r
}\r
\r
\r
Result = Semihost_SYS_READ(&ReadBlock);\r
\r
- if (Result == *Length) {\r
+ if ((*Length != 0) && (Result == *Length)) {\r
return RETURN_ABORTED;\r
} else {\r
*Length -= Result;\r
WriteBlock.Length = *Length;\r
\r
*Length = Semihost_SYS_WRITE(&WriteBlock);\r
- \r
- return RETURN_SUCCESS;\r
+\r
+ if (*Length != 0)\r
+ return RETURN_ABORTED;\r
+ else\r
+ return RETURN_SUCCESS;\r
}\r
\r
RETURN_STATUS\r
SEMIHOST_FILE_REMOVE_BLOCK RemoveBlock;\r
UINT32 Result;\r
\r
+ // Remove any leading separator (e.g.: '\'). EFI Shell adds one.\r
+ if (*FileName == '\\') {\r
+ FileName++;\r
+ }\r
+\r
RemoveBlock.FileName = FileName;\r
RemoveBlock.NameLength = AsciiStrLen(FileName);\r
\r