3 #include "kvm/virtio-pci-dev.h"
4 #include "kvm/framebuffer.h"
5 #include "kvm/kvm-cpu.h"
6 #include "kvm/ioport.h"
13 #include <sys/types.h>
14 #include <sys/ioctl.h>
18 static bool vesa_pci_io_in(struct ioport
*ioport
, struct kvm
*kvm
, u16 port
, void *data
, int size
)
23 static bool vesa_pci_io_out(struct ioport
*ioport
, struct kvm
*kvm
, u16 port
, void *data
, int size
)
28 static struct ioport_operations vesa_io_ops
= {
29 .io_in
= vesa_pci_io_in
,
30 .io_out
= vesa_pci_io_out
,
33 static struct pci_device_header vesa_pci_device
= {
34 .vendor_id
= PCI_VENDOR_ID_REDHAT_QUMRANET
,
35 .device_id
= PCI_DEVICE_ID_VESA
,
36 .header_type
= PCI_HEADER_TYPE_NORMAL
,
39 .subsys_vendor_id
= PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET
,
40 .subsys_id
= PCI_SUBSYSTEM_ID_VESA
,
41 .bar
[1] = VESA_MEM_ADDR
| PCI_BASE_ADDRESS_SPACE_MEMORY
,
42 .bar_size
[1] = VESA_MEM_SIZE
,
45 static struct framebuffer vesafb
;
47 struct framebuffer
*vesa__init(struct kvm
*kvm
)
53 if (irq__register_device(PCI_DEVICE_ID_VESA
, &dev
, &pin
, &line
) < 0)
56 vesa_pci_device
.irq_pin
= pin
;
57 vesa_pci_device
.irq_line
= line
;
58 vesa_base_addr
= ioport__register(IOPORT_EMPTY
, &vesa_io_ops
, IOPORT_SIZE
, NULL
);
59 vesa_pci_device
.bar
[0] = vesa_base_addr
| PCI_BASE_ADDRESS_SPACE_IO
;
60 pci__register(&vesa_pci_device
, dev
);
62 mem
= mmap(NULL
, VESA_MEM_SIZE
, PROT_RW
, MAP_ANON_NORESERVE
, -1, 0);
63 if (mem
== MAP_FAILED
)
66 kvm__register_mem(kvm
, VESA_MEM_ADDR
, VESA_MEM_SIZE
, mem
);
68 vesafb
= (struct framebuffer
) {
70 .height
= VESA_HEIGHT
,
73 .mem_addr
= VESA_MEM_ADDR
,
74 .mem_size
= VESA_MEM_SIZE
,
76 return fb__register(&vesafb
);