static void uvisor_disabled_default_vector(void) { uint32_t irqn, vector; const uint32_t *dst_box_cfgtbl_ptr; uint8_t dst_box_id; int ipsr; /* Get current IRQ number, from the IPSR. * We also allow system IRQs. This is inconsistent with the uVisor API, so * code written before uVisor might stop working when uVisor is enabled. */ irqn = 0; ipsr = ((int) (__get_IPSR() & 0x1FF)) - NVIC_USER_IRQ_OFFSET; if (ipsr < NonMaskableInt_IRQn || ipsr >= NVIC_USER_IRQ_NUMBER) { uvisor_error(USER_NOT_ALLOWED); } else { irqn = (uint32_t) ipsr; } /* Calculate the destination box configuration pointer. */ dst_box_id = g_uvisor_disabled_vectors[irqn].box_id; dst_box_cfgtbl_ptr = &__uvisor_cfgtbl_ptr_start + (uint32_t) dst_box_id; /* Get the IRQ handler. */ vector = g_uvisor_disabled_vectors[irqn].vector; if (!vector) { uvisor_error(USER_NOT_ALLOWED); } /* Switch contexts before and after executing the IRQ handler. */ uvisor_disabled_switch_in(dst_box_cfgtbl_ptr); ((void (*)(void)) vector)(); uvisor_disabled_switch_out(); }
static void uvisor_disabled_default_vector(void) { uint32_t irqn, vector; const uint32_t *dst_box_cfgtbl_ptr; uint8_t dst_box_id; int ipsr; /* Get current IRQ number, from the IPSR. * We only allow user IRQs to be registered (NVIC). This is consistent with * the corresponding API when uVisor is enabled. */ irqn = 0; ipsr = ((int) (__get_IPSR() & 0x1FF)) - NVIC_OFFSET; if (ipsr < 0 || ipsr >= NVIC_VECTORS) { uvisor_error(USER_NOT_ALLOWED); } else { irqn = (uint32_t) ipsr; } /* Calculate the destination box configuration pointer. */ dst_box_id = g_uvisor_disabled_vectors[irqn].box_id; dst_box_cfgtbl_ptr = &__uvisor_cfgtbl_ptr_start + (uint32_t) dst_box_id; /* Get the IRQ handler. */ vector = g_uvisor_disabled_vectors[irqn].vector; if (!vector) { uvisor_error(USER_NOT_ALLOWED); } /* Switch contexts before and after executing the IRQ handler. */ uvisor_disabled_switch_in(dst_box_cfgtbl_ptr); ((void (*)(void)) vector)(); uvisor_disabled_switch_out(); }