summaryrefslogtreecommitdiff
path: root/sys/kern/init.c
blob: 208df6dd2b88889f59b369dd89df09f767ecfb43 (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 <fdt.h>
#include <mm/kalloc.h>
#include <printf.h>
#include <stdint.h>
#include <spinlock.h>

extern uint64_t HEAP_START;

void 
init(unsigned long hartid, struct fdt_header *fdt)
{

	printf("booting from hart #%d\n", hartid);
        asm volatile ("mv tp, %0" : : "r"(hartid));
	if (fdt_uint32(fdt->magic) == FDT_HEADER_MAGIC) 
		printf("found flattened device tree at %p!\n", (uint64_t)fdt);
        
        printf("parsing device tree!\n");
        fdt_walk(fdt);

        printf("setting up the heap at %p\n", HEAP_START);
        kalloc_init();
        printf("done!\n");
       // printf("printing free pages:\n");
        //walkfree();
}

/* non boot harts enter here */ 
void 
mpinit(unsigned long hartid, struct fdt_header *fdt)
{
        unsigned char *uart = (unsigned char*)0x10000000;
        *uart = hartid + '0';
        *(uart + 1) = '\n';
}