--- /dev/null
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+
+#include "private.h"
+
+int xendevicemodel_set_pci_intx_level(xendevicemodel_handle *dm,
+ uint8_t domain, uint8_t bus, uint8_t dev,
+ uint8_t intx, bool assert)
+{
+ xen_hvm_set_pci_intx_level_t *arg;
+ int ret = -1;
+
+ arg = xencall_alloc_buffer(dm->call, sizeof(*arg));
+ if ( arg == NULL )
+ {
+ LOGE(ERROR, "unable to allocate memory for set PCI INTx hypercall");
+ goto err;
+ }
+
+ arg->domid = dm->domid;
+ arg->domain = domain;
+ arg->bus = bus;
+ arg->device = dev;
+ arg->intx = intx;
+ arg->level = assert ? 1 : 0;
+
+ ret = xencall2(dm->call, __HYPERVISOR_hvm_op,
+ HVMOP_set_pci_intx_level,
+ (uintptr_t)(arg));
+
+ if ( ret )
+ LOGE(ERROR, "set PCI INTx hypercall failed");
+
+ xencall_free_buffer(dm->call, arg);
+
+ err:
+ return ret;
+}
+
+int xendevicemodel_route_pci_intx_to_isa_irq(xendevicemodel_handle *dm,
+ uint8_t intx, uint8_t isa_irq)
+{
+ xen_hvm_set_pci_link_route_t *arg;
+ int ret = -1;
+
+ arg = xencall_alloc_buffer(dm->call, sizeof(*arg));
+ if ( arg == NULL )
+ {
+ LOGE(ERROR,
+ "unable to allocate memory for route PCI INTx to ISA IRQ hypercall");
+ goto err;
+ }
+
+ arg->domid = dm->domid;
+ arg->link = intx;
+ arg->isa_irq = isa_irq;
+
+ ret = xencall2(dm->call, __HYPERVISOR_hvm_op,
+ HVMOP_set_pci_link_route,
+ (uintptr_t)arg);
+
+ if ( ret )
+ LOGE(ERROR, "route PCI INTx to ISA IRQ hypercall failed");
+
+ xencall_free_buffer(dm->call, arg);
+
+ err:
+ return ret;
+}
+
+int xendevicemodel_set_isa_irq_level(xendevicemodel_handle *dm,
+ uint8_t isa_irq, bool assert)
+{
+ xen_hvm_set_isa_irq_level_t *arg;
+ int ret = -1;
+
+ arg = xencall_alloc_buffer(dm->call, sizeof(*arg));
+ if ( arg == NULL )
+ {
+ LOGE(ERROR, "unable to allocate memory for set ISA IRQ level hypercall");
+ goto err;
+ }
+
+ arg->domid = dm->domid;
+ arg->isa_irq = isa_irq;
+ arg->level = assert ? 1 : 0;
+
+ ret = xencall2(dm->call, __HYPERVISOR_hvm_op,
+ HVMOP_set_isa_irq_level,
+ (uintptr_t)arg);
+
+ if ( ret )
+ LOGE(ERROR, "set ISA IRQ level hypercall failed");
+
+ xencall_free_buffer(dm->call, arg);
+
+ err:
+ return ret;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
/*
* Indicate domain lifecycle changes to the hypervisor.
+ * ====================================================
*
* shutdown, reboot and s3_suspend indicate to the hypervisor that
* emulation has resulted in the given guest behaviour.
int xendevicemodel_s3_suspend(xendevicemodel_handle *dm);
int xendevicemodel_s3_awaken(xendevicemodel_handle *dm);
+/*
+ * Emulated interrupt control and injection.
+ * =========================================
+ *
+ * For PCI INTX and ISA IRQ related functions:
+ *
+ * @intx PCI INTA (=0) thru INTD (=3).
+ * @isa_irq ISA IRQ 0..15 (inclusive).
+ * @assert Whether the given interrupt of the given type should be
+ * asserted or deasserted.
+ */
+int xendevicemodel_set_pci_intx_level(xendevicemodel_handle *dm,
+ uint8_t domain, uint8_t bus, uint8_t dev,
+ uint8_t intx, bool assert);
+int xendevicemodel_route_pci_intx_to_isa_irq(xendevicemodel_handle *dm,
+ uint8_t intx, uint8_t isa_irq);
+int xendevicemodel_set_isa_irq_level(xendevicemodel_handle *dm,
+ uint8_t isa_irq, bool assert);
+
#endif
/*
* Local variables: