Skip to content
Browse files

Move the pagetables to a builtin location

  • Loading branch information...
1 parent d0122b1 commit b9816021e3cffb0e389eb625b2748f01edbbdf28 @zxombie committed Dec 25, 2013
Showing with 38 additions and 22 deletions.
  1. +2 −0 kernel/ldscript.arm64
  2. +36 −22 kernel/locore.S
View
2 kernel/ldscript.arm64
@@ -94,6 +94,8 @@ SECTIONS
*(.dynbss)
*(.bss)
*(COMMON)
+ __bss_end = .;
+ *(.init_pagetable)
}
. = ALIGN(32 / 8);
_end = . ;
View
58 kernel/locore.S
@@ -228,49 +228,58 @@ create_pagetables:
mov x5, x30
ldr x15, =(PAGE_SIZE * 3)
- /* x27 = The level 1 page table */
- sub x27, x28, x15
/* Clean the page table */
- mov x6, x27
+ adr x6, pagetable
+ mov x26, x6
+ add x27, x6, x15
1:
stp xzr, xzr, [x6], #16
stp xzr, xzr, [x6], #16
stp xzr, xzr, [x6], #16
stp xzr, xzr, [x6], #16
- cmp x6, x28
+ cmp x6, x27
b.lo 1b
- ldr x15, =(PAGE_SIZE)
- /* Create the VA = PA map */
- mov x6, x27 /* The initial page table */
- ldr x7, =1
- mov x9, x27
- mov x8, x9 /* VA start (== PA start) */
-
- bl build_section_pagetable
-
- /* Create a table for the UART */
- ldr x7, =0
- mov x8, 0x10000000 /* VA start (== PA start) */
- mov x9, 0x10000000 /* PA start */
-
- bl build_section_pagetable
- /* Build the TTBR1 maps */
- sub x26, x27, x15
+ /*
+ * Build the TTBR1 maps.
+ */
/* Create the kernel space L2 table */
- sub x6, x26, #(PAGE_SIZE)
+ mov x6, x26
ldr x7, =1
ldr x8, =(KERNBASE & L2_OUT_MASK)
mov x9, x28
bl build_block_pagetable
+ /* Move to the l1 table */
+ add x26, x26, #(PAGE_SIZE)
+
+ /* Link the l1 -> l2 table */
mov x9, x6
mov x6, x26
bl map_l1_pagetable
+
+ /*
+ * Build the TTBR0 maps.
+ */
+ add x27, x26, #(PAGE_SIZE)
+
+ /* Create the VA = PA map */
+ mov x6, x27 /* The initial page table */
+ ldr x7, =1
+ mov x9, x27
+ mov x8, x9 /* VA start (== PA start) */
+ bl build_section_pagetable
+
+ /* Create a table for the UART (TODO: Remove) */
+ ldr x7, =0
+ mov x8, 0x10000000 /* VA start (== PA start) */
+ mov x9, 0x10000000 /* PA start */
+ bl build_section_pagetable
+
/* Restore the Link register */
mov x30, x5
ret
@@ -433,3 +442,8 @@ start_mmu:
ret
+ .section .init_pagetable
+ .align 12 /* 4KiB aligned */
+pagetable:
+ .space (PAGE_SIZE * 3) /* 3 tables */
+

0 comments on commit b981602

Please sign in to comment.
Something went wrong with that request. Please try again.