summaryrefslogtreecommitdiffstats
path: root/bsps/riscv
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-01-11 08:27:40 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-01-12 08:15:58 +0100
commitd46366a2e755865884551166c9fec0533673ec87 (patch)
tree6b5d3b2d75662de0dc3e315ae1d688dd897cdb27 /bsps/riscv
parentbsps/xil: Use the LP64 header for ILP32 (diff)
downloadrtems-d46366a2e755865884551166c9fec0533673ec87.tar.bz2
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.
Diffstat (limited to 'bsps/riscv')
-rw-r--r--bsps/riscv/noel/include/bsp/riscv.h2
-rw-r--r--bsps/riscv/riscv/console/console-config.c9
-rw-r--r--bsps/riscv/riscv/console/htif.c4
-rw-r--r--bsps/riscv/riscv/include/bsp/riscv.h2
-rw-r--r--bsps/riscv/riscv/irq/irq.c18
-rw-r--r--bsps/riscv/riscv/start/bsp_fatal_halt.c7
6 files changed, 30 insertions, 12 deletions
diff --git a/bsps/riscv/noel/include/bsp/riscv.h b/bsps/riscv/noel/include/bsp/riscv.h
index 3ab75573f0..0fdf64747b 100644
--- a/bsps/riscv/noel/include/bsp/riscv.h
+++ b/bsps/riscv/noel/include/bsp/riscv.h
@@ -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
diff --git a/bsps/riscv/riscv/console/console-config.c b/bsps/riscv/riscv/console/console-config.c
index fe339c2353..4916191e0b 100644
--- a/bsps/riscv/riscv/console/console-config.c
+++ b/bsps/riscv/riscv/console/console-config.c
@@ -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) {
diff --git a/bsps/riscv/riscv/console/htif.c b/bsps/riscv/riscv/console/htif.c
index 750abe6e3e..159d9d72fb 100644
--- a/bsps/riscv/riscv/console/htif.c
+++ b/bsps/riscv/riscv/console/htif.c
@@ -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 */
diff --git a/bsps/riscv/riscv/include/bsp/riscv.h b/bsps/riscv/riscv/include/bsp/riscv.h
index a11ae4291e..bbaaa246c1 100644
--- a/bsps/riscv/riscv/include/bsp/riscv.h
+++ b/bsps/riscv/riscv/include/bsp/riscv.h
@@ -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
}
diff --git a/bsps/riscv/riscv/irq/irq.c b/bsps/riscv/riscv/irq/irq.c
index f0ccc6f5f0..e8d297052b 100644
--- a/bsps/riscv/riscv/irq/irq.c
+++ b/bsps/riscv/riscv/irq/irq.c
@@ -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;
diff --git a/bsps/riscv/riscv/start/bsp_fatal_halt.c b/bsps/riscv/riscv/start/bsp_fatal_halt.c
index cd7c5f20c5..e4db1f03ca 100644
--- a/bsps/riscv/riscv/start/bsp_fatal_halt.c
+++ b/bsps/riscv/riscv/start/bsp_fatal_halt.c
@@ -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(;;);