static int physdev_hvm_map_pirq( struct domain *d, int type, int *index, int *pirq) { int ret = 0; spin_lock(&d->event_lock); switch ( type ) { case MAP_PIRQ_TYPE_GSI: { const struct hvm_irq_dpci *hvm_irq_dpci; unsigned int machine_gsi = 0; if ( *index < 0 || *index >= NR_HVM_IRQS ) { ret = -EINVAL; break; } /* find the machine gsi corresponding to the * emulated gsi */ hvm_irq_dpci = domain_get_irq_dpci(d); if ( hvm_irq_dpci ) { const struct hvm_girq_dpci_mapping *girq; BUILD_BUG_ON(ARRAY_SIZE(hvm_irq_dpci->girq) < NR_HVM_IRQS); list_for_each_entry ( girq, &hvm_irq_dpci->girq[*index], list ) machine_gsi = girq->machine_gsi; } /* found one, this mean we are dealing with a pt device */ if ( machine_gsi ) { *index = domain_pirq_to_irq(d, machine_gsi); *pirq = machine_gsi; ret = (*pirq > 0) ? 0 : *pirq; } /* we didn't find any, this means we are dealing * with an emulated device */ else { if ( *pirq < 0 ) *pirq = get_free_pirq(d, type); ret = map_domain_emuirq_pirq(d, *pirq, *index); } break; } default: ret = -EINVAL; dprintk(XENLOG_G_WARNING, "map type %d not supported yet\n", type); break; } spin_unlock(&d->event_lock); return ret; }
static int physdev_hvm_map_pirq( struct domain *d, struct physdev_map_pirq *map) { int pirq, ret = 0; spin_lock(&d->event_lock); switch ( map->type ) { case MAP_PIRQ_TYPE_GSI: { struct hvm_irq_dpci *hvm_irq_dpci; struct hvm_girq_dpci_mapping *girq; uint32_t machine_gsi = 0; /* find the machine gsi corresponding to the * emulated gsi */ hvm_irq_dpci = domain_get_irq_dpci(d); if ( hvm_irq_dpci ) { list_for_each_entry ( girq, &hvm_irq_dpci->girq[map->index], list ) machine_gsi = girq->machine_gsi; } /* found one, this mean we are dealing with a pt device */ if ( machine_gsi ) { map->index = domain_pirq_to_irq(d, machine_gsi); pirq = machine_gsi; ret = (pirq > 0) ? 0 : pirq; } /* we didn't find any, this means we are dealing * with an emulated device */ else { pirq = map->pirq; if ( pirq < 0 ) pirq = get_free_pirq(d, map->type, map->index); ret = map_domain_emuirq_pirq(d, pirq, map->index); } map->pirq = pirq; break; } default: ret = -EINVAL; dprintk(XENLOG_G_WARNING, "map type %d not supported yet\n", map->type); break; } spin_unlock(&d->event_lock); return ret; }