Register VMware SVGA's memory io region with PCI framework.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4023 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
balrog 2008-03-06 20:28:49 +00:00
parent 134d77a14b
commit 3016d80bff

View file

@ -60,6 +60,7 @@ struct vmsvga_state_s {
int vram_size; int vram_size;
#endif #endif
uint8_t *vram; uint8_t *vram;
target_phys_addr_t vram_base;
int index; int index;
int scratch_size; int scratch_size;
@ -644,7 +645,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
return ((s->depth + 7) >> 3) * s->new_width; return ((s->depth + 7) >> 3) * s->new_width;
case SVGA_REG_FB_START: case SVGA_REG_FB_START:
return SVGA_MEM_BASE; return s->vram_base;
case SVGA_REG_FB_OFFSET: case SVGA_REG_FB_OFFSET:
return 0x0; return 0x0;
@ -671,7 +672,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
return caps; return caps;
case SVGA_REG_MEM_START: case SVGA_REG_MEM_START:
return SVGA_MEM_BASE + s->vram_size - SVGA_FIFO_SIZE; return s->vram_base + s->vram_size - SVGA_FIFO_SIZE;
case SVGA_REG_MEM_SIZE: case SVGA_REG_MEM_SIZE:
return SVGA_FIFO_SIZE; return SVGA_FIFO_SIZE;
@ -961,7 +962,7 @@ static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr) static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr)
{ {
struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
addr -= SVGA_MEM_BASE; addr -= s->vram_base;
if (addr < s->fb_size) if (addr < s->fb_size)
return *(uint8_t *) (s->ds->data + addr); return *(uint8_t *) (s->ds->data + addr);
else else
@ -971,7 +972,7 @@ static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr)
static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr) static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr)
{ {
struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
addr -= SVGA_MEM_BASE; addr -= s->vram_base;
if (addr < s->fb_size) if (addr < s->fb_size)
return *(uint16_t *) (s->ds->data + addr); return *(uint16_t *) (s->ds->data + addr);
else else
@ -981,7 +982,7 @@ static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr)
static uint32_t vmsvga_vram_readl(void *opaque, target_phys_addr_t addr) static uint32_t vmsvga_vram_readl(void *opaque, target_phys_addr_t addr)
{ {
struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
addr -= SVGA_MEM_BASE; addr -= s->vram_base;
if (addr < s->fb_size) if (addr < s->fb_size)
return *(uint32_t *) (s->ds->data + addr); return *(uint32_t *) (s->ds->data + addr);
else else
@ -992,7 +993,7 @@ static void vmsvga_vram_writeb(void *opaque, target_phys_addr_t addr,
uint32_t value) uint32_t value)
{ {
struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
addr -= SVGA_MEM_BASE; addr -= s->vram_base;
if (addr < s->fb_size) if (addr < s->fb_size)
*(uint8_t *) (s->ds->data + addr) = value; *(uint8_t *) (s->ds->data + addr) = value;
else else
@ -1003,7 +1004,7 @@ static void vmsvga_vram_writew(void *opaque, target_phys_addr_t addr,
uint32_t value) uint32_t value)
{ {
struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
addr -= SVGA_MEM_BASE; addr -= s->vram_base;
if (addr < s->fb_size) if (addr < s->fb_size)
*(uint16_t *) (s->ds->data + addr) = value; *(uint16_t *) (s->ds->data + addr) = value;
else else
@ -1014,7 +1015,7 @@ static void vmsvga_vram_writel(void *opaque, target_phys_addr_t addr,
uint32_t value) uint32_t value)
{ {
struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
addr -= SVGA_MEM_BASE; addr -= s->vram_base;
if (addr < s->fb_size) if (addr < s->fb_size)
*(uint32_t *) (s->ds->data + addr) = value; *(uint32_t *) (s->ds->data + addr) = value;
else else
@ -1089,7 +1090,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds,
uint8_t *vga_ram_base, unsigned long vga_ram_offset, uint8_t *vga_ram_base, unsigned long vga_ram_offset,
int vga_ram_size) int vga_ram_size)
{ {
int iomemtype;
s->ds = ds; s->ds = ds;
s->vram = vga_ram_base; s->vram = vga_ram_base;
s->vram_size = vga_ram_size; s->vram_size = vga_ram_size;
@ -1099,15 +1099,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds,
vmsvga_reset(s); vmsvga_reset(s);
#ifdef DIRECT_VRAM
iomemtype = cpu_register_io_memory(0, vmsvga_vram_read,
vmsvga_vram_write, s);
#else
iomemtype = vga_ram_offset | IO_MEM_RAM;
#endif
cpu_register_physical_memory(SVGA_MEM_BASE, vga_ram_size,
iomemtype);
graphic_console_init(ds, vmsvga_update_display, graphic_console_init(ds, vmsvga_update_display,
vmsvga_invalidate_display, vmsvga_screen_dump, vmsvga_invalidate_display, vmsvga_screen_dump,
vmsvga_text_update, s); vmsvga_text_update, s);
@ -1162,6 +1153,24 @@ static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num,
1, 4, vmsvga_bios_write, s); 1, 4, vmsvga_bios_write, s);
} }
static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
uint32_t addr, uint32_t size, int type)
{
struct pci_vmsvga_state_s *d = (struct pci_vmsvga_state_s *) pci_dev;
struct vmsvga_state_s *s = &d->chip;
int iomemtype;
s->vram_base = addr;
#ifdef DIRECT_VRAM
iomemtype = cpu_register_io_memory(0, vmsvga_vram_read,
vmsvga_vram_write, s);
#else
iomemtype = 0 | IO_MEM_RAM;
#endif
cpu_register_physical_memory(s->vram_base, s->vram_size,
iomemtype);
}
#define PCI_VENDOR_ID_VMWARE 0x15ad #define PCI_VENDOR_ID_VMWARE 0x15ad
#define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405 #define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405
#define PCI_DEVICE_ID_VMWARE_SVGA 0x0710 #define PCI_DEVICE_ID_VMWARE_SVGA 0x0710
@ -1207,6 +1216,8 @@ void pci_vmsvga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
pci_register_io_region(&s->card, 0, 0x10, pci_register_io_region(&s->card, 0, 0x10,
PCI_ADDRESS_SPACE_IO, pci_vmsvga_map_ioport); PCI_ADDRESS_SPACE_IO, pci_vmsvga_map_ioport);
pci_register_io_region(&s->card, 0, vga_ram_size,
PCI_ADDRESS_SPACE_MEM_PREFETCH, pci_vmsvga_map_mem);
vmsvga_init(&s->chip, ds, vga_ram_base, vga_ram_offset, vga_ram_size); vmsvga_init(&s->chip, ds, vga_ram_base, vga_ram_offset, vga_ram_size);