Mercurial > lcfOS
changeset 387:34ac19044b8a
Hello world with paging in emulator
author | Windel Bouwman |
---|---|
date | Thu, 01 May 2014 22:09:18 +0200 |
parents | 2a970e7270e2 |
children | e07c2a9abac1 |
files | experiments/qemu_vexpress_a9/layout.ld experiments/qemu_vexpress_a9/main.c experiments/qemu_vexpress_a9/make.sh experiments/qemu_vexpress_a9/run.sh experiments/qemu_vexpress_a9/startup.s |
diffstat | 5 files changed, 25 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/experiments/qemu_vexpress_a9/layout.ld Thu May 01 17:40:59 2014 +0200 +++ b/experiments/qemu_vexpress_a9/layout.ld Thu May 01 22:09:18 2014 +0200 @@ -3,7 +3,7 @@ SECTIONS { - . = 0x0010000; + . = 0x010000; .startup . : { startup.o(.init) } .text : {*(.text)} . = ALIGN(0x4000);
--- a/experiments/qemu_vexpress_a9/main.c Thu May 01 17:40:59 2014 +0200 +++ b/experiments/qemu_vexpress_a9/main.c Thu May 01 22:09:18 2014 +0200 @@ -1,6 +1,6 @@ -volatile unsigned int * const UART0_DR = (unsigned int *)0x10009000; +volatile unsigned int * const UART0_DR = (unsigned int *)0x109000; void print_uart0(const char *s)
--- a/experiments/qemu_vexpress_a9/make.sh Thu May 01 17:40:59 2014 +0200 +++ b/experiments/qemu_vexpress_a9/make.sh Thu May 01 22:09:18 2014 +0200 @@ -9,5 +9,6 @@ $TARGET-ld -g -T layout.ld main.o startup.o -o test.elf $TARGET-objcopy -O binary test.elf test.bin $TARGET-nm test.elf +$TARGET-objdump -x test.elf
--- a/experiments/qemu_vexpress_a9/run.sh Thu May 01 17:40:59 2014 +0200 +++ b/experiments/qemu_vexpress_a9/run.sh Thu May 01 22:09:18 2014 +0200 @@ -1,5 +1,5 @@ #!/bin/bash -qemu-system-arm -M vexpress-a9 -m 128M -kernel test.bin \ +qemu-system-arm -M vexpress-a9 -m 128M -kernel test.bin \ -serial stdio # -nographic
--- a/experiments/qemu_vexpress_a9/startup.s Thu May 01 17:40:59 2014 +0200 +++ b/experiments/qemu_vexpress_a9/startup.s Thu May 01 22:09:18 2014 +0200 @@ -3,6 +3,8 @@ .global _Reset; _Reset: + +_start: LDR sp, =stack_top ldr r2, =0x10009000 @@ -10,44 +12,44 @@ mov r1, #'1' str r1, [r2] +// Load TTBR0 and TTBR1 ldr r0, =kernel_table0 mcr p15, 0, r0, c2, c0, 1 mcr p15, 0, r0, c2, c0, 0 - mov r1, #'2' - str r1, [r2] - - mov r1, #'3' - str r1, [r2] - + // Domain 0: mov r0, #3 mcr p15, 0, r0, c3, c0, 0 - mov r1, #'4' - str r1, [r2] - + # ; Enable paging: mrc p15, 0, r0, c1, c0, 0 orr r0, r0, #1 mcr p15, 0, r0, c1, c0, 0 - mov r1, #'5' +// Change uart DR pointer (now located at 0x109000: + ldr r2, =0x109000 + mov r1, #'2' str r1, [r2] - BL start B . - - .section .padata +/* + Maybe the kernel is loaded at 0x60000000, so we need to map that to first + megabyte also... +*/ + kernel_table0: - .long 0x0402 - .rept 0xFFF + .long 0x00000000 + 0x402 // 0x00000000 # ; Identity map first 1 MB + .long 0x10000000 + 0x402 // 0x00100000 # ; second mb mapping to peripherals + + .rept 0x600 - 2 + .long 0x0 + .endr + .long 0x00000402 // 0x60000000 maps 1 MB to first MB + .rept 0x1000 - 0x601 .long 0x0 .endr - .rept 0xFFF - .long 0x0 - .endr -