From 070422db46af53cd692f01320b410d3ba07e57df Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Wed, 30 Mar 2022 17:51:54 +1000 Subject: [PATCH] arch: common: dedicated `SEMIHOST` symbol Control the usage of semihosting with a dedicated symbol, instead of implying semihosting from the usage of `SEMIHOST_CONSOLE`. This allows semihosting to be used without the semihost console. Signed-off-by: Jordan Yates --- arch/Kconfig | 2 ++ arch/common/Kconfig | 17 +++++++++++++++++ cmake/emu/qemu.cmake | 2 +- drivers/console/Kconfig | 11 ++--------- tests/drivers/console/prj_semihost.conf | 1 + 5 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 arch/common/Kconfig diff --git a/arch/Kconfig b/arch/Kconfig index 1fca3e3dac3..cb3564c2933 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -148,6 +148,8 @@ config ARCH_IS_SET menu "General Architecture Options" +source "$(ARCH_DIR)/common/Kconfig" + module = ARCH module-str = arch source "subsys/logging/Kconfig.template.log_config" diff --git a/arch/common/Kconfig b/arch/common/Kconfig new file mode 100644 index 00000000000..aabc599a4d5 --- /dev/null +++ b/arch/common/Kconfig @@ -0,0 +1,17 @@ +# Common architecture configuration options + +# Copyright (c) 2022, CSIRO. +# SPDX-License-Identifier: Apache-2.0 + +config SEMIHOST + bool "Semihosting support for ARM and RISC-V targets" + depends on ARM || ARM64 || RISCV + help + Semihosting is a mechanism that enables code running on an ARM or + RISC-V target to communicate and use the Input/Output facilities on + a host computer that is running a debugger. + Additional information can be found in: + https://developer.arm.com/documentation/dui0471/m/what-is-semihosting- + https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc + This option is compatible with hardware and with QEMU, through the + (automatic) use of the -semihosting-config switch when invoking it. diff --git a/cmake/emu/qemu.cmake b/cmake/emu/qemu.cmake index 317a6e566ad..b0d00356d91 100644 --- a/cmake/emu/qemu.cmake +++ b/cmake/emu/qemu.cmake @@ -70,7 +70,7 @@ endif() list(APPEND QEMU_FLAGS -serial chardev:con) # Connect semihosting console to the console chardev if configured. -if(CONFIG_SEMIHOST_CONSOLE) +if(CONFIG_SEMIHOST) list(APPEND QEMU_FLAGS -semihosting-config enable=on,target=auto,chardev=con ) diff --git a/drivers/console/Kconfig b/drivers/console/Kconfig index 1231e06a98e..51eb45acfc6 100644 --- a/drivers/console/Kconfig +++ b/drivers/console/Kconfig @@ -298,17 +298,10 @@ config NATIVE_POSIX_CONSOLE_INIT_PRIORITY config SEMIHOST_CONSOLE bool "Use semihosting for console" select CONSOLE_HAS_DRIVER - depends on CPU_CORTEX_M || ARM64 || RISCV + depends on SEMIHOST help Enable this option to use semihosting for console. - Semihosting is a mechanism that enables code running on an ARM or - RISC-V target to communicate and use the Input/Output facilities - on a host computer that is running a debugger. - Additional information can be found in: - https://developer.arm.com/docs/dui0471/k/what-is-semihosting/what-is-semihosting - https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc - This option is compatible with hardware and with QEMU, through the - (automatic) use of the -semihosting-config switch when invoking it. + See SEMIHOST for a more complete description of semihosting. module = UART_CONSOLE module-str = UART console diff --git a/tests/drivers/console/prj_semihost.conf b/tests/drivers/console/prj_semihost.conf index 7adbc210d7b..800bee2e935 100644 --- a/tests/drivers/console/prj_semihost.conf +++ b/tests/drivers/console/prj_semihost.conf @@ -2,4 +2,5 @@ CONFIG_TEST=y CONFIG_CONSOLE=y CONFIG_SERIAL=n CONFIG_UART_CONSOLE=n +CONFIG_SEMIHOST=y CONFIG_SEMIHOST_CONSOLE=y