hekate/nyx: use size defines where applicable

This commit is contained in:
CTCaer 2021-10-01 15:45:25 +03:00
parent c801ef8dda
commit 91b08f10fd
12 changed files with 90 additions and 90 deletions

View file

@ -53,10 +53,10 @@ void dump_packages12()
char path[64];
u8 *pkg1 = (u8 *)calloc(1, 0x40000);
u8 *warmboot = (u8 *)calloc(1, 0x40000);
u8 *secmon = (u8 *)calloc(1, 0x40000);
u8 *loader = (u8 *)calloc(1, 0x40000);
u8 *pkg1 = (u8 *)calloc(1, SZ_256K);
u8 *warmboot = (u8 *)calloc(1, SZ_256K);
u8 *secmon = (u8 *)calloc(1, SZ_256K);
u8 *loader = (u8 *)calloc(1, SZ_256K);
u8 *pkg2 = NULL;
u8 kb = 0;
@ -73,14 +73,14 @@ void dump_packages12()
sdmmc_storage_set_mmc_partition(&emmc_storage, EMMC_BOOT0);
// Read package1.
sdmmc_storage_read(&emmc_storage, 0x100000 / NX_EMMC_BLOCKSIZE, 0x40000 / NX_EMMC_BLOCKSIZE, pkg1);
sdmmc_storage_read(&emmc_storage, 0x100000 / NX_EMMC_BLOCKSIZE, SZ_256K / NX_EMMC_BLOCKSIZE, pkg1);
const pkg1_id_t *pkg1_id = pkg1_identify(pkg1);
if (!pkg1_id)
{
EPRINTF("Unknown pkg1 version for reading\nTSEC firmware.");
// Dump package1.
emmcsn_path_impl(path, "/pkg1", "pkg1_enc.bin", &emmc_storage);
if (sd_save_to_file(pkg1, 0x40000, path))
if (sd_save_to_file(pkg1, SZ_256K, path))
goto out_free;
gfx_puts("\nEnc pkg1 dumped to pkg1_enc.bin\n");
@ -134,7 +134,7 @@ void dump_packages12()
// Dump package1.1.
emmcsn_path_impl(path, "/pkg1", "pkg1_decr.bin", &emmc_storage);
if (sd_save_to_file(pkg1, 0x40000, path))
if (sd_save_to_file(pkg1, SZ_256K, path))
goto out_free;
gfx_puts("\npkg1 dumped to pkg1_decr.bin\n");

View file

@ -285,8 +285,8 @@ static void _hos_eks_save()
}
// Get keys.
u8 *keys = (u8 *)calloc(0x2000, 1);
se_get_aes_keys(keys + 0x1000, keys, SE_KEY_128_SIZE);
u8 *keys = (u8 *)calloc(SZ_4K, 2);
se_get_aes_keys(keys + SZ_4K, keys, SE_KEY_128_SIZE);
// Set magic and personalized info.
h_cfg.eks->magic = HOS_EKS_MAGIC;
@ -611,7 +611,7 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, bool stock, bool i
static int _read_emmc_pkg1(launch_ctxt_t *ctxt)
{
const u32 BOOTLOADER_SIZE = 0x40000;
const u32 BOOTLOADER_SIZE = SZ_256K;
const u32 BOOTLOADER_MAIN_OFFSET = 0x100000;
const u32 BOOTLOADER_BACKUP_OFFSET = 0x140000;
const u32 HOS_KEYBLOBS_OFFSET = 0x180000;
@ -685,7 +685,7 @@ DPRINTF("Parsed GPT\n");
goto out;
// Read in package2 header and get package2 real size.
const u32 BCT_SIZE = 0x4000;
const u32 BCT_SIZE = SZ_16K;
bctBuf = (u8 *)malloc(BCT_SIZE);
nx_emmc_part_read(&emmc_storage, pkg2_part, BCT_SIZE / NX_EMMC_BLOCKSIZE, 1, bctBuf);
u32 *hdr = (u32 *)(bctBuf + 0x100);
@ -1109,15 +1109,15 @@ int hos_launch(ini_sec_t *cfg)
// Clear BCT area for retail units and copy it over if dev unit.
if (kb <= KB_FIRMWARE_VERSION_500 && !is_exo)
{
memset((void *)SECMON_BCT_CFG_ADDR, 0, 0x3000);
memset((void *)SECMON_BCT_CFG_ADDR, 0, SZ_4K + SZ_8K);
if (fuse_read_hw_state() == FUSE_NX_HW_STATE_DEV)
memcpy((void *)SECMON_BCT_CFG_ADDR, bootConfigBuf, 0x1000);
memcpy((void *)SECMON_BCT_CFG_ADDR, bootConfigBuf, SZ_4K);
}
else
{
memset((void *)SECMON6_BCT_CFG_ADDR, 0, 0x800);
memset((void *)SECMON6_BCT_CFG_ADDR, 0, SZ_2K);
if (fuse_read_hw_state() == FUSE_NX_HW_STATE_DEV)
memcpy((void *)SECMON6_BCT_CFG_ADDR, bootConfigBuf, 0x800);
memcpy((void *)SECMON6_BCT_CFG_ADDR, bootConfigBuf, SZ_2K);
}
free(bootConfigBuf);

View file

@ -131,7 +131,7 @@ typedef struct _atm_fatal_error_ctx
#define ATM_FATAL_MAGIC 0x30454641 // AFE0
#define ATM_EXO_FATAL_ADDR 0x80020000
#define ATM_EXO_FATAL_SIZE 0x20000
#define ATM_EXO_FATAL_SIZE SZ_128K
#define ATM_WB_HEADER_OFF 0x244
#define ATM_WB_MAGIC 0x30544257 // WBT0

View file

@ -110,7 +110,7 @@ void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t
void render_default_bootlogo()
{
gfx_clear_grey(0x1B);
u8 *BOOTLOGO = (void *)malloc(0x4000);
u8 *BOOTLOGO = (void *)malloc(SZ_16K);
blz_uncompress_srcdest(BOOTLOGO_BLZ, SZ_BOOTLOGO_BLZ, BOOTLOGO, SZ_BOOTLOGO);
gfx_set_rect_grey(BOOTLOGO, X_BOOTLOGO, Y_BOOTLOGO, 326, 544);
free(BOOTLOGO);
@ -1002,10 +1002,10 @@ skip_list:
bmpData.size_x <= 720 &&
bmpData.size_y <= 1280)
{
if (bmpData.size <= fsize && ((bmpData.size - bmpData.offset) < 0x400000))
if (bmpData.size <= fsize && ((bmpData.size - bmpData.offset) < SZ_4M))
{
// Avoid unaligned access from BM 2-byte MAGIC and remove header.
BOOTLOGO = (u8 *)malloc(0x400000);
BOOTLOGO = (u8 *)malloc(SZ_4M);
memcpy(BOOTLOGO, bitmap + bmpData.offset, bmpData.size - bmpData.offset);
free(bitmap);
// Center logo if res < 720x1280.
@ -1262,7 +1262,7 @@ static void _check_low_battery()
goto out;
// Prepare battery icon resources.
u8 *battery_res = malloc(ALIGN(SZ_BATTERY_EMPTY, 0x1000));
u8 *battery_res = malloc(ALIGN(SZ_BATTERY_EMPTY, SZ_4K));
blz_uncompress_srcdest(BATTERY_EMPTY_BLZ, SZ_BATTERY_EMPTY_BLZ, battery_res, SZ_BATTERY_EMPTY);
u8 *battery_icon = malloc(0x95A); // 21x38x3

View file

@ -204,7 +204,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
lv_label_set_text(gui->label_pct, gui->txt_buf);
manual_system_maintenance(true);
clmt = f_expand_cltbl(&fp, 0x400000, 0);
clmt = f_expand_cltbl(&fp, SZ_4M, 0);
u32 num = 0;
while (totalSectorsVer > 0)
@ -526,9 +526,9 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
}
u64 totalSize = (u64)((u64)totalSectors << 9);
if (!isSmallSdCard && (sd_fs.fs_type == FS_EXFAT || totalSize <= FAT32_FILESIZE_LIMIT))
clmt = f_expand_cltbl(&fp, 0x400000, totalSize);
clmt = f_expand_cltbl(&fp, SZ_4M, totalSize);
else
clmt = f_expand_cltbl(&fp, 0x400000, MIN(totalSize, multipartSplitSize));
clmt = f_expand_cltbl(&fp, SZ_4M, MIN(totalSize, multipartSplitSize));
u32 num = 0;
u32 pct = 0;
@ -617,7 +617,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
bytesWritten = 0;
totalSize = (u64)((u64)totalSectors << 9);
clmt = f_expand_cltbl(&fp, 0x400000, MIN(totalSize, multipartSplitSize));
clmt = f_expand_cltbl(&fp, SZ_4M, MIN(totalSize, multipartSplitSize));
}
retryCount = 0;
@ -759,7 +759,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
int res = 0;
u32 timer = 0;
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
gui->txt_buf = txt_buf;
s_printf(txt_buf, "");
@ -1030,7 +1030,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
{
totalCheckFileSize += (u64)fno.fsize;
if (check_4MB_aligned && (((u64)fno.fsize) % 0x400000))
if (check_4MB_aligned && (((u64)fno.fsize) % SZ_4M))
{
s_printf(gui->txt_buf, "#FFDD00 The split file must be a#\n#FFDD00 multiple of 4 MiB.#\n#FFDD00 Aborting...#", res, outFilename);
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
@ -1167,7 +1167,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
u32 num = 0;
u32 pct = 0;
DWORD *clmt = f_expand_cltbl(&fp, 0x400000, 0);
DWORD *clmt = f_expand_cltbl(&fp, SZ_4M, 0);
u32 sector_start = 0, part_idx = 0;
u32 sector_size = totalSectors;
@ -1237,7 +1237,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
}
fileSize = (u64)f_size(&fp);
bytesWritten = 0;
clmt = f_expand_cltbl(&fp, 0x400000, 0);
clmt = f_expand_cltbl(&fp, SZ_4M, 0);
}
retryCount = 0;
@ -1363,7 +1363,7 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
int res = 0;
u32 timer = 0;
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
gui->txt_buf = txt_buf;
s_printf(txt_buf, "");

View file

@ -211,9 +211,9 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto
u64 totalSize = (u64)((u64)totalSectors << 9);
if (totalSize <= FAT32_FILESIZE_LIMIT)
clmt = f_expand_cltbl(&fp, 0x400000, totalSize);
clmt = f_expand_cltbl(&fp, SZ_4M, totalSize);
else
clmt = f_expand_cltbl(&fp, 0x400000, MIN(totalSize, multipartSplitSize));
clmt = f_expand_cltbl(&fp, SZ_4M, MIN(totalSize, multipartSplitSize));
u32 num = 0;
u32 pct = 0;
@ -250,7 +250,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto
bytesWritten = 0;
totalSize = (u64)((u64)totalSectors << 9);
clmt = f_expand_cltbl(&fp, 0x400000, MIN(totalSize, multipartSplitSize));
clmt = f_expand_cltbl(&fp, SZ_4M, MIN(totalSize, multipartSplitSize));
}
// Check for cancellation combo.
@ -360,7 +360,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui)
int base_len = 0;
u32 timer = 0;
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
gui->base_path = (char *)malloc(OUT_FILENAME_SZ);
gui->txt_buf = txt_buf;
@ -676,8 +676,8 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
manual_system_maintenance(true);
// Format USER partition.
u8 *buff = malloc(0x400000);
int mkfs_error = f_mkfs("emu:", FM_FAT32 | FM_SFD | FM_PRF2, 16384, buff, 0x400000);
u8 *buff = malloc(SZ_4M);
int mkfs_error = f_mkfs("emu:", FM_FAT32 | FM_SFD | FM_PRF2, 16384, buff, SZ_4M);
free(buff);
// Mount sd card back.
@ -770,13 +770,13 @@ static int _emummc_raw_derive_bis_keys(emmc_tool_gui_t *gui, u32 resized_count)
bool error = false;
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
txt_buf[0] = 0;
// Generate BIS keys.
hos_bis_keygen();
u8 *cal0_buf = malloc(0x10000);
u8 *cal0_buf = malloc(SZ_64K);
// Read and decrypt CAL0 for validation of working BIS keys.
sdmmc_storage_set_mmc_partition(&emmc_storage, EMMC_GPP);
@ -842,7 +842,7 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 r
int res = 0;
u32 timer = 0;
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
gui->base_path = (char *)malloc(OUT_FILENAME_SZ);
gui->txt_buf = txt_buf;
@ -889,7 +889,7 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 r
bootPart.lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
// Clear partition start.
memset((u8 *)MIXD_BUF_ALIGNED, 0, 0x1000000);
memset((u8 *)MIXD_BUF_ALIGNED, 0, SZ_16M);
sdmmc_storage_write(&sd_storage, sector_start - 0x8000, 0x8000, (u8 *)MIXD_BUF_ALIGNED);
for (i = 0; i < 2; i++)

