aboutsummaryrefslogtreecommitdiff
path: root/common/main.c
blob: f91fc222dedaa31b8adfa7be8bc59b1b41e02e4a (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
#include <apos/mem_nodes.h>
#include <apos/attrs.h>
#include <apos/proc.h>
#include <apos/debug.h>
#include <apos/vmem.h>
#include <apos/arch.h>
#include <apos/irq.h>
#include <libfdt.h>

#ifdef DEBUG
static struct dbg_info dbg_info = (struct dbg_info){0};

static void init_dbg(void *fdt)
{
	dbg_info = dbg_from_fdt(fdt);
}

static void setup_dmap_dbg()
{
	setup_dbg(dbg_info.dbg_ptr, dbg_info.dev);
}

static void setup_io_dbg(struct vm_branch *b)
{
	vm_t io_ptr = setup_kernel_io(b, dbg_info.dbg_ptr);
	setup_dbg(io_ptr, dbg_info.dev);
}
#else
#define init_dbg(...)
#define setup_dmap_dbg(...)
#define setup_io_dbg(...)
#endif

void __main main(void *fdt)
{
	/* dbg uses direct mapping at this point */
	init_dbg(fdt);
	setup_dmap_dbg();
	dbg_fdt(fdt);

	arch_setup(fdt);

	init_pmem(fdt);
	init_mem_blocks();
	struct vm_branch *b = init_vmem(fdt);

	/* start up debugging in kernel IO */
	setup_io_dbg(b);

	init_irq(fdt);
	init_proc(fdt, b);
}