summaryrefslogtreecommitdiff
path: root/include/semihosting.h
diff options
context:
space:
mode:
authorBradley Morgan <brads@mainlining.org>2026-10-04 10:42:10 +0000
committerBradley Morgan <brads@mainlining.org>2026-10-04 10:46:46 +0000
commit5ff54a875642962fc857cee00bde17f9a465f1fa (patch)
treeb265a12d538167c3bbb86b24118a7ad7a062fc74 /include/semihosting.h
tashaboot: arm64 bootloaderHEADmain
holy shit it's here, Tashaboot, based from arm arm, enjoy reading this masterpiece Signed-off-by: Bradley Morgan <brads@mainlining.org>
Diffstat (limited to 'include/semihosting.h')
-rw-r--r--include/semihosting.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/semihosting.h b/include/semihosting.h
new file mode 100644
index 0000000..450848e
--- /dev/null
+++ b/include/semihosting.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __SEMIHOSTING_H
+#define __SEMIHOSTING_H
+
+#include <sys/types.h>
+
+/*
+ * semihosting file io, backed by the host when qemu runs with
+ * -semihosting. all calls return negative errno style errors so the
+ * boot flow can fall back to whatever the board has without semihosting.
+ */
+
+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_write(long fd, const void *memp, size_t len, size_t *written);
+void smh_write0(const char *str);
+long smh_close(long fd);
+long smh_flen(long fd);
+long smh_seek(long fd, long pos);
+
+/* probe once, a boot without a debugger attached must not trap */
+bool smh_probe(void);
+
+#endif