From 43f5a0ef4541c9d4820e0afc84e23d5830bc10a8 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 12 Jun 2020 06:16:58 -0700 Subject: [PATCH] exo2: account for sleep/wake enabling jtag --- exosphere/Makefile | 6 ++++-- exosphere/program/source/secmon_setup.cpp | 4 +++- exosphere/warmboot/source/warmboot_main.cpp | 5 ++--- exosphere/warmboot/source/warmboot_misc.cpp | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/exosphere/Makefile b/exosphere/Makefile index 00aca3834..bf39b341b 100644 --- a/exosphere/Makefile +++ b/exosphere/Makefile @@ -21,10 +21,12 @@ program.lz4: build_program build_program: $(MAKE) -C program -warmboot.bin: - $(MAKE) -C warmboot +warmboot.bin: build_warmboot @cp warmboot/warmboot.bin warmboot.bin +build_warmboot: + $(MAKE) -C warmboot + boot_code.lz4: program.lz4 exosphere-clean: diff --git a/exosphere/program/source/secmon_setup.cpp b/exosphere/program/source/secmon_setup.cpp index 7c9ce28e8..a87539e72 100644 --- a/exosphere/program/source/secmon_setup.cpp +++ b/exosphere/program/source/secmon_setup.cpp @@ -949,7 +949,9 @@ namespace ams::secmon { void SetupForLp0Exit() { /* Exit HiZ mode in charger, if we need to. */ - if (smc::IsChargerHiZModeEnabled()) { + const auto target_fw = GetTargetFirmware(); + const bool force_exit_hiz_mode = (target_fw < TargetFirmware_4_0_0) || (target_fw < TargetFirmware_8_0_0 && fuse::GetHardwareType() == fuse::HardwareType_Icosa); + if (force_exit_hiz_mode || smc::IsChargerHiZModeEnabled()) { ExitChargerHiZMode(); } diff --git a/exosphere/warmboot/source/warmboot_main.cpp b/exosphere/warmboot/source/warmboot_main.cpp index 933b17e37..5042fa8ad 100644 --- a/exosphere/warmboot/source/warmboot_main.cpp +++ b/exosphere/warmboot/source/warmboot_main.cpp @@ -81,10 +81,9 @@ namespace ams::warmboot { PowerOnCpu(); /* Halt ourselves. */ - const bool disable_jtag = metadata->target_firmware >= TargetFirmware_4_0_0; while (true) { - reg::Write(secmon::MemoryRegionPhysicalDeviceFlowController.GetAddress() + FLOW_CTLR_HALT_COP_EVENTS, FLOW_REG_BITS_ENUM (HALT_COP_EVENTS_MODE, FLOW_MODE_STOP), - FLOW_REG_BITS_ENUM_SEL(HALT_COP_EVENTS_JTAG, disable_jtag, DISABLED, ENABLED)); + reg::Write(secmon::MemoryRegionPhysicalDeviceFlowController.GetAddress() + FLOW_CTLR_HALT_COP_EVENTS, FLOW_REG_BITS_ENUM(HALT_COP_EVENTS_MODE, FLOW_MODE_STOP), + FLOW_REG_BITS_ENUM(HALT_COP_EVENTS_JTAG, ENABLED)); } } diff --git a/exosphere/warmboot/source/warmboot_misc.cpp b/exosphere/warmboot/source/warmboot_misc.cpp index eeb5932f2..3c648a7e9 100644 --- a/exosphere/warmboot/source/warmboot_misc.cpp +++ b/exosphere/warmboot/source/warmboot_misc.cpp @@ -39,8 +39,8 @@ namespace ams::warmboot { const bool jtag_sts = reg::HasValue(PMC + APBDEV_PMC_STICKY_BITS, PMC_REG_BITS_ENUM(STICKY_BITS_JTAG_STS, ENABLE)); reg::ReadWrite(SYSTEM + SB_PFCFG, SB_REG_BITS_ENUM_SEL(PFCFG_DBGEN, jtag_sts, ENABLE, DISABLE), - SB_REG_BITS_ENUM_SEL(PFCFG_NIDEN, jtag_sts, ENABLE, DISABLE), SB_REG_BITS_ENUM_SEL(PFCFG_SPNIDEN, jtag_sts, ENABLE, DISABLE), + SB_REG_BITS_ENUM (PFCFG_NIDEN, ENABLE), SB_REG_BITS_ENUM (PFCFG_SPIDEN, DISABLE)); reg::ReadWrite(APB_MISC + APB_MISC_PP_CONFIG_CTL, APB_MISC_REG_BITS_ENUM_SEL(PP_CONFIG_CTL_JTAG, jtag_sts, ENABLE, DISABLE));