sysmodules: introduce "luma shared config", rewrite ndmu workaround
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <3ds/exheader.h>
|
||||
|
||||
#define HBLDR_3DSX_TID (*(vu64 *)0x1FF81100)
|
||||
|
||||
Result hbldrInit(void);
|
||||
void hbldrExit(void);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "ifile.h"
|
||||
#include "util.h"
|
||||
#include "hbldr.h"
|
||||
#include "luma_shared_config.h"
|
||||
|
||||
extern u32 config, multiConfig, bootConfig;
|
||||
extern bool isN3DS, isSdMode;
|
||||
@@ -91,6 +92,11 @@ static int lzss_decompress(u8 *end)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline bool hbldrIs3dsxTitle(u64 tid)
|
||||
{
|
||||
return Luma_SharedConfig->use_hbldr && tid == Luma_SharedConfig->hbldr_3dsx_tid;
|
||||
}
|
||||
|
||||
static Result allocateSharedMem(prog_addrs_t *shared, prog_addrs_t *vaddr, int flags)
|
||||
{
|
||||
u32 dummy;
|
||||
@@ -169,11 +175,8 @@ static Result GetProgramInfo(ExHeader_Info *exheaderInfo, u64 programHandle)
|
||||
}
|
||||
}
|
||||
|
||||
s64 nbSection0Modules;
|
||||
svcGetSystemInfo(&nbSection0Modules, 26, 0);
|
||||
|
||||
// Tweak 3dsx placeholder title exheaderInfo
|
||||
if (nbSection0Modules == 6 && exheaderInfo->aci.local_caps.title_id == HBLDR_3DSX_TID)
|
||||
if (hbldrIs3dsxTitle(exheaderInfo->aci.local_caps.title_id))
|
||||
{
|
||||
assertSuccess(hbldrInit());
|
||||
HBLDR_PatchExHeaderInfo(exheaderInfo);
|
||||
@@ -204,7 +207,7 @@ static Result LoadProcess(Handle *process, u64 programHandle)
|
||||
u64 titleId;
|
||||
|
||||
// make sure the cached info corrosponds to the current programHandle
|
||||
if (g_cached_programHandle != programHandle || g_exheaderInfo.aci.local_caps.title_id == HBLDR_3DSX_TID)
|
||||
if (g_cached_programHandle != programHandle || hbldrIs3dsxTitle(g_exheaderInfo.aci.local_caps.title_id))
|
||||
{
|
||||
res = GetProgramInfo(&g_exheaderInfo, programHandle);
|
||||
g_cached_programHandle = programHandle;
|
||||
@@ -230,7 +233,7 @@ static Result LoadProcess(Handle *process, u64 programHandle)
|
||||
titleId = g_exheaderInfo.aci.local_caps.title_id;
|
||||
ExHeader_CodeSetInfo *csi = &g_exheaderInfo.sci.codeset_info;
|
||||
|
||||
if (titleId == HBLDR_3DSX_TID)
|
||||
if (hbldrIs3dsxTitle(titleId))
|
||||
{
|
||||
assertSuccess(hbldrInit());
|
||||
assertSuccess(HBLDR_LoadProcess(&codeset, csi->text.address, flags & 0xF00, titleId, csi->name));
|
||||
@@ -377,7 +380,7 @@ void loaderHandleCommands(void *ctx)
|
||||
break;
|
||||
case 4: // GetProgramInfo
|
||||
memcpy(&programHandle, &cmdbuf[1], 8);
|
||||
if (programHandle != g_cached_programHandle || g_exheaderInfo.aci.local_caps.title_id == HBLDR_3DSX_TID)
|
||||
if (programHandle != g_cached_programHandle || hbldrIs3dsxTitle(g_exheaderInfo.aci.local_caps.title_id))
|
||||
{
|
||||
res = GetProgramInfo(&g_exheaderInfo, programHandle);
|
||||
g_cached_programHandle = R_SUCCEEDED(res) ? programHandle : 0;
|
||||
|
||||
28
sysmodules/loader/source/luma_shared_config.h
Normal file
28
sysmodules/loader/source/luma_shared_config.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* This paricular file is licensed under the following terms: */
|
||||
|
||||
/*
|
||||
* This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable
|
||||
* for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it
|
||||
* and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
|
||||
* If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
* This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
/// Luma shared config type.
|
||||
typedef struct LumaSharedConfig {
|
||||
u64 hbldr_3dsx_tid; ///< Title ID to use for 3DSX loading.
|
||||
bool use_hbldr; ///< Whether or not Loader should use hb:ldr (Rosalina writes 1).
|
||||
} LumaSharedConfig;
|
||||
|
||||
/// Luma shared config.
|
||||
#define Luma_SharedConfig ((volatile LumaSharedConfig *)(OS_SHAREDCFG_VADDR + 0x800))
|
||||
Reference in New Issue
Block a user