]>
git.proxmox.com Git - mirror_qemu.git/blob - hw/xen/xen_pt_graphics.c
5 #include "xen-host-pci-device.h"
6 #include "hw/xen/xen_backend.h"
8 typedef struct VGARegion
{
9 int type
; /* Memory or port I/O */
10 uint64_t guest_base_addr
;
11 uint64_t machine_base_addr
;
12 uint64_t size
; /* size of the region */
16 #define IORESOURCE_IO 0x00000100
17 #define IORESOURCE_MEM 0x00000200
19 static struct VGARegion vga_args
[] = {
21 .type
= IORESOURCE_IO
,
22 .guest_base_addr
= 0x3B0,
23 .machine_base_addr
= 0x3B0,
28 .type
= IORESOURCE_IO
,
29 .guest_base_addr
= 0x3C0,
30 .machine_base_addr
= 0x3C0,
35 .type
= IORESOURCE_MEM
,
36 .guest_base_addr
= 0xa0000 >> XC_PAGE_SHIFT
,
37 .machine_base_addr
= 0xa0000 >> XC_PAGE_SHIFT
,
44 * register VGA resources for the domain with assigned gfx
46 int xen_pt_register_vga_regions(XenHostPCIDevice
*dev
)
50 if (!is_igd_vga_passthrough(dev
)) {
54 for (i
= 0 ; i
< ARRAY_SIZE(vga_args
); i
++) {
55 if (vga_args
[i
].type
== IORESOURCE_IO
) {
56 vga_args
[i
].rc
= xc_domain_ioport_mapping(xen_xc
, xen_domid
,
57 vga_args
[i
].guest_base_addr
,
58 vga_args
[i
].machine_base_addr
,
59 vga_args
[i
].size
, DPCI_ADD_MAPPING
);
61 vga_args
[i
].rc
= xc_domain_memory_mapping(xen_xc
, xen_domid
,
62 vga_args
[i
].guest_base_addr
,
63 vga_args
[i
].machine_base_addr
,
64 vga_args
[i
].size
, DPCI_ADD_MAPPING
);
68 XEN_PT_ERR(NULL
, "VGA %s mapping failed! (rc: %i)\n",
69 vga_args
[i
].type
== IORESOURCE_IO
? "ioport" : "memory",
71 return vga_args
[i
].rc
;
79 * unregister VGA resources for the domain with assigned gfx
81 int xen_pt_unregister_vga_regions(XenHostPCIDevice
*dev
)
85 if (!is_igd_vga_passthrough(dev
)) {
89 for (i
= 0 ; i
< ARRAY_SIZE(vga_args
); i
++) {
90 if (vga_args
[i
].type
== IORESOURCE_IO
) {
91 vga_args
[i
].rc
= xc_domain_ioport_mapping(xen_xc
, xen_domid
,
92 vga_args
[i
].guest_base_addr
,
93 vga_args
[i
].machine_base_addr
,
94 vga_args
[i
].size
, DPCI_REMOVE_MAPPING
);
96 vga_args
[i
].rc
= xc_domain_memory_mapping(xen_xc
, xen_domid
,
97 vga_args
[i
].guest_base_addr
,
98 vga_args
[i
].machine_base_addr
,
99 vga_args
[i
].size
, DPCI_REMOVE_MAPPING
);
102 if (vga_args
[i
].rc
) {
103 XEN_PT_ERR(NULL
, "VGA %s unmapping failed! (rc: %i)\n",
104 vga_args
[i
].type
== IORESOURCE_IO
? "ioport" : "memory",
106 return vga_args
[i
].rc
;