diff options
author | Palmer Dabbelt <palmer@dabbelt.com> | 2017-11-03 16:30:35 -0700 |
---|---|---|
committer | Palmer Dabbelt <palmer@dabbelt.com> | 2017-11-03 16:36:40 -0700 |
commit | d1849cb5e3b8c714c2dae78bb15465f288707ac5 (patch) | |
tree | b3aad5d06c4b9fec59d1e6ecba1fbd25d1833814 /machine | |
parent | 3815c611158f435d36121c2c433af664ad86d8ca (diff) | |
download | riscv-pk-d1849cb5e3b8c714c2dae78bb15465f288707ac5.zip riscv-pk-d1849cb5e3b8c714c2dae78bb15465f288707ac5.tar.gz riscv-pk-d1849cb5e3b8c714c2dae78bb15465f288707ac5.tar.bz2 |
Remove the platform interface
We now automatically detect everything that the platform interface used
to be used for, so it's now obsolete!
Diffstat (limited to 'machine')
-rw-r--r-- | machine/htif.c | 51 | ||||
-rw-r--r-- | machine/htif.h | 2 | ||||
-rw-r--r-- | machine/machine.mk.in | 1 | ||||
-rw-r--r-- | machine/minit.c | 3 | ||||
-rw-r--r-- | machine/mtrap.c | 7 |
5 files changed, 58 insertions, 6 deletions
diff --git a/machine/htif.c b/machine/htif.c index fa3db53..44ec2dd 100644 --- a/machine/htif.c +++ b/machine/htif.c @@ -1,11 +1,21 @@ #include "htif.h" #include "atomic.h" #include "mtrap.h" +#include "fdt.h" +#include <string.h> +extern uint64_t __htif_base; volatile uint64_t tohost __attribute__((section(".htif"))); volatile uint64_t fromhost __attribute__((section(".htif"))); volatile int htif_console_buf; static spinlock_t htif_lock = SPINLOCK_INIT; +uintptr_t htif; + +#define TOHOST(base_int) (uint64_t *)(base_int + TOHOST_OFFSET) +#define FROMHOST(base_int) (uint64_t *)(base_int + FROMHOST_OFFSET) + +#define TOHOST_OFFSET ((uintptr_t)tohost - (uintptr_t)__htif_base) +#define FROMHOST_OFFSET ((uintptr_t)fromhost - (uintptr_t)__htif_base) static void __check_fromhost() { @@ -85,3 +95,44 @@ void htif_poweroff() tohost = 1; } } + +struct htif_scan +{ + int compat; +}; + +static void htif_open(const struct fdt_scan_node *node, void *extra) +{ + struct htif_scan *scan = (struct htif_scan *)extra; + memset(scan, 0, sizeof(*scan)); +} + +static void htif_prop(const struct fdt_scan_prop *prop, void *extra) +{ + struct htif_scan *scan = (struct htif_scan *)extra; + if (!strcmp(prop->name, "compatible") && !strcmp((const char*)prop->value, "ucb,htif0")) { + scan->compat = 1; + } +} + +static void htif_done(const struct fdt_scan_node *node, void *extra) +{ + struct htif_scan *scan = (struct htif_scan *)extra; + if (!scan->compat) return; + + htif = 1; +} + +void query_htif(uintptr_t fdt) +{ + struct fdt_cb cb; + struct htif_scan scan; + + memset(&cb, 0, sizeof(cb)); + cb.open = htif_open; + cb.prop = htif_prop; + cb.done = htif_done; + cb.extra = &scan; + + fdt_scan(fdt, &cb); +} diff --git a/machine/htif.h b/machine/htif.h index fa768d8..a96bf60 100644 --- a/machine/htif.h +++ b/machine/htif.h @@ -15,6 +15,8 @@ #define FROMHOST_CMD(fromhost_value) ((uint64_t)(fromhost_value) << 8 >> 56) #define FROMHOST_DATA(fromhost_value) ((uint64_t)(fromhost_value) << 16 >> 16) +extern uintptr_t htif; +void query_htif(uintptr_t dtb); void htif_console_putchar(uint8_t); int htif_console_getchar(); void htif_poweroff() __attribute__((noreturn)); diff --git a/machine/machine.mk.in b/machine/machine.mk.in index 59d0eb4..dc8492f 100644 --- a/machine/machine.mk.in +++ b/machine/machine.mk.in @@ -1,6 +1,5 @@ machine_subproject_deps = \ softfloat \ - platform \ machine_hdrs = \ atomic.h \ diff --git a/machine/minit.c b/machine/minit.c index 5f98501..3623f38 100644 --- a/machine/minit.c +++ b/machine/minit.c @@ -5,8 +5,8 @@ #include "fdt.h" #include "uart.h" #include "finisher.h" -#include "platform_interface.h" #include "disabled_hart_mask.h" +#include "htif.h" #include <string.h> #include <limits.h> @@ -141,6 +141,7 @@ void init_first_hart(uintptr_t hartid, uintptr_t dtb) { // Confirm console as early as possible query_uart(dtb); + query_htif(dtb); hart_init(); hls_init(0); // this might get called again from parse_config_string diff --git a/machine/mtrap.c b/machine/mtrap.c index dba3613..0f77def 100644 --- a/machine/mtrap.c +++ b/machine/mtrap.c @@ -8,7 +8,6 @@ #include "finisher.h" #include "fdt.h" #include "unprivileged_memory.h" -#include "platform_interface.h" #include "disabled_hart_mask.h" #include <errno.h> #include <stdarg.h> @@ -23,7 +22,7 @@ static uintptr_t mcall_console_putchar(uint8_t ch) { if (uart) { uart_putchar(ch); - } else if (platform__use_htif()) { + } else if (htif) { htif_console_putchar(ch); } return 0; @@ -33,7 +32,7 @@ void poweroff(uint16_t code) { printm("Power off\n"); finisher_exit(code); - if (platform__use_htif()) { + if (htif) { htif_poweroff(); } else { while (1); @@ -74,7 +73,7 @@ static uintptr_t mcall_console_getchar() { if (uart) { return uart_getchar(); - } else if (platform__use_htif()) { + } else if (htif) { return htif_console_getchar(); } else { return '\0'; |