From: Jon Feldman Date: Sat, 20 May 2017 06:06:59 +0000 (-0400) Subject: Partial (broken) FIRM support X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=b5eab8d3e403590f3b5ae4c8aeb0f9585b3ff0ab;p=corbenik%2Fcorbenik.git Partial (broken) FIRM support It's not quite working yet. For some reason, screeninit causes a complete lockup. That said, it does boot if: * No background images are present * Autoboot is on * Silent mode is on I'm aware this is currently broken. REPEAT. I am aware. --- diff --git a/.gitignore b/.gitignore index e14dd67..46be2a4 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ depcomp /external/Makefile /include/Makefile /boot/corbenik +/boot/corbenik.firm /bootstub/bootstub /m4 /include/config.h diff --git a/Makefile.am b/Makefile.am index aac6f20..ca7ae8e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ all-local: external loader boot bits patch mkdir -p out@sysconfdir@ mkdir -p out@localstatedir@ cp boot/corbenik.bin out/arm9loaderhax.bin + cp boot/corbenik.firm out/boot.firm cp boot/corbenik.bin out@libexecdir@/ cp boot/corbenik out/corbenik.elf cp loader/loader.cxi out@libdir@/module/native/loader.cxi diff --git a/boot/Makefile.am b/boot/Makefile.am index 9e1f60d..0dd7337 100644 --- a/boot/Makefile.am +++ b/boot/Makefile.am @@ -15,8 +15,9 @@ clean-local: corbenik.bin: corbenik $(OBJCOPY) $(OCFLAGS) -O binary $< $@ +# XXX - Firmtool seems to incorrectly copy the elf's sections to the output, so we have to do this for now corbenik.firm: corbenik.bin - firmtool build $@ -n 0x23F00000 -e 0 -D $^ -A 0x23F00000 -C NDMA + firmtool build $@ -i -n 0x23F00000 -e 0 -D $^ -A 0x23F00000 -C NDMA corbenikdir = $(top_srcdir)/source diff --git a/boot/arm11.c b/boot/arm11.c index 431085b..4e0e89e 100644 --- a/boot/arm11.c +++ b/boot/arm11.c @@ -42,34 +42,9 @@ struct framebuffers *framebuffers; -volatile uint32_t *arm11Entry = (volatile uint32_t *)0x1FFFFFF8; +volatile uint32_t *arm11Entry = (volatile uint32_t *)0x1FFFFFFC; static const uint32_t brightness[4] = {0x26, 0x39, 0x4C, 0x5F}; -void __attribute__((naked)) arm11Stub(void) -{ - //Disable interrupts - __asm(".word 0xF10C01C0"); - - //Wait for the entry to be set - while(*arm11Entry == ARM11_STUB_ADDRESS); - - //Jump to it - ((void (*)())*arm11Entry)(); -} - -void installArm11Stub(void) { - static int hasCopiedStub = false; - if(!hasCopiedStub) - { - memcpy((void *)ARM11_STUB_ADDRESS, arm11Stub, 0x30); - ctr_cache_clean_and_flush_all(); - hasCopiedStub = true; - } - - if (is_firmlaunch()) - arm11Entry = (volatile uint32_t*)0x1FFFFFFC; -} - void invokeArm11Function(void (*func)()) { installArm11Stub(); diff --git a/boot/corbenik.c b/boot/corbenik.c index f3e8291..5cd597d 100644 --- a/boot/corbenik.c +++ b/boot/corbenik.c @@ -63,8 +63,6 @@ main(int argc, char** argv) install_interrupts(); // Get some free debug info. - installArm11Stub(); - if (is_firmlaunch()) { shut_up(); @@ -110,6 +108,7 @@ main(int argc, char** argv) clear_disp(TOP_SCREEN); clear_disp(BOTTOM_SCREEN); } + menu_handler(); } diff --git a/boot/start.s b/boot/start.s index 09398ef..ea2997c 100644 --- a/boot/start.s +++ b/boot/start.s @@ -10,17 +10,18 @@ argc: .int 0 argv: .int 0 init: + // Disable IRQ + mrs r2, cpsr + orr r2, r2, #0x1C0 + msr cpsr_c, r2 + + // Save argc, argv ldr r2, =argc str r0, [r2] ldr r2, =argv str r1, [r2] - // Disable IRQ - mrs r0, cpsr - orr r0, r0, #0x80 - msr cpsr_c, r0 - // Flush caches, make sure to sync memory with what's on the cache before // turning off the MPU adr r0, flush_all_caches_offset @@ -215,6 +216,7 @@ enable_mpu_and_caching: // Enable caches, MPU, and itcm mrc p15, 0, r0, c1, c0, 0 // read control register orr r0, r0, #(1<<18) // - itcm enable + orr r0, r0, #(1<<13) // - alt exception vector enable orr r0, r0, #(1<<12) // - instruction cache enable orr r0, r0, #(1<<2) // - data cache enable orr r0, r0, #(1<<0) // - mpu enable