]> git.proxmox.com Git - qemu.git/blob - xen-all.c
piix_pci: Introduces Xen specific call for irq.
[qemu.git] / xen-all.c
1 /*
2 * Copyright (C) 2010 Citrix Ltd.
3 *
4 * This work is licensed under the terms of the GNU GPL, version 2. See
5 * the COPYING file in the top-level directory.
6 *
7 */
8
9 #include "hw/pci.h"
10 #include "hw/xen_common.h"
11 #include "hw/xen_backend.h"
12
13 /* Xen specific function for piix pci */
14
15 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
16 {
17 return irq_num + ((pci_dev->devfn >> 3) << 2);
18 }
19
20 void xen_piix3_set_irq(void *opaque, int irq_num, int level)
21 {
22 xc_hvm_set_pci_intx_level(xen_xc, xen_domid, 0, 0, irq_num >> 2,
23 irq_num & 3, level);
24 }
25
26 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
27 {
28 int i;
29
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;
35 }
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);
39 }
40 }
41 }
42
43 /* VCPU Operations, MMIO, IO ring ... */
44
45 static void xen_reset_vcpu(void *opaque)
46 {
47 CPUState *env = opaque;
48
49 env->halted = 1;
50 }
51
52 void xen_vcpu_init(void)
53 {
54 CPUState *first_cpu;
55
56 if ((first_cpu = qemu_get_cpu(0))) {
57 qemu_register_reset(xen_reset_vcpu, first_cpu);
58 xen_reset_vcpu(first_cpu);
59 }
60 }
61
62 /* Initialise Xen */
63
64 int xen_init(void)
65 {
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;
70 }
71
72 return 0;
73 }
74
75 int xen_hvm_init(void)
76 {
77 return 0;
78 }