|
47 | 47 | .globl swapper_pg_dir
|
48 | 48 | .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
|
49 | 49 |
|
| 50 | + /* |
| 51 | + * This needs to be assigned at runtime when the linker symbols are |
| 52 | + * resolved. |
| 53 | + */ |
| 54 | + .pushsection .data |
| 55 | + .align 2 |
| 56 | + .globl kernel_sec_start |
| 57 | + .globl kernel_sec_end |
| 58 | +kernel_sec_start: |
| 59 | + .long 0 |
| 60 | +kernel_sec_end: |
| 61 | + .long 0 |
| 62 | + .popsection |
| 63 | + |
50 | 64 | .macro pgtbl, rd, phys
|
51 | 65 | add \rd, \phys, #TEXT_OFFSET
|
52 | 66 | sub \rd, \rd, #PG_DIR_SIZE
|
@@ -229,16 +243,23 @@ __create_page_tables:
|
229 | 243 | blo 1b
|
230 | 244 |
|
231 | 245 | /*
|
232 |
| - * Map our RAM from the start to the end of the kernel .bss section. |
| 246 | + * The main matter: map in the kernel using section mappings, and |
| 247 | + * set two variables to indicate the physical start and end of the |
| 248 | + * kernel. |
233 | 249 | */
|
234 |
| - add r0, r4, #PAGE_OFFSET >> (SECTION_SHIFT - PMD_ORDER) |
| 250 | + add r0, r4, #KERNEL_OFFSET >> (SECTION_SHIFT - PMD_ORDER) |
235 | 251 | ldr r6, =(_end - 1)
|
236 |
| - orr r3, r8, r7 |
| 252 | + adr_l r5, kernel_sec_start @ _pa(kernel_sec_start) |
| 253 | + str r8, [r5] @ Save physical start of kernel |
| 254 | + orr r3, r8, r7 @ Add the MMU flags |
237 | 255 | add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
|
238 | 256 | 1: str r3, [r0], #1 << PMD_ORDER
|
239 | 257 | add r3, r3, #1 << SECTION_SHIFT
|
240 | 258 | cmp r0, r6
|
241 | 259 | bls 1b
|
| 260 | + eor r3, r3, r7 @ Remove the MMU flags |
| 261 | + adr_l r5, kernel_sec_end @ _pa(kernel_sec_end) |
| 262 | + str r3, [r5] @ Save physical end of kernel |
242 | 263 |
|
243 | 264 | #ifdef CONFIG_XIP_KERNEL
|
244 | 265 | /*
|
|
0 commit comments