]> Chaos Git - corbenik/corbenik.git/commitdiff
Fixups and renames for accuracy
authorchaoskagami <chaos.kagami@gmail.com>
Mon, 8 Aug 2016 04:22:58 +0000 (00:22 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Mon, 8 Aug 2016 04:22:58 +0000 (00:22 -0400)
13 files changed:
external/loader/source/interp.c
include/arm11.h [moved from include/screeninit.h with 99% similarity]
include/common.h
include/menu-backend.h [new file with mode: 0644]
source/Makefile.am
source/arm11.c [moved from source/screeninit.c with 97% similarity]
source/chainloader.c [moved from source/chain.c with 90% similarity]
source/config-file.c [moved from source/option.c with 100% similarity]
source/firm/firm.c
source/interpreter.c [moved from source/interp.c with 100% similarity]
source/menu-backend.c [moved from source/display.c with 96% similarity]
source/menu.c
source/std/draw.c

index 5344affdbf4047d4a18747eb6ae4f17c146972d7..28bc33831024d770fa554968bc49747a0cdaeb70 100644 (file)
@@ -25,7 +25,7 @@
 #define MAX_PATCHSIZE 16384
 
 // Yes, we're including a C file. Problem?
-#include "../../../source/interp.c"
+#include "../../../source/interpreter.c"
 
 #if 0
 
similarity index 99%
rename from include/screeninit.h
rename to include/arm11.h
index 0a27794a0cf31a78a7cdec4785744abc6eb43b5e..4dfeac41aa17af53295bec9b9f7fa8f10b33b050 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef __SCREENINIT_H
 #define __SCREENINIT_H
 
-
 #define PDN_GPU_CNT (*(volatile uint32_t*)0x10141200)
 
 #define LCD_REG(offset) (*((volatile uint32_t*)(0x10202000 + (offset))))
index 4f2e52133cef8e88a4c1302c3f6a3123a4faa797..53c17881795b4971e99c033d08845a9f7c12ccfe 100644 (file)
@@ -19,7 +19,7 @@
 #include <firm/decryptor.h>
 #include <firm/firm.h>
 
-#include <screeninit.h>
+#include <arm11.h>
 #include <interrupt.h>
 #include <option.h>
 #include <input.h>
diff --git a/include/menu-backend.h b/include/menu-backend.h
new file mode 100644 (file)
index 0000000..3d16475
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef __MENU_BACKEND_H__
+#define __MENU_BACKEND_H__
+
+void accent_color(void* screen, int fg);
+int show_menu(struct options_s *options, uint8_t *toggles);
+
+#endif
index 6f9bc98a80a9ce1d13fd2afcc3aa99b292622857..0e28efd9b63e7f74810c08222c03f17e278ae203 100644 (file)
@@ -19,4 +19,4 @@ corbenikdir = $(top_srcdir)/source
 
 inc_dir = $(top_srcdir)/include
 
-corbenik_SOURCES = patch/reboot.c patch/svc.c patch/module.c patch/emunand.c main.c option.c std/fs.c std/draw.c std/memory.c std/abort.c menu.c chain.c firm/version.c firm/firm.c firm/decryptor.c std/allocator.c interp.c input.c patcher.c display.c start.s interrupt.c screeninit.c
+corbenik_SOURCES = patch/reboot.c patch/svc.c patch/module.c patch/emunand.c main.c std/fs.c std/draw.c std/memory.c std/abort.c std/allocator.c menu.c firm/version.c firm/firm.c firm/decryptor.c interpreter.c input.c patcher.c chainloader.c config-file.c menu-backend.c start.s interrupt.c arm11.c
similarity index 97%
rename from source/screeninit.c
rename to source/arm11.c
index 5be8d08c54a9886cd2e1ddf2827888fc799f3b5d..2115a2c6774c2cd5d9841804e7d72f8f8daf3e05 100644 (file)
@@ -149,8 +149,10 @@ void screen_mode(uint32_t mode) {
     init_top    = MAKE_FRAMEBUFFER_PIXFMT(mode, 0, 1);
     init_bottom = MAKE_FRAMEBUFFER_PIXFMT(mode, 0, 0);
 
-       // We literally just discard the previous state - for sanity's sake.
     if (!framebuffers) {
+        // Look ma, dynamically allocating the CakeHax struct! (joking)
+               // We literally just discard the previous state - for sanity's sake.
+        // On chainload, it is needed to copy the framebuffer struct.
         framebuffers = malloc(sizeof(struct framebuffers));
     }
 
@@ -243,7 +245,7 @@ void screen_mode(uint32_t mode) {
                PDC1_FRAMEBUFFER_SETUP_FBA_ADDR_1 = 0x1835dc00;
                PDC1_FRAMEBUFFER_SETUP_FBA_ADDR_2 = 0x1835dc00;
 
-        //Set CakeBrah framebuffers
+        // Set not-actually cakebrah framebuffers. Meh.
         framebuffers->top_left  = (uint8_t *)0x18300000;
         framebuffers->top_right = (uint8_t *)0x18300000;
         framebuffers->bottom    = (uint8_t *)0x1835dc00;
similarity index 90%
rename from source/chain.c
rename to source/chainloader.c
index 7a102c46f84fe703df6b1d735a101754c3527a2c..82557a9287359628ffbef95ac3ca0b2dcc43343b 100644 (file)
@@ -2,9 +2,6 @@
 #if defined(CHAINLOADER) && CHAINLOADER == 1
 
 #include <common.h>
-#include <screeninit.h>
-#include <firm/firm.h>
-#include <firm/headers.h>
 
 uint32_t current_chain_index = 0;
 
@@ -16,7 +13,9 @@ int show_menu(struct options_s *options, uint8_t *toggles);
 //        be better to have a recursive listing that calls a function for
 //        each entry (it would cut code density)
 
-void chainload_file(char* chain_file_data) {
+__attribute__ ((noreturn))
+void chainload_file(char* chain_file_data)
+{
     // We copy because it's possible the payload will overwrite us in memory.
     char chain_file[256];
     strncpy(chain_file, chain_file_data, 255);
@@ -67,10 +66,15 @@ void chainload_file(char* chain_file_data) {
     argc_off[0] = 1;
     argv_off[0] = (uint32_t)off;
 
-    fprintf(stderr, "Chaining to copy payload...\n");
+    fprintf(stderr, "Changing display mode and chainloading...\n");
 
     screen_mode(1); // TODO - Because RGBA8 screeninit is non-standard...ugh
 
+    // Copy CakeHax struct where it is expected (at 0x23FFFE00)
+    // It's very very likely we'll corrupt memory with this, but we aren't coming back anyways as of the
+    // next call, so not my problem
+       memcpy((void*)0x23FFFE00, framebuffers, sizeof(struct framebuffers));
+
     ((void(*)(void*, uint32_t))0x24F00000)(chain_data, size + 256 + 8); // Size of payload + argv.
 }
 
similarity index 100%
rename from source/option.c
rename to source/config-file.c
index 51dce83b9fac12f02ba2e8c9227c33df644ecb4f..1be1a4d05689808cc7537c88e3e68eca52b10bfe 100644 (file)
@@ -429,6 +429,7 @@ void __attribute__((naked)) arm11_preboot_halt()
 
 extern void wait();
 
+__attribute__ ((noreturn))
 void
 boot_firm()
 {
similarity index 100%
rename from source/interp.c
rename to source/interpreter.c
similarity index 96%
rename from source/display.c
rename to source/menu-backend.c
index 1130e5508aef698aef4e9a9ee0cac163cb74563b..93e516c64ef9cb37a3edd10806811eff955c8ebf 100644 (file)
@@ -1,11 +1,18 @@
 #include <common.h>
 
-void header(char *append);
-
 extern int is_n3ds;
-
+extern unsigned int font_w;
 extern unsigned int font_h;
 
+void
+header(char *append)
+{
+    set_cursor(TOP_SCREEN, 0, 0);
+    fill_line(stdout, 0, config->options[OPTION_ACCENT_COLOR]);
+    accent_color(TOP_SCREEN, 0);
+    fprintf(stdout, "\x1b[30m ." FW_NAME " // %s\x1b[0m\n\n", append);
+}
+
 void show_help(char* help) {
     clear_disp(TOP_SCREEN);
     set_cursor(TOP_SCREEN, 0, 0);
index 36f07be30ad3c2780957c37dfb3b948a9e019547..73622a1fd2a3c012691c6714cdc6d48ebf49f038 100644 (file)
@@ -60,19 +60,6 @@ static struct options_s options[] = {
     { -1, "", "", 0, 0, 0 }, // cursor_min and cursor_max are stored in the last two.
 };
 
-extern unsigned int font_w;
-
-void accent_color(void* screen, int fg);
-
-void
-header(char *append)
-{
-    set_cursor(TOP_SCREEN, 0, 0);
-    fill_line(stdout, 0, config->options[OPTION_ACCENT_COLOR]);
-    accent_color(TOP_SCREEN, 0);
-    fprintf(stdout, "\x1b[30m ." FW_NAME " // %s\x1b[0m\n\n", append);
-}
-
 static int current_menu_index_patches = 0;
 
 // This function is based on PathDeleteWorker from GodMode9.
@@ -172,8 +159,6 @@ list_patches_build(char *name, int desc_is_fname)
     }
 }
 
-int show_menu(struct options_s *options, uint8_t *toggles);
-
 void
 menu_patches()
 {
index bab7f48a9c066f839e4053e39ef0743add513587..a59548282224cf5790eb7f5e7a30f50e521a431c 100644 (file)
@@ -379,6 +379,7 @@ int stdout_state = TEXT, stderr_state = TEXT;
 int stdout_val   = 0,    stderr_val   = 0;
 
 // Returns 1 if state machine is parsing - and will not output.
+// This is how colors are now handled.
 int
 ansi_statemach(void* buf, const int c)
 {
@@ -671,10 +672,6 @@ vfprintf(void *channel, const char *format, va_list ap)
                     }
                     break;
                 case 's':
-                    // FIXME - Substring ANSI colors will screw up hard, so don't do that.
-                    //         once the color handling is moved to putc as a state machine this
-                    //         will no longer be an issue.
-
                     //         For now, this warning stays.
                     disable_format = 1; // Disable format strings.
                     fprintf(channel, va_arg(ap, char *));
@@ -727,3 +724,14 @@ fprintf(void *channel, const char *format, ...)
 
     va_end(ap);
 }
+
+void
+printf(void *channel, const char *format, ...)
+{
+    va_list ap;
+    va_start(ap, format);
+
+    vfprintf(stdout, format, ap);
+
+    va_end(ap);
+}