aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Anderson2022-03-22 16:59:14 -0400
committerTom Rini2022-04-01 15:03:13 -0400
commitb10f724807312a996100c7c4b779d320ed40d573 (patch)
tree3a06ddbdb20e62cf443cf24d6d445a108b0b62a8
parentc8f4cc9590c480f962451344a4c795b1503c1359 (diff)
arm: smh: Export semihosting functions
This exports semihosting functions for use in other files. The header is in include/ and not arm/include/asm because I anticipate that RISC-V may want to add their own implementation at some point. smh_len_fd has been renamed to smh_flen to more closely match the semihosting spec. Signed-off-by: Sean Anderson <sean.anderson@seco.com>
-rw-r--r--arch/arm/lib/semihosting.c11
-rw-r--r--include/semihosting.h14
2 files changed, 20 insertions, 5 deletions
diff --git a/arch/arm/lib/semihosting.c b/arch/arm/lib/semihosting.c
index 9fd82459b24..c38892fdd88 100644
--- a/arch/arm/lib/semihosting.c
+++ b/arch/arm/lib/semihosting.c
@@ -15,6 +15,7 @@
#include <command.h>
#include <env.h>
#include <log.h>
+#include <semihosting.h>
#define SYSOPEN 0x01
#define SYSCLOSE 0x02
@@ -45,7 +46,7 @@ static noinline long smh_trap(unsigned int sysnum, void *addr)
* Open a file on the host. Mode is "r" or "rb" currently. Returns a file
* descriptor or -1 on error.
*/
-static long smh_open(const char *fname, char *modestr)
+long smh_open(const char *fname, char *modestr)
{
long fd;
unsigned long mode;
@@ -84,7 +85,7 @@ static long smh_open(const char *fname, char *modestr)
/*
* Read 'len' bytes of file into 'memp'. Returns 0 on success, else failure
*/
-static long smh_read(long fd, void *memp, size_t len)
+long smh_read(long fd, void *memp, size_t len)
{
long ret;
struct smh_read_s {
@@ -118,7 +119,7 @@ static long smh_read(long fd, void *memp, size_t len)
/*
* Close the file using the file descriptor
*/
-static long smh_close(long fd)
+long smh_close(long fd)
{
long ret;
@@ -134,7 +135,7 @@ static long smh_close(long fd)
/*
* Get the file length from the file descriptor
*/
-static long smh_len_fd(long fd)
+long smh_flen(long fd)
{
long ret;
@@ -158,7 +159,7 @@ static int smh_load_file(const char * const name, ulong load_addr,
if (fd == -1)
return -1;
- len = smh_len_fd(fd);
+ len = smh_flen(fd);
if (len < 0) {
smh_close(fd);
return -1;
diff --git a/include/semihosting.h b/include/semihosting.h
new file mode 100644
index 00000000000..38438630465
--- /dev/null
+++ b/include/semihosting.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2022 Sean Anderson <sean.anderson@seco.com>
+ */
+
+#ifndef _SEMIHOSTING_H
+#define _SEMIHOSTING_H
+
+long smh_open(const char *fname, char *modestr);
+long smh_read(long fd, void *memp, size_t len);
+long smh_close(long fd);
+long smh_flen(long fd);
+
+#endif /* _SEMIHOSTING_H */