[PATCH v2 3/3] RISC-V: Always probe for HTIF and remove RISCV_ENABLE_HTIF_SUPPORT
heshamelmatary at gmail.com
heshamelmatary at gmail.com
Thu Dec 22 12:22:15 UTC 2022
From: Hesham Almatary <hesham.almatary at cl.cam.ac.uk>
Updates #4779
---
bsps/riscv/noel/include/bsp/riscv.h | 2 --
bsps/riscv/riscv/console/console-config.c | 10 ++--------
bsps/riscv/riscv/console/htif.c | 4 ----
bsps/riscv/riscv/include/bsp/riscv.h | 2 --
bsps/riscv/riscv/irq/irq.c | 15 +++++++++------
bsps/riscv/riscv/start/bsp_fatal_halt.c | 11 +++++++----
6 files changed, 18 insertions(+), 26 deletions(-)
diff --git a/bsps/riscv/noel/include/bsp/riscv.h b/bsps/riscv/noel/include/bsp/riscv.h
index 8ac049bb7c..3ab75573f0 100644
--- a/bsps/riscv/noel/include/bsp/riscv.h
+++ b/bsps/riscv/noel/include/bsp/riscv.h
@@ -50,9 +50,7 @@ extern uint32_t riscv_hart_count;
uint32_t riscv_get_hart_index_by_phandle(uint32_t phandle);
-#if RISCV_ENABLE_HTIF_SUPPORT != 0
void htif_poweroff(void);
-#endif
#ifdef __cplusplus
}
diff --git a/bsps/riscv/riscv/console/console-config.c b/bsps/riscv/riscv/console/console-config.c
index 7908c2f325..fe339c2353 100644
--- a/bsps/riscv/riscv/console/console-config.c
+++ b/bsps/riscv/riscv/console/console-config.c
@@ -60,9 +60,7 @@
static fe310_uart_context fe310_uart_instance;
#endif
-#if RISCV_ENABLE_HTIF_SUPPORT != 0
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];
@@ -165,7 +163,7 @@ static void riscv_console_probe(void)
compat_len = 0;
}
-#if RISCV_ENABLE_HTIF_SUPPORT != 0
+ /* 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);
@@ -173,7 +171,6 @@ 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 (
@@ -280,10 +277,9 @@ rtems_status_code console_initialize(
void *arg
)
{
-#if RISCV_ENABLE_HTIF_SUPPORT != 0
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;
@@ -296,14 +292,12 @@ rtems_status_code console_initialize(
rtems_termios_initialize();
-#if RISCV_ENABLE_HTIF_SUPPORT != 0
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 bcfe6a5db5..750abe6e3e 100644
--- a/bsps/riscv/riscv/console/htif.c
+++ b/bsps/riscv/riscv/console/htif.c
@@ -29,8 +29,6 @@
#include <bsp/riscv.h>
-#if RISCV_ENABLE_HTIF_SUPPORT != 0
-
#include <dev/serial/htif.h>
#include <assert.h>
@@ -139,5 +137,3 @@ 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 d38f46c069..a11ae4291e 100644
--- a/bsps/riscv/riscv/include/bsp/riscv.h
+++ b/bsps/riscv/riscv/include/bsp/riscv.h
@@ -52,9 +52,7 @@ extern uint32_t riscv_hart_count;
uint32_t riscv_get_hart_index_by_phandle(uint32_t phandle);
-#if RISCV_ENABLE_HTIF_SUPPORT != 0
void htif_poweroff(void);
-#endif
#ifdef __cplusplus
}
diff --git a/bsps/riscv/riscv/irq/irq.c b/bsps/riscv/riscv/irq/irq.c
index 3ef06a16bd..f0ccc6f5f0 100644
--- a/bsps/riscv/riscv/irq/irq.c
+++ b/bsps/riscv/riscv/irq/irq.c
@@ -247,13 +247,16 @@ static void riscv_plic_init(const void *fdt)
node = fdt_node_offset_by_compatible(fdt, -1, "riscv,plic0");
plic = riscv_fdt_get_address(fdt, node);
+
if (plic == NULL) {
-#if RISCV_ENABLE_HTIF_SUPPORT != 0
- /* Spike platform has HTIF and does not have a PLIC */
- return;
-#else
- bsp_fatal(RISCV_FATAL_NO_PLIC_REG_IN_DEVICE_TREE);
-#endif
+ 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);
+ }
}
riscv_plic = plic;
diff --git a/bsps/riscv/riscv/start/bsp_fatal_halt.c b/bsps/riscv/riscv/start/bsp_fatal_halt.c
index fb0787c606..cd7c5f20c5 100644
--- a/bsps/riscv/riscv/start/bsp_fatal_halt.c
+++ b/bsps/riscv/riscv/start/bsp_fatal_halt.c
@@ -38,14 +38,17 @@ void _CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr error )
int node;
volatile uint32_t *sifive_test;
-#if RISCV_ENABLE_HTIF_SUPPORT != 0
- htif_poweroff();
-#endif
+ fdt = bsp_fdt_get();
+
+ node = fdt_node_offset_by_compatible(fdt, -1, "ucb,htif0");
+
+ if (node != -1)
+ htif_poweroff();
+
#if RISCV_ENABLE_MPFS_SUPPORT != 0
for(;;);
#endif
- fdt = bsp_fdt_get();
node = fdt_node_offset_by_compatible(fdt, -1, "sifive,test0");
sifive_test = riscv_fdt_get_address(fdt, node);
--
2.25.1
More information about the devel
mailing list