Message ID | 20221205050038.195746-1-bmeng@tinylab.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Palmer Dabbelt |
Headers | show |
Series | [1/2] serial: Adapt Arm semihosting earlycon driver to RISC-V | expand |
Context | Check | Description |
---|---|---|
conchuod/patch_count | success | Link |
conchuod/cover_letter | success | Single patches do not need cover letters |
conchuod/tree_selection | success | Guessed tree name to be for-next |
conchuod/fixes_present | success | Fixes tag not required for -next series |
conchuod/verify_signedoff | success | Signed-off-by tag matches author and committer |
conchuod/kdoc | success | Errors and warnings before: 0 this patch: 0 |
conchuod/module_param | success | Was 0 now: 0 |
conchuod/alphanumeric_selects | success | Out of order selects before the patch: 57 and now 57 |
conchuod/build_rv32_defconfig | success | Build OK |
conchuod/build_warn_rv64 | success | Errors and warnings before: 0 this patch: 0 |
conchuod/dtb_warn_rv64 | success | Errors and warnings before: 0 this patch: 0 |
conchuod/header_inline | success | No static functions without inline keyword in header files |
conchuod/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 37 lines checked |
conchuod/source_inline | success | Was 0 now: 0 |
conchuod/build_rv64_nommu_k210_defconfig | success | Build OK |
conchuod/verify_fixes | success | No Fixes tag |
conchuod/build_rv64_nommu_virt_defconfig | success | Build OK |
On 05. 12. 22, 6:00, Bin Meng wrote: ... > --- a/drivers/tty/serial/earlycon-arm-semihost.c > +++ b/drivers/tty/serial/earlycon-arm-semihost.c ... > @@ -23,7 +27,18 @@ > */ > static void smh_putc(struct uart_port *port, unsigned char c) > { > -#ifdef CONFIG_ARM64 > +#if defined(CONFIG_RISCV) > + asm volatile("addi a1, %0, 0\n" > + "addi a0, zero, 3\n" > + ".balign 16\n" > + ".option push\n" > + ".option norvc\n" > + "slli zero, zero, 0x1f\n" > + "ebreak\n" > + "srai zero, zero, 0x7\n" > + ".option pop\n" > + : : "r" (&c) : "a0", "a1", "memory"); > +#elif defined(CONFIG_ARM64) > asm volatile("mov x1, %0\n" > "mov x0, #3\n" > "hlt 0xf000\n" Hmm, can we implement all those smh_putc() variants in respective arch/*/include/semihost.h instead? thanks,
On Tue, Dec 6, 2022 at 2:47 PM Jiri Slaby <jirislaby@kernel.org> wrote: > > On 05. 12. 22, 6:00, Bin Meng wrote: > ... > > --- a/drivers/tty/serial/earlycon-arm-semihost.c > > +++ b/drivers/tty/serial/earlycon-arm-semihost.c > ... > > @@ -23,7 +27,18 @@ > > */ > > static void smh_putc(struct uart_port *port, unsigned char c) > > { > > -#ifdef CONFIG_ARM64 > > +#if defined(CONFIG_RISCV) > > + asm volatile("addi a1, %0, 0\n" > > + "addi a0, zero, 3\n" > > + ".balign 16\n" > > + ".option push\n" > > + ".option norvc\n" > > + "slli zero, zero, 0x1f\n" > > + "ebreak\n" > > + "srai zero, zero, 0x7\n" > > + ".option pop\n" > > + : : "r" (&c) : "a0", "a1", "memory"); > > +#elif defined(CONFIG_ARM64) > > asm volatile("mov x1, %0\n" > > "mov x0, #3\n" > > "hlt 0xf000\n" > > Hmm, can we implement all those smh_putc() variants in respective > arch/*/include/semihost.h instead? > I think so. Will do in v2. Regards, Bin
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 434f83168546..e94d1265151c 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -75,7 +75,7 @@ config SERIAL_AMBA_PL011_CONSOLE config SERIAL_EARLYCON_ARM_SEMIHOST bool "Early console using ARM semihosting" - depends on ARM64 || ARM + depends on ARM64 || ARM || RISCV select SERIAL_CORE select SERIAL_CORE_CONSOLE select SERIAL_EARLYCON diff --git a/drivers/tty/serial/earlycon-arm-semihost.c b/drivers/tty/serial/earlycon-arm-semihost.c index fcdec5f42376..25a0f91926a3 100644 --- a/drivers/tty/serial/earlycon-arm-semihost.c +++ b/drivers/tty/serial/earlycon-arm-semihost.c @@ -6,6 +6,10 @@ * Adapted for ARM and earlycon: * Copyright (C) 2014 Linaro Ltd. * Author: Rob Herring <robh@kernel.org> + * + * Adapted for RISC-V and earlycon: + * Copyright (C) 2022 tinylab.org + * Author: Bin Meng <bmeng@tinylab.org> */ #include <linux/kernel.h> #include <linux/console.h> @@ -23,7 +27,18 @@ */ static void smh_putc(struct uart_port *port, unsigned char c) { -#ifdef CONFIG_ARM64 +#if defined(CONFIG_RISCV) + asm volatile("addi a1, %0, 0\n" + "addi a0, zero, 3\n" + ".balign 16\n" + ".option push\n" + ".option norvc\n" + "slli zero, zero, 0x1f\n" + "ebreak\n" + "srai zero, zero, 0x7\n" + ".option pop\n" + : : "r" (&c) : "a0", "a1", "memory"); +#elif defined(CONFIG_ARM64) asm volatile("mov x1, %0\n" "mov x0, #3\n" "hlt 0xf000\n"
Per RISC-V semihosting spec [1], adapt the existing Arm semihosting earlycon driver to RISC-V. [1] https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc Signed-off-by: Bin Meng <bmeng@tinylab.org> --- drivers/tty/serial/Kconfig | 2 +- drivers/tty/serial/earlycon-arm-semihost.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-)