Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: earlycon-arm-semihost: Move smh_putc() variants in respective arch's semihost.h

Move smh_putc() variants in respective arch/*/include/asm/semihost.h,
in preparation to add RISC-V support.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Tested-by: Sergey Matyukevich <sergey.matyukevich@syntacore.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Link: https://lore.kernel.org/r/20221209150437.795918-2-bmeng@tinylab.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Bin Meng and committed by
Greg Kroah-Hartman
88907175 41000b03

+55 -24
+30
arch/arm/include/asm/semihost.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2012 ARM Ltd. 4 + * Author: Marc Zyngier <marc.zyngier@arm.com> 5 + * 6 + * Adapted for ARM and earlycon: 7 + * Copyright (C) 2014 Linaro Ltd. 8 + * Author: Rob Herring <robh@kernel.org> 9 + */ 10 + 11 + #ifndef _ARM_SEMIHOST_H_ 12 + #define _ARM_SEMIHOST_H_ 13 + 14 + #ifdef CONFIG_THUMB2_KERNEL 15 + #define SEMIHOST_SWI "0xab" 16 + #else 17 + #define SEMIHOST_SWI "0x123456" 18 + #endif 19 + 20 + struct uart_port; 21 + 22 + static inline void smh_putc(struct uart_port *port, unsigned char c) 23 + { 24 + asm volatile("mov r1, %0\n" 25 + "mov r0, #3\n" 26 + "svc " SEMIHOST_SWI "\n" 27 + : : "r" (&c) : "r0", "r1", "memory"); 28 + } 29 + 30 + #endif /* _ARM_SEMIHOST_H_ */
+24
arch/arm64/include/asm/semihost.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2012 ARM Ltd. 4 + * Author: Marc Zyngier <marc.zyngier@arm.com> 5 + * 6 + * Adapted for ARM and earlycon: 7 + * Copyright (C) 2014 Linaro Ltd. 8 + * Author: Rob Herring <robh@kernel.org> 9 + */ 10 + 11 + #ifndef _ARM64_SEMIHOST_H_ 12 + #define _ARM64_SEMIHOST_H_ 13 + 14 + struct uart_port; 15 + 16 + static inline void smh_putc(struct uart_port *port, unsigned char c) 17 + { 18 + asm volatile("mov x1, %0\n" 19 + "mov x0, #3\n" 20 + "hlt 0xf000\n" 21 + : : "r" (&c) : "x0", "x1", "memory"); 22 + } 23 + 24 + #endif /* _ARM64_SEMIHOST_H_ */
+1 -24
drivers/tty/serial/earlycon-arm-semihost.c
··· 11 11 #include <linux/console.h> 12 12 #include <linux/init.h> 13 13 #include <linux/serial_core.h> 14 - 15 - #ifdef CONFIG_THUMB2_KERNEL 16 - #define SEMIHOST_SWI "0xab" 17 - #else 18 - #define SEMIHOST_SWI "0x123456" 19 - #endif 20 - 21 - /* 22 - * Semihosting-based debug console 23 - */ 24 - static void smh_putc(struct uart_port *port, unsigned char c) 25 - { 26 - #ifdef CONFIG_ARM64 27 - asm volatile("mov x1, %0\n" 28 - "mov x0, #3\n" 29 - "hlt 0xf000\n" 30 - : : "r" (&c) : "x0", "x1", "memory"); 31 - #else 32 - asm volatile("mov r1, %0\n" 33 - "mov r0, #3\n" 34 - "svc " SEMIHOST_SWI "\n" 35 - : : "r" (&c) : "r0", "r1", "memory"); 36 - #endif 37 - } 14 + #include <asm/semihost.h> 38 15 39 16 static void smh_write(struct console *con, const char *s, unsigned n) 40 17 {