# HG changeset patch # User Windel Bouwman # Date 1424438735 -3600 # Node ID b1daa462ee17a3f42ff28206aaf016c5a26bbe5f # Parent f381cea07fec3b8404d71ebc62ec31e9881aa3a6 Made kernel run again diff -r f381cea07fec -r b1daa462ee17 experiments/qemu_vexpress_a9/run.sh --- a/experiments/qemu_vexpress_a9/run.sh Thu Feb 19 14:10:52 2015 +0100 +++ b/experiments/qemu_vexpress_a9/run.sh Fri Feb 20 14:25:35 2015 +0100 @@ -1,5 +1,7 @@ #!/bin/bash -qemu-system-arm -M vexpress-a9 -m 128M -kernel test.bin \ +MACH=vexpress-a9 +#MACH=realview-pb-a8 +qemu-system-arm -M ${MACH} -m 128M -kernel test.bin \ -serial stdio # -nographic diff -r f381cea07fec -r b1daa462ee17 experiments/qemu_vexpress_a9/startup.s --- a/experiments/qemu_vexpress_a9/startup.s Thu Feb 19 14:10:52 2015 +0100 +++ b/experiments/qemu_vexpress_a9/startup.s Fri Feb 20 14:25:35 2015 +0100 @@ -7,15 +7,14 @@ _start: LDR sp, =stack_top - ldr r2, =0x10009000 - - mov r1, #'1' - str r1, [r2] +ldr r2, =0x10009000 +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 +ldr r0, =kernel_table0 +mcr p15, 0, r0, c2, c0, 1 +mcr p15, 0, r0, c2, c0, 0 // Domain 0: mov r0, #3 @@ -42,9 +41,8 @@ */ kernel_table0: - .long 0x00000000 + 0x402 // 0x00000000 # ; Identity map first 1 MB - .long 0x10000000 + 0x402 // 0x00100000 # ; second mb mapping to peripherals - + .long 0x00000402 // 0x00000000 # ; Identity map first 1 MB + .long 0x10000402 // 0x00100000 # ; second mb mapping to peripherals .rept 0x600 - 2 .long 0x0 .endr diff -r f381cea07fec -r b1daa462ee17 kernel/arch/qemu_vexpress/layout.mmap --- a/kernel/arch/qemu_vexpress/layout.mmap Thu Feb 19 14:10:52 2015 +0100 +++ b/kernel/arch/qemu_vexpress/layout.mmap Fri Feb 20 14:25:35 2015 +0100 @@ -1,5 +1,5 @@ -MEMORY image LOCATION=0x10000 SIZE=0x10000 { +MEMORY image LOCATION=0x60010000 SIZE=0x10000 { SECTION(reset) SECTION(code) ALIGN(0x4000) @@ -8,7 +8,7 @@ SECTION(ramdisk) } -MEMORY ram LOCATION=0x20000 SIZE=0x10000 { +MEMORY ram LOCATION=0x60020000 SIZE=0x10000 { SECTION(data) } diff -r f381cea07fec -r b1daa462ee17 kernel/arch/qemu_vexpress/start.asm --- a/kernel/arch/qemu_vexpress/start.asm Thu Feb 19 14:10:52 2015 +0100 +++ b/kernel/arch/qemu_vexpress/start.asm Fri Feb 20 14:25:35 2015 +0100 @@ -19,12 +19,18 @@ ; Setup the memory manager and the stack before entering kernel +; Output an 'A' to indicate aliveness: +ldr r0, txtA +ldr r1, DRreg +str r0, [r1, 0] + ; Setup TTBR1 (translation table base register) -ldr r0, =kernel_table0 ; pseudo instruction which loads the value of the symbol + +ldr r0, =kernel_table0 ; Load address of label ; -KERNEL_BASE +mcr p15, 0, r0, c2, c0, 0 ; TTBR0 mcr p15, 0, r0, c2, c0, 1 ; TTBR1 -mcr p15, 0, r0, c2, c0, 0 ; TTBR0 ; Prepare the TTBCR (translation table base control register) mov r0, 0x1 ; TBD: why set this to 1? @@ -35,14 +41,20 @@ mov r0, 3 mcr p15, 0, r0, c3, c0, 0 +ldr r0, txtB +ldr r1, DRreg +str r0, [r1, 0] ; Enable the VMSA (Virtual memory system architecture): mrc p15, 0, r0, c1, c0, 0 -; TODO: mov r1, 0x1 -orr r0, r0, r1 ; TODO: implement orr r0, r0, 1 +orr r0, r0, r1 mcr p15, 0, r0, c1, c0, 0 +ldr r0, txtA +ldr r1, DRregmapped +str r0, [r1, 0] + ; Setup stack: mov sp, 0x30000 BL kernel_start ; Branch to main (this is actually in the interrupt vector) @@ -74,19 +86,32 @@ mrc p15, 0, r0, c0, c0, 4 mov pc, lr +; data: +txtA: +dcd 65 +txtB: +dcd 66 +DRreg: +dcd 0x10009000 +DRregmapped: +dcd 0x109000 ; Memory map tables: +; Possibly, we are loaded into highmem at address 0x6000 0000, +; or it may as well be 0x0000 0000 as an alias. +; In any case, we must put an alias at 0x6000 0000 virtual. + section mem_tables kernel_table0: - dcd 0x00000402 ; Identity map first 1 MB + dcd 0x60000402 ; Identity map first 1 MB dcd 0x10000402 ; Map to peripheral space 1 MB repeat 0x5FE dcd 0 endrepeat - dcd 0x00000402 ; Alias to 0x0 + dcd 0x60000402 ; Alias to 0x0 repeat 0x9FF dcd 0 diff -r f381cea07fec -r b1daa462ee17 run.sh --- a/run.sh Thu Feb 19 14:10:52 2015 +0100 +++ b/run.sh Fri Feb 20 14:25:35 2015 +0100 @@ -3,6 +3,6 @@ set -e # -S means halt at start: -qemu-system-arm -M vexpress-a9 -m 128M -kernel kernel_arm.bin \ +qemu-system-arm -M vexpress-a9 -m 128M -kernel kernel/kernel_arm.bin \ -serial stdio