exosphere: fix sleep mode when debugmode is enabled

This commit is contained in:
Michael Scire 2018-12-04 15:59:30 -08:00
parent 903789cf6e
commit a79f4cf6f6
5 changed files with 30 additions and 2 deletions

View file

@ -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);

View file

@ -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) {

View file

@ -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);

View file

@ -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();

View file

@ -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. */