piix_pci: Introduces Xen specific call for irq.
[qemu.git] / xen-all.c
blobacb051cffc4cbe04e93af352d91ce214a1a23c3f
1 /*
2 * Copyright (C) 2010 Citrix Ltd.
4 * This work is licensed under the terms of the GNU GPL, version 2. See
5 * the COPYING file in the top-level directory.
7 */
9 #include "hw/pci.h"
10 #include "hw/xen_common.h"
11 #include "hw/xen_backend.h"
13 /* Xen specific function for piix pci */
15 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
17 return irq_num + ((pci_dev->devfn >> 3) << 2);
20 void xen_piix3_set_irq(void *opaque, int irq_num, int level)
22 xc_hvm_set_pci_intx_level(xen_xc, xen_domid, 0, 0, irq_num >> 2,
23 irq_num & 3, level);
26 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
28 int i;
30 /* Scan for updates to PCI link routes (0x60-0x63). */
31 for (i = 0; i < len; i++) {
32 uint8_t v = (val >> (8 * i)) & 0xff;
33 if (v & 0x80) {
34 v = 0;
36 v &= 0xf;
37 if (((address + i) >= 0x60) && ((address + i) <= 0x63)) {
38 xc_hvm_set_pci_link_route(xen_xc, xen_domid, address + i - 0x60, v);
43 /* VCPU Operations, MMIO, IO ring ... */
45 static void xen_reset_vcpu(void *opaque)
47 CPUState *env = opaque;
49 env->halted = 1;
52 void xen_vcpu_init(void)
54 CPUState *first_cpu;
56 if ((first_cpu = qemu_get_cpu(0))) {
57 qemu_register_reset(xen_reset_vcpu, first_cpu);
58 xen_reset_vcpu(first_cpu);
62 /* Initialise Xen */
64 int xen_init(void)
66 xen_xc = xen_xc_interface_open(0, 0, 0);
67 if (xen_xc == XC_HANDLER_INITIAL_VALUE) {
68 xen_be_printf(NULL, 0, "can't open xen interface\n");
69 return -1;
72 return 0;
75 int xen_hvm_init(void)
77 return 0;