#include <palacios/vmm_lock.h>
-typedef enum {V3_INVALID_INTR, V3_EXTERNAL_IRQ, V3_VIRTUAL_IRQ, V3_NMI, V3_SOFTWARE_INTR} v3_intr_type_t;
+typedef enum {V3_INVALID_INTR=0, V3_EXTERNAL_IRQ, V3_VIRTUAL_IRQ, V3_NMI, V3_SOFTWARE_INTR} v3_intr_type_t;
struct guest_info;
struct v3_vm_info;
void v3_remove_intr_router(struct v3_vm_info * vm, void * handle);
v3_intr_type_t v3_intr_pending(struct guest_info * info);
-uint32_t v3_get_intr(struct guest_info * info);
+int v3_get_intr(struct guest_info * info);
int v3_injecting_intr(struct guest_info * info, uint_t intr_num, v3_intr_type_t type);
// External IRQs have lowest priority
list_for_each_entry(ctrl, &(intr_state->controller_list), ctrl_node) {
- if (ctrl->ctrl_ops->intr_pending(info, ctrl->priv_data) == 1) {
+ if (ctrl->ctrl_ops->intr_pending(info, ctrl->priv_data)) {
ret = V3_EXTERNAL_IRQ;
break;
}
}
-uint32_t v3_get_intr(struct guest_info * info) {
+int v3_get_intr(struct guest_info * info) {
struct v3_intr_core_state * intr_state = &(info->intr_core_state);
struct intr_controller * ctrl = NULL;
- uint_t ret = 0;
+ int ret = -1;
int i = 0;
int j = 0;
+ int found_virq=0;
+ int found_irq=0;
addr_t irq_state = v3_lock_irqsave(intr_state->irq_lock);
for (j = 0; j < 8; j++) {
if (intr_state->virq_map[i] & (1 << j)) {
ret = (i * 8) + j;
+ // need to be able to find virq 0
+ found_virq=1;
break;
}
}
}
}
- if (!ret) {
+ if (!found_virq) {
list_for_each_entry(ctrl, &(intr_state->controller_list), ctrl_node) {
if (ctrl->ctrl_ops->intr_pending(info, ctrl->priv_data)) {
- uint_t intr_num = ctrl->ctrl_ops->get_intr_number(info, ctrl->priv_data);
+ int intr_num = ctrl->ctrl_ops->get_intr_number(info, ctrl->priv_data);
- // PrintDebug(info->vm_info, info, "[get_intr_number] intr_number = %d\n", intr_num);
- ret = intr_num;
- break;
+ if (intr_num >= 0) {
+ // PrintDebug(info->vm_info, info, "[get_intr_number] intr_number = %d\n", intr_num);
+ ret = intr_num;
+ found_irq=1;
+ break;
+ }
+
}
}
}
v3_unlock_irqrestore(intr_state->irq_lock, irq_state);
+ if (!found_virq && !found_irq) {
+ PrintError(info->vm_info,info,"Strange... neither a VIRQ nor an IRQ was found...\n");
+ }
+
return ret;
}