diff options
author | Anup Patel <anup.patel@wdc.com> | 2021-04-22 09:23:32 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-04-28 14:55:00 +0300 |
commit | 043d088e3964ec64b091f739e2282f53f7d264fb (patch) | |
tree | e5ec82451c097df3f3416ec077752527d81107a7 /lib/utils/sys | |
parent | dc39c7b630a607b96c25f8ea50f0bb1af619928a (diff) | |
download | opensbi-043d088e3964ec64b091f739e2282f53f7d264fb.tar.xz |
lib: sbi: Simplify system reset platform operations
Instead of having system_reset_check() and system_reset() callbacks
in platform operations, it will be much simpler for reset driver to
directly register these operations as a device to the sbi_system
implementation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'lib/utils/sys')
-rw-r--r-- | lib/utils/sys/htif.c | 18 | ||||
-rw-r--r-- | lib/utils/sys/sifive_test.c | 12 |
2 files changed, 26 insertions, 4 deletions
diff --git a/lib/utils/sys/htif.c b/lib/utils/sys/htif.c index 2fd38a7..330a9a6 100644 --- a/lib/utils/sys/htif.c +++ b/lib/utils/sys/htif.c @@ -7,6 +7,7 @@ #include <sbi/riscv_locks.h> #include <sbi/sbi_console.h> +#include <sbi/sbi_system.h> #include <sbi_utils/sys/htif.h> #define HTIF_DATA_BITS 48 @@ -154,15 +155,28 @@ int htif_serial_init(void) return 0; } -int htif_system_reset_check(u32 type, u32 reason) +static int htif_system_reset_check(u32 type, u32 reason) { return 1; } -void htif_system_reset(u32 type, u32 reason) +static void htif_system_reset(u32 type, u32 reason) { while (1) { fromhost = 0; tohost = 1; } } + +static struct sbi_system_reset_device htif_reset = { + .name = "htif", + .system_reset_check = htif_system_reset_check, + .system_reset = htif_system_reset +}; + +int htif_system_reset_init(void) +{ + sbi_system_reset_set_device(&htif_reset); + + return 0; +} diff --git a/lib/utils/sys/sifive_test.c b/lib/utils/sys/sifive_test.c index fdf3169..4533954 100644 --- a/lib/utils/sys/sifive_test.c +++ b/lib/utils/sys/sifive_test.c @@ -9,6 +9,7 @@ #include <sbi/riscv_io.h> #include <sbi/sbi_ecall_interface.h> +#include <sbi/sbi_system.h> #include <sbi_utils/sys/sifive_test.h> #define FINISHER_FAIL 0x3333 @@ -17,7 +18,7 @@ static void *sifive_test_base; -int sifive_test_system_reset_check(u32 type, u32 reason) +static int sifive_test_system_reset_check(u32 type, u32 reason) { switch (type) { case SBI_SRST_RESET_TYPE_SHUTDOWN: @@ -29,7 +30,7 @@ int sifive_test_system_reset_check(u32 type, u32 reason) return 0; } -void sifive_test_system_reset(u32 type, u32 reason) +static void sifive_test_system_reset(u32 type, u32 reason) { /* * Tell the "finisher" that the simulation @@ -49,9 +50,16 @@ void sifive_test_system_reset(u32 type, u32 reason) } } +static struct sbi_system_reset_device sifive_test_reset = { + .name = "sifive_test", + .system_reset_check = sifive_test_system_reset_check, + .system_reset = sifive_test_system_reset +}; + int sifive_test_init(unsigned long base) { sifive_test_base = (void *)base; + sbi_system_reset_set_device(&sifive_test_reset); return 0; } |