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#include "qemu/osdep.h"
27#include "hw/hw.h"
28#include "ui/console.h"
29#include "hw/i386/pc.h"
30#include "vga_int.h"
31#include "ui/pixel_ops.h"
32#include "qemu/timer.h"
33#include "hw/loader.h"
34
35#define TYPE_ISA_VGA "isa-vga"
36#define ISA_VGA(obj) OBJECT_CHECK(ISAVGAState, (obj), TYPE_ISA_VGA)
37
38typedef struct ISAVGAState {
39 ISADevice parent_obj;
40
41 struct VGACommonState state;
42} ISAVGAState;
43
44static void vga_isa_reset(DeviceState *dev)
45{
46 ISAVGAState *d = ISA_VGA(dev);
47 VGACommonState *s = &d->state;
48
49 vga_common_reset(s);
50}
51
52static void vga_isa_realizefn(DeviceState *dev, Error **errp)
53{
54 ISADevice *isadev = ISA_DEVICE(dev);
55 ISAVGAState *d = ISA_VGA(dev);
56 VGACommonState *s = &d->state;
57 MemoryRegion *vga_io_memory;
58 const MemoryRegionPortio *vga_ports, *vbe_ports;
59
60 vga_common_init(s, OBJECT(dev), true);
61 s->legacy_address_space = isa_address_space(isadev);
62 vga_io_memory = vga_init_io(s, OBJECT(dev), &vga_ports, &vbe_ports);
63 isa_register_portio_list(isadev, 0x3b0, vga_ports, s, "vga");
64 if (vbe_ports) {
65 isa_register_portio_list(isadev, 0x1ce, vbe_ports, s, "vbe");
66 }
67 memory_region_add_subregion_overlap(isa_address_space(isadev),
68 0x000a0000,
69 vga_io_memory, 1);
70 memory_region_set_coalescing(vga_io_memory);
71 s->con = graphic_console_init(DEVICE(dev), 0, s->hw_ops, s);
72
73 vga_init_vbe(s, OBJECT(dev), isa_address_space(isadev));
74
75 rom_add_vga(VGABIOS_FILENAME);
76}
77
78static Property vga_isa_properties[] = {
79 DEFINE_PROP_UINT32("vgamem_mb", ISAVGAState, state.vram_size_mb, 8),
80 DEFINE_PROP_END_OF_LIST(),
81};
82
83static void vga_isa_class_initfn(ObjectClass *klass, void *data)
84{
85 DeviceClass *dc = DEVICE_CLASS(klass);
86
87 dc->realize = vga_isa_realizefn;
88 dc->reset = vga_isa_reset;
89 dc->vmsd = &vmstate_vga_common;
90 dc->props = vga_isa_properties;
91 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
92}
93
94static const TypeInfo vga_isa_info = {
95 .name = TYPE_ISA_VGA,
96 .parent = TYPE_ISA_DEVICE,
97 .instance_size = sizeof(ISAVGAState),
98 .class_init = vga_isa_class_initfn,
99};
100
101static void vga_isa_register_types(void)
102{
103 type_register_static(&vga_isa_info);
104}
105
106type_init(vga_isa_register_types)
107