]> git.proxmox.com Git - mirror_qemu.git/blame - hw/display/vga-isa.c
isa: Use realizefn for ISADevice
[mirror_qemu.git] / hw / display / vga-isa.c
CommitLineData
76323919
JQ
1/*
2 * QEMU ISA VGA Emulator.
3 *
cc228248
GH
4 * see docs/specs/standard-vga.txt for virtual hardware specs.
5 *
76323919
JQ
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 */
83c9f4ca 26#include "hw/hw.h"
28ecbaee 27#include "ui/console.h"
0d09e41a 28#include "hw/i386/pc.h"
47b43a1f 29#include "vga_int.h"
28ecbaee 30#include "ui/pixel_ops.h"
1de7afc9 31#include "qemu/timer.h"
83c9f4ca 32#include "hw/loader.h"
76323919 33
a72dc5fc
AF
34#define TYPE_ISA_VGA "isa-vga"
35#define ISA_VGA(obj) OBJECT_CHECK(ISAVGAState, (obj), TYPE_ISA_VGA)
36
7435b791 37typedef struct ISAVGAState {
a72dc5fc
AF
38 ISADevice parent_obj;
39
7435b791
BS
40 struct VGACommonState state;
41} ISAVGAState;
42
a72dc5fc 43static void vga_isa_reset(DeviceState *dev)
76323919 44{
a72dc5fc 45 ISAVGAState *d = ISA_VGA(dev);
7435b791 46 VGACommonState *s = &d->state;
76323919 47
7435b791
BS
48 vga_common_reset(s);
49}
76323919 50
db895a1e 51static void vga_isa_realizefn(DeviceState *dev, Error **errp)
7435b791 52{
db895a1e 53 ISADevice *isadev = ISA_DEVICE(dev);
a72dc5fc 54 ISAVGAState *d = ISA_VGA(dev);
7435b791 55 VGACommonState *s = &d->state;
b1950430 56 MemoryRegion *vga_io_memory;
0a039dc7 57 const MemoryRegionPortio *vga_ports, *vbe_ports;
76323919 58
4a1e244e 59 vga_common_init(s);
db895a1e 60 s->legacy_address_space = isa_address_space(isadev);
0a039dc7 61 vga_io_memory = vga_init_io(s, &vga_ports, &vbe_ports);
db895a1e 62 isa_register_portio_list(isadev, 0x3b0, vga_ports, s, "vga");
0a039dc7 63 if (vbe_ports) {
db895a1e 64 isa_register_portio_list(isadev, 0x1ce, vbe_ports, s, "vbe");
0a039dc7 65 }
db895a1e 66 memory_region_add_subregion_overlap(isa_address_space(isadev),
b1950430
AK
67 isa_mem_base + 0x000a0000,
68 vga_io_memory, 1);
69 memory_region_set_coalescing(vga_io_memory);
aa2beaa1 70 s->con = graphic_console_init(DEVICE(dev), s->hw_ops, s);
76323919 71
db895a1e 72 vga_init_vbe(s, isa_address_space(isadev));
5245d57a
GH
73 /* ROM BIOS */
74 rom_add_vga(VGABIOS_FILENAME);
76323919 75}
7435b791 76
4a1e244e
GH
77static Property vga_isa_properties[] = {
78 DEFINE_PROP_UINT32("vgamem_mb", ISAVGAState, state.vram_size_mb, 8),
79 DEFINE_PROP_END_OF_LIST(),
80};
81
a72dc5fc 82static void vga_isa_class_initfn(ObjectClass *klass, void *data)
8f04ee08 83{
39bffca2 84 DeviceClass *dc = DEVICE_CLASS(klass);
a72dc5fc 85
db895a1e 86 dc->realize = vga_isa_realizefn;
a72dc5fc 87 dc->reset = vga_isa_reset;
39bffca2 88 dc->vmsd = &vmstate_vga_common;
4a1e244e 89 dc->props = vga_isa_properties;
8f04ee08
AL
90}
91
a72dc5fc
AF
92static const TypeInfo vga_isa_info = {
93 .name = TYPE_ISA_VGA,
39bffca2
AL
94 .parent = TYPE_ISA_DEVICE,
95 .instance_size = sizeof(ISAVGAState),
a72dc5fc 96 .class_init = vga_isa_class_initfn,
7435b791
BS
97};
98
a72dc5fc 99static void vga_isa_register_types(void)
7435b791 100{
a72dc5fc 101 type_register_static(&vga_isa_info);
7435b791 102}
83f7d43a 103
a72dc5fc 104type_init(vga_isa_register_types)