From e1cadf4d72c2c98150e153fadae145c1fc022eae Mon Sep 17 00:00:00 2001 From: Jon Feldman Date: Sat, 11 Feb 2017 09:31:14 -0500 Subject: [PATCH] Clean up screeninit and arm11 logic as prep work --- boot/arm11.c | 14 +++++--------- boot/corbenik.c | 8 ++++---- boot/firm/firmlaunch.c | 13 ++++--------- include/arm11.h | 2 -- include/patcher.h | 3 --- include/util.h | 7 +++++++ 6 files changed, 20 insertions(+), 27 deletions(-) create mode 100644 include/util.h diff --git a/boot/arm11.c b/boot/arm11.c index 22ef514..431085b 100644 --- a/boot/arm11.c +++ b/boot/arm11.c @@ -38,12 +38,11 @@ #include // for i2cWriteRegister, I2C_DEV_MCU #include // for memalign #include // for framebuffers - -int screen_is_init = 0; +#include struct framebuffers *framebuffers; -volatile uint32_t *const arm11Entry = (volatile uint32_t *)0x1FFFFFF8; +volatile uint32_t *arm11Entry = (volatile uint32_t *)0x1FFFFFF8; static const uint32_t brightness[4] = {0x26, 0x39, 0x4C, 0x5F}; void __attribute__((naked)) arm11Stub(void) @@ -66,6 +65,9 @@ void installArm11Stub(void) { ctr_cache_clean_and_flush_all(); hasCopiedStub = true; } + + if (is_firmlaunch()) + arm11Entry = (volatile uint32_t*)0x1FFFFFFC; } void invokeArm11Function(void (*func)()) @@ -162,10 +164,6 @@ void set_fb_struct() { } } -int get_screen_is_init() { - return screen_is_init; -} - void screen_mode(uint32_t mode, uint32_t bright_level) { static uint32_t stride, init_top, init_bottom, bright; @@ -288,7 +286,5 @@ void screen_mode(uint32_t mode, uint32_t bright_level) { // i2cWriteRegister(I2C_DEV_MCU, 0x22, 1 << 1); //Turn on backlight i2cWriteRegister(I2C_DEV_MCU, 0x22, 0x2A); - - screen_is_init = 1; } diff --git a/boot/corbenik.c b/boot/corbenik.c index 0eacb4f..f3e8291 100644 --- a/boot/corbenik.c +++ b/boot/corbenik.c @@ -61,6 +61,10 @@ main(int argc, char** argv) // Check key down for autoboot set_fb_struct(); + install_interrupts(); // Get some free debug info. + + installArm11Stub(); + if (is_firmlaunch()) { shut_up(); @@ -71,10 +75,6 @@ main(int argc, char** argv) ctr_system_poweroff(); } - install_interrupts(); // Get some free debug info. - - installArm11Stub(); - if (CFG_BOOTENV == 7) set_opt_u32(OPTION_EMUNAND, 0); // Disable EmuNAND on AGB reboot. diff --git a/boot/firm/firmlaunch.c b/boot/firm/firmlaunch.c index 3894935..0e613e3 100644 --- a/boot/firm/firmlaunch.c +++ b/boot/firm/firmlaunch.c @@ -11,11 +11,10 @@ #include "std/draw.h" // for crflush, stderr #include "std/fs.h" // for crumount -#include "patcher.h" +#include "util.h" #include -static volatile uint32_t *const a11_entry = (volatile uint32_t *)0x1FFFFFF8; -static volatile uint32_t *const a11_entry_fl = (volatile uint32_t *)0x1FFFFFFC; +extern volatile uint32_t *arm11Entry; void firmlaunch(firm_h* firm) { // Get entrypoints @@ -33,13 +32,9 @@ void firmlaunch(firm_h* firm) { crumount(); // Unmount SD. - if (get_screen_is_init()) - deinitScreens(); // Turn off display if on + deinitScreens(); // Turn off display if on - if (is_firmlaunch()) - *a11_entry_fl = (uint32_t)entry11; // Start kernel11 - else - *a11_entry = (uint32_t)entry11; // Start kernel11 + *arm11Entry = (uint32_t)entry11; // Start kernel11 entry9(); // Start process9 } diff --git a/include/arm11.h b/include/arm11.h index 2ad4b1a..57e9c8f 100644 --- a/include/arm11.h +++ b/include/arm11.h @@ -43,8 +43,6 @@ #define ARM11_STUB_ADDRESS (0x25000000 - 0x30) //It's currently only 0x28 bytes large. We're putting 0x30 just to be sure here #define WAIT_FOR_ARM9() *arm11Entry = 0; while(!*arm11Entry); ((void (*)())*arm11Entry)(); -int get_screen_is_init(); - /* Initializes the screen and sets the display mode. * * \param mode Screen mode to initialize in, one of RGBA8, BGR8, RGB565_OES, RGB5_A1_OES, or RGBA4_OES diff --git a/include/patcher.h b/include/patcher.h index cd32930..d13ab36 100644 --- a/include/patcher.h +++ b/include/patcher.h @@ -1,9 +1,6 @@ #ifndef __PATCHER_H #define __PATCHER_H -int is_firmlaunch(); -int get_firmtype(); - /* Patches firmware with the current configuration. * * \return zero on success diff --git a/include/util.h b/include/util.h new file mode 100644 index 0000000..576da6c --- /dev/null +++ b/include/util.h @@ -0,0 +1,7 @@ +#ifndef UTIL_H +#define UTIL_H + +int is_firmlaunch(); +int get_firmtype(); + +#endif -- 2.39.5