mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 05:47:56 +08:00
riscv: Resurrect RISCV_ENABLE_HTIF_SUPPORT
Low-end configurations may want to have the HTIF support removed. Enable the option by default. Fix formatting. Fix node validity checks. Updates #4779.
This commit is contained in:
@@ -50,8 +50,6 @@ extern uint32_t riscv_hart_count;
|
||||
|
||||
uint32_t riscv_get_hart_index_by_phandle(uint32_t phandle);
|
||||
|
||||
void htif_poweroff(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -60,7 +60,9 @@
|
||||
static fe310_uart_context fe310_uart_instance;
|
||||
#endif
|
||||
|
||||
#ifdef RISCV_ENABLE_HTIF_SUPPORT
|
||||
static htif_console_context htif_console_instance;
|
||||
#endif
|
||||
|
||||
#if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0
|
||||
static ns16550_context ns16550_instances[RISCV_CONSOLE_MAX_NS16550_DEVICES];
|
||||
@@ -163,6 +165,7 @@ static void riscv_console_probe(void)
|
||||
compat_len = 0;
|
||||
}
|
||||
|
||||
#ifdef RISCV_ENABLE_HTIF_SUPPORT
|
||||
/* Search for HTIF (eg. on Spike) and use it if found */
|
||||
if (fdt_stringlist_contains(compat, compat_len, "ucb,htif0")) {
|
||||
htif_console_context_init(&htif_console_instance.base, node);
|
||||
@@ -171,6 +174,7 @@ static void riscv_console_probe(void)
|
||||
riscv_console.putchar = htif_console_putchar;
|
||||
riscv_console.getchar = htif_console_getchar;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0
|
||||
if (
|
||||
@@ -277,9 +281,10 @@ rtems_status_code console_initialize(
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
#ifdef RISCV_ENABLE_HTIF_SUPPORT
|
||||
rtems_termios_device_context *base;
|
||||
char htif_path[] = "/dev/ttyShtif";
|
||||
|
||||
#endif
|
||||
#if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0
|
||||
char path[] = "/dev/ttyS?";
|
||||
size_t i;
|
||||
@@ -292,12 +297,14 @@ rtems_status_code console_initialize(
|
||||
|
||||
rtems_termios_initialize();
|
||||
|
||||
#ifdef RISCV_ENABLE_HTIF_SUPPORT
|
||||
base = &htif_console_instance.base;
|
||||
rtems_termios_device_install(htif_path, &htif_console_handler, NULL, base);
|
||||
|
||||
if (base == riscv_console.context) {
|
||||
link(htif_path, CONSOLE_DEVICE_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0
|
||||
for (i = 0; i < RISCV_CONSOLE_MAX_NS16550_DEVICES; ++i) {
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
#include <bsp/riscv.h>
|
||||
|
||||
#ifdef RISCV_ENABLE_HTIF_SUPPORT
|
||||
|
||||
#include <dev/serial/htif.h>
|
||||
|
||||
#include <assert.h>
|
||||
@@ -137,3 +139,5 @@ const rtems_termios_device_handler htif_console_handler = {
|
||||
.poll_read = htif_console_getchar,
|
||||
.mode = TERMIOS_POLLED
|
||||
};
|
||||
|
||||
#endif /* RISCV_ENABLE_HTIF_SUPPORT */
|
||||
|
||||
@@ -52,7 +52,9 @@ extern uint32_t riscv_hart_count;
|
||||
|
||||
uint32_t riscv_get_hart_index_by_phandle(uint32_t phandle);
|
||||
|
||||
#ifdef RISCV_ENABLE_HTIF_SUPPORT
|
||||
void htif_poweroff(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -249,14 +249,18 @@ static void riscv_plic_init(const void *fdt)
|
||||
plic = riscv_fdt_get_address(fdt, node);
|
||||
|
||||
if (plic == NULL) {
|
||||
node = fdt_node_offset_by_compatible(fdt, -1, "ucb,htif0");
|
||||
#ifdef RISCV_ENABLE_HTIF_SUPPORT
|
||||
node = fdt_node_offset_by_compatible(fdt, -1, "ucb,htif0");
|
||||
|
||||
/* Spike platform has HTIF and does not have a PLIC */
|
||||
if (node != -1) {
|
||||
return;
|
||||
} else {
|
||||
bsp_fatal(RISCV_FATAL_NO_PLIC_REG_IN_DEVICE_TREE);
|
||||
}
|
||||
/* Spike platform has HTIF and does not have a PLIC */
|
||||
if (node >= 0) {
|
||||
return;
|
||||
} else {
|
||||
bsp_fatal(RISCV_FATAL_NO_PLIC_REG_IN_DEVICE_TREE);
|
||||
}
|
||||
#else
|
||||
bsp_fatal(RISCV_FATAL_NO_PLIC_REG_IN_DEVICE_TREE);
|
||||
#endif
|
||||
}
|
||||
|
||||
riscv_plic = plic;
|
||||
|
||||
@@ -40,10 +40,13 @@ void _CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr error )
|
||||
|
||||
fdt = bsp_fdt_get();
|
||||
|
||||
#ifdef RISCV_ENABLE_HTIF_SUPPORT
|
||||
node = fdt_node_offset_by_compatible(fdt, -1, "ucb,htif0");
|
||||
|
||||
if (node != -1)
|
||||
htif_poweroff();
|
||||
if (node >= 0) {
|
||||
htif_poweroff();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if RISCV_ENABLE_MPFS_SUPPORT != 0
|
||||
for(;;);
|
||||
|
||||
@@ -5,10 +5,10 @@ actions:
|
||||
build-type: option
|
||||
copyrights:
|
||||
- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||
default: false
|
||||
default: true
|
||||
default-by-variant: []
|
||||
description: |
|
||||
enables the HTIF support if defined to a non-zero value, otherwise it is disabled (disabled by default)
|
||||
Enable the Host/Target Interface (HTIF) support.
|
||||
enabled-by: true
|
||||
links: []
|
||||
name: RISCV_ENABLE_HTIF_SUPPORT
|
||||
|
||||
Reference in New Issue
Block a user