root / hw / vga-isa-mm.c @ 77047bb7
History | View | Annotate | Download (4 kB)
1 | 79b97bf2 | Juan Quintela | /*
|
---|---|---|---|
2 | 79b97bf2 | Juan Quintela | * QEMU ISA MM VGA Emulator.
|
3 | 79b97bf2 | Juan Quintela | *
|
4 | 79b97bf2 | Juan Quintela | * Copyright (c) 2003 Fabrice Bellard
|
5 | 79b97bf2 | Juan Quintela | *
|
6 | 79b97bf2 | Juan Quintela | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 79b97bf2 | Juan Quintela | * of this software and associated documentation files (the "Software"), to deal
|
8 | 79b97bf2 | Juan Quintela | * in the Software without restriction, including without limitation the rights
|
9 | 79b97bf2 | Juan Quintela | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 79b97bf2 | Juan Quintela | * copies of the Software, and to permit persons to whom the Software is
|
11 | 79b97bf2 | Juan Quintela | * furnished to do so, subject to the following conditions:
|
12 | 79b97bf2 | Juan Quintela | *
|
13 | 79b97bf2 | Juan Quintela | * The above copyright notice and this permission notice shall be included in
|
14 | 79b97bf2 | Juan Quintela | * all copies or substantial portions of the Software.
|
15 | 79b97bf2 | Juan Quintela | *
|
16 | 79b97bf2 | Juan Quintela | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 79b97bf2 | Juan Quintela | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 79b97bf2 | Juan Quintela | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 79b97bf2 | Juan Quintela | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 79b97bf2 | Juan Quintela | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 79b97bf2 | Juan Quintela | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 79b97bf2 | Juan Quintela | * THE SOFTWARE.
|
23 | 79b97bf2 | Juan Quintela | */
|
24 | 79b97bf2 | Juan Quintela | #include "hw.h" |
25 | 79b97bf2 | Juan Quintela | #include "console.h" |
26 | 79b97bf2 | Juan Quintela | #include "pc.h" |
27 | 79b97bf2 | Juan Quintela | #include "vga_int.h" |
28 | 79b97bf2 | Juan Quintela | #include "pixel_ops.h" |
29 | 79b97bf2 | Juan Quintela | #include "qemu-timer.h" |
30 | 79b97bf2 | Juan Quintela | |
31 | 79b97bf2 | Juan Quintela | typedef struct ISAVGAMMState { |
32 | 79b97bf2 | Juan Quintela | VGACommonState vga; |
33 | 79b97bf2 | Juan Quintela | int it_shift;
|
34 | 79b97bf2 | Juan Quintela | } ISAVGAMMState; |
35 | 79b97bf2 | Juan Quintela | |
36 | 79b97bf2 | Juan Quintela | /* Memory mapped interface */
|
37 | c227f099 | Anthony Liguori | static uint32_t vga_mm_readb (void *opaque, target_phys_addr_t addr) |
38 | 79b97bf2 | Juan Quintela | { |
39 | 79b97bf2 | Juan Quintela | ISAVGAMMState *s = opaque; |
40 | 79b97bf2 | Juan Quintela | |
41 | 79b97bf2 | Juan Quintela | return vga_ioport_read(&s->vga, addr >> s->it_shift) & 0xff; |
42 | 79b97bf2 | Juan Quintela | } |
43 | 79b97bf2 | Juan Quintela | |
44 | 79b97bf2 | Juan Quintela | static void vga_mm_writeb (void *opaque, |
45 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
46 | 79b97bf2 | Juan Quintela | { |
47 | 79b97bf2 | Juan Quintela | ISAVGAMMState *s = opaque; |
48 | 79b97bf2 | Juan Quintela | |
49 | 79b97bf2 | Juan Quintela | vga_ioport_write(&s->vga, addr >> s->it_shift, value & 0xff);
|
50 | 79b97bf2 | Juan Quintela | } |
51 | 79b97bf2 | Juan Quintela | |
52 | c227f099 | Anthony Liguori | static uint32_t vga_mm_readw (void *opaque, target_phys_addr_t addr) |
53 | 79b97bf2 | Juan Quintela | { |
54 | 79b97bf2 | Juan Quintela | ISAVGAMMState *s = opaque; |
55 | 79b97bf2 | Juan Quintela | |
56 | 79b97bf2 | Juan Quintela | return vga_ioport_read(&s->vga, addr >> s->it_shift) & 0xffff; |
57 | 79b97bf2 | Juan Quintela | } |
58 | 79b97bf2 | Juan Quintela | |
59 | 79b97bf2 | Juan Quintela | static void vga_mm_writew (void *opaque, |
60 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
61 | 79b97bf2 | Juan Quintela | { |
62 | 79b97bf2 | Juan Quintela | ISAVGAMMState *s = opaque; |
63 | 79b97bf2 | Juan Quintela | |
64 | 79b97bf2 | Juan Quintela | vga_ioport_write(&s->vga, addr >> s->it_shift, value & 0xffff);
|
65 | 79b97bf2 | Juan Quintela | } |
66 | 79b97bf2 | Juan Quintela | |
67 | c227f099 | Anthony Liguori | static uint32_t vga_mm_readl (void *opaque, target_phys_addr_t addr) |
68 | 79b97bf2 | Juan Quintela | { |
69 | 79b97bf2 | Juan Quintela | ISAVGAMMState *s = opaque; |
70 | 79b97bf2 | Juan Quintela | |
71 | 79b97bf2 | Juan Quintela | return vga_ioport_read(&s->vga, addr >> s->it_shift);
|
72 | 79b97bf2 | Juan Quintela | } |
73 | 79b97bf2 | Juan Quintela | |
74 | 79b97bf2 | Juan Quintela | static void vga_mm_writel (void *opaque, |
75 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
76 | 79b97bf2 | Juan Quintela | { |
77 | 79b97bf2 | Juan Quintela | ISAVGAMMState *s = opaque; |
78 | 79b97bf2 | Juan Quintela | |
79 | 79b97bf2 | Juan Quintela | vga_ioport_write(&s->vga, addr >> s->it_shift, value); |
80 | 79b97bf2 | Juan Quintela | } |
81 | 79b97bf2 | Juan Quintela | |
82 | 79b97bf2 | Juan Quintela | static CPUReadMemoryFunc * const vga_mm_read_ctrl[] = { |
83 | 79b97bf2 | Juan Quintela | &vga_mm_readb, |
84 | 79b97bf2 | Juan Quintela | &vga_mm_readw, |
85 | 79b97bf2 | Juan Quintela | &vga_mm_readl, |
86 | 79b97bf2 | Juan Quintela | }; |
87 | 79b97bf2 | Juan Quintela | |
88 | 79b97bf2 | Juan Quintela | static CPUWriteMemoryFunc * const vga_mm_write_ctrl[] = { |
89 | 79b97bf2 | Juan Quintela | &vga_mm_writeb, |
90 | 79b97bf2 | Juan Quintela | &vga_mm_writew, |
91 | 79b97bf2 | Juan Quintela | &vga_mm_writel, |
92 | 79b97bf2 | Juan Quintela | }; |
93 | 79b97bf2 | Juan Quintela | |
94 | c227f099 | Anthony Liguori | static void vga_mm_init(ISAVGAMMState *s, target_phys_addr_t vram_base, |
95 | c227f099 | Anthony Liguori | target_phys_addr_t ctrl_base, int it_shift)
|
96 | 79b97bf2 | Juan Quintela | { |
97 | 79b97bf2 | Juan Quintela | int s_ioport_ctrl, vga_io_memory;
|
98 | 79b97bf2 | Juan Quintela | |
99 | 79b97bf2 | Juan Quintela | s->it_shift = it_shift; |
100 | 79b97bf2 | Juan Quintela | s_ioport_ctrl = cpu_register_io_memory(vga_mm_read_ctrl, vga_mm_write_ctrl, s); |
101 | 79b97bf2 | Juan Quintela | vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s); |
102 | 79b97bf2 | Juan Quintela | |
103 | c63a5886 | Juan Quintela | vmstate_register(0, &vmstate_vga_common, s);
|
104 | 79b97bf2 | Juan Quintela | |
105 | 79b97bf2 | Juan Quintela | cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl);
|
106 | 79b97bf2 | Juan Quintela | s->vga.bank_offset = 0;
|
107 | 79b97bf2 | Juan Quintela | cpu_register_physical_memory(vram_base + 0x000a0000, 0x20000, vga_io_memory); |
108 | 79b97bf2 | Juan Quintela | qemu_register_coalesced_mmio(vram_base + 0x000a0000, 0x20000); |
109 | 79b97bf2 | Juan Quintela | } |
110 | 79b97bf2 | Juan Quintela | |
111 | c227f099 | Anthony Liguori | int isa_vga_mm_init(target_phys_addr_t vram_base,
|
112 | c227f099 | Anthony Liguori | target_phys_addr_t ctrl_base, int it_shift)
|
113 | 79b97bf2 | Juan Quintela | { |
114 | 79b97bf2 | Juan Quintela | ISAVGAMMState *s; |
115 | 79b97bf2 | Juan Quintela | |
116 | 79b97bf2 | Juan Quintela | s = qemu_mallocz(sizeof(*s));
|
117 | 79b97bf2 | Juan Quintela | |
118 | 79b97bf2 | Juan Quintela | vga_common_init(&s->vga, VGA_RAM_SIZE); |
119 | 79b97bf2 | Juan Quintela | vga_mm_init(s, vram_base, ctrl_base, it_shift); |
120 | 79b97bf2 | Juan Quintela | |
121 | 79b97bf2 | Juan Quintela | s->vga.ds = graphic_console_init(s->vga.update, s->vga.invalidate, |
122 | 79b97bf2 | Juan Quintela | s->vga.screen_dump, s->vga.text_update, s); |
123 | 79b97bf2 | Juan Quintela | |
124 | 79b97bf2 | Juan Quintela | #ifdef CONFIG_BOCHS_VBE
|
125 | 79b97bf2 | Juan Quintela | /* XXX: use optimized standard vga accesses */
|
126 | 79b97bf2 | Juan Quintela | cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS, |
127 | 79b97bf2 | Juan Quintela | VGA_RAM_SIZE, s->vga.vram_offset); |
128 | 79b97bf2 | Juan Quintela | #endif
|
129 | 79b97bf2 | Juan Quintela | return 0; |
130 | 79b97bf2 | Juan Quintela | } |