View file

@ -217,7 +217,7 @@ static void _create_mbox_emummc_raw()
lv_mbox_set_recolor_text(mbox, true);
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 6);
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
mbr_t *mbr = (mbr_t *)malloc(sizeof(mbr_t));
memset(&mbr_ctx, 0, sizeof(mbr_ctxt_t));
@ -690,7 +690,7 @@ static lv_res_t _create_emummc_migrate_action(lv_obj_t * btns, const char * txt)
lv_mbox_set_recolor_text(mbox, true);
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 6);
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
if (backup)
{
@ -1070,7 +1070,7 @@ out0:;
lv_btn_ext_t *ext;
lv_obj_t *btn_label = NULL;
lv_obj_t *lv_desc = NULL;
char *txt_buf = malloc(0x4000);
char *txt_buf = malloc(SZ_16K);
// Create RAW buttons.
for (u32 raw_btn_idx = 0; raw_btn_idx < 3; raw_btn_idx++)
@ -1218,7 +1218,7 @@ lv_res_t create_win_emummc_tools(lv_obj_t *btn)
lv_obj_t *label_txt2 = lv_label_create(h1, NULL);
lv_label_set_recolor(label_txt2, true);
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
if (emu_info.enabled)
{

View file

@ -69,7 +69,7 @@ static lv_res_t _create_window_dump_done(int error, char *dump_filenames)
lv_mbox_set_recolor_text(mbox, true);
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5);
char *txt_buf = (char *)malloc(0x1000);
char *txt_buf = (char *)malloc(SZ_4K);
if (error)
s_printf(txt_buf, "#FFDD00 Failed to dump to# %s#FFDD00 !#\nError: %d", dump_filenames, error);
@ -102,7 +102,7 @@ static lv_res_t _cal0_dump_window_action(lv_obj_t *btns, const char * txt)
{
char path[64];
emmcsn_path_impl(path, "/dumps", "cal0.bin", NULL);
error = sd_save_to_file((u8 *)cal0_buf, 0x8000, path);
error = sd_save_to_file((u8 *)cal0_buf, SZ_32K, path);
sd_unmount();
}
@ -272,7 +272,7 @@ static lv_res_t _create_mbox_cal0(lv_obj_t *btn)
lv_mbox_set_text(mbox, "#C7EA46 CAL0 Info#");
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
txt_buf[0] = 0;
lv_obj_t * lb_desc = lv_label_create(mbox, NULL);
@ -295,7 +295,7 @@ static lv_res_t _create_mbox_cal0(lv_obj_t *btn)
hos_bis_keygen();
if (!cal0_buf)
cal0_buf = malloc(0x10000);
cal0_buf = malloc(SZ_64K);
// Read and decrypt CAL0.
sdmmc_storage_set_mmc_partition(&emmc_storage, EMMC_GPP);
@ -476,7 +476,7 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn)
lv_obj_t * lb_val = lv_label_create(val, lb_desc);
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
// Decode fuses.
char *sku;
@ -1025,7 +1025,7 @@ static lv_res_t _create_window_bootrom_info_status(lv_obj_t *btn)
lv_label_set_recolor(lb_desc, true);
lv_label_set_style(lb_desc, &monospace_text);
char *txt_buf = (char *)malloc(0x1000);
char *txt_buf = (char *)malloc(SZ_4K);
ipatches_txt = txt_buf;
s_printf(txt_buf, "#00DDFF Ipatches:#\n#FF8000 Address "SYMBOL_DOT" Val "SYMBOL_DOT" Instruction#\n");
@ -1104,8 +1104,8 @@ static lv_res_t _create_mbox_emmc_sandisk_report(lv_obj_t * btn)
lv_mbox_set_text(mbox, "#C7EA46 Sandisk Device Report#");
u8 *buf = calloc(512, 1);
char *txt_buf = (char *)malloc(0x8000);
char *txt_buf2 = (char *)malloc(0x8000);
char *txt_buf = (char *)malloc(SZ_32K);
char *txt_buf2 = (char *)malloc(SZ_32K);
txt_buf[0] = 0;
txt_buf2[0] = 0;
@ -1288,7 +1288,7 @@ static lv_res_t _create_mbox_benchmark(bool sd_bench)
lv_mbox_set_recolor_text(mbox, true);
lv_obj_set_width(mbox, LV_HOR_RES / 7 * 4);
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
s_printf(txt_buf, "#FF8000 %s Benchmark#\n[Raw Reads] Abort: VOL- & VOL+",
sd_bench ? "SD Card" : "eMMC");
@ -1557,7 +1557,7 @@ static lv_res_t _create_window_emmc_info_status(lv_obj_t *btn)
lv_label_set_long_mode(lb_desc, LV_LABEL_LONG_BREAK);
lv_label_set_recolor(lb_desc, true);
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
txt_buf[0] = '\n';
txt_buf[1] = 0;
@ -1803,7 +1803,7 @@ static lv_res_t _create_window_sdcard_info_status(lv_obj_t *btn)
lv_obj_t * lb_val = lv_label_create(val, lb_desc);
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
txt_buf[0] = '\n';
txt_buf[1] = 0;
@ -2116,7 +2116,7 @@ static lv_res_t _create_window_battery_status(lv_obj_t *btn)
lv_obj_t * lb_val = lv_label_create(val, lb_desc);
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
int value = 0;
int cap_pct = 0;

