blob: 2e4a22ca21b0ef5a849ae560a7b0cc9bcfdfd105 (
plain) (
blame)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
__attribute__((always_inline))
static inline char hex_char(unsigned x)
{
if (x <= 9)
return x + '0';
return (x - 10) + 'a';
}
__attribute__((always_inline))
static inline void print_int32(volatile char *uart, unsigned x)
{
*uart = hex_char((x >> 28) & 0xf);
*uart = hex_char((x >> 24) & 0xf);
*uart = hex_char((x >> 20) & 0xf);
*uart = hex_char((x >> 16) & 0xf);
*uart = hex_char((x >> 12) & 0xf);
*uart = hex_char((x >> 8) & 0xf);
*uart = hex_char((x >> 4) & 0xf);
*uart = hex_char((x >> 0) & 0xf);
}
__attribute__((always_inline))
static inline void print_addr(volatile char *uart, unsigned x)
{
*uart = '(';
print_int32(uart, x);
*uart = ')';
*uart = '\n';
}
void _start(unsigned x, unsigned X)
{
volatile char *uart = (char *)4096;
volatile unsigned *control = (unsigned *)(1ULL << 32);
if (x == 2) {
goto do_work;
} else {
while (*control != x) {}
}
do_work:
print_addr(uart, x);
*control = x + 1;
if (x == X - 1)
asm("ebreak");
/* otherwise just loop */
while (1) {}
}
|