2 * QEMU PCI VGA Emulator.
4 * Copyright (c) 2003 Fabrice Bellard
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
28 #include "pixel_ops.h"
29 #include "qemu-timer.h"
32 typedef struct PCIVGAState
{
37 static const VMStateDescription vmstate_vga_pci
= {
40 .minimum_version_id
= 2,
41 .minimum_version_id_old
= 2,
42 .fields
= (VMStateField
[]) {
43 VMSTATE_PCI_DEVICE(dev
, PCIVGAState
),
44 VMSTATE_STRUCT(vga
, PCIVGAState
, 0, vmstate_vga_common
, VGACommonState
),
49 static int pci_std_vga_initfn(PCIDevice
*dev
)
51 PCIVGAState
*d
= DO_UPCAST(PCIVGAState
, dev
, dev
);
52 VGACommonState
*s
= &d
->vga
;
56 vga_init(s
, pci_address_space(dev
), pci_address_space_io(dev
), true);
58 s
->ds
= graphic_console_init(s
->update
, s
->invalidate
,
59 s
->screen_dump
, s
->text_update
, s
);
61 /* XXX: VGA_RAM_SIZE must be a power of two */
62 pci_register_bar(&d
->dev
, 0, PCI_BASE_ADDRESS_MEM_PREFETCH
, &s
->vram
);
65 /* compatibility with pc-0.13 and older */
66 vga_init_vbe(s
, pci_address_space(dev
));
72 static Property vga_pci_properties
[] = {
73 DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState
, vga
.vram_size_mb
, 16),
74 DEFINE_PROP_END_OF_LIST(),
77 static void vga_class_init(ObjectClass
*klass
, void *data
)
79 DeviceClass
*dc
= DEVICE_CLASS(klass
);
80 PCIDeviceClass
*k
= PCI_DEVICE_CLASS(klass
);
83 k
->init
= pci_std_vga_initfn
;
84 k
->romfile
= "vgabios-stdvga.bin";
85 k
->vendor_id
= PCI_VENDOR_ID_QEMU
;
86 k
->device_id
= PCI_DEVICE_ID_QEMU_VGA
;
87 k
->class_id
= PCI_CLASS_DISPLAY_VGA
;
88 dc
->vmsd
= &vmstate_vga_pci
;
89 dc
->props
= vga_pci_properties
;
92 static TypeInfo vga_info
= {
94 .parent
= TYPE_PCI_DEVICE
,
95 .instance_size
= sizeof(PCIVGAState
),
96 .class_init
= vga_class_init
,
99 static void vga_register_types(void)
101 type_register_static(&vga_info
);
104 type_init(vga_register_types
)