View file

@ -764,8 +764,8 @@ static lv_res_t _joycon_info_dump_action(lv_obj_t * btn)
bool is_r_hos = false;
jc_gamepad_rpt_t *jc_pad = jc_get_bt_pairing_info(&is_l_hos, &is_r_hos);
char *data = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(0x1000);
char *data = (char *)malloc(SZ_16K);
char *txt_buf = (char *)malloc(SZ_4K);
if (!jc_pad)
{

View file

@ -169,7 +169,7 @@ static lv_res_t _create_mbox_hid(usb_ctxt_t *usbs)
lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL);
lv_mbox_set_recolor_text(mbox, true);
char *txt_buf = malloc(0x1000);
char *txt_buf = malloc(SZ_4K);
s_printf(txt_buf, "#FF8000 HID Emulation#\n\n#C7EA46 Device:# ");
@ -214,7 +214,7 @@ static lv_res_t _create_mbox_ums(usb_ctxt_t *usbs)
lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL);
lv_mbox_set_recolor_text(mbox, true);
char *txt_buf = malloc(0x1000);
char *txt_buf = malloc(SZ_4K);
s_printf(txt_buf, "#FF8000 USB Mass Storage#\n\n#C7EA46 Device:# ");
@ -951,7 +951,7 @@ static lv_res_t _create_mbox_fix_touchscreen(lv_obj_t *btn)
lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL);
lv_mbox_set_recolor_text(mbox, true);
char *txt_buf = malloc(0x4000);
char *txt_buf = malloc(SZ_16K);
strcpy(txt_buf, "#FF8000 Don't touch the screen!#\n\nThe tuning process will start in ");
u32 text_idx = strlen(txt_buf);
lv_mbox_set_text(mbox, txt_buf);
@ -1084,13 +1084,13 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
char path[128];
u8 kb = 0;
u8 *pkg1 = (u8 *)calloc(1, 0x40000);
u8 *warmboot = (u8 *)calloc(1, 0x40000);
u8 *secmon = (u8 *)calloc(1, 0x40000);
u8 *loader = (u8 *)calloc(1, 0x40000);
u8 *pkg1 = (u8 *)calloc(1, SZ_256K);
u8 *warmboot = (u8 *)calloc(1, SZ_256K);
u8 *secmon = (u8 *)calloc(1, SZ_256K);
u8 *loader = (u8 *)calloc(1, SZ_256K);
u8 *pkg2 = NULL;
char *txt_buf = (char *)malloc(0x4000);
char *txt_buf = (char *)malloc(SZ_16K);
if (!sdmmc_storage_init_mmc(&emmc_storage, &emmc_sdmmc, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS400))
{
@ -1102,7 +1102,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
sdmmc_storage_set_mmc_partition(&emmc_storage, EMMC_BOOT0);
// Read package1.
static const u32 BOOTLOADER_SIZE = 0x40000;
static const u32 BOOTLOADER_SIZE = SZ_256K;
static const u32 BOOTLOADER_MAIN_OFFSET = 0x100000;
static const u32 HOS_KEYBLOBS_OFFSET = 0x180000;
@ -1198,7 +1198,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
// Dump package1.1.
emmcsn_path_impl(path, "/pkg1", "pkg1_decr.bin", &emmc_storage);
if (sd_save_to_file(pkg1, 0x40000, path))
if (sd_save_to_file(pkg1, SZ_256K, path))
goto out_free;
strcat(txt_buf, "pkg1 dumped to pkg1_decr.bin\n");
lv_label_set_text(lb_desc, txt_buf);
@ -1342,7 +1342,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
ptr += sizeof(pkg2_ini1_t);
// Dump all kips.
u8 *kip_buffer = (u8 *)malloc(0x400000);
u8 *kip_buffer = (u8 *)malloc(SZ_4M);
for (u32 i = 0; i < ini1->num_procs; i++)
{
@ -1614,7 +1614,7 @@ static void _create_tab_tools_arc_autorcm(lv_theme_t *th, lv_obj_t *parent)
}
autorcm_btn = btn3;
char *txt_buf = (char *)malloc(0x1000);
char *txt_buf = (char *)malloc(SZ_4K);
s_printf(txt_buf,
"Allows you to enter RCM without using #C7EA46 VOL+# & #C7EA46 HOME# (jig).\n"

View file

@ -137,7 +137,7 @@ static int _backup_and_restore_files(char *path, u32 *total_files, u32 *total_si
if ((file_size + *total_size) < *total_size)
{
// Set size to > 1GB, skip next folders and return.
*total_size = 0x80000000;
*total_size = SZ_2G;
res = -1;
break;
}
@ -161,7 +161,7 @@ static int _backup_and_restore_files(char *path, u32 *total_files, u32 *total_si
while (file_size)
{
u32 chunk_size = MIN(file_size, 0x400000); // 4MB chunks.
u32 chunk_size = MIN(file_size, SZ_4M); // 4MB chunks.
file_size -= chunk_size;
// Copy file to buffer.
@ -182,7 +182,7 @@ static int _backup_and_restore_files(char *path, u32 *total_files, u32 *total_si
}
// If total is > 1GB exit.
if (*total_size > (RAM_DISK_SZ - 0x1000000)) // 0x2400000.
if (*total_size > (RAM_DISK_SZ - SZ_16M)) // 0x2400000.
{
// Skip next folders and return.
res = -1;
@ -232,7 +232,7 @@ static void _prepare_and_flash_mbr_gpt()
memcpy(&mbr.bootstrap[0x80], &part_info.mbr_old.bootstrap[0x80], 304);
// Clear the first 16MB.
memset((void *)SDMMC_UPPER_BUFFER, 0, 0x8000);
memset((void *)SDMMC_UPPER_BUFFER, 0, SZ_16M);
sdmmc_storage_write(&sd_storage, 0, 0x8000, (void *)SDMMC_UPPER_BUFFER);
u8 mbr_idx = 1;
@ -591,7 +591,7 @@ static lv_res_t _action_flash_linux_data(lv_obj_t * btns, const char * txt)
int res = 0;
char *path = malloc(1024);
char *txt_buf = malloc(0x1000);
char *txt_buf = malloc(SZ_4K);
strcpy(path, "switchroot/install/l4t.00");
u32 path_len = strlen(path) - 2;
@ -617,7 +617,7 @@ static lv_res_t _action_flash_linux_data(lv_obj_t * btns, const char * txt)
u32 total_size_sct = l4t_flash_ctxt.image_size_sct;
u8 *buf = (u8 *)MIXD_BUF_ALIGNED;
DWORD *clmt = f_expand_cltbl(&fp, 0x400000, 0);
DWORD *clmt = f_expand_cltbl(&fp, SZ_4M, 0);
while (total_size_sct > 0)
{
@ -650,7 +650,7 @@ static lv_res_t _action_flash_linux_data(lv_obj_t * btns, const char * txt)
}
fileSize = (u64)f_size(&fp);
bytesWritten = 0;
clmt = f_expand_cltbl(&fp, 0x400000, 0);
clmt = f_expand_cltbl(&fp, SZ_4M, 0);
}
retryCount = 0;
@ -867,7 +867,7 @@ static lv_res_t _action_check_flash_linux(lv_obj_t *btn)
// Check for alignment.
if (!f_stat(path, &fno))
{
if ((u64)fno.fsize % 0x400000)
if ((u64)fno.fsize % SZ_4M)
{
// Check if last part.
idx++;
@ -904,7 +904,7 @@ static lv_res_t _action_check_flash_linux(lv_obj_t *btn)
goto error;
}
char *txt_buf = malloc(0x1000);
char *txt_buf = malloc(SZ_4K);
s_printf(txt_buf,
"#C7EA46 Status:# Found installation files and partition.\n"
"#00DDFF Offset:# %08x, #00DDFF Size:# %X, #00DDFF Image size:# %d MiB\n"
@ -964,7 +964,7 @@ static lv_res_t _action_flash_android_data(lv_obj_t * btns, const char * txt)
{
char path[128];
gpt_t *gpt = calloc(1, sizeof(gpt_t));
char *txt_buf = malloc(0x1000);
char *txt_buf = malloc(SZ_4K);
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_style(dark_bg, &mbox_darken);
@ -1309,7 +1309,7 @@ static lv_res_t _create_mbox_start_partitioning(lv_obj_t *btn)
if (!part_info.backup_possible)
{
char *txt_buf = malloc(0x1000);
char *txt_buf = malloc(SZ_4K);
strcpy(txt_buf, "#FF8000 Partition Manager#\n\nSafety wait ends in ");
lv_mbox_set_text(mbox, txt_buf);
@ -1414,17 +1414,17 @@ static lv_res_t _create_mbox_start_partitioning(lv_obj_t *btn)
u32 part_rsvd_size = (part_info.emu_size << 11) + (part_info.l4t_size << 11) + (part_info.and_size << 11);
part_rsvd_size += part_info.alignment;
disk_set_info(DRIVE_SD, SET_SECTOR_COUNT, &part_rsvd_size);
u8 *buf = malloc(0x400000);
u8 *buf = malloc(SZ_4M);
u32 cluster_size = 65536;
u32 mkfs_error = f_mkfs("sd:", FM_FAT32, cluster_size, buf, 0x400000);
u32 mkfs_error = f_mkfs("sd:", FM_FAT32, cluster_size, buf, SZ_4M);
if (mkfs_error)
{
// Retry by halving cluster size.
while (cluster_size > 4096)
{
cluster_size /= 2;
mkfs_error = f_mkfs("sd:", FM_FAT32, cluster_size, buf, 0x400000);
mkfs_error = f_mkfs("sd:", FM_FAT32, cluster_size, buf, SZ_4M);
if (!mkfs_error)
break;
@ -1619,7 +1619,7 @@ static lv_res_t _create_mbox_partitioning_next(lv_obj_t *btn)
lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL);
lv_mbox_set_recolor_text(mbox, true);
char *txt_buf = malloc(0x1000);
char *txt_buf = malloc(SZ_4K);
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 6);
lv_mbox_set_text(mbox, "#FF8000 Partition Manager#");
@ -1885,7 +1885,7 @@ static void create_mbox_check_files_total_size()
sep_and_bg.body.main_color = LV_COLOR_HEX(0xFF8000);
sep_and_bg.body.grad_color = sep_and_bg.body.main_color;
char *txt_buf = malloc(0x2000);
char *txt_buf = malloc(SZ_8K);
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_style(dark_bg, &mbox_darken);
@ -1911,7 +1911,7 @@ static void create_mbox_check_files_total_size()
int res = _backup_and_restore_files(path, &total_files, &total_size, NULL, NULL, NULL);
// Not more than 1.0GB.
part_info.backup_possible = !res && !(total_size > (RAM_DISK_SZ - 0x1000000)); // 0x2400000
part_info.backup_possible = !res && !(total_size > (RAM_DISK_SZ - SZ_16M)); // 0x2400000
if (part_info.backup_possible)
{
@ -2145,7 +2145,7 @@ static lv_res_t _action_fix_mbr(lv_obj_t *btn)
goto out;
}
char *txt_buf = malloc(0x4000);
char *txt_buf = malloc(SZ_16K);
s_printf(txt_buf, "#00DDFF Current MBR Layout:#\n");
s_printf(txt_buf + strlen(txt_buf),
@ -2286,7 +2286,7 @@ lv_res_t create_window_partition_manager(lv_obj_t *btn)
memset(&part_info, 0, sizeof(partition_ctxt_t));
create_mbox_check_files_total_size();
char *txt_buf = malloc(0x2000);
char *txt_buf = malloc(SZ_8K);
part_info.total_sct = sd_storage.sec_cnt;

View file

@ -259,8 +259,8 @@ static void _hos_eks_save()
}
// Get keys.
u8 *keys = (u8 *)calloc(0x2000, 1);
se_get_aes_keys(keys + 0x1000, keys, SE_KEY_128_SIZE);
u8 *keys = (u8 *)calloc(SZ_4K, 2);
se_get_aes_keys(keys + SZ_4K, keys, SE_KEY_128_SIZE);
// Set magic and personalized info.
h_cfg.eks->magic = HOS_EKS_MAGIC;