blob: 7d1be2a2cc2c0679cb52198df656796a8d92d8bf (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#include "bbl.h"
#include "mtrap.h"
#include "atomic.h"
#include "vm.h"
#include "bits.h"
#include "config.h"
#include "fdt.h"
#include "platform_interface.h"
#include <string.h>
static const void* entry_point;
static uintptr_t dtb_output()
{
extern char _payload_end;
uintptr_t end = (uintptr_t) &_payload_end;
return (end + MEGAPAGE_SIZE - 1) / MEGAPAGE_SIZE * MEGAPAGE_SIZE;
}
static uintptr_t filter_dtb(uintptr_t source)
{
uintptr_t dest = dtb_output();
uint32_t size = fdt_size(source);
memcpy((void*)dest, (void*)source, size);
// Remove information from the chained FDT
filter_harts(dest, platform__disabled_hart_mask);
filter_plic(dest);
filter_compat(dest, "riscv,clint0");
filter_compat(dest, "riscv,debug-013");
return dest;
}
void boot_other_hart(uintptr_t dtb)
{
const void* entry;
do {
entry = entry_point;
mb();
} while (!entry);
enter_supervisor_mode(entry, read_csr(mhartid), dtb);
}
void boot_loader(uintptr_t dtb)
{
extern char _payload_start;
dtb = filter_dtb(dtb);
#ifdef PK_ENABLE_LOGO
print_logo();
#endif
#ifdef PK_PRINT_DEVICE_TREE
fdt_print(dtb);
#endif
mb();
entry_point = &_payload_start;
boot_other_hart(dtb);
}
|