1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include "qemu/osdep.h"
28#include "hw/isa/isa.h"
29#include "vga_int.h"
30#include "ui/pixel_ops.h"
31#include "qemu/module.h"
32#include "qemu/timer.h"
33#include "hw/loader.h"
34#include "hw/qdev-properties.h"
35#include "qom/object.h"
36
37#define TYPE_ISA_VGA "isa-vga"
38OBJECT_DECLARE_SIMPLE_TYPE(ISAVGAState, ISA_VGA)
39
40struct ISAVGAState {
41 ISADevice parent_obj;
42
43 struct VGACommonState state;
44 PortioList portio_vga;
45 PortioList portio_vbe;
46};
47
48static void vga_isa_reset(DeviceState *dev)
49{
50 ISAVGAState *d = ISA_VGA(dev);
51 VGACommonState *s = &d->state;
52
53 vga_common_reset(s);
54}
55
56static void vga_isa_realizefn(DeviceState *dev, Error **errp)
57{
58 ISADevice *isadev = ISA_DEVICE(dev);
59 ISAVGAState *d = ISA_VGA(dev);
60 VGACommonState *s = &d->state;
61 MemoryRegion *vga_io_memory;
62 const MemoryRegionPortio *vga_ports, *vbe_ports;
63
64 s->global_vmstate = true;
65 vga_common_init(s, OBJECT(dev));
66 s->legacy_address_space = isa_address_space(isadev);
67 vga_io_memory = vga_init_io(s, OBJECT(dev), &vga_ports, &vbe_ports);
68 isa_register_portio_list(isadev, &d->portio_vga,
69 0x3b0, vga_ports, s, "vga");
70 if (vbe_ports) {
71 isa_register_portio_list(isadev, &d->portio_vbe,
72 0x1ce, vbe_ports, s, "vbe");
73 }
74 memory_region_add_subregion_overlap(isa_address_space(isadev),
75 0x000a0000,
76 vga_io_memory, 1);
77 memory_region_set_coalescing(vga_io_memory);
78 s->con = graphic_console_init(dev, 0, s->hw_ops, s);
79
80 memory_region_add_subregion(isa_address_space(isadev),
81 VBE_DISPI_LFB_PHYSICAL_ADDRESS,
82 &s->vram);
83
84 rom_add_vga(VGABIOS_FILENAME);
85}
86
87static Property vga_isa_properties[] = {
88 DEFINE_PROP_UINT32("vgamem_mb", ISAVGAState, state.vram_size_mb, 8),
89 DEFINE_PROP_END_OF_LIST(),
90};
91
92static void vga_isa_class_initfn(ObjectClass *klass, void *data)
93{
94 DeviceClass *dc = DEVICE_CLASS(klass);
95
96 dc->realize = vga_isa_realizefn;
97 dc->reset = vga_isa_reset;
98 dc->vmsd = &vmstate_vga_common;
99 device_class_set_props(dc, vga_isa_properties);
100 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
101}
102
103static const TypeInfo vga_isa_info = {
104 .name = TYPE_ISA_VGA,
105 .parent = TYPE_ISA_DEVICE,
106 .instance_size = sizeof(ISAVGAState),
107 .class_init = vga_isa_class_initfn,
108};
109
110static void vga_isa_register_types(void)
111{
112 type_register_static(&vga_isa_info);
113}
114
115type_init(vga_isa_register_types)
116