aboutsummaryrefslogtreecommitdiff
path: root/test/test_dt.c
blob: 1eb975156207ea1c47580ec136022b08ef8e6a35 (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
29
30
31
32
33
34
35
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#include <fbos/dt.h>

int main(void)
{
	FILE *fh = fopen("./test/testdata/qemu.dtb", "rb");
	assert(fh);

	fseek(fh, 0, SEEK_END);
	long fsize = ftell(fh);
	rewind(fh);

	uint32_t *contents = malloc((unsigned long)fsize + 1);
	fread(contents, (unsigned long)fsize, sizeof(uint32_t *), fh);
	fclose(fh);

	contents[fsize] = 0;

	struct dt_info info = {
		.cpu_freq = 0,
		.initrd_start = 0,
		.initrd_end = 0,
	};
	get_dt_info(contents, &info);
	free(contents);

	assert(info.initrd_start == 0x84200000);
	assert(info.initrd_end == 0x84200c00);
	assert(info.cpu_freq == 0x989680);

	exit(0);
}