ldr: ProgramInfo is 0x410 now, and fix debug flags for hbl

This commit is contained in:
Michael Scire 2024-10-10 03:45:09 -07:00
parent 49763aee92
commit 0c4ae55731
6 changed files with 25 additions and 2 deletions

View file

@ -34,9 +34,10 @@ namespace ams::ldr {
u32 aci_sac_size; u32 aci_sac_size;
u32 acid_fac_size; u32 acid_fac_size;
u32 aci_fah_size; u32 aci_fah_size;
u8 unused_20[0x10];
u8 ac_buffer[0x3E0]; u8 ac_buffer[0x3E0];
}; };
static_assert(util::is_pod<ProgramInfo>::value && sizeof(ProgramInfo) == 0x400, "ProgramInfo definition!"); static_assert(util::is_pod<ProgramInfo>::value && sizeof(ProgramInfo) == 0x410, "ProgramInfo definition!");
enum ProgramInfoFlag { enum ProgramInfoFlag {
ProgramInfoFlag_SystemModule = (0 << 0), ProgramInfoFlag_SystemModule = (0 << 0),

View file

@ -24,6 +24,7 @@ namespace ams::ldr::pm {
} }
Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc) { Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc) {
static_assert(sizeof(*out) == sizeof(LoaderProgramInfo));
R_RETURN(ldrPmGetProgramInfo(reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)), reinterpret_cast<LoaderProgramInfo *>(out))); R_RETURN(ldrPmGetProgramInfo(reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)), reinterpret_cast<LoaderProgramInfo *>(out)));
} }
@ -42,6 +43,7 @@ namespace ams::ldr::pm {
Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) { Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) {
static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!"); static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!");
static_assert(sizeof(*out) == sizeof(LoaderProgramInfo));
R_RETURN(ldrPmAtmosphereGetProgramInfo(reinterpret_cast<LoaderProgramInfo *>(out), reinterpret_cast<CfgOverrideStatus *>(out_status), reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)))); R_RETURN(ldrPmAtmosphereGetProgramInfo(reinterpret_cast<LoaderProgramInfo *>(out), reinterpret_cast<CfgOverrideStatus *>(out_status), reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc))));
} }

View file

@ -425,6 +425,20 @@ namespace ams::ldr {
} }
} }
void FixDebugCapabilityForHbl(util::BitPack32 *kac, size_t count) {
for (size_t i = 0; i < count; ++i) {
const auto cap = kac[i];
switch (GetCapabilityId(cap)) {
case CapabilityId::DebugFlags:
/* 19.0.0+ disallows more than one flag set; we are always DebugMode for kernel, so ForceDebug is the most powerful/flexible flag to set. */
kac[i] = CapabilityDebugFlags::Encode(false, false, true);
break;
default:
break;
}
}
}
void PreProcessCapability(util::BitPack32 *kac, size_t count) { void PreProcessCapability(util::BitPack32 *kac, size_t count) {
for (size_t i = 0; i < count; ++i) { for (size_t i = 0; i < count; ++i) {
const auto cap = kac[i]; const auto cap = kac[i];

View file

@ -23,6 +23,8 @@ namespace ams::ldr {
u16 MakeProgramInfoFlag(const util::BitPack32 *kac, size_t count); u16 MakeProgramInfoFlag(const util::BitPack32 *kac, size_t count);
void UpdateProgramInfoFlag(u16 flags, util::BitPack32 *kac, size_t count); void UpdateProgramInfoFlag(u16 flags, util::BitPack32 *kac, size_t count);
void FixDebugCapabilityForHbl(util::BitPack32 *kac, size_t count);
void PreProcessCapability(util::BitPack32 *kac, size_t count); void PreProcessCapability(util::BitPack32 *kac, size_t count);
} }

View file

@ -46,7 +46,7 @@ namespace ams {
namespace { namespace {
struct ServerOptions { struct ServerOptions {
static constexpr size_t PointerBufferSize = 0x400; static constexpr size_t PointerBufferSize = 0x420;
static constexpr size_t MaxDomains = 0; static constexpr size_t MaxDomains = 0;
static constexpr size_t MaxDomainObjects = 0; static constexpr size_t MaxDomainObjects = 0;
static constexpr bool CanDeferInvokeRequest = false; static constexpr bool CanDeferInvokeRequest = false;

View file

@ -252,6 +252,10 @@ namespace ams::ldr {
meta->npdm->main_thread_priority = HblMainThreadPriorityApplet; meta->npdm->main_thread_priority = HblMainThreadPriorityApplet;
} }
} }
/* Fix the debug capabilities, to prevent needing a hbl recompilation. */
FixDebugCapabilityForHbl(static_cast<util::BitPack32 *>(meta->acid_kac), meta->acid->kac_size / sizeof(util::BitPack32));
FixDebugCapabilityForHbl(static_cast<util::BitPack32 *>(meta->aci_kac), meta->aci->kac_size / sizeof(util::BitPack32));
} else if (hos::GetVersion() >= hos::Version_10_0_0) { } else if (hos::GetVersion() >= hos::Version_10_0_0) {
/* If storage id is none, there is no base code filesystem, and thus it is impossible for us to validate. */ /* If storage id is none, there is no base code filesystem, and thus it is impossible for us to validate. */
/* However, if we're an application, we are guaranteed a base code filesystem. */ /* However, if we're an application, we are guaranteed a base code filesystem. */