Merge branch 'master' into emunand_dev
This commit is contained in:
@@ -668,7 +668,7 @@ static int sdmmc_int_clk_enable(sdmmc_t *sdmmc)
|
||||
|
||||
/* Clock failed to stabilize. */
|
||||
if (is_timeout) {
|
||||
sdmmc_error(sdmmc, "clock never stabilized!");
|
||||
sdmmc_error(sdmmc, "Clock never stabilized!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1353,8 +1353,11 @@ static int sdmmc_dma_init(sdmmc_t *sdmmc, sdmmc_request_t *req)
|
||||
{
|
||||
/* Invalid block count or size. */
|
||||
if (!req->blksz || !req->num_blocks)
|
||||
{
|
||||
sdmmc_error(sdmmc, "Empty DMA request!");
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
uint32_t blkcnt = req->num_blocks;
|
||||
|
||||
/* Truncate block count. Length can't be over 65536 bytes. */
|
||||
@@ -1366,8 +1369,11 @@ static int sdmmc_dma_init(sdmmc_t *sdmmc, sdmmc_request_t *req)
|
||||
|
||||
/* DMA buffer address must be aligned to 4 bytes. */
|
||||
if ((4 - (dma_base_addr & 0x03)) & 0x03)
|
||||
{
|
||||
sdmmc_error(sdmmc, "Invalid DMA request data buffer: 0x%08X", dma_base_addr);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* Write our address to the registers. */
|
||||
if (sdmmc->use_adma)
|
||||
{
|
||||
|
||||
@@ -96,7 +96,7 @@ export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
KIPFILES := loader.kip pm.kip sm.kip ams_mitm.kip spl.kip boot_100.kip boot_200.kip
|
||||
KIPFILES := loader.kip pm.kip sm.kip ams_mitm.kip spl.kip boot.kip
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) fusee-primary.bin \
|
||||
exosphere.bin lp0fw.bin rebootstub.bin thermosphere.bin splash_screen.bmp \
|
||||
sept-primary.bin sept-secondary.enc \
|
||||
|
||||
@@ -220,10 +220,8 @@ SECTIONS
|
||||
======================= */
|
||||
PROVIDE(__ams_mitm_kip_start__ = ams_mitm_kip - __start__);
|
||||
PROVIDE(__ams_mitm_kip_size__ = ams_mitm_kip_end - ams_mitm_kip);
|
||||
PROVIDE(__boot_100_kip_start__ = boot_100_kip - __start__);
|
||||
PROVIDE(__boot_100_kip_size__ = boot_100_kip_end - boot_100_kip);
|
||||
PROVIDE(__boot_200_kip_start__ = boot_200_kip - __start__);
|
||||
PROVIDE(__boot_200_kip_size__ = boot_200_kip_end - boot_200_kip);
|
||||
PROVIDE(__boot_kip_start__ = boot_kip - __start__);
|
||||
PROVIDE(__boot_kip_size__ = boot_kip_end - boot_kip);
|
||||
PROVIDE(__exosphere_bin_start__ = exosphere_bin - __start__);
|
||||
PROVIDE(__exosphere_bin_size__ = exosphere_bin_end - exosphere_bin);
|
||||
PROVIDE(__fusee_primary_bin_start__ = fusee_primary_bin - __start__);
|
||||
|
||||
@@ -24,10 +24,11 @@
|
||||
/* "EXO0" */
|
||||
#define MAGIC_EXOSPHERE_CONFIG (0x304F5845)
|
||||
|
||||
#define EXOSPHERE_FLAGS_DEFAULT 0x00000000
|
||||
#define EXOSPHERE_FLAG_PERFORM_620_KEYGEN (1 << 0u)
|
||||
#define EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV (1 << 1u)
|
||||
#define EXOSPHERE_FLAG_IS_DEBUGMODE_USER (1 << 2u)
|
||||
#define EXOSPHERE_FLAG_PERFORM_620_KEYGEN (1 << 0u)
|
||||
#define EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV (1 << 1u)
|
||||
#define EXOSPHERE_FLAG_IS_DEBUGMODE_USER (1 << 2u)
|
||||
#define EXOSPHERE_FLAG_DISABLE_USERMODE_EXCEPTION_HANDLERS (1 << 3u)
|
||||
#define EXOSPHERE_FLAGS_DEFAULT (EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV)
|
||||
|
||||
typedef struct {
|
||||
unsigned int magic;
|
||||
@@ -41,5 +42,6 @@ typedef struct {
|
||||
#define EXOSPHERE_TARGETFW_KEY "target_firmware"
|
||||
#define EXOSPHERE_DEBUGMODE_PRIV_KEY "debugmode"
|
||||
#define EXOSPHERE_DEBUGMODE_USER_KEY "debugmode_user"
|
||||
#define EXOSPHERE_DISABLE_USERMODE_EXCEPTION_HANDLERS_KEY "disable_user_exception_handlers"
|
||||
|
||||
#endif
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
extern void (*__program_exit_callback)(int rc);
|
||||
|
||||
static __attribute__((__aligned__(0x200))) stage2_args_t g_stage2_args_store;
|
||||
static stage2_args_t *g_stage2_args;
|
||||
static bool g_do_nxboot;
|
||||
|
||||
@@ -86,7 +87,8 @@ int main(int argc, void **argv) {
|
||||
generic_panic();
|
||||
}
|
||||
|
||||
g_stage2_args = (stage2_args_t *)argv[STAGE2_ARGV_ARGUMENT_STRUCT];
|
||||
g_stage2_args = &g_stage2_args_store;
|
||||
memcpy(g_stage2_args, (stage2_args_t *)argv[STAGE2_ARGV_ARGUMENT_STRUCT], sizeof(*g_stage2_args));
|
||||
|
||||
if (g_stage2_args->version != 0) {
|
||||
generic_panic();
|
||||
@@ -103,10 +105,11 @@ int main(int argc, void **argv) {
|
||||
|
||||
/* Load BCT0 from SD if needed. */
|
||||
if (strcmp(g_stage2_args->bct0, "") == 0) {
|
||||
read_from_file(g_stage2_args->bct0, sizeof(g_stage2_args->bct0) - 1, "atmosphere/BCT.ini");
|
||||
if (!read_from_file(g_stage2_args->bct0, sizeof(g_stage2_args->bct0) - 1, "atmosphere/BCT.ini")) {
|
||||
uint32_t bct_tmp_buf[sizeof(g_stage2_args->bct0) / sizeof(uint32_t)] = {0};
|
||||
if (!read_from_file(bct_tmp_buf, sizeof(bct_tmp_buf) - 1, "atmosphere/BCT.ini")) {
|
||||
fatal_error("Failed to read BCT0 from SD!\n");
|
||||
}
|
||||
memcpy(g_stage2_args->bct0, bct_tmp_buf, sizeof(bct_tmp_buf));
|
||||
}
|
||||
|
||||
/* This will load all remaining binaries off of the SD. */
|
||||
|
||||
@@ -126,22 +126,27 @@ static int exosphere_ini_handler(void *user, const char *section, const char *na
|
||||
if (strcmp(section, "exosphere") == 0) {
|
||||
if (strcmp(name, EXOSPHERE_TARGETFW_KEY) == 0) {
|
||||
sscanf(value, "%d", &exo_cfg->target_firmware);
|
||||
}
|
||||
if (strcmp(name, EXOSPHERE_DEBUGMODE_PRIV_KEY) == 0) {
|
||||
} else if (strcmp(name, EXOSPHERE_DEBUGMODE_PRIV_KEY) == 0) {
|
||||
sscanf(value, "%d", &tmp);
|
||||
if (tmp) {
|
||||
exo_cfg->flags |= EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV;
|
||||
} else {
|
||||
exo_cfg->flags &= ~(EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV);
|
||||
}
|
||||
}
|
||||
if (strcmp(name, EXOSPHERE_DEBUGMODE_USER_KEY) == 0) {
|
||||
} else if (strcmp(name, EXOSPHERE_DEBUGMODE_USER_KEY) == 0) {
|
||||
sscanf(value, "%d", &tmp);
|
||||
if (tmp) {
|
||||
exo_cfg->flags |= EXOSPHERE_FLAG_IS_DEBUGMODE_USER;
|
||||
} else {
|
||||
exo_cfg->flags &= ~(EXOSPHERE_FLAG_IS_DEBUGMODE_USER);
|
||||
}
|
||||
} else if (strcmp(name, EXOSPHERE_DISABLE_USERMODE_EXCEPTION_HANDLERS_KEY) == 0) {
|
||||
sscanf(value, "%d", &tmp);
|
||||
if (tmp) {
|
||||
exo_cfg->flags |= EXOSPHERE_FLAG_DISABLE_USERMODE_EXCEPTION_HANDLERS;
|
||||
} else {
|
||||
exo_cfg->flags &= ~(EXOSPHERE_FLAG_DISABLE_USERMODE_EXCEPTION_HANDLERS);
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -668,7 +668,7 @@ static int sdmmc_int_clk_enable(sdmmc_t *sdmmc)
|
||||
|
||||
/* Clock failed to stabilize. */
|
||||
if (is_timeout) {
|
||||
sdmmc_error(sdmmc, "clock never stabilized!");
|
||||
sdmmc_error(sdmmc, "Clock never stabilized!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1353,8 +1353,11 @@ static int sdmmc_dma_init(sdmmc_t *sdmmc, sdmmc_request_t *req)
|
||||
{
|
||||
/* Invalid block count or size. */
|
||||
if (!req->blksz || !req->num_blocks)
|
||||
{
|
||||
sdmmc_error(sdmmc, "Empty DMA request!");
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
uint32_t blkcnt = req->num_blocks;
|
||||
|
||||
/* Truncate block count. Length can't be over 65536 bytes. */
|
||||
@@ -1366,8 +1369,11 @@ static int sdmmc_dma_init(sdmmc_t *sdmmc, sdmmc_request_t *req)
|
||||
|
||||
/* DMA buffer address must be aligned to 4 bytes. */
|
||||
if ((4 - (dma_base_addr & 0x03)) & 0x03)
|
||||
{
|
||||
sdmmc_error(sdmmc, "Invalid DMA request data buffer: 0x%08X", dma_base_addr);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* Write our address to the registers. */
|
||||
if (sdmmc->use_adma)
|
||||
{
|
||||
|
||||
@@ -103,20 +103,12 @@ _content_headers:
|
||||
.asciz "ams_mitm"
|
||||
.align 5
|
||||
|
||||
/* boot_100 content header */
|
||||
.word __boot_100_kip_start__
|
||||
.word __boot_100_kip_size__
|
||||
/* boot content header */
|
||||
.word __boot_kip_start__
|
||||
.word __boot_kip_size__
|
||||
.word CONTENT_TYPE_KIP
|
||||
.word 0xCCCCCCCC
|
||||
.asciz "boot_100"
|
||||
.align 5
|
||||
|
||||
/* boot_200 content header */
|
||||
.word __boot_200_kip_start__
|
||||
.word __boot_200_kip_size__
|
||||
.word CONTENT_TYPE_KIP
|
||||
.word 0xCCCCCCCC
|
||||
.asciz "boot_200"
|
||||
.asciz "boot"
|
||||
.align 5
|
||||
|
||||
/* exosphere content header */
|
||||
|
||||
@@ -33,8 +33,7 @@
|
||||
#include "pm_kip.h"
|
||||
#include "sm_kip.h"
|
||||
#include "ams_mitm_kip.h"
|
||||
#include "boot_100_kip.h"
|
||||
#include "boot_200_kip.h"
|
||||
#include "boot_kip.h"
|
||||
#include "spl_kip.h"
|
||||
#undef u8
|
||||
#undef u32
|
||||
@@ -47,18 +46,14 @@ static bool g_stratosphere_sm_enabled = true;
|
||||
static bool g_stratosphere_pm_enabled = true;
|
||||
static bool g_stratosphere_ams_mitm_enabled = true;
|
||||
static bool g_stratosphere_spl_enabled = true;
|
||||
static bool g_stratosphere_boot_enabled = false;
|
||||
static bool g_stratosphere_boot_enabled = true;
|
||||
|
||||
extern const uint8_t boot_100_kip[], boot_200_kip[];
|
||||
extern const uint8_t loader_kip[], pm_kip[], sm_kip[], spl_kip[], ams_mitm_kip[];
|
||||
extern const uint32_t boot_100_kip_size, boot_200_kip_size;
|
||||
extern const uint32_t loader_kip_size, pm_kip_size, sm_kip_size, spl_kip_size, ams_mitm_kip_size;
|
||||
extern const uint8_t loader_kip[], pm_kip[], sm_kip[], spl_kip[], boot_kip[], ams_mitm_kip[];
|
||||
extern const uint32_t loader_kip_size, pm_kip_size, sm_kip_size, spl_kip_size, boot_kip_size, ams_mitm_kip_size;
|
||||
|
||||
/* GCC doesn't consider the size as const... we have to write it ourselves. */
|
||||
|
||||
ini1_header_t *stratosphere_get_ini1(uint32_t target_firmware) {
|
||||
const uint8_t *boot_kip = NULL;
|
||||
uint32_t boot_kip_size = 0;
|
||||
uint32_t num_processes = 0;
|
||||
uint8_t *data;
|
||||
|
||||
@@ -66,14 +61,6 @@ ini1_header_t *stratosphere_get_ini1(uint32_t target_firmware) {
|
||||
return g_stratosphere_ini1;
|
||||
}
|
||||
|
||||
if (target_firmware <= ATMOSPHERE_TARGET_FIRMWARE_100) {
|
||||
boot_kip = boot_100_kip;
|
||||
boot_kip_size = boot_100_kip_size;
|
||||
} else {
|
||||
boot_kip = boot_200_kip;
|
||||
boot_kip_size = boot_200_kip_size;
|
||||
}
|
||||
|
||||
size_t size = sizeof(ini1_header_t);
|
||||
|
||||
/* Calculate our processes' sizes. */
|
||||
|
||||
Reference in New Issue
Block a user