From b9428dd2f398617ec864c467167918b1fc2b7dc9 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 29 Nov 2020 18:41:19 -0800 Subject: [PATCH] fusee: fixup extents for chainloader/stack --- .../fusee-primary/fusee-primary-main/linker.ld | 4 ++-- .../fusee-primary-main/src/chainloader.h | 2 +- .../fusee-primary-main/src/stage2.c | 18 +++++++++--------- .../fusee-primary-main/src/stage2.h | 4 ++-- fusee/fusee-secondary/src/stage2.h | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/fusee/fusee-primary/fusee-primary-main/linker.ld b/fusee/fusee-primary/fusee-primary-main/linker.ld index cc397c02d..2c381df64 100644 --- a/fusee/fusee-primary/fusee-primary-main/linker.ld +++ b/fusee/fusee-primary/fusee-primary-main/linker.ld @@ -14,14 +14,14 @@ MEMORY { NULL : ORIGIN = 0x00000000, LENGTH = 0x1000 main : ORIGIN = 0x40008000, LENGTH = 0x28000 - low_iram : ORIGIN = 0x40003000, LENGTH = 0x1000 + low_iram : ORIGIN = 0x40000000, LENGTH = 0x6000 } SECTIONS { PROVIDE(__start__ = 0x40008000); PROVIDE(__stack_top__ = 0x40008000); - PROVIDE(__stack_bottom__ = 0x40004000); + PROVIDE(__stack_bottom__ = 0x40006000); PROVIDE(__heap_start__ = 0); PROVIDE(__heap_end__ = 0); diff --git a/fusee/fusee-primary/fusee-primary-main/src/chainloader.h b/fusee/fusee-primary/fusee-primary-main/src/chainloader.h index 3a7dd384d..f08bf6396 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/chainloader.h +++ b/fusee/fusee-primary/fusee-primary-main/src/chainloader.h @@ -20,7 +20,7 @@ #include #include -#define CHAINLOADER_ARG_DATA_MAX_SIZE 0x640 +#define CHAINLOADER_ARG_DATA_MAX_SIZE 0x5400 #define CHAINLOADER_MAX_ENTRIES 128 typedef struct chainloader_entry_t { diff --git a/fusee/fusee-primary/fusee-primary-main/src/stage2.c b/fusee/fusee-primary/fusee-primary-main/src/stage2.c index 150fcb310..68c65bda9 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/stage2.c +++ b/fusee/fusee-primary/fusee-primary-main/src/stage2.c @@ -58,21 +58,21 @@ static int stage2_ini_handler(void *user, const char *section, const char *name, static bool run_mtc(const char *mtc_path, uintptr_t mtc_address) { FILINFO info; size_t size; - + /* Check if the MTC binary is present. */ if (f_stat(mtc_path, &info) != FR_OK) { print(SCREEN_LOG_LEVEL_WARNING, "Stage2's MTC binary not found!\n"); return false; } - + size = (size_t)info.fsize; - + /* Try to read the MTC binary. */ if (read_from_file((void *)mtc_address, size, mtc_path) != size) { print(SCREEN_LOG_LEVEL_WARNING, "Failed to read stage2's MTC binary (%s)!\n", mtc_path); return false; } - + ScreenLogLevel mtc_log_level = log_get_log_level(); bool mtc_res = false; int mtc_argc = 1; @@ -81,13 +81,13 @@ static bool run_mtc(const char *mtc_path, uintptr_t mtc_address) { /* Setup argument data. */ memcpy(&mtc_args->log_level, &mtc_log_level, sizeof(mtc_log_level)); - + /* Run the MTC binary. */ mtc_res = (((int (*)(int, void *))mtc_address)(mtc_argc, mtc_arg_data) == 0); - + /* Cleanup right away. */ memset((void *)mtc_address, 0, size); - + return mtc_res; } @@ -116,7 +116,7 @@ void load_stage2(const char *bct0) { if (!check_32bit_address_loadable(config.load_address)) { fatal_error("Stage2's load address is invalid!\n"); } - + print(SCREEN_LOG_LEVEL_DEBUG, "Stage 2 Config:\n"); print(SCREEN_LOG_LEVEL_DEBUG | SCREEN_LOG_LEVEL_NO_PREFIX, " File Path: %s\n", config.path); print(SCREEN_LOG_LEVEL_DEBUG | SCREEN_LOG_LEVEL_NO_PREFIX, " MTC File Path: %s\n", config.mtc_path); @@ -152,7 +152,7 @@ void load_stage2(const char *bct0) { } else { tmp_addr = config.load_address; } - + /* Try to read stage2. */ if (read_from_file((void *)tmp_addr, size, config.path) != size) { fatal_error("Failed to read stage2 (%s)!\n", config.path); diff --git a/fusee/fusee-primary/fusee-primary-main/src/stage2.h b/fusee/fusee-primary/fusee-primary-main/src/stage2.h index 559c920a4..39d5f8ccc 100644 --- a/fusee/fusee-primary/fusee-primary-main/src/stage2.h +++ b/fusee/fusee-primary/fusee-primary-main/src/stage2.h @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #ifndef FUSEE_STAGE2_H #define FUSEE_STAGE2_H @@ -36,7 +36,7 @@ #define STAGE2_ADDRESS_KEY "stage2_addr" #define STAGE2_ENTRYPOINT_KEY "stage2_entrypoint" -#define BCTO_MAX_SIZE 0x5800 +#define BCTO_MAX_SIZE 0x5000 typedef struct { char path[0x100]; diff --git a/fusee/fusee-secondary/src/stage2.h b/fusee/fusee-secondary/src/stage2.h index e81b4cdf1..8b3a44033 100644 --- a/fusee/fusee-secondary/src/stage2.h +++ b/fusee/fusee-secondary/src/stage2.h @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #ifndef FUSEE_STAGE2_H #define FUSEE_STAGE2_H @@ -25,7 +25,7 @@ #define STAGE2_ARGV_ARGUMENT_STRUCT 1 #define STAGE2_ARGC 2 -#define BCTO_MAX_SIZE 0x5800 +#define BCTO_MAX_SIZE 0x5000 typedef struct { uint32_t version;