aboutsummaryrefslogtreecommitdiff
path: root/include/semihosting.h
diff options
context:
space:
mode:
authorSean Anderson2022-03-22 16:59:15 -0400
committerTom Rini2022-04-01 15:03:13 -0400
commiteff77c3a24ff6623f3767816ca54b8124f0e69a7 (patch)
tree40464d4b5457de29ef9de2d9e32185a34b9a9cfe /include/semihosting.h
parentb10f724807312a996100c7c4b779d320ed40d573 (diff)
arm: smh: Use numeric modes for smh_open
There's no point in using string constants for smh_open if we are just going to have to parse them. Instead, use numeric modes. The user needs to be a bit careful with these, since they are much closer semantically to string modes used by fopen(3) than the numeric modes used with open(2). Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Diffstat (limited to 'include/semihosting.h')
-rw-r--r--include/semihosting.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/include/semihosting.h b/include/semihosting.h
index 38438630465..cf54819192b 100644
--- a/include/semihosting.h
+++ b/include/semihosting.h
@@ -6,7 +6,30 @@
#ifndef _SEMIHOSTING_H
#define _SEMIHOSTING_H
-long smh_open(const char *fname, char *modestr);
+/**
+ * enum smh_open_mode - Numeric file modes for use with smh_open()
+ * MODE_READ: 'r'
+ * MODE_BINARY: 'b'
+ * MODE_PLUS: '+'
+ * MODE_WRITE: 'w'
+ * MODE_APPEND: 'a'
+ *
+ * These modes represent the mode string used by fopen(3) in a form which can
+ * be passed to smh_open(). These do NOT correspond directly to %O_RDONLY,
+ * %O_CREAT, etc; see fopen(3) for details. In particular, @MODE_PLUS
+ * effectively results in adding %O_RDWR, and @MODE_WRITE will add %O_TRUNC.
+ * For compatibility, @MODE_BINARY should be added when opening non-text files
+ * (such as images).
+ */
+enum smh_open_mode {
+ MODE_READ = 0x0,
+ MODE_BINARY = 0x1,
+ MODE_PLUS = 0x2,
+ MODE_WRITE = 0x4,
+ MODE_APPEND = 0x8,
+};
+
+long smh_open(const char *fname, enum smh_open_mode mode);
long smh_read(long fd, void *memp, size_t len);
long smh_close(long fd);
long smh_flen(long fd);