Skip to content

Commit

Permalink
fix(irq): include verbose output to assess interrupt reservation
Browse files Browse the repository at this point in the history
Signed-off-by: Diogo Costa <[email protected]>
  • Loading branch information
Diogo21Costa committed Oct 12, 2023
1 parent 27fde53 commit df3168c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/core/inc/interrupts.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct vm;
typedef void (*irq_handler_t)(irqid_t int_id);

void interrupts_init();
void interrupts_reserve(irqid_t int_id, irq_handler_t handler);
bool interrupts_reserve(irqid_t int_id, irq_handler_t handler);

void interrupts_cpu_sendipi(cpuid_t target_cpu, irqid_t ipi_id);
void interrupts_cpu_enable(irqid_t int_id, bool en);
Expand All @@ -27,7 +27,7 @@ void interrupts_clear(irqid_t int_id);
enum irq_res { HANDLED_BY_HYP, FORWARD_TO_VM };
enum irq_res interrupts_handle(irqid_t int_id);

void interrupts_vm_assign(struct vm *vm, irqid_t id);
bool interrupts_vm_assign(struct vm *vm, irqid_t id);

/* Must be implemented by architecture */

Expand Down
26 changes: 17 additions & 9 deletions src/core/interrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,35 @@ enum irq_res interrupts_handle(irqid_t int_id)
}
}

void interrupts_vm_assign(struct vm *vm, irqid_t id)
bool interrupts_vm_assign(struct vm *vm, irqid_t id)
{
spin_lock(&irq_reserve_lock);
if (interrupts_arch_conflict(global_interrupt_bitmap, id)) {
ERROR("Interrupts conflict, id = %d\n", id);
}
bool ret = false;

interrupts_arch_vm_assign(vm, id);
spin_lock(&irq_reserve_lock);
if (!interrupts_arch_conflict(global_interrupt_bitmap, id)) {
ret = true;
interrupts_arch_vm_assign(vm, id);

bitmap_set(vm->interrupt_bitmap, id);
bitmap_set(global_interrupt_bitmap, id);
bitmap_set(vm->interrupt_bitmap, id);
bitmap_set(global_interrupt_bitmap, id);
}
spin_unlock(&irq_reserve_lock);

return ret;
}

void interrupts_reserve(irqid_t int_id, irq_handler_t handler)
bool interrupts_reserve(irqid_t int_id, irq_handler_t handler)
{
bool ret = false;

spin_lock(&irq_reserve_lock);
if ((int_id < MAX_INTERRUPTS) && !interrupt_assigned(int_id)) {
ret = true;
interrupt_handlers[int_id] = handler;
bitmap_set(hyp_interrupt_bitmap, int_id);
bitmap_set(global_interrupt_bitmap, int_id);
}
spin_unlock(&irq_reserve_lock);

return ret;
}

0 comments on commit df3168c

Please sign in to comment.