diff --git a/exosphere/src/bootup.c b/exosphere/src/bootup.c index 962ef8e75..4836f4610 100644 --- a/exosphere/src/bootup.c +++ b/exosphere/src/bootup.c @@ -31,6 +31,7 @@ #include "configitem.h" #include "timers.h" #include "misc.h" +#include "uart.h" #include "bpmp.h" #include "sysreg.h" #include "interrupt.h" @@ -213,6 +214,13 @@ void bootup_misc_mmio(void) { } if (!g_has_booted_up) { + /* N doesn't do this, but we should for compatibility. */ + if (configitem_is_debugmode_priv()) { + uart_select(UART_A); + clkrst_reboot(CARDEVICE_UARTA); + uart_init(UART_A, 115200); + } + intr_register_handler(INTERRUPT_ID_SECURITY_ENGINE, se_operation_completed); if (exosphere_get_target_firmware() >= EXOSPHERE_TARGET_FIRMWARE_400) { intr_register_handler(INTERRUPT_ID_ACTIVITY_MONITOR_4X, actmon_interrupt_handler); diff --git a/exosphere/src/configitem.c b/exosphere/src/configitem.c index a0309ec2b..cac02b835 100644 --- a/exosphere/src/configitem.c +++ b/exosphere/src/configitem.c @@ -72,6 +72,15 @@ bool configitem_should_profile_battery(void) { return g_battery_profile; } +bool configitem_is_debugmode_priv(void) { + uint64_t debugmode = 0; + if (configitem_get(true, CONFIGITEM_ISDEBUGMODE, &debugmode) != 0) { + generic_panic(); + } + + return debugmode != 0; +} + uint64_t configitem_get_hardware_type(void) { uint64_t hardware_type; if (configitem_get(true, CONFIGITEM_HARDWARETYPE, &hardware_type) != 0) { diff --git a/exosphere/src/configitem.h b/exosphere/src/configitem.h index 8aef4e975..df54c5740 100644 --- a/exosphere/src/configitem.h +++ b/exosphere/src/configitem.h @@ -50,6 +50,7 @@ uint32_t configitem_get(bool privileged, ConfigItem item, uint64_t *p_outvalue); bool configitem_is_recovery_boot(void); bool configitem_is_retail(void); bool configitem_should_profile_battery(void); +bool configitem_is_debugmode_priv(void); void configitem_set_debugmode_override(bool user, bool priv); diff --git a/exosphere/src/lp0.c b/exosphere/src/lp0.c index e6e19d3bf..e38693cf0 100644 --- a/exosphere/src/lp0.c +++ b/exosphere/src/lp0.c @@ -35,6 +35,7 @@ #include "smc_api.h" #include "timers.h" #include "misc.h" +#include "uart.h" #include "exocfg.h" #define u8 uint8_t @@ -241,7 +242,7 @@ void save_se_and_power_down_cpu(void) { save_se_state(); if (!configitem_is_retail()) { - /* TODO: uart_log("OYASUMI"); */ + uart_send(UART_A, "OYASUMI", 8); } finalize_powerdown(); diff --git a/exosphere/src/warmboot_main.c b/exosphere/src/warmboot_main.c index 8ee15c4fd..d6f66aeb3 100644 --- a/exosphere/src/warmboot_main.c +++ b/exosphere/src/warmboot_main.c @@ -30,6 +30,7 @@ #include "car.h" #include "i2c.h" #include "misc.h" +#include "uart.h" #include "interrupt.h" #include "pmc.h" @@ -55,8 +56,16 @@ void __attribute__((noreturn)) warmboot_main(void) { /* On warmboot (not cpu_on) only */ if (VIRT_MC_SECURITY_CFG3 == 0) { + /* N only does this on dev units, but we will do it unconditionally. */ + { + uart_select(UART_A); + clkrst_reboot(CARDEVICE_UARTA); + uart_init(UART_A, 115200); + } + if (!configitem_is_retail()) { - /* TODO: uart_log("OHAYO"); */ + uart_send(UART_A, "OHAYO", 6); + uart_wait_idle(UART_A, UART_VENDOR_STATE_TX_IDLE); } /* Sanity check the Security Engine. */