bpc.mitm/exo: support pmic reboot/shutdown on mariko (thanks @CTCaer)

This commit is contained in:
Michael Scire 2023-10-11 18:50:38 -07:00 committed by SciresM
parent 71d0274884
commit 2ec3e141c7
7 changed files with 54 additions and 15 deletions

View file

@ -33,6 +33,7 @@ namespace ams::mitm::bpc {
Standard,
ToRcm,
ToPayload,
ByPmic,
};
/* Globals. */
@ -93,6 +94,9 @@ namespace ams::mitm::bpc {
void RebootSystem() {
switch (g_reboot_type) {
case RebootType::ByPmic:
exosphere::ForceRebootByPmic();
break;
case RebootType::ToRcm:
exosphere::ForceRebootToRcm();
break;
@ -113,6 +117,11 @@ namespace ams::mitm::bpc {
}
void SetRebootPayload(const void *payload, size_t payload_size) {
/* Mariko does not support reboot-to-payload. */
if (spl::GetSocType() == spl::SocType_Mariko) {
return;
}
/* Clear payload buffer */
std::memset(g_reboot_payload, 0xCC, sizeof(g_reboot_payload));
@ -131,6 +140,9 @@ namespace ams::mitm::bpc {
}
Result LoadRebootPayload() {
/* Mariko does not support reboot-to-payload. */
R_SUCCEED_IF(spl::GetSocType() == spl::SocType_Mariko)
/* Clear payload buffer */
std::memset(g_reboot_payload, 0xCC, sizeof(g_reboot_payload));
@ -163,6 +175,11 @@ namespace ams::mitm::bpc {
g_reboot_type = RebootType::ToPayload;
}
/* TODO: Should we actually allow control over this on mariko? */
if (spl::GetSocType() == spl::SocType_Mariko) {
g_reboot_type = RebootType::ByPmic;
}
R_SUCCEED();
}

View file

@ -67,11 +67,6 @@ namespace ams::mitm::bpc {
/* Wait until initialization is complete. */
mitm::WaitInitialized();
/* On Mariko, we can't reboot to payload/do exosphere-shutdown...so there is no point in bpc.mitm. */
if (spl::GetSocType() == spl::SocType_Mariko) {
return;
}
/* Create bpc mitm. */
const sm::ServiceName service_name = (hos::GetVersion() >= hos::Version_2_0_0) ? MitmServiceName : DeprecatedMitmServiceName;