Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/locore.S
Show All 32 Lines | |||||
#include <machine/armreg.h> | #include <machine/armreg.h> | ||||
#include <machine/hypervisor.h> | #include <machine/hypervisor.h> | ||||
#include <machine/param.h> | #include <machine/param.h> | ||||
#include <machine/pte.h> | #include <machine/pte.h> | ||||
#include <machine/vm.h> | #include <machine/vm.h> | ||||
#include <machine/vmparam.h> | #include <machine/vmparam.h> | ||||
#define VIRT_BITS 48 | #define VIRT_BITS 48 | ||||
#define DMAP_TABLES ((DMAP_MAX_ADDRESS - DMAP_MIN_ADDRESS) >> L0_SHIFT) | |||||
.globl kernbase | .globl kernbase | ||||
.set kernbase, KERNBASE | .set kernbase, KERNBASE | ||||
/* | /* | ||||
* We assume: | * We assume: | ||||
* MMU on with an identity map, or off | * MMU on with an identity map, or off | ||||
* D-Cache: off | * D-Cache: off | ||||
▲ Show 20 Lines • Show All 323 Lines • ▼ Show 20 Lines | |||||
* TODO: This is out of date. | * TODO: This is out of date. | ||||
* There are at least 5 pages before that address for the page tables | * There are at least 5 pages before that address for the page tables | ||||
* The pages used are: | * The pages used are: | ||||
* - The Kernel L2 table | * - The Kernel L2 table | ||||
* - The Kernel L1 table | * - The Kernel L1 table | ||||
* - The Kernel L0 table (TTBR1) | * - The Kernel L0 table (TTBR1) | ||||
* - The identity (PA = VA) L1 table | * - The identity (PA = VA) L1 table | ||||
* - The identity (PA = VA) L0 table (TTBR0) | * - The identity (PA = VA) L0 table (TTBR0) | ||||
* - The DMAP L1 tables | |||||
*/ | */ | ||||
LENTRY(create_pagetables) | LENTRY(create_pagetables) | ||||
/* Save the Link register */ | /* Save the Link register */ | ||||
mov x5, x30 | mov x5, x30 | ||||
/* Clean the page table */ | /* Clean the page table */ | ||||
adrp x6, pagetable | adrp x6, pagetable | ||||
add x6, x6, :lo12:pagetable | add x6, x6, :lo12:pagetable | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | common: | ||||
add x24, x26, #PAGE_SIZE | add x24, x26, #PAGE_SIZE | ||||
/* Link the l0 -> l1 table */ | /* Link the l0 -> l1 table */ | ||||
mov x9, x6 | mov x9, x6 | ||||
mov x6, x24 | mov x6, x24 | ||||
mov x10, #1 | mov x10, #1 | ||||
bl link_l0_pagetable | bl link_l0_pagetable | ||||
/* Link the DMAP tables */ | |||||
ldr x8, =DMAP_MIN_ADDRESS | |||||
adrp x9, pagetable_dmap | |||||
add x9, x9, :lo12:pagetable_dmap | |||||
mov x10, #DMAP_TABLES | |||||
bl link_l0_pagetable | |||||
/* | /* | ||||
* Build the TTBR0 maps. As TTBR0 maps, they must specify ATTR_S1_nG. | * Build the TTBR0 maps. As TTBR0 maps, they must specify ATTR_S1_nG. | ||||
* They are only needed early on, so the VA = PA map is uncached. | * They are only needed early on, so the VA = PA map is uncached. | ||||
*/ | */ | ||||
add x27, x24, #PAGE_SIZE | add x27, x24, #PAGE_SIZE | ||||
mov x6, x27 /* The initial page table */ | mov x6, x27 /* The initial page table */ | ||||
▲ Show 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | END(abort) | ||||
* 6 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 | ||||
* L0 for kernel | * L0 for kernel | ||||
* L1 bootstrap for user (Low addresses) | * L1 bootstrap for user (Low addresses) | ||||
* L0 bootstrap for user | * L0 bootstrap for user | ||||
* L0 for user | * L0 for user | ||||
*/ | */ | ||||
.globl pagetable_l0_ttbr1 | |||||
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_l2_ttbr0_bootstrap: | pagetable_l2_ttbr0_bootstrap: | ||||
.space PAGE_SIZE | .space PAGE_SIZE | ||||
pagetable_l1_ttbr0_bootstrap: | pagetable_l1_ttbr0_bootstrap: | ||||
.space PAGE_SIZE | .space PAGE_SIZE | ||||
pagetable_l0_ttbr0_boostrap: | 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 | |||||
pagetable_dmap: | |||||
.space PAGE_SIZE * DMAP_TABLES | |||||
pagetable_end: | pagetable_end: | ||||
el2_pagetable: | el2_pagetable: | ||||
.space PAGE_SIZE | .space PAGE_SIZE | ||||
.align 4 | .align 4 | ||||
initstack: | initstack: | ||||
.space (PAGE_SIZE * KSTACK_PAGES) | .space (PAGE_SIZE * KSTACK_PAGES) | ||||
Show All 21 Lines |