diff --git a/exosphere/bootconfig.h b/exosphere/bootconfig.h index 67db52e34..20d1120c5 100644 --- a/exosphere/bootconfig.h +++ b/exosphere/bootconfig.h @@ -18,5 +18,6 @@ void bootconfig_clear(void); /* Actual configuration getters. */ bool bootconfig_is_package2_plaintext(void); bool bootconfig_is_package2_unsigned(void); +bool bootconfig_disable_program_verification(void); #endif \ No newline at end of file diff --git a/exosphere/configitem.c b/exosphere/configitem.c index ccf9b44d0..d4f3a8e38 100644 --- a/exosphere/configitem.c +++ b/exosphere/configitem.c @@ -1,6 +1,8 @@ #include #include "utils.h" +#include "bootconfig.h" +#include "se.h" #include "configitem.h" int g_battery_profile = 0; @@ -26,19 +28,18 @@ uint32_t configitem_get(enum ConfigItem item, uint64_t *p_outvalue) { uint32_t result = 0; switch (item) { case CONFIGITEM_DISABLEPROGRAMVERIFICATION: - /* TODO: This is loaded from BootConfig on dev units, always zero on retail. How should we support? */ - *p_outvalue = 0; + *p_outvalue = (int)(bootconfig_disable_program_verification()); break; case CONFIGITEM_MEMORYCONFIGURATION: /* TODO: Fuse driver */ break; case CONFIGITEM_SECURITYENGINEIRQ: - /* SE is interrupt #44. */ - *p_outvalue = 0x2C; + /* SE is interrupt #0x2C. */ + *p_outvalue = INTERRUPT_ID_USER_SECURITY_ENGINE; break; case CONFIGITEM_UNK04: - /* Always returns 2 on hardware. */ - *p_outvalue = 2; + /* Always returns maxver - 1 on hardware. */ + *p_outvalue = PACKAGE2_MAXVER_400_CURRENT - 1; break; case CONFIGITEM_HARDWARETYPE: /* TODO: Fuse driver */ @@ -47,7 +48,7 @@ uint32_t configitem_get(enum ConfigItem item, uint64_t *p_outvalue) { /* TODO: Fuse driver */ break; case CONFIGITEM_ISRECOVERYBOOT: - /* TODO: This is just a constant, hardcoded into TZ on retail. How should we support? */ + /* TODO: This requires reading values passed to crt0 via NX_Bootloader. TBD pending crt0 implementation. */ *p_outvalue = 0; break; case CONFIGITEM_DEVICEID: diff --git a/exosphere/configitem.h b/exosphere/configitem.h index 593f653e9..474566760 100644 --- a/exosphere/configitem.h +++ b/exosphere/configitem.h @@ -8,7 +8,7 @@ enum ConfigItem { CONFIGITEM_DISABLEPROGRAMVERIFICATION = 1, CONFIGITEM_MEMORYCONFIGURATION = 2, CONFIGITEM_SECURITYENGINEIRQ = 3, - CONFIGITEM_UNK04 = 4, + CONFIGITEM_VERSION = 4, CONFIGITEM_HARDWARETYPE = 5, CONFIGITEM_ISRETAIL = 6, CONFIGITEM_ISRECOVERYBOOT = 7, diff --git a/exosphere/interrupt.h b/exosphere/interrupt.h index 3b631f38c..d48614959 100644 --- a/exosphere/interrupt.h +++ b/exosphere/interrupt.h @@ -9,6 +9,7 @@ #define MAX_REGISTERED_INTERRUPTS 4 #define INTERRUPT_ID_SECURITY_ENGINE 0x5A +#define INTERRUPT_ID_USER_SECURITY_ENGINE 0x2C #define GICD_BASE (mmio_get_device_address(MMIO_DEVID_GICD)) #define GICC_BASE (mmio_get_device_address(MMIO_DEVID_GICC)) diff --git a/exosphere/se.c b/exosphere/se.c index 49a2a7fbe..76e6529bf 100644 --- a/exosphere/se.c +++ b/exosphere/se.c @@ -3,6 +3,7 @@ #include #include "utils.h" +#include "interrupt.h" #include "mmu.h" #include "cache.h" #include "se.h" @@ -65,7 +66,7 @@ void se_check_for_error(void) { } void se_trigger_intrrupt(void) { - /* TODO */ + intr_set_pending(INTERRUPT_ID_USER_SECURITY_ENGINE); } void se_verify_flags_cleared(void) { diff --git a/exosphere/se.h b/exosphere/se.h index de1f99825..4b5faf594 100644 --- a/exosphere/se.h +++ b/exosphere/se.h @@ -145,7 +145,6 @@ void se_check_for_error(void); void se_trigger_interrupt(void); void se_verify_flags_cleared(void); -void se_clear_interrupts(void); void set_aes_keyslot_flags(unsigned int keyslot, unsigned int flags); void set_rsa_keyslot_flags(unsigned int keyslot, unsigned int flags);