]>
Commit | Line | Data |
---|---|---|
47d37dd9 JQ |
1 | /* |
2 | * QEMU PCI VGA Emulator. | |
3 | * | |
4 | * Copyright (c) 2003 Fabrice Bellard | |
5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 | * of this software and associated documentation files (the "Software"), to deal | |
8 | * in the Software without restriction, including without limitation the rights | |
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | * copies of the Software, and to permit persons to whom the Software is | |
11 | * furnished to do so, subject to the following conditions: | |
12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | |
15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
22 | * THE SOFTWARE. | |
23 | */ | |
24 | #include "hw.h" | |
25 | #include "console.h" | |
47d37dd9 | 26 | #include "pci.h" |
c1195d16 | 27 | #include "vga-pci.h" |
47d37dd9 JQ |
28 | #include "vga_int.h" |
29 | #include "pixel_ops.h" | |
30 | #include "qemu-timer.h" | |
5245d57a | 31 | #include "loader.h" |
47d37dd9 JQ |
32 | |
33 | typedef struct PCIVGAState { | |
34 | PCIDevice dev; | |
35 | VGACommonState vga; | |
36 | } PCIVGAState; | |
37 | ||
a4f9631c JQ |
38 | static const VMStateDescription vmstate_vga_pci = { |
39 | .name = "vga", | |
40 | .version_id = 2, | |
41 | .minimum_version_id = 2, | |
42 | .minimum_version_id_old = 2, | |
43 | .fields = (VMStateField []) { | |
44 | VMSTATE_PCI_DEVICE(dev, PCIVGAState), | |
45 | VMSTATE_STRUCT(vga, PCIVGAState, 0, vmstate_vga_common, VGACommonState), | |
46 | VMSTATE_END_OF_LIST() | |
47d37dd9 | 47 | } |
a4f9631c | 48 | }; |
47d37dd9 | 49 | |
47d37dd9 JQ |
50 | static int pci_vga_initfn(PCIDevice *dev) |
51 | { | |
52 | PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev); | |
53 | VGACommonState *s = &d->vga; | |
47d37dd9 JQ |
54 | |
55 | // vga + console init | |
4a1e244e | 56 | vga_common_init(s); |
0a039dc7 | 57 | vga_init(s, pci_address_space(dev), pci_address_space_io(dev), true); |
47d37dd9 JQ |
58 | |
59 | s->ds = graphic_console_init(s->update, s->invalidate, | |
60 | s->screen_dump, s->text_update, s); | |
61 | ||
47d37dd9 | 62 | /* XXX: VGA_RAM_SIZE must be a power of two */ |
e824b2cc | 63 | pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram); |
47d37dd9 | 64 | |
281a26b1 GH |
65 | if (!dev->rom_bar) { |
66 | /* compatibility with pc-0.13 and older */ | |
be20f9e9 | 67 | vga_init_vbe(s, pci_address_space(dev)); |
281a26b1 GH |
68 | } |
69 | ||
47d37dd9 JQ |
70 | return 0; |
71 | } | |
72 | ||
ad6d45fa | 73 | DeviceState *pci_vga_init(PCIBus *bus) |
47d37dd9 | 74 | { |
ad6d45fa | 75 | return &pci_create_simple(bus, -1, "VGA")->qdev; |
47d37dd9 JQ |
76 | } |
77 | ||
4a1e244e | 78 | static Property vga_pci_properties[] = { |
9e56edcf | 79 | DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState, vga.vram_size_mb, 16), |
4a1e244e GH |
80 | DEFINE_PROP_END_OF_LIST(), |
81 | }; | |
82 | ||
40021f08 AL |
83 | static void vga_class_init(ObjectClass *klass, void *data) |
84 | { | |
39bffca2 | 85 | DeviceClass *dc = DEVICE_CLASS(klass); |
40021f08 AL |
86 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
87 | ||
88 | k->no_hotplug = 1; | |
89 | k->init = pci_vga_initfn; | |
90 | k->romfile = "vgabios-stdvga.bin"; | |
91 | k->vendor_id = PCI_VENDOR_ID_QEMU; | |
92 | k->device_id = PCI_DEVICE_ID_QEMU_VGA; | |
93 | k->class_id = PCI_CLASS_DISPLAY_VGA; | |
39bffca2 | 94 | dc->vmsd = &vmstate_vga_pci; |
4a1e244e | 95 | dc->props = vga_pci_properties; |
40021f08 | 96 | } |
32902772 | 97 | |
39bffca2 AL |
98 | static TypeInfo vga_info = { |
99 | .name = "VGA", | |
100 | .parent = TYPE_PCI_DEVICE, | |
101 | .instance_size = sizeof(PCIVGAState), | |
102 | .class_init = vga_class_init, | |
47d37dd9 JQ |
103 | }; |
104 | ||
83f7d43a | 105 | static void vga_register_types(void) |
47d37dd9 | 106 | { |
39bffca2 | 107 | type_register_static(&vga_info); |
47d37dd9 | 108 | } |
83f7d43a AF |
109 | |
110 | type_init(vga_register_types) |