Statistics
| Branch: | Revision:

root / hw / vga-isa.c @ ae710b99

History | View | Annotate | Download (3 kB)

1 76323919 Juan Quintela
/*
2 76323919 Juan Quintela
 * QEMU ISA VGA Emulator.
3 76323919 Juan Quintela
 *
4 76323919 Juan Quintela
 * Copyright (c) 2003 Fabrice Bellard
5 76323919 Juan Quintela
 *
6 76323919 Juan Quintela
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 76323919 Juan Quintela
 * of this software and associated documentation files (the "Software"), to deal
8 76323919 Juan Quintela
 * in the Software without restriction, including without limitation the rights
9 76323919 Juan Quintela
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 76323919 Juan Quintela
 * copies of the Software, and to permit persons to whom the Software is
11 76323919 Juan Quintela
 * furnished to do so, subject to the following conditions:
12 76323919 Juan Quintela
 *
13 76323919 Juan Quintela
 * The above copyright notice and this permission notice shall be included in
14 76323919 Juan Quintela
 * all copies or substantial portions of the Software.
15 76323919 Juan Quintela
 *
16 76323919 Juan Quintela
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 76323919 Juan Quintela
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 76323919 Juan Quintela
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 76323919 Juan Quintela
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 76323919 Juan Quintela
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 76323919 Juan Quintela
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 76323919 Juan Quintela
 * THE SOFTWARE.
23 76323919 Juan Quintela
 */
24 76323919 Juan Quintela
#include "hw.h"
25 76323919 Juan Quintela
#include "console.h"
26 76323919 Juan Quintela
#include "pc.h"
27 76323919 Juan Quintela
#include "vga_int.h"
28 76323919 Juan Quintela
#include "pixel_ops.h"
29 76323919 Juan Quintela
#include "qemu-timer.h"
30 5245d57a Gerd Hoffmann
#include "loader.h"
31 76323919 Juan Quintela
32 7435b791 Blue Swirl
typedef struct ISAVGAState {
33 7435b791 Blue Swirl
    ISADevice dev;
34 7435b791 Blue Swirl
    struct VGACommonState state;
35 7435b791 Blue Swirl
} ISAVGAState;
36 7435b791 Blue Swirl
37 7435b791 Blue Swirl
static void vga_reset_isa(DeviceState *dev)
38 76323919 Juan Quintela
{
39 7435b791 Blue Swirl
    ISAVGAState *d = container_of(dev, ISAVGAState, dev.qdev);
40 7435b791 Blue Swirl
    VGACommonState *s = &d->state;
41 76323919 Juan Quintela
42 7435b791 Blue Swirl
    vga_common_reset(s);
43 7435b791 Blue Swirl
}
44 76323919 Juan Quintela
45 7435b791 Blue Swirl
static int vga_initfn(ISADevice *dev)
46 7435b791 Blue Swirl
{
47 7435b791 Blue Swirl
    ISAVGAState *d = DO_UPCAST(ISAVGAState, dev, dev);
48 7435b791 Blue Swirl
    VGACommonState *s = &d->state;
49 b1950430 Avi Kivity
    MemoryRegion *vga_io_memory;
50 0a039dc7 Richard Henderson
    const MemoryRegionPortio *vga_ports, *vbe_ports;
51 76323919 Juan Quintela
52 7435b791 Blue Swirl
    vga_common_init(s, VGA_RAM_SIZE);
53 53d6e682 Jan Kiszka
    s->legacy_address_space = isa_address_space(dev);
54 0a039dc7 Richard Henderson
    vga_io_memory = vga_init_io(s, &vga_ports, &vbe_ports);
55 0a039dc7 Richard Henderson
    isa_register_portio_list(dev, 0x3b0, vga_ports, s, "vga");
56 0a039dc7 Richard Henderson
    if (vbe_ports) {
57 0a039dc7 Richard Henderson
        isa_register_portio_list(dev, 0x1ce, vbe_ports, s, "vbe");
58 0a039dc7 Richard Henderson
    }
59 be20f9e9 Avi Kivity
    memory_region_add_subregion_overlap(isa_address_space(dev),
60 b1950430 Avi Kivity
                                        isa_mem_base + 0x000a0000,
61 b1950430 Avi Kivity
                                        vga_io_memory, 1);
62 b1950430 Avi Kivity
    memory_region_set_coalescing(vga_io_memory);
63 76323919 Juan Quintela
    s->ds = graphic_console_init(s->update, s->invalidate,
64 76323919 Juan Quintela
                                 s->screen_dump, s->text_update, s);
65 76323919 Juan Quintela
66 be20f9e9 Avi Kivity
    vga_init_vbe(s, isa_address_space(dev));
67 5245d57a Gerd Hoffmann
    /* ROM BIOS */
68 5245d57a Gerd Hoffmann
    rom_add_vga(VGABIOS_FILENAME);
69 76323919 Juan Quintela
    return 0;
70 76323919 Juan Quintela
}
71 7435b791 Blue Swirl
72 8f04ee08 Anthony Liguori
static void vga_class_initfn(ObjectClass *klass, void *data)
73 8f04ee08 Anthony Liguori
{
74 39bffca2 Anthony Liguori
    DeviceClass *dc = DEVICE_CLASS(klass);
75 8f04ee08 Anthony Liguori
    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
76 8f04ee08 Anthony Liguori
    ic->init = vga_initfn;
77 39bffca2 Anthony Liguori
    dc->reset = vga_reset_isa;
78 39bffca2 Anthony Liguori
    dc->vmsd = &vmstate_vga_common;
79 8f04ee08 Anthony Liguori
}
80 8f04ee08 Anthony Liguori
81 39bffca2 Anthony Liguori
static TypeInfo vga_info = {
82 39bffca2 Anthony Liguori
    .name          = "isa-vga",
83 39bffca2 Anthony Liguori
    .parent        = TYPE_ISA_DEVICE,
84 39bffca2 Anthony Liguori
    .instance_size = sizeof(ISAVGAState),
85 39bffca2 Anthony Liguori
    .class_init    = vga_class_initfn,
86 7435b791 Blue Swirl
};
87 7435b791 Blue Swirl
88 83f7d43a Andreas Färber
static void vga_register_types(void)
89 7435b791 Blue Swirl
{
90 39bffca2 Anthony Liguori
    type_register_static(&vga_info);
91 7435b791 Blue Swirl
}
92 83f7d43a Andreas Färber
93 83f7d43a Andreas Färber
type_init(vga_register_types)