-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyscon.c
33 lines (26 loc) · 790 Bytes
/
syscon.c
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
29
30
31
32
33
#include <stdint.h>
#include <stdlib.h>
#include "riscv.h"
#include "rvexec.h"
extern wbk_t *wbk; /* FIXME */
static unsigned char syscon[4];
static void sysconwbk(struct hart *t) {
xword_t v = syscon[0] |
((xword_t)syscon[1] << 8) |
((xword_t)syscon[2] << 16) |
((xword_t)syscon[3] << 24);
syscon[0] = syscon[1] = syscon[2] = syscon[3] = 0;
switch (v) {
case 0x5555: exit(EXIT_SUCCESS);
case 0x7777: /* FIXME restart */
default: abort();
}
}
static unsigned char *sysconmap(struct hart *t, xword_t addr, xword_t size, int type) {
addr &= 0xFFFFF;
if (addr != 0x00000 || size != 4) return 0;
syscon[0] = syscon[1] = syscon[2] = syscon[3] = 0;
if (type >= MAPA) wbk = &sysconwbk;
return &syscon[0];
}
__attribute__((alias("sysconmap"))) map_t meg111;