Reboot to Hekate menu once without changing hekate_ipl.ini
Mariko: RTC REBOOT_REASON_MENU + PMIC reboot. Erista: patch in-memory boot_cfg on valid Hekate payload and try common SD paths.
This commit is contained in:
@@ -94,7 +94,26 @@ void reloc_patcher(u32 payload_dst, u32 payload_src, u32 payload_size)
|
||||
}
|
||||
}
|
||||
|
||||
int launch_payload(char *path)
|
||||
#define HEKATE_BOOT_CFG_OFFSET 0x94
|
||||
#define HEKATE_MAGIC_OFFSET 0x118
|
||||
#define HEKATE_MAGIC 0x43544349u
|
||||
#define HEKATE_PAYLOAD_MAX 0x24000
|
||||
|
||||
static void _patch_hekate_menu_skip(void *buf, u32 size)
|
||||
{
|
||||
if (size > HEKATE_PAYLOAD_MAX)
|
||||
return;
|
||||
|
||||
if (*(u32 *)((u8 *)buf + HEKATE_MAGIC_OFFSET) != HEKATE_MAGIC)
|
||||
return;
|
||||
|
||||
boot_cfg_t *cfg = (boot_cfg_t *)((u8 *)buf + HEKATE_BOOT_CFG_OFFSET);
|
||||
memset(cfg, 0, sizeof(boot_cfg_t));
|
||||
cfg->boot_cfg = 1;
|
||||
cfg->autoboot = 0;
|
||||
}
|
||||
|
||||
int launch_payload_ex(char *path, bool force_hekate_menu)
|
||||
{
|
||||
gfx_clear_grey(0x1B);
|
||||
gfx_con_setpos(0, 0);
|
||||
@@ -134,6 +153,16 @@ int launch_payload(char *path)
|
||||
|
||||
f_close(&fp);
|
||||
|
||||
if (force_hekate_menu)
|
||||
{
|
||||
if (size > HEKATE_PAYLOAD_MAX || *(u32 *)((u8 *)buf + HEKATE_MAGIC_OFFSET) != HEKATE_MAGIC)
|
||||
{
|
||||
sd_unmount();
|
||||
return 2;
|
||||
}
|
||||
_patch_hekate_menu_skip(buf, size);
|
||||
}
|
||||
|
||||
sd_unmount();
|
||||
|
||||
if (size < 0x30000)
|
||||
@@ -160,6 +189,11 @@ int launch_payload(char *path)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int launch_payload(char *path)
|
||||
{
|
||||
return launch_payload_ex(path, false);
|
||||
}
|
||||
|
||||
extern void pivot_stack(u32 stack_top);
|
||||
|
||||
#define EXCP_EN_ADDR 0x4003FFFC
|
||||
|
||||
Reference in New Issue
Block a user