FIRM mounting: use proper names for sections

This commit is contained in:
d0k3 2017-09-12 01:52:46 +02:00
parent e63953585d
commit 5dc2634183
3 changed files with 12 additions and 5 deletions

View File

@ -110,7 +110,7 @@ u32 ValidateFirm(void* firm, u32 firm_size, bool installable) {
FirmSectionHeader* FindFirmArm9Section(FirmHeader* firm) { FirmSectionHeader* FindFirmArm9Section(FirmHeader* firm) {
for (u32 i = 0; i < 4; i++) { for (u32 i = 0; i < 4; i++) {
FirmSectionHeader* section = firm->sections + i; FirmSectionHeader* section = firm->sections + i;
if (section->size && (section->type == 0)) if (section->size && (section->method == FIRM_NDMA_CPY))
return section; return section;
} }
return NULL; return NULL;

View File

@ -8,12 +8,16 @@
#define ARM11NCCH_OFFSET 0, 0x2A000, 0x2B000, 0x2C000 #define ARM11NCCH_OFFSET 0, 0x2A000, 0x2B000, 0x2C000
#define ARM9BIN_OFFSET 0x800 #define ARM9BIN_OFFSET 0x800
#define FIRM_NDMA_CPY 0
#define FIRM_XDMA_CPY 1
#define FIRM_CPU_MEMCPY 2
// see: https://www.3dbrew.org/wiki/FIRM#Firmware_Section_Headers // see: https://www.3dbrew.org/wiki/FIRM#Firmware_Section_Headers
typedef struct { typedef struct {
u32 offset; u32 offset;
u32 address; u32 address;
u32 size; u32 size;
u32 type; u32 method;
u8 hash[0x20]; u8 hash[0x20];
} __attribute__((packed)) FirmSectionHeader; } __attribute__((packed)) FirmSectionHeader;

View File

@ -565,13 +565,16 @@ bool BuildVGameFirmDir(void) {
for (u32 i = 0; i < 4; i++) { for (u32 i = 0; i < 4; i++) {
FirmSectionHeader* section = firm->sections + i; FirmSectionHeader* section = firm->sections + i;
if (!section->size) continue; if (!section->size) continue;
snprintf(templates[n].name, 32, NAME_FIRM_SECTION, i, (section->type == 0) ? "arm9" : "arm11"); snprintf(templates[n].name, 32, NAME_FIRM_SECTION, i,
(section->method == FIRM_NDMA_CPY) ? "ndma.arm9" :
(section->method == FIRM_XDMA_CPY) ? "xdma.arm11" :
(section->method == FIRM_CPU_MEMCPY) ? "memcpy" : "unknown");
templates[n].offset = section->offset; templates[n].offset = section->offset;
templates[n].size = section->size; templates[n].size = section->size;
templates[n].keyslot = 0xFF; templates[n].keyslot = 0xFF;
templates[n].flags = VFLAG_NO_CRYPTO; templates[n].flags = VFLAG_NO_CRYPTO;
n++; n++;
if (section->type == 0) { // ARM9 section, search for Process9 if (section->method == FIRM_NDMA_CPY) { // ARM9 section, search for Process9
u8* buffer = (u8*) (TEMP_BUFFER + (TEMP_BUFFER_SIZE/2)); u8* buffer = (u8*) (TEMP_BUFFER + (TEMP_BUFFER_SIZE/2));
u32 buffer_size = TEMP_BUFFER_SIZE/4; u32 buffer_size = TEMP_BUFFER_SIZE/4;
NcchHeader* p9_ncch; NcchHeader* p9_ncch;
@ -600,7 +603,7 @@ bool BuildVGameFirmDir(void) {
templates[n].flags |= (VFLAG_NCCH | VFLAG_DIR); templates[n].flags |= (VFLAG_NCCH | VFLAG_DIR);
n++; n++;
} }
} else if (section->type == 1) { // ARM11 section, search for modules } else if (section->method == FIRM_XDMA_CPY) { // ARM11 section, search for modules
const u32 arm11_ncch_offset[] = { ARM11NCCH_OFFSET }; const u32 arm11_ncch_offset[] = { ARM11NCCH_OFFSET };
NcchHeader firm_ncch; NcchHeader firm_ncch;
for (u32 v = 0; v < sizeof(arm11_ncch_offset) / sizeof(u32); v++) { for (u32 v = 0; v < sizeof(arm11_ncch_offset) / sizeof(u32); v++) {