aboutsummaryrefslogtreecommitdiff
path: root/tests/simple_grid/test.c
blob: 07f11236797808208964cacf67897a087511f5c0 (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
#define X 64
#define Y 64

void _start(unsigned short x, unsigned short y)
{
	volatile unsigned long *counter = (unsigned long *)((1ULL << 48) | (1ULL << 32));
	volatile char *uart = (char *)4096;

	/* very hacky, not recommended but good enough for testing */
	if (x == 0 && y == 1) {
		*counter = 0;
		*uart = '0';
		*uart = '\n';
	}
	else
		while (*counter != ((x << 8) | y))
			;

	*uart = '(';
	/* [0 - 63] as two octal numbers */
	*uart = ((x >> 3) & 0x7) + '0';
	*uart = ((x >> 0) & 0x7) + '0';

	*uart = ',';
	*uart = ' ';

	*uart = ((y >> 3) & 0x7) + '0';
	*uart = ((y >> 0) & 0x7) + '0';

	*uart = ')';
	*uart = '\n';

	if (y == 63) {
		x++;
		y = 0;
	}
	else
		y++;

	*counter = (x << 8) | y;

	while (*counter != (64 << 8))
		;

	asm ("ebreak\n");
}