From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/6] ARM: lib32: semihosting: prepare for more general use
Date: Tue, 11 Jun 2024 08:59:18 +0200 [thread overview]
Message-ID: <20240611065923.2900168-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240611065923.2900168-1-a.fatoum@pengutronix.de>
So far, we limited semihosting support to 32-bit ARM, but it's also
usable on ARM64 and even RISC-V. Move the common code to
drivers/firmware, so it can be shared by all architectures.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/Kconfig | 1 +
arch/arm/cpu/Makefile | 2 ++
.../semihosting-trap_32.S} | 2 +-
arch/arm/include/asm/semihosting.h | 15 +-----------
arch/arm/lib32/Makefile | 1 -
drivers/firmware/Kconfig | 3 +++
drivers/firmware/Makefile | 1 +
.../lib32 => drivers/firmware}/semihosting.c | 0
fs/Kconfig | 2 +-
include/asm-generic/semihosting.h | 23 +++++++++++++++++++
10 files changed, 33 insertions(+), 17 deletions(-)
rename arch/arm/{lib32/semihosting-trap.S => cpu/semihosting-trap_32.S} (84%)
rename {arch/arm/lib32 => drivers/firmware}/semihosting.c (100%)
create mode 100644 include/asm-generic/semihosting.h
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index be18b609c782..26547cd3ba71 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -373,6 +373,7 @@ config ARM_UNWIND
config ARM_SEMIHOSTING
bool "enable ARM semihosting support"
depends on !CPU_V8
+ select SEMIHOSTING
help
This option enables ARM semihosting support in barebox. ARM
semihosting is a communication discipline that allows code
diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
index 28161cd7d714..999cc375da1c 100644
--- a/arch/arm/cpu/Makefile
+++ b/arch/arm/cpu/Makefile
@@ -23,6 +23,8 @@ obj-pbl-y += setupc_$(S64_32).o cache_$(S64_32).o
obj-$(CONFIG_ARM_PSCI_CLIENT) += psci-client.o
+obj-$(CONFIG_ARM_SEMIHOSTING) += semihosting-trap_$(S64_32).o
+
#
# Any variants can be called as start-armxyz.S
#
diff --git a/arch/arm/lib32/semihosting-trap.S b/arch/arm/cpu/semihosting-trap_32.S
similarity index 84%
rename from arch/arm/lib32/semihosting-trap.S
rename to arch/arm/cpu/semihosting-trap_32.S
index f7960d7cea96..069cdaa1dd38 100644
--- a/arch/arm/lib32/semihosting-trap.S
+++ b/arch/arm/cpu/semihosting-trap_32.S
@@ -2,7 +2,7 @@
/* SPDX-FileCopyrightText: 2015 Zodiac Inflight Innovations */
/*
- * semihosting-trap.S -- Assembly code needed to make a semihosting call
+ * semihosting-trap_32.S -- Assembly code needed to make a semihosting call
*
* Author: Andrey Smirnov <andrew.smirnov@gmail.com>
*/
diff --git a/arch/arm/include/asm/semihosting.h b/arch/arm/include/asm/semihosting.h
index 9e1606c4aeaa..c18aa1a5fef5 100644
--- a/arch/arm/include/asm/semihosting.h
+++ b/arch/arm/include/asm/semihosting.h
@@ -3,19 +3,6 @@
#ifndef __ASM_ARM_SEMIHOSTING_H
#define __ASM_ARM_SEMIHOSTING_H
-int semihosting_open(const char *fname, int flags);
-int semihosting_close(int fd);
-int semihosting_writec(char c);
-int semihosting_write0(const char *str);
-ssize_t semihosting_write(int fd, const void *buf, size_t count);
-ssize_t semihosting_read(int fd, void *buf, size_t count);
-int semihosting_readc(void);
-int semihosting_isatty(int fd);
-int semihosting_seek(int fd, loff_t pos);
-int semihosting_flen(int fd);
-int semihosting_remove(const char *fname);
-int semihosting_rename(const char *fname1, const char *fname2);
-int semihosting_errno(void);
-int semihosting_system(const char *command);
+#include <asm-generic/semihosting.h>
#endif
diff --git a/arch/arm/lib32/Makefile b/arch/arm/lib32/Makefile
index d54fb7644c39..511a029062e6 100644
--- a/arch/arm/lib32/Makefile
+++ b/arch/arm/lib32/Makefile
@@ -23,7 +23,6 @@ pbl-y += runtime-offset.o
obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS) += memcpy.o
obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS) += memset.o
obj-$(CONFIG_ARM_UNWIND) += unwind.o
-obj-$(CONFIG_ARM_SEMIHOSTING) += semihosting-trap.o semihosting.o
obj-$(CONFIG_MODULES) += module.o
obj-$(CONFIG_ARM_MODULE_PLTS) += module-plts.o
extra-y += barebox.lds
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index 3252b61bc764..89c8bdeda3f0 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -1,6 +1,9 @@
# SPDX-License-Identifier: GPL-2.0-only
menu "Firmware Drivers"
+config SEMIHOSTING
+ bool
+
config FIRMWARE_ALTERA_SERIAL
bool "Altera SPI programming"
depends on OFDEVICE
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile
index 4eabf42fd639..d0ebe663ea55 100644
--- a/drivers/firmware/Makefile
+++ b/drivers/firmware/Makefile
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_SEMIHOSTING) += semihosting.o
obj-$(CONFIG_FIRMWARE_ALTERA_SERIAL) += altera_serial.o
obj-$(CONFIG_FIRMWARE_ALTERA_SOCFPGA) += socfpga.o socfpga_sdr.o
obj-$(CONFIG_FIRMWARE_ZYNQMP_FPGA) += zynqmp-fpga.o
diff --git a/arch/arm/lib32/semihosting.c b/drivers/firmware/semihosting.c
similarity index 100%
rename from arch/arm/lib32/semihosting.c
rename to drivers/firmware/semihosting.c
diff --git a/fs/Kconfig b/fs/Kconfig
index a3ba84b6aefd..e02cb939a5cf 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -113,7 +113,7 @@ config FS_UIMAGEFS
prompt "uImage FS support"
config FS_SMHFS
- depends on ARM_SEMIHOSTING
+ depends on SEMIHOSTING
select FS_LEGACY
bool
prompt "Semihosting FS support"
diff --git a/include/asm-generic/semihosting.h b/include/asm-generic/semihosting.h
new file mode 100644
index 000000000000..d337c33ff486
--- /dev/null
+++ b/include/asm-generic/semihosting.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_GENERIC_SEMIHOSTING_H
+#define __ASM_GENERIC_SEMIHOSTING_H
+
+#include <linux/types.h>
+
+int semihosting_open(const char *fname, int flags);
+int semihosting_close(int fd);
+int semihosting_writec(char c);
+int semihosting_write0(const char *str);
+ssize_t semihosting_write(int fd, const void *buf, size_t count);
+ssize_t semihosting_read(int fd, void *buf, size_t count);
+int semihosting_readc(void);
+int semihosting_isatty(int fd);
+int semihosting_seek(int fd, loff_t pos);
+int semihosting_flen(int fd);
+int semihosting_remove(const char *fname);
+int semihosting_rename(const char *fname1, const char *fname2);
+int semihosting_errno(void);
+int semihosting_system(const char *command);
+
+#endif
--
2.39.2
next prev parent reply other threads:[~2024-06-11 7:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-11 6:59 [PATCH 0/6] semihosting: extend support for ARM64, console Ahmad Fatoum
2024-06-11 6:59 ` Ahmad Fatoum [this message]
2024-06-11 6:59 ` [PATCH 2/6] firmware: semihosting: add ARMv8-A semihosting support Ahmad Fatoum
2024-06-11 6:59 ` [PATCH 3/6] firmware: semihosting: don't return error code from writec/write0 Ahmad Fatoum
2024-06-11 6:59 ` [PATCH 4/6] firmware: semihosting: translate return values in wrappers Ahmad Fatoum
2024-06-11 6:59 ` [PATCH 5/6] ARM: semihosting: add DEBUG_LL implementation Ahmad Fatoum
2024-06-11 6:59 ` [PATCH 6/6] serial: add semihosting console Ahmad Fatoum
2024-06-13 7:18 ` [PATCH 0/6] semihosting: extend support for ARM64, console Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240611065923.2900168-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox