]>
Commit | Line | Data |
---|---|---|
3285cf4f AP |
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 | ||
41445300 | 9 | #include "hw/pci.h" |
3285cf4f AP |
10 | #include "hw/xen_common.h" |
11 | #include "hw/xen_backend.h" | |
12 | ||
41445300 AP |
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 | ||
9c11a8ac AP |
43 | /* Xen Interrupt Controller */ |
44 | ||
45 | static void xen_set_irq(void *opaque, int irq, int level) | |
46 | { | |
47 | xc_hvm_set_isa_irq_level(xen_xc, xen_domid, irq, level); | |
48 | } | |
49 | ||
50 | qemu_irq *xen_interrupt_controller_init(void) | |
51 | { | |
52 | return qemu_allocate_irqs(xen_set_irq, NULL, 16); | |
53 | } | |
54 | ||
29d3ccde AP |
55 | /* VCPU Operations, MMIO, IO ring ... */ |
56 | ||
57 | static void xen_reset_vcpu(void *opaque) | |
58 | { | |
59 | CPUState *env = opaque; | |
60 | ||
61 | env->halted = 1; | |
62 | } | |
63 | ||
64 | void xen_vcpu_init(void) | |
65 | { | |
66 | CPUState *first_cpu; | |
67 | ||
68 | if ((first_cpu = qemu_get_cpu(0))) { | |
69 | qemu_register_reset(xen_reset_vcpu, first_cpu); | |
70 | xen_reset_vcpu(first_cpu); | |
71 | } | |
72 | } | |
73 | ||
3285cf4f AP |
74 | /* Initialise Xen */ |
75 | ||
76 | int xen_init(void) | |
77 | { | |
78 | xen_xc = xen_xc_interface_open(0, 0, 0); | |
79 | if (xen_xc == XC_HANDLER_INITIAL_VALUE) { | |
80 | xen_be_printf(NULL, 0, "can't open xen interface\n"); | |
81 | return -1; | |
82 | } | |
83 | ||
84 | return 0; | |
85 | } | |
29d3ccde AP |
86 | |
87 | int xen_hvm_init(void) | |
88 | { | |
89 | return 0; | |
90 | } |