]> Chaos Git - corbenik/corbenik.git/commitdiff
Clean up screeninit and arm11 logic as prep work wip/firmlaunch-refactor
authorJon Feldman <chaos.kagami@gmail.com>
Sat, 11 Feb 2017 14:31:14 +0000 (09:31 -0500)
committerJon Feldman <chaos.kagami@gmail.com>
Sat, 11 Feb 2017 14:31:24 +0000 (09:31 -0500)
boot/arm11.c
boot/corbenik.c
boot/firm/firmlaunch.c
include/arm11.h
include/patcher.h
include/util.h [new file with mode: 0644]

index 22ef514af065c2287381235b8690b5eccf2528ae..431085b067da30d725c6c03b16c7ae2f965ddc54 100644 (file)
 #include <ctr9/i2c.h>        // for i2cWriteRegister, I2C_DEV_MCU
 #include <malloc.h>          // for memalign
 #include <std/draw.h>        // for framebuffers
-
-int screen_is_init = 0;
+#include <util.h>
 
 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;
 }
 
index 0eacb4f78689e220ddb429c4ebcbfdb064d94485..f3e82914f8e9b7c321fdc68a317b6acbec842472 100644 (file)
@@ -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.
 
index 38949357891f876e7f04e713de6ca075c2fdb080..0e613e38045845b1a4dc0895c217316ad47014af 100644 (file)
 #include "std/draw.h"       // for crflush, stderr
 #include "std/fs.h"         // for crumount
 
-#include "patcher.h"
+#include "util.h"
 #include <ctr9/ctr_system.h>
 
-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
 }
index 2ad4b1a3aabfb72bcf3ac10052779d536346b604..57e9c8f8efc3b75ccf0f5f4c559eaef1c66d146c 100644 (file)
@@ -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
index cd3293051b1d4657de249bb7716c56617709c3b3..d13ab36f81844e05025a11235c0911c966da58fa 100644 (file)
@@ -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 (file)
index 0000000..576da6c
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef UTIL_H
+#define UTIL_H
+
+int is_firmlaunch();
+int get_firmtype();
+
+#endif