1 #include <lunaix/boot_generic.h>
11 EE=0, E0E=0 // all little endian
12 WXN=1 // write implie exec never
13 SA0=1, SA=1 // alignment check on SP
14 A=1 // alignment check on memref
15 NMI=1 // mask interrupt
19 unsigned long sctrl = 0;
22 sctrl |= SCTRL_WXN | SCTRL_nAA;
23 sctrl |= SCTRL_SA | SCTRL_SA0;
24 sctrl |= SCTRL_A | SCTRL_M;
26 set_sysreg(TCR_EL1, sctrl);
33 // TODO install exception vectors, setup VBAR
42 SH0=3 // Inner sharable
43 ORGN0=0 // Normal memory, Outer Non-cacheable.
44 IRGN0=1 // Normal memory, Inner Write-Back Read-Allocate Write-Allocate Cacheable.
45 A1=0 // TTBR0 define ASID
49 T0SZ=16 // disable TTBR1, Use TTBR0 for all translation
50 TG0=0 // VA48, 256T, 4K Granule
52 TBI0=0 // Ignore top bits
55 HD=1 // Hardware managed dirty and access
58 We may use the follow practice later
59 TTBR0: Translation for user-land (lowmem)
60 TTBR1: Translation for kernel-land (highmem)
63 unsigned long tcr = 0;
66 tcr |= TCR_T1SZ(0) | TCR_T0SZ(16);
67 tcr |= TCR_TG0(TCR_G4K);
68 tcr |= TCR_AS | TCR_HA | TCR_HD;
73 set_sysreg(TTBR0_EL1, ttb);
74 set_sysreg(TCR_EL1, tcr);
78 extract_dtb_bootinfo(ptr_t dtb, struct boot_handoff* handoff)
80 handoff->kexec.dtb_pa = dtb;
82 // TODO extract /memory, /reserved-memories from dtb
86 aarch64_init(ptr_t dtb)
92 struct boot_handoff* handoff;
94 handoff = bootmem_alloc(sizeof(*handoff));
96 extract_dtb_bootinfo(dtb, handoff);