#define MAX_PATCHSIZE 16384
// Yes, we're including a C file. Problem?
-#include "../../../source/interp.c"
+#include "../../../source/interpreter.c"
#if 0
#ifndef __SCREENINIT_H
#define __SCREENINIT_H
-
#define PDN_GPU_CNT (*(volatile uint32_t*)0x10141200)
#define LCD_REG(offset) (*((volatile uint32_t*)(0x10202000 + (offset))))
#include <firm/decryptor.h>
#include <firm/firm.h>
-#include <screeninit.h>
+#include <arm11.h>
#include <interrupt.h>
#include <option.h>
#include <input.h>
--- /dev/null
+#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
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
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));
}
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;
#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;
// 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);
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.
}
extern void wait();
+__attribute__ ((noreturn))
void
boot_firm()
{
#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);
{ -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.
}
}
-int show_menu(struct options_s *options, uint8_t *toggles);
-
void
menu_patches()
{
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)
{
}
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 *));
va_end(ap);
}
+
+void
+printf(void *channel, const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+
+ vfprintf(stdout, format, ap);
+
+ va_end(ap);
+}