drivers: console: add jailhouse debug console

Support jailhouse hypervisor debug console

Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
Peng Fan 2022-03-01 15:54:13 +08:00 committed by Anas Nashif
commit d1b8743b37
4 changed files with 69 additions and 0 deletions

View file

@ -230,6 +230,7 @@
/drivers/counter/ @nordic-krch /drivers/counter/ @nordic-krch
/drivers/console/ipm_console.c @finikorg /drivers/console/ipm_console.c @finikorg
/drivers/console/semihost_console.c @luozhongyao /drivers/console/semihost_console.c @luozhongyao
/drivers/console/jailhouse_debug_console.c @MrVan
/drivers/counter/counter_cmos.c @dcpleung /drivers/counter/counter_cmos.c @dcpleung
/drivers/counter/counter_ll_stm32_timer.c @kentjhall /drivers/counter/counter_ll_stm32_timer.c @kentjhall
/drivers/crypto/*nrf_ecb* @maciekfabia @anangl /drivers/crypto/*nrf_ecb* @maciekfabia @anangl

View file

@ -5,6 +5,7 @@ zephyr_library_sources_ifdef(CONFIG_GSM_MUX gsm_mux.c)
zephyr_library_sources_ifdef(CONFIG_IPM_CONSOLE_RECEIVER ipm_console_receiver.c) zephyr_library_sources_ifdef(CONFIG_IPM_CONSOLE_RECEIVER ipm_console_receiver.c)
zephyr_library_sources_ifdef(CONFIG_IPM_CONSOLE_SENDER ipm_console_sender.c) zephyr_library_sources_ifdef(CONFIG_IPM_CONSOLE_SENDER ipm_console_sender.c)
zephyr_library_sources_ifdef(CONFIG_IPM_CONSOLE ipm_console.c) zephyr_library_sources_ifdef(CONFIG_IPM_CONSOLE ipm_console.c)
zephyr_library_sources_ifdef(CONFIG_JAILHOUSE_DEBUG_CONSOLE jailhouse_debug_console.c)
zephyr_library_sources_ifdef(CONFIG_NATIVE_POSIX_CONSOLE native_posix_console.c) zephyr_library_sources_ifdef(CONFIG_NATIVE_POSIX_CONSOLE native_posix_console.c)
zephyr_library_sources_ifdef(CONFIG_RAM_CONSOLE ram_console.c) zephyr_library_sources_ifdef(CONFIG_RAM_CONSOLE ram_console.c)
zephyr_library_sources_ifdef(CONFIG_RTT_CONSOLE rtt_console.c) zephyr_library_sources_ifdef(CONFIG_RTT_CONSOLE rtt_console.c)

View file

@ -87,6 +87,15 @@ config UART_CONSOLE_INPUT_EXPIRED_TIMEOUT
Fixed amount of time which unit is milliseconds to keep the UART Fixed amount of time which unit is milliseconds to keep the UART
console in use flag true. console in use flag true.
config JAILHOUSE_DEBUG_CONSOLE
bool "Use JAILHOUSE_DEBUG console"
select CONSOLE_HAS_DRIVER
depends on ARM64
help
Emit console messages to a jailhouse hypervisor debug console.
Useful in board bring-up if there aren't any working serial
drivers.
config RAM_CONSOLE config RAM_CONSOLE
bool "Use RAM console" bool "Use RAM console"
select CONSOLE_HAS_DRIVER select CONSOLE_HAS_DRIVER

View file

@ -0,0 +1,58 @@
/*
* Copyright 2022 NXP
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel.h>
#include <sys/printk.h>
#include <device.h>
#include <init.h>
#if defined(CONFIG_PRINTK) || defined(CONFIG_STDOUT_CONSOLE)
/**
* @brief Output one character to SIMULATOR console
* @param c Character to output
* @return The character passed as input.
*/
static int console_out(int c)
{
register unsigned long x0 __asm__("x0") = 8;
register unsigned long x1 __asm__("x1") = c;
__asm__ volatile ("hvc #0x4a48\r\n"
: "+r" (x0), "+r" (x1) : : );
return c;
}
#endif
#if defined(CONFIG_STDOUT_CONSOLE)
extern void __stdout_hook_install(int (*hook)(int));
#else
#define __stdout_hook_install(x) \
do {/* nothing */ \
} while ((0))
#endif
#if defined(CONFIG_PRINTK)
extern void __printk_hook_install(int (*fn)(int));
#else
#define __printk_hook_install(x) \
do {/* nothing */ \
} while ((0))
#endif
/**
* @brief Initialize the console/debug port
* @return 0 if successful, otherwise failed.
*/
static int jailhouse_console_init(const struct device *arg)
{
ARG_UNUSED(arg);
__stdout_hook_install(console_out);
__printk_hook_install(console_out);
return 0;
}
SYS_INIT(jailhouse_console_init,
PRE_KERNEL_1,
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);