1
0
mirror of https://github.com/CTCaer/hekate.git synced 2024-12-25 15:17:19 +00:00

hos: Add support for mesosphere

The change adds support for mesosphere loading from fss0 or sd (kernel=).
This commit is contained in:
CTCaer 2020-10-17 23:18:48 +03:00
parent d825be5eb2
commit bf222290b8
4 changed files with 15 additions and 2 deletions

View File

@ -190,6 +190,10 @@ int parse_fss(launch_ctxt_t *ctxt, const char *path, fss0_sept_t *sept_ctxt)
ctxt->warmboot_size = curr_fss_cnt[i].size; ctxt->warmboot_size = curr_fss_cnt[i].size;
ctxt->warmboot = content; ctxt->warmboot = content;
break; break;
case CNT_TYPE_KRN:
ctxt->kernel_size = curr_fss_cnt[i].size;
ctxt->kernel = content;
break;
default: default:
continue; continue;
} }

View File

@ -1415,6 +1415,11 @@ void pkg2_build_encrypt(void *dst, void *hos_ctxt, link_t *kips_info)
u8 *pdst = (u8 *)dst; u8 *pdst = (u8 *)dst;
launch_ctxt_t * ctxt = (launch_ctxt_t *)hos_ctxt; launch_ctxt_t * ctxt = (launch_ctxt_t *)hos_ctxt;
u32 kernel_size = ctxt->kernel_size; u32 kernel_size = ctxt->kernel_size;
bool is_meso = *(u32 *)(ctxt->kernel + 4) == ATM_MESOSPHERE;
// Force new Package2 if Mesosphere.
if (is_meso)
ctxt->new_pkg2 = true;
// Signature. // Signature.
memset(pdst, 0, 0x100); memset(pdst, 0, 0x100);
@ -1433,7 +1438,7 @@ void pkg2_build_encrypt(void *dst, void *hos_ctxt, link_t *kips_info)
hdr->base = 0x10000000; hdr->base = 0x10000000;
else else
hdr->base = 0x60000; hdr->base = 0x60000;
DPRINTF("kernel @ %08X (%08X)\n", (u32)ctxt->kernel, kernel_size); DPRINTF("%s @ %08X (%08X)\n", is_meso ? "Mesosphere": "kernel",(u32)ctxt->kernel, kernel_size);
pdst += sizeof(pkg2_hdr_t); pdst += sizeof(pkg2_hdr_t);
@ -1444,7 +1449,7 @@ DPRINTF("kernel @ %08X (%08X)\n", (u32)ctxt->kernel, kernel_size);
else else
{ {
// Set new INI1 offset to kernel. // Set new INI1 offset to kernel.
*(u32 *)(pdst + pkg2_newkern_ini1_val) = kernel_size; *(u32 *)(pdst + (is_meso ? 8 : pkg2_newkern_ini1_val)) = kernel_size;
// Build INI1 for new Package2. // Build INI1 for new Package2.
kernel_size += _pkg2_ini1_build(pdst + kernel_size, hdr, kips_info, ctxt->new_pkg2); kernel_size += _pkg2_ini1_build(pdst + kernel_size, hdr, kips_info, ctxt->new_pkg2);

View File

@ -30,6 +30,8 @@
#define PKG2_NEWKERN_GET_INI1_HEURISTIC 0xD2800015 // Offset of OP + 12 is the INI1 offset. #define PKG2_NEWKERN_GET_INI1_HEURISTIC 0xD2800015 // Offset of OP + 12 is the INI1 offset.
#define PKG2_NEWKERN_START 0x800 #define PKG2_NEWKERN_START 0x800
#define ATM_MESOSPHERE 0x3053534D
extern u32 pkg2_newkern_ini1_val; extern u32 pkg2_newkern_ini1_val;
extern u32 pkg2_newkern_ini1_start; extern u32 pkg2_newkern_ini1_start;
extern u32 pkg2_newkern_ini1_end; extern u32 pkg2_newkern_ini1_end;

View File

@ -344,6 +344,8 @@ static const char *get_error_desc(u32 error_desc)
return "SYS"; // System Error. return "SYS"; // System Error.
case 0x301: case 0x301:
return "SVC"; // Bad arguments or unimplemented SVC. return "SVC"; // Bad arguments or unimplemented SVC.
case 0xF00:
return "KRNL"; // Kernel panic.
case 0xFFD: case 0xFFD:
return "SO"; // Stack Overflow. return "SO"; // Stack Overflow.
case 0xFFE: case 0xFFE: