Merge pull request #3 from jakcron/master

[makerom/ctrtool] fixes
This commit is contained in:
profi200
2015-10-06 18:15:59 +02:00
13 changed files with 56 additions and 44 deletions
+13 -2
View File
@@ -136,7 +136,7 @@ void exheader_deserialise_arm11localcaps_permissions(exheader_arm11systemlocalca
caps->core_version = getle32(arm11->coreversion);
caps->enable_l2_cache = (arm11->flag[0] >> 0) & 1;
caps->use_additional_cores = (arm11->flag[0] >> 1) & 1;
caps->new3ds_cpu_speed = (arm11->flag[0] >> 1) & 1;
caps->new3ds_systemmode = (arm11->flag[1] >> 0) & 15;
caps->ideal_processor = (arm11->flag[2] >> 0) & 3;
@@ -278,6 +278,7 @@ void exheader_print_arm11kernelcapabilities(exheader_context* ctx)
fprintf(stdout, " > Shared device mem: %s\n", (descriptor&(1<<6))?"YES":"NO");
fprintf(stdout, " > Runnable on sleep: %s\n", (descriptor&(1<<7))?"YES":"NO");
fprintf(stdout, " > Special memory: %s\n", (descriptor&(1<<12))?"YES":"NO");
fprintf(stdout, " > Access Core 2: %s\n", (descriptor&(1<<13))?"YES":"NO");
switch(memorytype)
@@ -504,7 +505,7 @@ void exheader_verify(exheader_context* ctx)
ctx->validold3dssystemmode = Good;
ctx->validnew3dssystemmode = Good;
ctx->validenablel2cache = Good;
ctx->validuseadditionalcores = Good;
ctx->validnew3dscpuspeed = Good;
ctx->validservicecontrol = Good;
for(i=0; i<8; i++)
@@ -533,6 +534,14 @@ void exheader_verify(exheader_context* ctx)
if (ctx->system_local_caps.new3ds_systemmode > accessdesc.new3ds_systemmode)
ctx->validnew3dssystemmode = Fail;
if (ctx->system_local_caps.enable_l2_cache != accessdesc.enable_l2_cache)
ctx->validenablel2cache = Fail;
if (ctx->system_local_caps.new3ds_cpu_speed != accessdesc.new3ds_cpu_speed)
ctx->validnew3dscpuspeed = Fail;
// Storage Info Verify
if(ctx->system_local_caps.system_saveid[0] & ~accessdesc.system_saveid[0])
@@ -628,6 +637,8 @@ void exheader_print(exheader_context* ctx)
fprintf(stdout, "Core version: 0x%X\n", getle32(ctx->header.arm11systemlocalcaps.coreversion));
fprintf(stdout, "System mode: %d %s\n", ctx->system_local_caps.old3ds_systemmode, exheader_getvalidstring(ctx->validold3dssystemmode));
fprintf(stdout, "System mode (New3DS): %d %s\n", ctx->system_local_caps.new3ds_systemmode, exheader_getvalidstring(ctx->validnew3dssystemmode));
fprintf(stdout, "CPU Speed (New3DS): %s %s\n", ctx->system_local_caps.new3ds_cpu_speed? "804MHz" : "268MHz", exheader_getvalidstring(ctx->validnew3dscpuspeed));
fprintf(stdout, "Enable L2 Cache: %s %s\n", ctx->system_local_caps.enable_l2_cache ? "YES" : "NO", exheader_getvalidstring(ctx->validnew3dscpuspeed));
fprintf(stdout, "Ideal processor: %d %s\n", ctx->system_local_caps.ideal_processor, exheader_getvalidstring(ctx->valididealprocessor));
fprintf(stdout, "Affinity mask: %d %s\n", ctx->system_local_caps.affinity_mask, exheader_getvalidstring(ctx->validaffinitymask));
fprintf(stdout, "Main thread priority: %d %s\n", ctx->system_local_caps.priority, exheader_getvalidstring(ctx->validpriority));
+2 -2
View File
@@ -72,7 +72,7 @@ typedef struct
// flag
u8 enable_l2_cache;
u8 use_additional_cores;
u8 new3ds_cpu_speed;
u8 new3ds_systemmode;
u8 ideal_processor;
u8 affinity_mask;
@@ -154,7 +154,7 @@ typedef struct
int validold3dssystemmode;
int validnew3dssystemmode;
int validenablel2cache;
int validuseadditionalcores;
int validnew3dscpuspeed;
int validcoreversion;
int validsystemsaveID[2];
int validaccessinfo;
+2 -1
View File
@@ -965,6 +965,7 @@ int CreateElfSegments(elf_context *elf, u8 *elfFile)
if (IsIgnoreSection(elf->sections[curr]))
continue;
if (!foundFirstSection) {
if (elf->sections[curr].address != elf->programHeaders[i].virtualAddress)
continue;
@@ -1007,5 +1008,5 @@ int CreateElfSegments(elf_context *elf, u8 *elfFile)
bool IsIgnoreSection(elf_section_entry info)
{
return (info.type != SHT_PROGBITS && info.type != SHT_NOBITS && info.type != SHT_INIT_ARRAY && info.type != SHT_FINI_ARRAY);
return (info.type != SHT_PROGBITS && info.type != SHT_NOBITS && info.type != SHT_INIT_ARRAY && info.type != SHT_FINI_ARRAY && info.type != SHT_ARM_EXIDX);
}
+19 -14
View File
@@ -79,26 +79,31 @@ typedef struct
/* Legal values for sh_type (section type). */
#define SHT_NULL 0 /* Section header table entry unused */
#define SHT_PROGBITS 1 /* Program data */
#define SHT_SYMTAB 2 /* Symbol table */
#define SHT_STRTAB 3 /* String table */
#define SHT_RELA 4 /* Relocation entries with addends */
#define SHT_HASH 5 /* Symbol hash table */
#define SHT_DYNAMIC 6 /* Dynamic linking information */
#define SHT_NOTE 7 /* Notes */
#define SHT_NOBITS 8 /* Program space with no data (bss) */
#define SHT_REL 9 /* Relocation entries, no addends */
#define SHT_SHLIB 10 /* Reserved */
#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
#define SHT_NULL 0 /* Section header table entry unused */
#define SHT_PROGBITS 1 /* Program data */
#define SHT_SYMTAB 2 /* Symbol table */
#define SHT_STRTAB 3 /* String table */
#define SHT_RELA 4 /* Relocation entries with addends */
#define SHT_HASH 5 /* Symbol hash table */
#define SHT_DYNAMIC 6 /* Dynamic linking information */
#define SHT_NOTE 7 /* Notes */
#define SHT_NOBITS 8 /* Program space with no data (bss) */
#define SHT_REL 9 /* Relocation entries, no addends */
#define SHT_SHLIB 10 /* Reserved */
#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
#define SHT_UNKNOWN12 12
#define SHT_UNKNOWN13 13
#define SHT_INIT_ARRAY 14
#define SHT_FINI_ARRAY 15
#define SHT_PREINIT_ARRAY 16
#define SHT_GROUP 17
#define SHT_GROUP 17
#define SHT_SYMTAB_SHNDX 18
#define SHT_NUM 19
#define SHT_NUM 19
#define SHT_ARM_EXIDX 0x70000001 /* Exception Index table */
#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking pre-emption map*/
#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility attributes */
#define SHT_ARM_DEBUGOVERLAY 0x70000004
#define SHT_ARM_OVERLAYSECTION 0x70000005
#define SHF_WRITE 0x01 /* sh_flags */
#define SHF_ALLOC 0x02
+2
View File
@@ -1014,6 +1014,8 @@ int SetARM11KernelDescOtherCapabilities(ARM11KernelCapabilityDescriptor *desc, r
otherCapabilities |= othcap_RUNNABLE_ON_SLEEP;
if(rsf->AccessControlInfo.SpecialMemoryArrange)
otherCapabilities |= othcap_SPECIAL_MEMORY_ARRANGE;
if (rsf->AccessControlInfo.CanAccessCore2)
otherCapabilities |= othcap_CAN_ACCESS_CORE2;
if(rsf->AccessControlInfo.MemoryType){
if(strcasecmp(rsf->AccessControlInfo.MemoryType,"application") == 0)
+1
View File
@@ -45,6 +45,7 @@ typedef enum
othcap_CAN_SHARE_DEVICE_MEMORY = (1 << 6),
othcap_RUNNABLE_ON_SLEEP = (1 << 7),
othcap_SPECIAL_MEMORY_ARRANGE = (1 << 12),
othcap_CAN_ACCESS_CORE2 = (1 << 13),
} other_capabilities_flags;
typedef enum
+2 -4
View File
@@ -96,10 +96,8 @@ int LoadKeysFromResources(keys_struct *keys)
SetCurrentCommonKey(keys,0);
// NCCH
keys->aes.normalKey = NULL;
keys->aes.systemFixedKey = NULL;
//SetNormalKey(keys,zeros_aesKey);
//SetSystemFixedKey(keys,(u8*)zeros_aesKey);
SetNormalKey(keys,zeros_aesKey);
SetSystemFixedKey(keys,zeros_aesKey);
/* RSA Keys */
keys->rsa.isFalseSign = true;
+1 -2
View File
@@ -49,8 +49,7 @@ int SignCXI(ncch_hdr *hdr, keys_struct *keys)
int CheckCXISignature(ncch_hdr *hdr, u8 *pubk)
{
int result = RsaSignVerify(GetNcchHdrData(hdr),GetNcchHdrDataLen(hdr),GetNcchHdrSig(hdr),pubk,NULL,RSA_2048_SHA256,CTR_RSA_VERIFY);
return result;
return RsaSignVerify(GetNcchHdrData(hdr), GetNcchHdrDataLen(hdr), GetNcchHdrSig(hdr), pubk, NULL, RSA_2048_SHA256, CTR_RSA_VERIFY);
}
// NCCH Build Functions
-2
View File
@@ -45,8 +45,6 @@ int BuildRomFs(romfs_buildctx *ctx)
void FreeRomFsCtx(romfs_buildctx *ctx)
{
if(ctx->romfsBinary)
fclose(ctx->romfsBinary);
if(ctx->fs){
fs_FreeFiles(ctx->fs);
fs_FreeDir(ctx->fs);
+2 -4
View File
@@ -86,18 +86,16 @@ typedef struct
fs_dir *fs;
u32 *dirHashTable;
u8 *dirHashTable;
u32 m_dirHashTable;
u32 u_dirHashTable;
u8 *dirTable;
u32 dirNum;
u32 m_dirTableLen;
u32 u_dirTableLen;
u32 *fileHashTable;
u8 *fileHashTable;
u32 m_fileHashTable;
u32 u_fileHashTable;
u8 *fileTable;
u32 fileNum;
+10 -13
View File
@@ -186,10 +186,8 @@ void CalcRomfsSize(romfs_buildctx *ctx)
ctx->dirNum = 1; // root dir
CalcDirSize(ctx,ctx->fs);
ctx->u_dirHashTable = 0;
ctx->m_dirHashTable = GetHashTableCount(ctx->dirNum);
ctx->u_fileHashTable = 0;
ctx->m_fileHashTable = GetHashTableCount(ctx->fileNum);
u32 romfsHdrSize = align(sizeof(romfs_infoheader) + ctx->m_dirHashTable*sizeof(u32) + ctx->m_dirTableLen + ctx->m_fileHashTable*sizeof(u32) + ctx->m_fileTableLen,0x10);
@@ -267,7 +265,7 @@ void BuildRomfsHeader(romfs_buildctx *ctx)
for(int i = 0; i < 4; i++){
if(i == 0){
ctx->dirHashTable = (u32*)(ctx->level[3].pos + level3_pos);
ctx->dirHashTable = ctx->level[3].pos + level3_pos;
u32_to_u8(ctx->romfsHdr->section[i].offset,level3_pos,LE);
u32_to_u8(ctx->romfsHdr->section[i].size,ctx->m_dirHashTable*sizeof(u32),LE);
level3_pos += ctx->m_dirHashTable*sizeof(u32);
@@ -279,7 +277,7 @@ void BuildRomfsHeader(romfs_buildctx *ctx)
level3_pos += ctx->m_dirTableLen;
}
else if(i == 2){
ctx->fileHashTable = (u32*)(ctx->level[3].pos + level3_pos);
ctx->fileHashTable = ctx->level[3].pos + level3_pos;
u32_to_u8(ctx->romfsHdr->section[i].offset,level3_pos,LE);
u32_to_u8(ctx->romfsHdr->section[i].size,ctx->m_fileHashTable*sizeof(u32),LE);
level3_pos += ctx->m_fileHashTable*sizeof(u32);
@@ -300,11 +298,11 @@ void BuildRomfsHeader(romfs_buildctx *ctx)
u32_to_u8(ctx->romfsHdr->dataoffset,align(level3_pos,0x10),LE);
for (u32 i = 0; i < ctx->m_dirHashTable; i++) {
ctx->dirHashTable[i] = ROMFS_UNUSED_ENTRY;
u32_to_u8(ctx->dirHashTable+i*4, ROMFS_UNUSED_ENTRY, LE);
}
for (u32 i = 0; i < ctx->m_fileHashTable; i++) {
ctx->fileHashTable[i] = ROMFS_UNUSED_ENTRY;
u32_to_u8(ctx->fileHashTable+i*4, ROMFS_UNUSED_ENTRY, LE);
}
}
@@ -335,9 +333,8 @@ void AddFileToRomfs(romfs_buildctx *ctx, fs_file *file, u32 parent, u32 sibling)
/* Set hash data */
u32 hashindex = GetFileHashTableIndex(ctx, parent, file->name);
u32_to_u8(entry->hashoffset, ctx->fileHashTable[hashindex], LE);
ctx->fileHashTable[hashindex] = ctx->u_fileTableLen;
u32_to_u8(entry->hashoffset, u8_to_u32(ctx->fileHashTable + hashindex*4, LE), LE);
u32_to_u8(ctx->fileHashTable + hashindex*4, ctx->u_fileTableLen, LE);
/* Import data */
if(file->size)
@@ -376,7 +373,7 @@ void AddDirToRomfs(romfs_buildctx *ctx, fs_dir *fs, u32 parent, u32 sibling)
u32_to_u8(entry->namesize,0,LE);
/* Get hash table index */
hashindex = GetFileHashTableIndex(ctx, parent, (fs_romfs_char*)ROMFS_EMPTY_PATH);
hashindex = GetDirHashTableIndex(ctx, parent, (fs_romfs_char*)ROMFS_EMPTY_PATH);
/* Increment used dir table length */
ctx->u_dirTableLen += sizeof(romfs_direntry);
@@ -390,15 +387,15 @@ void AddDirToRomfs(romfs_buildctx *ctx, fs_dir *fs, u32 parent, u32 sibling)
memcpy(name_pos,(u8*)fs->name,fs->name_len);
/* Get hash table index */
hashindex = GetFileHashTableIndex(ctx, parent, fs->name);
hashindex = GetDirHashTableIndex(ctx, parent, fs->name);
/* Increment used dir table length */
ctx->u_dirTableLen += sizeof(romfs_direntry) + (u32)align(fs->name_len,4);
}
/* Set hash data */
u32_to_u8(entry->hashoffset, ctx->dirHashTable[hashindex], LE);
ctx->dirHashTable[hashindex] = offset;
u32_to_u8(entry->hashoffset, u8_to_u32(ctx->dirHashTable + hashindex*4, LE), LE);
u32_to_u8(ctx->dirHashTable + hashindex*4, offset, LE);
}
void AddDirChildrenToRomfs(romfs_buildctx *ctx, fs_dir *fs, u32 parent, u32 dir)
+1
View File
@@ -102,6 +102,7 @@ void GET_AccessControlInfo(ctr_yaml_context *ctx, rsf_settings *rsf)
else if(cmpYamlValue("UseOtherVariationSaveData",ctx)) SetBoolYAMLValue(&rsf->AccessControlInfo.UseOtherVariationSaveData,"UseOtherVariationSaveData",ctx);
else if(cmpYamlValue("RunnableOnSleep",ctx)) SetBoolYAMLValue(&rsf->AccessControlInfo.RunnableOnSleep,"RunnableOnSleep",ctx);
else if(cmpYamlValue("SpecialMemoryArrange",ctx)) SetBoolYAMLValue(&rsf->AccessControlInfo.SpecialMemoryArrange,"SpecialMemoryArrange",ctx);
else if(cmpYamlValue("CanAccessCore2", ctx)) SetBoolYAMLValue(&rsf->AccessControlInfo.CanAccessCore2, "CanAccessCore2", ctx);
else if(cmpYamlValue("UseExtSaveData", ctx)) SetBoolYAMLValue(&rsf->AccessControlInfo.UseExtSaveData, "UseExtSaveData", ctx);
else if(cmpYamlValue("EnableL2Cache", ctx)) SetBoolYAMLValue(&rsf->AccessControlInfo.EnableL2Cache, "EnableL2Cache", ctx);
+1
View File
@@ -86,6 +86,7 @@ typedef struct
bool UseOtherVariationSaveData;
bool RunnableOnSleep;
bool SpecialMemoryArrange;
bool CanAccessCore2;
bool UseExtSaveData;
bool EnableL2Cache;