Signed-off-by: Chad Jablonski <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
---
hw/display/ati.c | 16 ++++++++++++++--
hw/display/ati_int.h | 5 +++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/hw/display/ati.c b/hw/display/ati.c
index f7c0006a87..0b4298d078 100644
--- a/hw/display/ati.c
+++ b/hw/display/ati.c
@@ -361,7 +361,7 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr,
unsigned int size)
PCI_BASE_ADDRESS_0, size) &
0xfffffff0;
break;
case CONFIG_APER_SIZE:
- val = s->vga.vram_size / 2;
+ val = memory_region_size(&s->linear_aper) / 2;
break;
case CONFIG_REG_1_BASE:
val = pci_default_read_config(&s->dev,
@@ -952,6 +952,7 @@ static void ati_vga_realize(PCIDevice *dev, Error
**errp)
{
ATIVGAState *s = ATI_VGA(dev);
VGACommonState *vga = &s->vga;
+ uint64_t aper_size;
#ifndef CONFIG_PIXMAN
if (s->use_pixman != 0) {
@@ -1011,7 +1012,18 @@ static void ati_vga_realize(PCIDevice *dev, Error
**errp)
/* io space is alias to beginning of mmregs */
memory_region_init_alias(&s->io, OBJECT(s), "ati.io", &s->mm, 0,
0x100);
- pci_register_bar(dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &vga->vram);
+ /*
+ * The framebuffer is at the beginning of the linear aperture. For
+ * Rage128 the upper half of the aperture is reserved for an AGP
+ * window (which we do not emulate.)
+ */
+ aper_size = s->dev_id == PCI_DEVICE_ID_ATI_RAGE128_PF ?
+ ATI_RAGE128_LINEAR_APER_SIZE : ATI_R100_LINEAR_APER_SIZE;
+ memory_region_init(&s->linear_aper, OBJECT(dev),
"ati-linear-aperture0",
+ aper_size);
+ memory_region_add_subregion(&s->linear_aper, 0, &vga->vram);
+
+ pci_register_bar(dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH,
&s->linear_aper);
pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io);
pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mm);
diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h
index f5a47b82b0..708cc1dd3a 100644
--- a/hw/display/ati_int.h
+++ b/hw/display/ati_int.h
@@ -10,6 +10,7 @@
#define ATI_INT_H
#include "qemu/timer.h"
+#include "qemu/units.h"
#include "hw/pci/pci_device.h"
#include "hw/i2c/bitbang_i2c.h"
#include "vga_int.h"
@@ -29,6 +30,9 @@
/* Radeon RV100 (VE) */
#define PCI_DEVICE_ID_ATI_RADEON_QY 0x5159
+#define ATI_RAGE128_LINEAR_APER_SIZE (64 * MiB)
+#define ATI_R100_LINEAR_APER_SIZE (128 * MiB)
+
#define TYPE_ATI_VGA "ati-vga"
OBJECT_DECLARE_SIMPLE_TYPE(ATIVGAState, ATI_VGA)
@@ -97,6 +101,7 @@ struct ATIVGAState {
QEMUCursor *cursor;
QEMUTimer vblank_timer;
bitbang_i2c_interface bbi2c;
+ MemoryRegion linear_aper;
MemoryRegion io;
MemoryRegion mm;
ATIVGARegs regs;