Pass screen status and mmc struct from stage1 to 2
This commit is contained in:
@@ -15,15 +15,8 @@
|
||||
|
||||
static bool g_ahb_redirect_enabled = false;
|
||||
|
||||
// Only use voltage switching in stage2 and later.
|
||||
#ifdef FUSEE_STAGE1_SRC
|
||||
#define MMC_VOLTAGE_SWITCHING_ALLOWED false
|
||||
#else
|
||||
#define MMC_VOLTAGE_SWITCHING_ALLOWED true
|
||||
#endif
|
||||
|
||||
/* Global sd struct. */
|
||||
static struct mmc g_sd_mmc = {0};
|
||||
struct mmc g_sd_mmc = {0};
|
||||
static bool g_sd_initialized = false;
|
||||
|
||||
int initialize_sd_mmc(void) {
|
||||
@@ -33,7 +26,7 @@ int initialize_sd_mmc(void) {
|
||||
}
|
||||
|
||||
if (!g_sd_initialized) {
|
||||
int rc = sdmmc_init(&g_sd_mmc, SWITCH_MICROSD, MMC_VOLTAGE_SWITCHING_ALLOWED);
|
||||
int rc = sdmmc_init(&g_sd_mmc, SWITCH_MICROSD, false);
|
||||
if (rc == 0) {
|
||||
g_sd_initialized = true;
|
||||
return 0;
|
||||
|
||||
@@ -108,7 +108,9 @@ int main(void) {
|
||||
const char *stage2_path;
|
||||
stage2_args_t *stage2_args;
|
||||
uint32_t stage2_version = 0;
|
||||
extern struct mmc g_sd_mmc;
|
||||
|
||||
sdmmc_set_loglevel(2);
|
||||
/* Initialize the display, console, etc. */
|
||||
setup_env();
|
||||
|
||||
@@ -134,6 +136,8 @@ int main(void) {
|
||||
strcpy(g_chainloader_arg_data, stage2_path);
|
||||
stage2_args = (stage2_args_t *)(g_chainloader_arg_data + strlen(stage2_path) + 1); /* May be unaligned. */
|
||||
memcpy(&stage2_args->version, &stage2_version, 4);
|
||||
stage2_args->display_initialized = false;
|
||||
memcpy(&stage2_args->sd_mmc, &g_sd_mmc, sizeof(g_sd_mmc));
|
||||
strcpy(stage2_args->bct0, bct0);
|
||||
g_chainloader_argc = 2;
|
||||
|
||||
|
||||
@@ -2259,7 +2259,7 @@ static int sdmmc_send_app_command(struct mmc *mmc, enum sdmmc_command command,
|
||||
}
|
||||
|
||||
// And issue the body of the command.
|
||||
return sdmmc_send_command(mmc, command, response_type, checks, argument, response_buffer,
|
||||
return sdmmc_send_command(mmc, command, response_type, checks, argument, response_buffer,
|
||||
blocks_to_transfer, false, auto_terminate, data_buffer);
|
||||
}
|
||||
|
||||
@@ -3382,8 +3382,8 @@ static int sdmmc_initialize_defaults(struct mmc *mmc)
|
||||
* @param controler The controller description to be used; usually SWITCH_EMMC
|
||||
* or SWITCH_MICROSD.
|
||||
* @param allow_voltage_switching True if we should allow voltage switching,
|
||||
* which may not make sense if we're about to chainload to another component,
|
||||
* a la fusee stage1.
|
||||
* which may not make sense if we're about to chainload to another component without
|
||||
* preseving the overall structure.
|
||||
*/
|
||||
int sdmmc_init(struct mmc *mmc, enum sdmmc_controller controller, bool allow_voltage_switching)
|
||||
{
|
||||
@@ -3445,6 +3445,29 @@ int sdmmc_init(struct mmc *mmc, enum sdmmc_controller controller, bool allow_vol
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Imports a SDMMC driver struct from another program. This mainly intended for stage2,
|
||||
* so that it can reuse stage1's SDMMC struct instance(s).
|
||||
*
|
||||
* @param mmc The SDMMC structure to be imported.
|
||||
*/
|
||||
int sdmmc_import_struct(struct mmc *mmc)
|
||||
{
|
||||
int rc;
|
||||
bool uses_block_addressing = mmc->uses_block_addressing;
|
||||
mmc->regs = sdmmc_get_regs(mmc->controller);
|
||||
|
||||
rc = sdmmc_initialize_defaults(mmc);
|
||||
if (rc) {
|
||||
printk("ERROR: controller SDMMC%d not currently supported!\n", mmc->controller + 1);
|
||||
return rc;
|
||||
}
|
||||
|
||||
mmc->uses_block_addressing = uses_block_addressing;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects the active MMC partition. Can be used to select
|
||||
* boot partitions for access. Affects all operations going forward.
|
||||
|
||||
@@ -234,12 +234,21 @@ int sdmmc_set_loglevel(int loglevel);
|
||||
* @param controler The controller description to be used; usually SWITCH_EMMC
|
||||
* or SWITCH_MICROSD.
|
||||
* @param allow_voltage_switching True if we should allow voltage switching,
|
||||
* which may not make sense if we're about to chainload to another component,
|
||||
* a la fusee stage1.
|
||||
* which may not make sense if we're about to chainload to another component without
|
||||
* preseving the overall structure.
|
||||
*/
|
||||
int sdmmc_init(struct mmc *mmc, enum sdmmc_controller controller, bool allow_voltage_switching);
|
||||
|
||||
|
||||
/**
|
||||
* Imports a SDMMC driver struct from another program. This mainly intended for stage2,
|
||||
* so that it can reuse stage1's SDMMC struct instance(s).
|
||||
*
|
||||
* @param mmc The SDMMC structure to be imported.
|
||||
*/
|
||||
int sdmmc_import_struct(struct mmc *mmc);
|
||||
|
||||
|
||||
/**
|
||||
* Selects the active MMC partition. Can be used to select
|
||||
* boot partitions for access. Affects all operations going forward.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define FUSEE_STAGE2_H
|
||||
|
||||
#include "utils.h"
|
||||
#include "sdmmc.h"
|
||||
|
||||
/* TODO: Is there a more concise way to do this? */
|
||||
#define STAGE2_ARGV_PROGRAM_PATH 0
|
||||
@@ -11,7 +12,7 @@
|
||||
#define STAGE2_NAME_KEY "stage2_path"
|
||||
#define STAGE2_ADDRESS_KEY "stage2_addr"
|
||||
#define STAGE2_ENTRYPOINT_KEY "stage2_entrypoint"
|
||||
#define BCTO_MAX_SIZE 0x6000
|
||||
#define BCTO_MAX_SIZE 0x5800
|
||||
|
||||
typedef struct {
|
||||
char path[0x100];
|
||||
@@ -21,6 +22,8 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
uint32_t version;
|
||||
struct mmc sd_mmc;
|
||||
bool display_initialized;
|
||||
char bct0[BCTO_MAX_SIZE];
|
||||
} stage2_args_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user