summaryrefslogtreecommitdiff
path: root/riscv/riscv-probe/libfemto/drivers/sifive_test.c
blob: 1bda9e99a6f0193dff4a363e13787ac7cd58dee4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// See LICENSE for license details.

#include "femto.h"

enum {
	SIFIVE_TEST_FAIL = 0x3333,
	SIFIVE_TEST_PASS = 0x5555,
};

static volatile uint32_t *test;

static void sifive_test_init()
{
	test = (uint32_t *)(void *)getauxval(SIFIVE_TEST_CTRL_ADDR);
}

static void sifive_test_poweroff(int status)
{
    *test = SIFIVE_TEST_PASS;
    while (1) {
        asm volatile("");
    }
}

poweroff_device_t poweroff_sifive_test = {
	sifive_test_init,
	sifive_test_poweroff
};