Make 3dsx feature compatible with n3ds safe_firm, HOWEVER apps that actually use the GPU won't work

This commit is contained in:
TuxSH 2020-05-02 22:37:15 +01:00
parent 85cfa5cba6
commit 3d0ec9b785

View File

@ -37,6 +37,7 @@
#include "pmdbgext.h" #include "pmdbgext.h"
#define MAP_BASE 0x10000000 #define MAP_BASE 0x10000000
#define SYSCOREVER (*(vu32 *)0x1FF80010)
extern GDBContext *nextApplicationGdbCtx; extern GDBContext *nextApplicationGdbCtx;
extern GDBServer gdbServer; extern GDBServer gdbServer;
@ -77,16 +78,13 @@ static const char serviceList[32][8] =
"y2r:u", "y2r:u",
}; };
static const u64 dependencyList[] = static const u64 dependencyListNativeFirm[] =
{ {
0x0004013000002402LL, //ac 0x0004013000002402LL, //ac
0x0004013000001502LL, //am 0x0004013000001502LL, //am
0x0004013000003402LL, //boss
0x0004013000001602LL, //camera
0x0004013000001702LL, //cfg 0x0004013000001702LL, //cfg
0x0004013000001802LL, //codec 0x0004013000001802LL, //codec
0x0004013000002702LL, //csnd 0x0004013000002702LL, //csnd
0x0004013000002802LL, //dlp
0x0004013000001A02LL, //dsp 0x0004013000001A02LL, //dsp
0x0004013000001B02LL, //gpio 0x0004013000001B02LL, //gpio
0x0004013000001C02LL, //gsp 0x0004013000001C02LL, //gsp
@ -95,18 +93,50 @@ static const u64 dependencyList[] =
0x0004013000001E02LL, //i2c 0x0004013000001E02LL, //i2c
0x0004013000003302LL, //ir 0x0004013000003302LL, //ir
0x0004013000001F02LL, //mcu 0x0004013000001F02LL, //mcu
0x0004013000002002LL, //mic
0x0004013000002B02LL, //ndm
0x0004013000003502LL, //news
0x0004013000002C02LL, //nim 0x0004013000002C02LL, //nim
0x0004013000002D02LL, //nwm 0x0004013000002D02LL, //nwm
0x0004013000002102LL, //pdn 0x0004013000002102LL, //pdn
0x0004013000003102LL, //ps 0x0004013000003102LL, //ps
0x0004013000002202LL, //ptm 0x0004013000002202LL, //ptm
0x0004013000003702LL, //ro
0x0004013000002E02LL, //socket 0x0004013000002E02LL, //socket
0x0004013000002302LL, //spi 0x0004013000002302LL, //spi
0x0004013000002F02LL, //ssl 0x0004013000002F02LL, //ssl
// Not present on SAFE_FIRM:
0x0004013000003402LL, //boss
0x0004013000001602LL, //camera
0x0004013000002802LL, //dlp
0x0004013000002002LL, //mic
0x0004013000002B02LL, //ndm
0x0004013000003502LL, //news
0x0004013000003702LL, //ro
};
static const u64 dependencyListSafeFirm[] =
{
0x0004013000002403LL, //ac
0x0004013000001503LL, //am
0x0004013000001703LL, //cfg
0x0004013000001803LL, //codec
0x0004013000002703LL, //csnd
0x0004013000001A03LL, //dsp
0x0004013000001B03LL, //gpio
0x0004013000001C03LL, //gsp
0x0004013000001D03LL, //hid
0x0004013000002903LL, //http
0x0004013000001E03LL, //i2c
0x0004013000003303LL, //ir
0x0004013000001F03LL, //mcu
0x0004013000002C03LL, //nim
0x0004013000002D03LL, //nwm
0x0004013000002103LL, //pdn
0x0004013000003103LL, //ps
0x0004013000002203LL, //ptm
0x0004013000002E03LL, //socket
0x0004013000002303LL, //spi
0x0004013000002F03LL, //ssl
0x0004013000003203LL, //friends (wouldn't be launched otherwise)
}; };
static const u32 kernelCaps[] = static const u32 kernelCaps[] =
@ -264,11 +294,15 @@ void HBLDR_HandleCommands(void *ctx)
memcpy(exhi->sci.codeset_info.name, "3dsx_app", 8); memcpy(exhi->sci.codeset_info.name, "3dsx_app", 8);
memcpy(&exhi->sci.codeset_info.stack_size, &stacksize, 4); memcpy(&exhi->sci.codeset_info.stack_size, &stacksize, 4);
memset(&exhi->sci.dependencies, 0, sizeof(exhi->sci.dependencies)); memset(&exhi->sci.dependencies, 0, sizeof(exhi->sci.dependencies));
memcpy(exhi->sci.dependencies, dependencyList, sizeof(dependencyList));
if (SYSCOREVER == 2)
memcpy(exhi->sci.dependencies, dependencyListNativeFirm, sizeof(dependencyListNativeFirm));
else if (SYSCOREVER == 3)
memcpy(exhi->sci.dependencies, dependencyListSafeFirm, sizeof(dependencyListSafeFirm));
ExHeader_Arm11SystemLocalCapabilities* localcaps0 = &exhi->aci.local_caps; ExHeader_Arm11SystemLocalCapabilities* localcaps0 = &exhi->aci.local_caps;
localcaps0->core_info.core_version = 2; localcaps0->core_info.core_version = SYSCOREVER;
localcaps0->core_info.use_cpu_clockrate_804MHz = false; localcaps0->core_info.use_cpu_clockrate_804MHz = false;
localcaps0->core_info.enable_l2c = false; localcaps0->core_info.enable_l2c = false;
localcaps0->core_info.n3ds_system_mode = SYSMODE_N3DS_PROD; localcaps0->core_info.n3ds_system_mode = SYSMODE_N3DS_PROD;
@ -287,7 +321,7 @@ void HBLDR_HandleCommands(void *ctx)
localcaps0->storage_info.no_romfs = true; localcaps0->storage_info.no_romfs = true;
localcaps0->storage_info.use_extended_savedata_access = true; // Whatever localcaps0->storage_info.use_extended_savedata_access = true; // Whatever
/* We have a patched SM, so whatever... */ // We have a patched SM, so whatever...
memset(localcaps0->service_access, 0, sizeof(localcaps0->service_access)); memset(localcaps0->service_access, 0, sizeof(localcaps0->service_access));
memcpy(localcaps0->service_access, serviceList, sizeof(serviceList)); memcpy(localcaps0->service_access, serviceList, sizeof(serviceList));
@ -300,9 +334,9 @@ void HBLDR_HandleCommands(void *ctx)
// Set kernel release version to the current kernel version // Set kernel release version to the current kernel version
kcaps0->descriptors[0] = 0xFC000000 | (osGetKernelVersion() >> 16); kcaps0->descriptors[0] = 0xFC000000 | (osGetKernelVersion() >> 16);
u64 lastdep = sizeof(dependencyList)/8; if (GET_VERSION_MINOR(osGetKernelVersion()) >= 50 && SYSCOREVER == 2) // 9.6+ NFIRM
if (GET_VERSION_MINOR(osGetKernelVersion()) >= 50) // 9.6+ FIRM
{ {
u64 lastdep = sizeof(dependencyListNativeFirm)/8;
exhi->sci.dependencies[lastdep++] = 0x0004013000004002ULL; // nfc exhi->sci.dependencies[lastdep++] = 0x0004013000004002ULL; // nfc
strncpy((char*)&localcaps0->service_access[0x20], "nfc:u", 8); strncpy((char*)&localcaps0->service_access[0x20], "nfc:u", 8);
s64 dummy = 0; s64 dummy = 0;