uint8_t trig_mode_reg[32];
struct {
- int (*ack)(struct guest_info * core, uint8_t irq, void * private_data);
+ int (*ack)(struct guest_info * core, uint32_t irq, void * private_data);
void * private_data;
} irq_ack_cbs[256];
*req_location |= flag;
apic->irq_ack_cbs[irq_num].ack = ack;
apic->irq_ack_cbs[irq_num].private_data = private_data;
+
return 1;
} else {
PrintDebug("apic %u: core %d: Interrupt not enabled... %.2x\n",
static void drain_irq_entries(struct apic_state * apic) {
-
while (1) {
unsigned int flags = 0;
struct irq_queue_entry * entry = NULL;
static int get_highest_isr(struct apic_state * apic) {
int i = 0, j = 0;
- // We iterate backwards to find the highest priority
+ // We iterate backwards to find the highest priority in-service request
for (i = 31; i >= 0; i--) {
uint8_t * svc_major = apic->int_svc_reg + i;
static int get_highest_irr(struct apic_state * apic) {
int i = 0, j = 0;
- // We iterate backwards to find the highest priority
+ // We iterate backwards to find the highest priority enabled requested interrupt
for (i = 31; i >= 0; i--) {
uint8_t * req_major = apic->int_req_reg + i;
-
+ uint8_t * en_major = apic->int_en_reg + i;
+
if ((*req_major) & 0xff) {
for (j = 7; j >= 0; j--) {
uint8_t flag = 0x1 << j;
- if ((*req_major) & flag) {
+ if ((*req_major & *en_major) & flag) {
return ((i * 8) + j);
}
}
add_apic_irq_entry(dst_apic, ipi->vector, ipi->ack, ipi->private_data);
-#ifdef V3_CONFIG_MULTITHREAD_OS
if (dst_apic != src_apic) {
PrintDebug(" non-local core with new interrupt, forcing it to exit now\n");
v3_interrupt_cpu(dst_core->vm_info, dst_core->pcpu_id, 0);
}
-#endif
-
break;
}
apic_dev = (struct apic_dev_state *)V3_Malloc(sizeof(struct apic_dev_state) +
sizeof(struct apic_state) * vm->num_cores);
+
+ if (!apic_dev) {
+ PrintError("Failed to allocate space for APIC\n");
+ return -1;
+ }
+
apic_dev->num_apics = vm->num_cores;
v3_lock_init(&(apic_dev->state_lock));