RISC-V: Always probe for HTIF and remove RISCV_ENABLE_HTIF_SUPPORT

Updates #4779
This commit is contained in:
Hesham Almatary
2022-12-18 15:07:16 +00:00
parent a430dd43d9
commit 88b80a5fd0
6 changed files with 18 additions and 26 deletions

View File

@@ -50,9 +50,7 @@ extern uint32_t riscv_hart_count;
uint32_t riscv_get_hart_index_by_phandle(uint32_t phandle); uint32_t riscv_get_hart_index_by_phandle(uint32_t phandle);
#if RISCV_ENABLE_HTIF_SUPPORT != 0
void htif_poweroff(void); void htif_poweroff(void);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -60,9 +60,7 @@
static fe310_uart_context fe310_uart_instance; static fe310_uart_context fe310_uart_instance;
#endif #endif
#if RISCV_ENABLE_HTIF_SUPPORT != 0
static htif_console_context htif_console_instance; static htif_console_context htif_console_instance;
#endif
#if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0 #if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0
static ns16550_context ns16550_instances[RISCV_CONSOLE_MAX_NS16550_DEVICES]; static ns16550_context ns16550_instances[RISCV_CONSOLE_MAX_NS16550_DEVICES];
@@ -165,7 +163,7 @@ static void riscv_console_probe(void)
compat_len = 0; 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")) { if (fdt_stringlist_contains(compat, compat_len, "ucb,htif0")) {
htif_console_context_init(&htif_console_instance.base, node); 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.putchar = htif_console_putchar;
riscv_console.getchar = htif_console_getchar; riscv_console.getchar = htif_console_getchar;
}; };
#endif
#if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0 #if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0
if ( if (
@@ -280,10 +277,9 @@ rtems_status_code console_initialize(
void *arg void *arg
) )
{ {
#if RISCV_ENABLE_HTIF_SUPPORT != 0
rtems_termios_device_context *base; rtems_termios_device_context *base;
char htif_path[] = "/dev/ttyShtif"; char htif_path[] = "/dev/ttyShtif";
#endif
#if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0 #if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0
char path[] = "/dev/ttyS?"; char path[] = "/dev/ttyS?";
size_t i; size_t i;
@@ -296,14 +292,12 @@ rtems_status_code console_initialize(
rtems_termios_initialize(); rtems_termios_initialize();
#if RISCV_ENABLE_HTIF_SUPPORT != 0
base = &htif_console_instance.base; base = &htif_console_instance.base;
rtems_termios_device_install(htif_path, &htif_console_handler, NULL, base); rtems_termios_device_install(htif_path, &htif_console_handler, NULL, base);
if (base == riscv_console.context) { if (base == riscv_console.context) {
link(htif_path, CONSOLE_DEVICE_NAME); link(htif_path, CONSOLE_DEVICE_NAME);
} }
#endif
#if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0 #if RISCV_CONSOLE_MAX_NS16550_DEVICES > 0
for (i = 0; i < RISCV_CONSOLE_MAX_NS16550_DEVICES; ++i) { for (i = 0; i < RISCV_CONSOLE_MAX_NS16550_DEVICES; ++i) {

View File

@@ -29,8 +29,6 @@
#include <bsp/riscv.h> #include <bsp/riscv.h>
#if RISCV_ENABLE_HTIF_SUPPORT != 0
#include <dev/serial/htif.h> #include <dev/serial/htif.h>
#include <assert.h> #include <assert.h>
@@ -139,5 +137,3 @@ const rtems_termios_device_handler htif_console_handler = {
.poll_read = htif_console_getchar, .poll_read = htif_console_getchar,
.mode = TERMIOS_POLLED .mode = TERMIOS_POLLED
}; };
#endif /* RISCV_ENABLE_HTIF_SUPPORT */

View File

@@ -52,9 +52,7 @@ extern uint32_t riscv_hart_count;
uint32_t riscv_get_hart_index_by_phandle(uint32_t phandle); uint32_t riscv_get_hart_index_by_phandle(uint32_t phandle);
#if RISCV_ENABLE_HTIF_SUPPORT != 0
void htif_poweroff(void); void htif_poweroff(void);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -247,13 +247,16 @@ static void riscv_plic_init(const void *fdt)
node = fdt_node_offset_by_compatible(fdt, -1, "riscv,plic0"); node = fdt_node_offset_by_compatible(fdt, -1, "riscv,plic0");
plic = riscv_fdt_get_address(fdt, node); plic = riscv_fdt_get_address(fdt, node);
if (plic == NULL) { if (plic == NULL) {
#if RISCV_ENABLE_HTIF_SUPPORT != 0 node = fdt_node_offset_by_compatible(fdt, -1, "ucb,htif0");
/* Spike platform has HTIF and does not have a PLIC */
return; /* Spike platform has HTIF and does not have a PLIC */
#else if (node != -1) {
bsp_fatal(RISCV_FATAL_NO_PLIC_REG_IN_DEVICE_TREE); return;
#endif } else {
bsp_fatal(RISCV_FATAL_NO_PLIC_REG_IN_DEVICE_TREE);
}
} }
riscv_plic = plic; riscv_plic = plic;

View File

@@ -38,14 +38,17 @@ void _CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr error )
int node; int node;
volatile uint32_t *sifive_test; volatile uint32_t *sifive_test;
#if RISCV_ENABLE_HTIF_SUPPORT != 0 fdt = bsp_fdt_get();
htif_poweroff();
#endif node = fdt_node_offset_by_compatible(fdt, -1, "ucb,htif0");
if (node != -1)
htif_poweroff();
#if RISCV_ENABLE_MPFS_SUPPORT != 0 #if RISCV_ENABLE_MPFS_SUPPORT != 0
for(;;); for(;;);
#endif #endif
fdt = bsp_fdt_get();
node = fdt_node_offset_by_compatible(fdt, -1, "sifive,test0"); node = fdt_node_offset_by_compatible(fdt, -1, "sifive,test0");
sifive_test = riscv_fdt_get_address(fdt, node); sifive_test = riscv_fdt_get_address(fdt, node);