]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/freedom-metal/src/drivers/sifive_test0.c
4ef0aa86170a1bfae9c1d2cfe88f605686a31aba
[freertos] / FreeRTOS / Demo / RISC-V_RV32_SiFive_HiFive1_GCC / freedom-metal / src / drivers / sifive_test0.c
1 /* Copyright 2018 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
3
4 #include <metal/machine/platform.h>
5
6 #ifdef METAL_SIFIVE_TEST0
7
8 #include <metal/drivers/sifive_test0.h>
9 #include <metal/io.h>
10 #include <stdint.h>
11 #include <metal/machine.h>
12
13 void __metal_driver_sifive_test0_exit(const struct __metal_shutdown *sd, int code) __attribute__((noreturn));
14 void __metal_driver_sifive_test0_exit(const struct __metal_shutdown *sd, int code)
15 {
16     long base = __metal_driver_sifive_test0_base();
17     uint32_t out = (code << 16) + (code == 0 ? 0x5555 : 0x3333);
18     while (1) {
19         __METAL_ACCESS_ONCE((__metal_io_u32 *)(base + METAL_SIFIVE_TEST0_FINISHER_OFFSET)) = out;
20     }
21 }
22
23 __METAL_DEFINE_VTABLE(__metal_driver_vtable_sifive_test0) = {
24     .shutdown.exit       = &__metal_driver_sifive_test0_exit,
25 };
26 #endif /* METAL_SIFIVE_TEST0 */