X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=rpikern;a=blobdiff_plain;f=src%2Fstartup.s;h=84e7e94d0b4037cec5229b228900e0f530504cec;hp=d0b402f24a24ea29b366d8072956c0049355fb5a;hb=38a008b8d1a3a20c401397b4e132fb578e5f0c10;hpb=311d50a18e3cdc236781882198671b4e1a538535 diff --git a/src/startup.s b/src/startup.s index d0b402f..84e7e94 100644 --- a/src/startup.s +++ b/src/startup.s @@ -3,11 +3,37 @@ .section .startup .code 32 + .global startup startup: - ldr sp, =_stacktop - - mov r0, #2 - bl dbgled + cpsid if + + @ stop all but one of the cores + mrc p15, 0, r0, c0, c0, 5 + ands r0, r0, #0xff + bne exit + + @ detect if we're running in hyp mode, and drop to svc + mrs r0, cpsr + and r1, r0, #0x1f + cmp r1, #0x1a + bne hypend + + bic r0, #0x1f + orr r0, #0x13 + @msr spsr_cxsf, r0 + add r0, pc, #4 + msr elr_hyp, r0 + @eret + mov pc, r0 +hypend: + + @ setup initial stacks, allow 4k stack for IRQs + @mov r0, #0x12 @ switch to IRQ mode + @msr cpsr, r0 + @ldr sp, =_stacktop + @mov r0, #0x13 @ switch to supervisor mode + @msr cpsr, r0 + ldr sp, =_stacktop - 4096 @ clear bss ldr r0, =_bss_start @@ -19,28 +45,10 @@ startup: subs r1, #4 bne 0b 1: - bl main - - mov r0, #0 - bl dbgled + blx main .global exit exit: wfe b exit - .global dbgled -dbgled: - ldr r3, =0x3f200000 @ gpio base - ldr r2, =0x9000 @ gpio 24 and 25 -> output - str r2, [r3, #8] @ store to GPFSEL2 - ldr r2, =0x01000000 @ bit 24 - tst r0, #1 - strne r2, [r3, #0x1c] @ GPSET0 - streq r2, [r3, #0x28] @ GPCLR0 - lsl r2, #1 - tst r0, #2 - strne r2, [r3, #0x1c] @ GPSET0 - streq r2, [r3, #0x28] @ GPCLR0 - bx lr - @ vi:set filetype=armasm: