arm: smh: Add some file manipulation commands

In order to add filesystem support, we will need to be able to seek and
write files. Add the appropriate helper functions.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
This commit is contained in:
Sean Anderson 2022-03-22 16:59:18 -04:00 committed by Tom Rini
parent 79f6ad6a7b
commit 12a05b3bcd
2 changed files with 76 additions and 11 deletions

View file

@ -50,6 +50,17 @@ long smh_open(const char *fname, enum smh_open_mode mode);
*/
long smh_read(long fd, void *memp, size_t len);
/**
* smh_write() - Write data to a file
* @fd: A file descriptor returned from smh_open()
* @memp: Pointer to a buffer of memory of at least @len bytes
* @len: The number of bytes to read
* @written: Pointer which will be updated with the actual bytes written
*
* Return: 0 on success or negative error on failure
*/
long smh_write(long fd, const void *memp, size_t len, ulong *written);
/**
* smh_close() - Close an open file
* @fd: A file descriptor returned from smh_open()
@ -66,4 +77,13 @@ long smh_close(long fd);
*/
long smh_flen(long fd);
/**
* smh_seek() - Seek to a position in a file
* @fd: A file descriptor returned from smh_open()
* @pos: The offset (in bytes) to seek to
*
* Return: 0 on success or negative error on failure
*/
long smh_seek(long fd, long pos);
#endif /* _SEMIHOSTING_H */