From: Jon Feldman Date: Wed, 25 Jan 2017 20:54:10 +0000 (-0500) Subject: Update firm header based on latest 3dbrew docs X-Git-Tag: v0.3.1~20 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=d9e2e8dd4a1ffd78d5a3638667245df339bee990;p=corbenik%2Fcorbenik.git Update firm header based on latest 3dbrew docs --- diff --git a/boot/firm/firm.c b/boot/firm/firm.c index da89d3d..aa4db06 100644 --- a/boot/firm/firm.c +++ b/boot/firm/firm.c @@ -92,7 +92,7 @@ load_firm(const char *path, size_t *size_out) return NULL; } - // If this is a FIRM and not a k9l decrypted FIRM... + // If the firm's K9L is not decrypted... if (!memcmp(firm->magic, "FIRM", 4) && memcmp(firm->magic + 4, "DEC", 3)) { if (sig->console == console_n3ds) { if (dec_k9l(firm)) { diff --git a/boot/firm/util.c b/boot/firm/util.c index 2d8ff59..d1b50f5 100644 --- a/boot/firm/util.c +++ b/boot/firm/util.c @@ -109,7 +109,9 @@ int dec_k9l(firm_h* firm) { // Recalc section hash. sha256sum(arm9->hash, (uint8_t*)firm + arm9->offset, arm9->size); - // Magic like D9. + // FIXME - Note that this is not technically correct as of recent 3dbrew docs; + // the second reserved field is "boot priority". We probably should stop tampering + // with it once firmhax becomes relevant, preferably sooner than that. memcpy(firm->magic, "FIRMDEC", 7); free(sig); diff --git a/include/firm/headers.h b/include/firm/headers.h index 3c344bf..a7ba09e 100644 --- a/include/firm/headers.h +++ b/include/firm/headers.h @@ -22,16 +22,17 @@ typedef struct firm_section_h uint32_t offset; uint32_t address; uint32_t size; - uint32_t type; // Firmware Type ('0'=ARM9/'1'=ARM11) + uint32_t type; // Copy method (0=NDMA/ARM9, 1=XDMA/ARM11, 2=CPU copy) uint8_t hash[0x20]; // SHA-256 Hash of Firmware Section } __attribute__((packed)) firm_section_h; // 0x30 typedef struct firm_h { - char magic[8]; // "FIRM" normally, but D9 has this as "FIRMDEC" + char magic[4]; // "FIRM" normally. + uint32_t bootprio; // Boot priority (normally 0) uint32_t a11Entry; // ARM11 entry uint32_t a9Entry; // ARM9 entry - uint8_t reserved2[0x30]; + uint8_t reserved[0x30]; firm_section_h section[4]; uint8_t sig[0x100]; } __attribute__((packed)) firm_h;