]>
Commit | Line | Data |
---|---|---|
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 | */ | |
0b8fa32f | 26 | |
47df5154 | 27 | #include "qemu/osdep.h" |
866e2b37 | 28 | #include "hw/isa/isa.h" |
47b43a1f | 29 | #include "vga_int.h" |
28ecbaee | 30 | #include "ui/pixel_ops.h" |
0b8fa32f | 31 | #include "qemu/module.h" |
1de7afc9 | 32 | #include "qemu/timer.h" |
83c9f4ca | 33 | #include "hw/loader.h" |
a27bd6c7 | 34 | #include "hw/qdev-properties.h" |
db1015e9 | 35 | #include "qom/object.h" |
76323919 | 36 | |
a72dc5fc | 37 | #define TYPE_ISA_VGA "isa-vga" |
8063396b | 38 | OBJECT_DECLARE_SIMPLE_TYPE(ISAVGAState, ISA_VGA) |
a72dc5fc | 39 | |
db1015e9 | 40 | struct ISAVGAState { |
a72dc5fc AF |
41 | ISADevice parent_obj; |
42 | ||
7435b791 | 43 | struct VGACommonState state; |
e305a165 MAL |
44 | PortioList portio_vga; |
45 | PortioList portio_vbe; | |
db1015e9 | 46 | }; |
7435b791 | 47 | |
a72dc5fc | 48 | static void vga_isa_reset(DeviceState *dev) |
76323919 | 49 | { |
a72dc5fc | 50 | ISAVGAState *d = ISA_VGA(dev); |
7435b791 | 51 | VGACommonState *s = &d->state; |
76323919 | 52 | |
7435b791 BS |
53 | vga_common_reset(s); |
54 | } | |
76323919 | 55 | |
db895a1e | 56 | static void vga_isa_realizefn(DeviceState *dev, Error **errp) |
7435b791 | 57 | { |
db895a1e | 58 | ISADevice *isadev = ISA_DEVICE(dev); |
a72dc5fc | 59 | ISAVGAState *d = ISA_VGA(dev); |
7435b791 | 60 | VGACommonState *s = &d->state; |
b1950430 | 61 | MemoryRegion *vga_io_memory; |
0a039dc7 | 62 | const MemoryRegionPortio *vga_ports, *vbe_ports; |
76323919 | 63 | |
1fcfdc43 GH |
64 | s->global_vmstate = true; |
65 | vga_common_init(s, OBJECT(dev)); | |
db895a1e | 66 | s->legacy_address_space = isa_address_space(isadev); |
c84b28ee | 67 | vga_io_memory = vga_init_io(s, OBJECT(dev), &vga_ports, &vbe_ports); |
e305a165 MAL |
68 | isa_register_portio_list(isadev, &d->portio_vga, |
69 | 0x3b0, vga_ports, s, "vga"); | |
0a039dc7 | 70 | if (vbe_ports) { |
e305a165 MAL |
71 | isa_register_portio_list(isadev, &d->portio_vbe, |
72 | 0x1ce, vbe_ports, s, "vbe"); | |
0a039dc7 | 73 | } |
db895a1e | 74 | memory_region_add_subregion_overlap(isa_address_space(isadev), |
b19c1c08 | 75 | 0x000a0000, |
b1950430 AK |
76 | vga_io_memory, 1); |
77 | memory_region_set_coalescing(vga_io_memory); | |
8e5c952b | 78 | s->con = graphic_console_init(dev, 0, s->hw_ops, s); |
76323919 | 79 | |
e2328a11 PB |
80 | memory_region_add_subregion(isa_address_space(isadev), |
81 | VBE_DISPI_LFB_PHYSICAL_ADDRESS, | |
82 | &s->vram); | |
5245d57a GH |
83 | /* ROM BIOS */ |
84 | rom_add_vga(VGABIOS_FILENAME); | |
76323919 | 85 | } |
7435b791 | 86 | |
4a1e244e GH |
87 | static Property vga_isa_properties[] = { |
88 | DEFINE_PROP_UINT32("vgamem_mb", ISAVGAState, state.vram_size_mb, 8), | |
89 | DEFINE_PROP_END_OF_LIST(), | |
90 | }; | |
91 | ||
a72dc5fc | 92 | static void vga_isa_class_initfn(ObjectClass *klass, void *data) |
8f04ee08 | 93 | { |
39bffca2 | 94 | DeviceClass *dc = DEVICE_CLASS(klass); |
a72dc5fc | 95 | |
db895a1e | 96 | dc->realize = vga_isa_realizefn; |
a72dc5fc | 97 | dc->reset = vga_isa_reset; |
39bffca2 | 98 | dc->vmsd = &vmstate_vga_common; |
4f67d30b | 99 | device_class_set_props(dc, vga_isa_properties); |
125ee0ed | 100 | set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); |
8f04ee08 AL |
101 | } |
102 | ||
a72dc5fc AF |
103 | static const TypeInfo vga_isa_info = { |
104 | .name = TYPE_ISA_VGA, | |
39bffca2 AL |
105 | .parent = TYPE_ISA_DEVICE, |
106 | .instance_size = sizeof(ISAVGAState), | |
a72dc5fc | 107 | .class_init = vga_isa_class_initfn, |
7435b791 BS |
108 | }; |
109 | ||
a72dc5fc | 110 | static void vga_isa_register_types(void) |
7435b791 | 111 | { |
a72dc5fc | 112 | type_register_static(&vga_isa_info); |
7435b791 | 113 | } |
83f7d43a | 114 | |
a72dc5fc | 115 | type_init(vga_isa_register_types) |