diff --git a/exosphere/src/interrupt.c b/exosphere/src/interrupt.c index 7f79b20f0..418fc895a 100644 --- a/exosphere/src/interrupt.c +++ b/exosphere/src/interrupt.c @@ -28,6 +28,18 @@ void intr_initialize_gic(void) { GICC_BPR = 7; } +/* Initializes Interrupt Groups 1-7 in the GIC. Called by pk2ldr. */ +void intr_initialize_gic_nonsecure(void) { + for (unsigned int i = 1; i < 8; i++) { + GICD_IGROUPR[i] = 0xFFFFFFFF + } + + for (unsigned int i = 0x20; i < 0xE0; i++) { + GICD_IPRIORITYR[i] = GIC_PRI_HIGHEST_NONSECURE; + } + GICD_CTLR = 1; +} + /* Sets GICC_CTLR to appropriate pre-sleep value. */ void intr_prepare_gicc_for_sleep(void) { GICC_CTLR = 0x1E0; diff --git a/exosphere/src/interrupt.h b/exosphere/src/interrupt.h index 9dbc0e61a..8283cd9f8 100644 --- a/exosphere/src/interrupt.h +++ b/exosphere/src/interrupt.h @@ -22,6 +22,7 @@ static inline uintptr_t get_gicc_base(void) { #define GICD_BASE (get_gicd_base()) #define GICC_BASE (get_gicc_base()) +#define GICD_CTLR (*((volatile uint32_t *)(GICD_BASE + 0x000ull))) #define GICD_IGROUPR ((volatile uint32_t *)(GICD_BASE + 0x080ull)) #define GICD_ISENABLER ((volatile uint32_t *)(GICD_BASE + 0x100ull)) #define GICD_ISPENDR ((volatile uint32_t *)(GICD_BASE + 0x200ull)) @@ -46,6 +47,7 @@ void handle_registered_interrupt(void); /* Initializes the GIC. TODO: This must be called during wakeup. */ void intr_initialize_gic(void); +void intr_initialize_gic_nonsecure(void); void intr_prepare_gicc_for_sleep(void); diff --git a/exosphere/src/package2.c b/exosphere/src/package2.c index c88d620b0..b214f1bc9 100644 --- a/exosphere/src/package2.c +++ b/exosphere/src/package2.c @@ -18,7 +18,9 @@ static void setup_se(void) { /* Sanity check the Security Engine. */ se_verify_flags_cleared(); - se_clear_interrupts(); + + /* Initialize Interrupts. */ + intr_initialize_gic_nonsecure(); /* Perform some sanity initialization. */ volatile security_engine_t *p_security_engine = get_security_engine(); diff --git a/exosphere/src/se.c b/exosphere/src/se.c index e529c892b..d19863a12 100644 --- a/exosphere/src/se.c +++ b/exosphere/src/se.c @@ -71,10 +71,6 @@ void se_verify_flags_cleared(void) { } } -void se_clear_interrupts(void) { - /* TODO */ -} - /* Set the flags for an AES keyslot. */ void set_aes_keyslot_flags(unsigned int keyslot, unsigned int flags) { if (keyslot >= KEYSLOT_AES_MAX) { diff --git a/exosphere/src/se.h b/exosphere/src/se.h index ac0951ecd..4f598d298 100644 --- a/exosphere/src/se.h +++ b/exosphere/src/se.h @@ -174,7 +174,6 @@ void se_operation_completed(void); void se_check_error_status_reg(void); void se_check_for_error(void); void se_trigger_interrupt(void); -void se_clear_interrupts(void); /* TODO */ void se_verify_flags_cleared(void);