bpc.mitm: detect preferred reboot function (closes #785)

This commit is contained in:
Michael Scire 2020-01-01 21:50:06 -08:00
parent 2619ccad0c
commit 48772307bf
3 changed files with 21 additions and 1 deletions

View file

@ -112,10 +112,25 @@ namespace ams::mitm::bpc {
fsFileRead(&payload_file, 0, g_reboot_payload, sizeof(g_reboot_payload), FsReadOption_None, &actual_size);
}
/* TODO: Parse reboot type from settings. */
/* NOTE: Preferred reboot type will be parsed from settings later on. */
g_reboot_type = RebootType::ToPayload;
return ResultSuccess();
}
Result DetectPreferredRebootFunctionality() {
char reboot_type[0x40] = {};
settings::fwdbg::GetSettingsItemValue(reboot_type, sizeof(reboot_type) - 1, "atmosphere", "power_menu_reboot_function");
if (strcasecmp(reboot_type, "stock") == 0 || strcasecmp(reboot_type, "normal") == 0 || strcasecmp(reboot_type, "standard") == 0) {
g_reboot_type = RebootType::Standard;
} else if (strcasecmp(reboot_type, "rcm") == 0) {
g_reboot_type = RebootType::ToRcm;
} else if (strcasecmp(reboot_type, "payload") == 0) {
g_reboot_type = RebootType::ToPayload;
}
return ResultSuccess();
}
}

View file

@ -25,6 +25,7 @@ namespace ams::mitm::bpc {
/* Atmosphere power utilities. */
Result LoadRebootPayload();
Result DetectPreferredRebootFunctionality();
void RebootForFatalError(const ams::FatalErrorContext *ctx);
}

View file

@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../amsmitm_initialization.hpp"
#include "../bpc_mitm/bpc_ams_power_utils.hpp"
#include "setmitm_module.hpp"
#include "set_mitm_service.hpp"
#include "setsys_mitm_service.hpp"
@ -45,6 +46,9 @@ namespace ams::mitm::settings {
/* Load settings off the SD card. */
ams::settings::fwdbg::InitializeSdCardKeyValueStore();
/* Ensure that we reboot using the user's preferred method. */
R_ASSERT(ams::mitm::bpc::DetectPreferredRebootFunctionality());
/* Create mitm servers. */
R_ASSERT(g_server_manager.RegisterMitmServer<SetMitmService>(SetMitmServiceName));
R_ASSERT(g_server_manager.RegisterMitmServer<SetSysMitmService>(SetSysMitmServiceName));