sdmmc: Use global emmc storage in various places
This commit is contained in:
@@ -594,8 +594,8 @@ static int _read_emmc_pkg1(launch_ctxt_t *ctxt)
|
||||
|
||||
try_load:
|
||||
// Read package1.
|
||||
emummc_storage_set_mmc_partition(&emmc_storage, EMMC_BOOT0);
|
||||
emummc_storage_read(&emmc_storage, bootloader_offset / NX_EMMC_BLOCKSIZE, BOOTLOADER_SIZE / NX_EMMC_BLOCKSIZE, ctxt->pkg1);
|
||||
emummc_storage_set_mmc_partition(EMMC_BOOT0);
|
||||
emummc_storage_read(bootloader_offset / NX_EMMC_BLOCKSIZE, BOOTLOADER_SIZE / NX_EMMC_BLOCKSIZE, ctxt->pkg1);
|
||||
|
||||
ctxt->pkg1_id = pkg1_identify(ctxt->pkg1 + pk1_offset);
|
||||
if (!ctxt->pkg1_id)
|
||||
@@ -618,7 +618,7 @@ try_load:
|
||||
|
||||
// Read the correct keyblob.
|
||||
ctxt->keyblob = (u8 *)calloc(NX_EMMC_BLOCKSIZE, 1);
|
||||
emummc_storage_read(&emmc_storage, HOS_KEYBLOBS_OFFSET / NX_EMMC_BLOCKSIZE + ctxt->pkg1_id->kb, 1, ctxt->keyblob);
|
||||
emummc_storage_read(HOS_KEYBLOBS_OFFSET / NX_EMMC_BLOCKSIZE + ctxt->pkg1_id->kb, 1, ctxt->keyblob);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -627,7 +627,7 @@ static u8 *_read_emmc_pkg2(launch_ctxt_t *ctxt)
|
||||
{
|
||||
u8 *bctBuf = NULL;
|
||||
|
||||
emummc_storage_set_mmc_partition(&emmc_storage, EMMC_GPP);
|
||||
emummc_storage_set_mmc_partition(EMMC_GPP);
|
||||
|
||||
// Parse eMMC GPT.
|
||||
LIST_INIT(gpt);
|
||||
@@ -738,13 +738,13 @@ int hos_launch(ini_sec_t *cfg)
|
||||
gfx_puts("Initializing...\n\n");
|
||||
|
||||
// Initialize eMMC/emuMMC.
|
||||
int res = emummc_storage_init_mmc(&emmc_storage, &emmc_sdmmc);
|
||||
int res = emummc_storage_init_mmc();
|
||||
if (res)
|
||||
{
|
||||
if (res == 2)
|
||||
_hos_crit_error("Failed to init eMMC");
|
||||
_hos_crit_error("Failed to init eMMC.");
|
||||
else
|
||||
_hos_crit_error("Failed to init emuMMC");
|
||||
_hos_crit_error("Failed to init emuMMC.");
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 CTCaer
|
||||
* Copyright (c) 2019-2021 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -93,23 +93,21 @@ void check_sept(ini_sec_t *cfg_sec)
|
||||
|
||||
u8 *pkg1 = (u8 *)calloc(1, 0x40000);
|
||||
|
||||
sdmmc_storage_t storage;
|
||||
sdmmc_t sdmmc;
|
||||
int res = emummc_storage_init_mmc(&storage, &sdmmc);
|
||||
int res = emummc_storage_init_mmc();
|
||||
if (res)
|
||||
{
|
||||
if (res == 2)
|
||||
EPRINTF("Failed to init eMMC");
|
||||
EPRINTF("Failed to init eMMC.");
|
||||
else
|
||||
EPRINTF("Failed to init emuMMC");
|
||||
EPRINTF("Failed to init emuMMC.");
|
||||
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
emummc_storage_set_mmc_partition(&storage, EMMC_BOOT0);
|
||||
emummc_storage_set_mmc_partition(EMMC_BOOT0);
|
||||
|
||||
// Read package1.
|
||||
emummc_storage_read(&storage, 0x100000 / NX_EMMC_BLOCKSIZE, 0x40000 / NX_EMMC_BLOCKSIZE, pkg1);
|
||||
emummc_storage_read(0x100000 / NX_EMMC_BLOCKSIZE, 0x40000 / NX_EMMC_BLOCKSIZE, pkg1);
|
||||
const pkg1_id_t *pkg1_id = pkg1_identify(pkg1);
|
||||
if (!pkg1_id)
|
||||
{
|
||||
@@ -129,13 +127,13 @@ void check_sept(ini_sec_t *cfg_sec)
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
sdmmc_storage_end(&storage);
|
||||
sdmmc_storage_end(&emmc_storage);
|
||||
reboot_to_sept((u8 *)pkg1 + pkg1_id->tsec_off, pkg1_id->kb, cfg_sec);
|
||||
}
|
||||
|
||||
out_free:
|
||||
free(pkg1);
|
||||
sdmmc_storage_end(&storage);
|
||||
sdmmc_storage_end(&emmc_storage);
|
||||
}
|
||||
|
||||
int reboot_to_sept(const u8 *tsec_fw, u32 kb, ini_sec_t *cfg_sec)
|
||||
|
||||
Reference in New Issue
Block a user