]> Chaos Git - corbenik/corbenik.git/commitdiff
Update firm header based on latest 3dbrew docs
authorJon Feldman <chaos.kagami@gmail.com>
Wed, 25 Jan 2017 20:54:10 +0000 (15:54 -0500)
committerJon Feldman <chaos.kagami@gmail.com>
Wed, 25 Jan 2017 20:54:10 +0000 (15:54 -0500)
boot/firm/firm.c
boot/firm/util.c
include/firm/headers.h

index da89d3d2b248e4de5e519a7db0ff59cb84e89250..aa4db06e105b9d6f23a15334bf4e3aa50a05bf29 100644 (file)
@@ -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)) {
index 2d8ff59944aaff346e89cf62621729768736dcd6..d1b50f505a06fdd70671bf8f3da0b0b731ea9c48 100644 (file)
@@ -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);
index 3c344bf0d887a5cb9bde43087c543f8a98269d91..a7ba09e19178754082ffa4f126cc9b9fb3068e95 100644 (file)
@@ -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;