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);
30 extern void aa64_vbase();
35 set_sysreg(VBAR_EL1, aa64_vbase);
44 SH0=3 // Inner sharable
45 ORGN0=0 // Normal memory, Outer Non-cacheable.
46 IRGN0=1 // Normal memory, Inner Write-Back Read-Allocate Write-Allocate Cacheable.
47 A1=0 // TTBR0 define ASID
51 T0SZ=16 // disable TTBR1, Use TTBR0 for all translation
52 TG0=0 // VA48, 256T, 4K Granule
54 TBI0=0 // Ignore top bits
57 HD=1 // Hardware managed dirty and access
60 We may use the follow practice later
61 TTBR0: Translation for user-land (lowmem)
62 TTBR1: Translation for kernel-land (highmem)
65 unsigned long tcr = 0;
68 tcr |= TCR_T1SZ(0) | TCR_T0SZ(16);
69 tcr |= TCR_TG0(TCR_G4K);
70 tcr |= TCR_AS | TCR_HA | TCR_HD;
75 set_sysreg(TTBR0_EL1, ttb);
76 set_sysreg(TCR_EL1, tcr);
80 extract_dtb_bootinfo(ptr_t dtb, struct boot_handoff* handoff)
82 handoff->kexec.dtb_pa = dtb;
84 // TODO extract /memory, /reserved-memories from dtb
88 aarch64_init(ptr_t dtb)
94 struct boot_handoff* handoff;
96 handoff = bootmem_alloc(sizeof(*handoff));
98 extract_dtb_bootinfo(dtb, handoff);