Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/locore.S
| Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | #endif /* defined(LINUX_BOOT_ABI) */ | ||||
| * x27 = TTBR0 table | * x27 = TTBR0 table | ||||
| * x26 = Kernel L1 table | * x26 = Kernel L1 table | ||||
| * x24 = TTBR1 table | * x24 = TTBR1 table | ||||
| */ | */ | ||||
| /* Enable the mmu */ | /* Enable the mmu */ | ||||
| bl start_mmu | bl start_mmu | ||||
| /* Load the new ttbr0 pagetable */ | |||||
| adr x27, pagetable_l0_ttbr0 | |||||
| /* Jump to the virtual address space */ | /* Jump to the virtual address space */ | ||||
| ldr x15, .Lvirtdone | ldr x15, .Lvirtdone | ||||
| br x15 | br x15 | ||||
| virtdone: | virtdone: | ||||
| /* Set up the stack */ | /* Set up the stack */ | ||||
| adr x25, initstack_end | adr x25, initstack_end | ||||
| mov sp, x25 | mov sp, x25 | ||||
| Show All 22 Lines | 1: | ||||
| str x1, [x0, #BP_MODULEP] | str x1, [x0, #BP_MODULEP] | ||||
| str x26, [x0, #BP_KERN_L1PT] | str x26, [x0, #BP_KERN_L1PT] | ||||
| str x29, [x0, #BP_KERN_DELTA] | str x29, [x0, #BP_KERN_DELTA] | ||||
| adr x25, initstack | adr x25, initstack | ||||
| str x25, [x0, #BP_KERN_STACK] | str x25, [x0, #BP_KERN_STACK] | ||||
| str x24, [x0, #BP_KERN_L0PT] | str x24, [x0, #BP_KERN_L0PT] | ||||
| str x23, [x0, #BP_BOOT_EL] | str x23, [x0, #BP_BOOT_EL] | ||||
| str x27, [x0, 40] /* kern_ttbr0 */ | |||||
| /* trace back starts here */ | /* trace back starts here */ | ||||
| mov fp, #0 | mov fp, #0 | ||||
| /* Branch to C code */ | /* Branch to C code */ | ||||
| bl initarm | bl initarm | ||||
| bl mi_startup | bl mi_startup | ||||
| /* We should not get here */ | /* We should not get here */ | ||||
| Show All 22 Lines | ENTRY(mpentry) | ||||
| bl drop_to_el1 | bl drop_to_el1 | ||||
| /* Set the context id */ | /* Set the context id */ | ||||
| msr contextidr_el1, xzr | msr contextidr_el1, xzr | ||||
| /* Load the kernel page table */ | /* Load the kernel page table */ | ||||
| adr x24, pagetable_l0_ttbr1 | adr x24, pagetable_l0_ttbr1 | ||||
| /* Load the identity page table */ | /* Load the identity page table */ | ||||
| adr x27, pagetable_l0_ttbr0 | adr x27, pagetable_l0_ttbr0_boostrap | ||||
| /* Enable the mmu */ | /* Enable the mmu */ | ||||
| bl start_mmu | bl start_mmu | ||||
| /* Load the new ttbr0 pagetable */ | |||||
| adr x27, pagetable_l0_ttbr0 | |||||
| /* Jump to the virtual address space */ | /* Jump to the virtual address space */ | ||||
| ldr x15, =mp_virtdone | ldr x15, =mp_virtdone | ||||
| br x15 | br x15 | ||||
| mp_virtdone: | mp_virtdone: | ||||
| /* Start using the AP boot stack */ | /* Start using the AP boot stack */ | ||||
| ldr x4, =bootstack | ldr x4, =bootstack | ||||
| ldr x4, [x4] | ldr x4, [x4] | ||||
| mov sp, x4 | mov sp, x4 | ||||
| /* Load the kernel ttbr0 pagetable */ | |||||
| msr ttbr0_el1, x27 | |||||
| isb | |||||
| /* Invalidate the TLB */ | |||||
| tlbi vmalle1 | |||||
| dsb sy | |||||
| isb | |||||
| b init_secondary | b init_secondary | ||||
| END(mpentry) | END(mpentry) | ||||
| #endif | #endif | ||||
| /* | /* | ||||
| * If we are started in EL2, configure the required hypervisor | * If we are started in EL2, configure the required hypervisor | ||||
| * registers and drop to EL1. | * registers and drop to EL1. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 439 Lines • ▼ Show 20 Lines | start_mmu: | ||||
| msr ttbr0_el1, x27 | msr ttbr0_el1, x27 | ||||
| msr ttbr1_el1, x24 | msr ttbr1_el1, x24 | ||||
| isb | isb | ||||
| /* Clear the Monitor Debug System control register */ | /* Clear the Monitor Debug System control register */ | ||||
| msr mdscr_el1, xzr | msr mdscr_el1, xzr | ||||
| /* Invalidate the TLB */ | /* Invalidate the TLB */ | ||||
| tlbi vmalle1is | tlbi vmalle1is | ||||
alc: Should we have a dsb instruction here to ensure that the invalidation has completed before… | |||||
| ldr x2, mair | ldr x2, mair | ||||
| msr mair_el1, x2 | msr mair_el1, x2 | ||||
| /* | /* | ||||
| * Setup TCR according to the PARange and ASIDBits fields | * Setup TCR according to the PARange and ASIDBits fields | ||||
| * from ID_AA64MMFR0_EL1 and the HAFDBS field from the | * from ID_AA64MMFR0_EL1 and the HAFDBS field from the | ||||
| * ID_AA64MMFR1_EL1. More precisely, set TCR_EL1.AS | * ID_AA64MMFR1_EL1. More precisely, set TCR_EL1.AS | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | sctlr_clear: | ||||
| .globl abort | .globl abort | ||||
| abort: | abort: | ||||
| b abort | b abort | ||||
| //.section .init_pagetable | //.section .init_pagetable | ||||
| .align 12 /* 4KiB aligned */ | .align 12 /* 4KiB aligned */ | ||||
| /* | /* | ||||
| * 3 initial tables (in the following order): | * 6 initial tables (in the following order): | ||||
| * L2 for kernel (High addresses) | * L2 for kernel (High addresses) | ||||
| * L1 for kernel | * L1 for kernel | ||||
| * L1 for user (Low addresses) | * L0 for kernel | ||||
| * L1 bootstrap for user (Low addresses) | |||||
| * L0 bootstrap for user | |||||
| * L0 for user | |||||
| */ | */ | ||||
| pagetable: | pagetable: | ||||
| .space PAGE_SIZE | .space PAGE_SIZE | ||||
| pagetable_l1_ttbr1: | pagetable_l1_ttbr1: | ||||
| .space PAGE_SIZE | .space PAGE_SIZE | ||||
| pagetable_l0_ttbr1: | pagetable_l0_ttbr1: | ||||
| .space PAGE_SIZE | .space PAGE_SIZE | ||||
| pagetable_l1_ttbr0: | pagetable_l1_ttbr0_bootstrap: | ||||
| .space PAGE_SIZE | |||||
| pagetable_l0_ttbr0_boostrap: | |||||
| .space PAGE_SIZE | .space PAGE_SIZE | ||||
| pagetable_l0_ttbr0: | pagetable_l0_ttbr0: | ||||
| .space PAGE_SIZE | .space PAGE_SIZE | ||||
| .globl pagetable_dmap | .globl pagetable_dmap | ||||
| pagetable_dmap: | pagetable_dmap: | ||||
| .space PAGE_SIZE * DMAP_TABLES | .space PAGE_SIZE * DMAP_TABLES | ||||
| pagetable_end: | pagetable_end: | ||||
| ▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines | |||||
Should we have a dsb instruction here to ensure that the invalidation has completed before setting the SCTLR register below?