Revision 7969d9ed
b/hw/cirrus_vga.c | ||
---|---|---|
205 | 205 |
bool linear_vram; /* vga.vram mapped over cirrus_linear_io */ |
206 | 206 |
MemoryRegion low_mem_container; /* container for 0xa0000-0xc0000 */ |
207 | 207 |
MemoryRegion low_mem; /* always mapped, overridden by: */ |
208 |
MemoryRegion *cirrus_bank[2]; /* aliases at 0xa0000-0xb0000 */
|
|
208 |
MemoryRegion cirrus_bank[2]; /* aliases at 0xa0000-0xb0000 */
|
|
209 | 209 |
uint32_t cirrus_addr_mask; |
210 | 210 |
uint32_t linear_mmio_mask; |
211 | 211 |
uint8_t cirrus_shadow_gr0; |
... | ... | |
2363 | 2363 |
}, |
2364 | 2364 |
}; |
2365 | 2365 |
|
2366 |
static void unmap_bank(CirrusVGAState *s, unsigned bank) |
|
2367 |
{ |
|
2368 |
if (s->cirrus_bank[bank]) { |
|
2369 |
memory_region_del_subregion(&s->low_mem_container, |
|
2370 |
s->cirrus_bank[bank]); |
|
2371 |
memory_region_destroy(s->cirrus_bank[bank]); |
|
2372 |
g_free(s->cirrus_bank[bank]); |
|
2373 |
s->cirrus_bank[bank] = NULL; |
|
2374 |
} |
|
2375 |
} |
|
2376 |
|
|
2377 | 2366 |
static void map_linear_vram_bank(CirrusVGAState *s, unsigned bank) |
2378 | 2367 |
{ |
2379 |
MemoryRegion *mr; |
|
2380 |
static const char *names[] = { "vga.bank0", "vga.bank1" }; |
|
2381 |
|
|
2382 |
if (!(s->cirrus_srcptr != s->cirrus_srcptr_end) |
|
2368 |
MemoryRegion *mr = &s->cirrus_bank[bank]; |
|
2369 |
bool enabled = !(s->cirrus_srcptr != s->cirrus_srcptr_end) |
|
2383 | 2370 |
&& !((s->vga.sr[0x07] & 0x01) == 0) |
2384 | 2371 |
&& !((s->vga.gr[0x0B] & 0x14) == 0x14) |
2385 |
&& !(s->vga.gr[0x0B] & 0x02)) { |
|
2386 |
|
|
2387 |
mr = g_malloc(sizeof(*mr)); |
|
2388 |
memory_region_init_alias(mr, names[bank], &s->vga.vram, |
|
2389 |
s->cirrus_bank_base[bank], 0x8000); |
|
2390 |
memory_region_add_subregion_overlap( |
|
2391 |
&s->low_mem_container, |
|
2392 |
0x8000 * bank, |
|
2393 |
mr, |
|
2394 |
1); |
|
2395 |
unmap_bank(s, bank); |
|
2396 |
s->cirrus_bank[bank] = mr; |
|
2397 |
} else { |
|
2398 |
unmap_bank(s, bank); |
|
2399 |
} |
|
2372 |
&& !(s->vga.gr[0x0B] & 0x02); |
|
2373 |
|
|
2374 |
memory_region_set_enabled(mr, enabled); |
|
2375 |
memory_region_set_alias_offset(mr, s->cirrus_bank_base[bank]); |
|
2400 | 2376 |
} |
2401 | 2377 |
|
2402 | 2378 |
static void map_linear_vram(CirrusVGAState *s) |
... | ... | |
2415 | 2391 |
s->linear_vram = false; |
2416 | 2392 |
memory_region_del_subregion(&s->pci_bar, &s->vga.vram); |
2417 | 2393 |
} |
2418 |
unmap_bank(s, 0);
|
|
2419 |
unmap_bank(s, 1);
|
|
2394 |
memory_region_set_enabled(&s->cirrus_bank[0], false);
|
|
2395 |
memory_region_set_enabled(&s->cirrus_bank[1], false);
|
|
2420 | 2396 |
} |
2421 | 2397 |
|
2422 | 2398 |
/* Compute the memory access functions */ |
... | ... | |
2856 | 2832 |
memory_region_init_io(&s->low_mem, &cirrus_vga_mem_ops, s, |
2857 | 2833 |
"cirrus-low-memory", 0x20000); |
2858 | 2834 |
memory_region_add_subregion(&s->low_mem_container, 0, &s->low_mem); |
2835 |
for (i = 0; i < 2; ++i) { |
|
2836 |
static const char *names[] = { "vga.bank0", "vga.bank1" }; |
|
2837 |
MemoryRegion *bank = &s->cirrus_bank[i]; |
|
2838 |
memory_region_init_alias(bank, names[i], &s->vga.vram, 0, 0x8000); |
|
2839 |
memory_region_set_enabled(bank, false); |
|
2840 |
memory_region_add_subregion_overlap(&s->low_mem_container, i * 0x8000, |
|
2841 |
bank, 1); |
|
2842 |
} |
|
2859 | 2843 |
memory_region_add_subregion_overlap(system_memory, |
2860 | 2844 |
isa_mem_base + 0x000a0000, |
2861 | 2845 |
&s->low_mem_container, |
Also available in: Unified diff