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.
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,
26 void xen_piix_pci_write_config_client(uint32_t address
, uint32_t val
, int len
)
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;
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
;
52 void xen_vcpu_init(void)
56 if ((first_cpu
= qemu_get_cpu(0))) {
57 qemu_register_reset(xen_reset_vcpu
, first_cpu
);
58 xen_reset_vcpu(first_cpu
);
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");
75 int xen_hvm_init(void)