]> git.proxmox.com Git - mirror_qemu.git/blob - hw/display/vga-isa.c
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-3.0-pull-request...
[mirror_qemu.git] / hw / display / vga-isa.c
1 /*
2 * QEMU ISA VGA Emulator.
3 *
4 * see docs/specs/standard-vga.txt for virtual hardware specs.
5 *
6 * Copyright (c) 2003 Fabrice Bellard
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26 #include "qemu/osdep.h"
27 #include "hw/hw.h"
28 #include "hw/isa/isa.h"
29 #include "vga_int.h"
30 #include "ui/pixel_ops.h"
31 #include "qemu/timer.h"
32 #include "hw/loader.h"
33
34 #define TYPE_ISA_VGA "isa-vga"
35 #define ISA_VGA(obj) OBJECT_CHECK(ISAVGAState, (obj), TYPE_ISA_VGA)
36
37 typedef struct ISAVGAState {
38 ISADevice parent_obj;
39
40 struct VGACommonState state;
41 PortioList portio_vga;
42 PortioList portio_vbe;
43 } ISAVGAState;
44
45 static void vga_isa_reset(DeviceState *dev)
46 {
47 ISAVGAState *d = ISA_VGA(dev);
48 VGACommonState *s = &d->state;
49
50 vga_common_reset(s);
51 }
52
53 static void vga_isa_realizefn(DeviceState *dev, Error **errp)
54 {
55 ISADevice *isadev = ISA_DEVICE(dev);
56 ISAVGAState *d = ISA_VGA(dev);
57 VGACommonState *s = &d->state;
58 MemoryRegion *vga_io_memory;
59 const MemoryRegionPortio *vga_ports, *vbe_ports;
60
61 vga_common_init(s, OBJECT(dev), true);
62 s->legacy_address_space = isa_address_space(isadev);
63 vga_io_memory = vga_init_io(s, OBJECT(dev), &vga_ports, &vbe_ports);
64 isa_register_portio_list(isadev, &d->portio_vga,
65 0x3b0, vga_ports, s, "vga");
66 if (vbe_ports) {
67 isa_register_portio_list(isadev, &d->portio_vbe,
68 0x1ce, vbe_ports, s, "vbe");
69 }
70 memory_region_add_subregion_overlap(isa_address_space(isadev),
71 0x000a0000,
72 vga_io_memory, 1);
73 memory_region_set_coalescing(vga_io_memory);
74 s->con = graphic_console_init(DEVICE(dev), 0, s->hw_ops, s);
75
76 vga_init_vbe(s, OBJECT(dev), isa_address_space(isadev));
77 /* ROM BIOS */
78 rom_add_vga(VGABIOS_FILENAME);
79 }
80
81 static Property vga_isa_properties[] = {
82 DEFINE_PROP_UINT32("vgamem_mb", ISAVGAState, state.vram_size_mb, 8),
83 DEFINE_PROP_END_OF_LIST(),
84 };
85
86 static void vga_isa_class_initfn(ObjectClass *klass, void *data)
87 {
88 DeviceClass *dc = DEVICE_CLASS(klass);
89
90 dc->realize = vga_isa_realizefn;
91 dc->reset = vga_isa_reset;
92 dc->vmsd = &vmstate_vga_common;
93 dc->props = vga_isa_properties;
94 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
95 }
96
97 static const TypeInfo vga_isa_info = {
98 .name = TYPE_ISA_VGA,
99 .parent = TYPE_ISA_DEVICE,
100 .instance_size = sizeof(ISAVGAState),
101 .class_init = vga_isa_class_initfn,
102 };
103
104 static void vga_isa_register_types(void)
105 {
106 type_register_static(&vga_isa_info);
107 }
108
109 type_init(vga_isa_register_types)