Commit 3016d80bff9ba63e67c1b18798180b2a9ffb58c0

Authored by balrog
1 parent 134d77a1

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
Showing 1 changed file with 29 additions and 18 deletions
hw/vmware_vga.c
@@ -60,6 +60,7 @@ struct vmsvga_state_s { @@ -60,6 +60,7 @@ struct vmsvga_state_s {
60 int vram_size; 60 int vram_size;
61 #endif 61 #endif
62 uint8_t *vram; 62 uint8_t *vram;
  63 + target_phys_addr_t vram_base;
63 64
64 int index; 65 int index;
65 int scratch_size; 66 int scratch_size;
@@ -644,7 +645,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) @@ -644,7 +645,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
644 return ((s->depth + 7) >> 3) * s->new_width; 645 return ((s->depth + 7) >> 3) * s->new_width;
645 646
646 case SVGA_REG_FB_START: 647 case SVGA_REG_FB_START:
647 - return SVGA_MEM_BASE; 648 + return s->vram_base;
648 649
649 case SVGA_REG_FB_OFFSET: 650 case SVGA_REG_FB_OFFSET:
650 return 0x0; 651 return 0x0;
@@ -671,7 +672,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) @@ -671,7 +672,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
671 return caps; 672 return caps;
672 673
673 case SVGA_REG_MEM_START: 674 case SVGA_REG_MEM_START:
674 - return SVGA_MEM_BASE + s->vram_size - SVGA_FIFO_SIZE; 675 + return s->vram_base + s->vram_size - SVGA_FIFO_SIZE;
675 676
676 case SVGA_REG_MEM_SIZE: 677 case SVGA_REG_MEM_SIZE:
677 return SVGA_FIFO_SIZE; 678 return SVGA_FIFO_SIZE;
@@ -961,7 +962,7 @@ static void vmsvga_text_update(void *opaque, console_ch_t *chardata) @@ -961,7 +962,7 @@ static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
961 static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr) 962 static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr)
962 { 963 {
963 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; 964 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
964 - addr -= SVGA_MEM_BASE; 965 + addr -= s->vram_base;
965 if (addr < s->fb_size) 966 if (addr < s->fb_size)
966 return *(uint8_t *) (s->ds->data + addr); 967 return *(uint8_t *) (s->ds->data + addr);
967 else 968 else
@@ -971,7 +972,7 @@ static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr) @@ -971,7 +972,7 @@ static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr)
971 static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr) 972 static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr)
972 { 973 {
973 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; 974 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
974 - addr -= SVGA_MEM_BASE; 975 + addr -= s->vram_base;
975 if (addr < s->fb_size) 976 if (addr < s->fb_size)
976 return *(uint16_t *) (s->ds->data + addr); 977 return *(uint16_t *) (s->ds->data + addr);
977 else 978 else
@@ -981,7 +982,7 @@ static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr) @@ -981,7 +982,7 @@ static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr)
981 static uint32_t vmsvga_vram_readl(void *opaque, target_phys_addr_t addr) 982 static uint32_t vmsvga_vram_readl(void *opaque, target_phys_addr_t addr)
982 { 983 {
983 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; 984 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
984 - addr -= SVGA_MEM_BASE; 985 + addr -= s->vram_base;
985 if (addr < s->fb_size) 986 if (addr < s->fb_size)
986 return *(uint32_t *) (s->ds->data + addr); 987 return *(uint32_t *) (s->ds->data + addr);
987 else 988 else
@@ -992,7 +993,7 @@ static void vmsvga_vram_writeb(void *opaque, target_phys_addr_t addr, @@ -992,7 +993,7 @@ static void vmsvga_vram_writeb(void *opaque, target_phys_addr_t addr,
992 uint32_t value) 993 uint32_t value)
993 { 994 {
994 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; 995 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
995 - addr -= SVGA_MEM_BASE; 996 + addr -= s->vram_base;
996 if (addr < s->fb_size) 997 if (addr < s->fb_size)
997 *(uint8_t *) (s->ds->data + addr) = value; 998 *(uint8_t *) (s->ds->data + addr) = value;
998 else 999 else
@@ -1003,7 +1004,7 @@ static void vmsvga_vram_writew(void *opaque, target_phys_addr_t addr, @@ -1003,7 +1004,7 @@ static void vmsvga_vram_writew(void *opaque, target_phys_addr_t addr,
1003 uint32_t value) 1004 uint32_t value)
1004 { 1005 {
1005 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; 1006 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
1006 - addr -= SVGA_MEM_BASE; 1007 + addr -= s->vram_base;
1007 if (addr < s->fb_size) 1008 if (addr < s->fb_size)
1008 *(uint16_t *) (s->ds->data + addr) = value; 1009 *(uint16_t *) (s->ds->data + addr) = value;
1009 else 1010 else
@@ -1014,7 +1015,7 @@ static void vmsvga_vram_writel(void *opaque, target_phys_addr_t addr, @@ -1014,7 +1015,7 @@ static void vmsvga_vram_writel(void *opaque, target_phys_addr_t addr,
1014 uint32_t value) 1015 uint32_t value)
1015 { 1016 {
1016 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; 1017 struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
1017 - addr -= SVGA_MEM_BASE; 1018 + addr -= s->vram_base;
1018 if (addr < s->fb_size) 1019 if (addr < s->fb_size)
1019 *(uint32_t *) (s->ds->data + addr) = value; 1020 *(uint32_t *) (s->ds->data + addr) = value;
1020 else 1021 else
@@ -1089,7 +1090,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds, @@ -1089,7 +1090,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds,
1089 uint8_t *vga_ram_base, unsigned long vga_ram_offset, 1090 uint8_t *vga_ram_base, unsigned long vga_ram_offset,
1090 int vga_ram_size) 1091 int vga_ram_size)
1091 { 1092 {
1092 - int iomemtype;  
1093 s->ds = ds; 1093 s->ds = ds;
1094 s->vram = vga_ram_base; 1094 s->vram = vga_ram_base;
1095 s->vram_size = vga_ram_size; 1095 s->vram_size = vga_ram_size;
@@ -1099,15 +1099,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds, @@ -1099,15 +1099,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds,
1099 1099
1100 vmsvga_reset(s); 1100 vmsvga_reset(s);
1101 1101
1102 -#ifdef DIRECT_VRAM  
1103 - iomemtype = cpu_register_io_memory(0, vmsvga_vram_read,  
1104 - vmsvga_vram_write, s);  
1105 -#else  
1106 - iomemtype = vga_ram_offset | IO_MEM_RAM;  
1107 -#endif  
1108 - cpu_register_physical_memory(SVGA_MEM_BASE, vga_ram_size,  
1109 - iomemtype);  
1110 -  
1111 graphic_console_init(ds, vmsvga_update_display, 1102 graphic_console_init(ds, vmsvga_update_display,
1112 vmsvga_invalidate_display, vmsvga_screen_dump, 1103 vmsvga_invalidate_display, vmsvga_screen_dump,
1113 vmsvga_text_update, s); 1104 vmsvga_text_update, s);
@@ -1162,6 +1153,24 @@ static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num, @@ -1162,6 +1153,24 @@ static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num,
1162 1, 4, vmsvga_bios_write, s); 1153 1, 4, vmsvga_bios_write, s);
1163 } 1154 }
1164 1155
  1156 +static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
  1157 + uint32_t addr, uint32_t size, int type)
  1158 +{
  1159 + struct pci_vmsvga_state_s *d = (struct pci_vmsvga_state_s *) pci_dev;
  1160 + struct vmsvga_state_s *s = &d->chip;
  1161 + int iomemtype;
  1162 +
  1163 + s->vram_base = addr;
  1164 +#ifdef DIRECT_VRAM
  1165 + iomemtype = cpu_register_io_memory(0, vmsvga_vram_read,
  1166 + vmsvga_vram_write, s);
  1167 +#else
  1168 + iomemtype = 0 | IO_MEM_RAM;
  1169 +#endif
  1170 + cpu_register_physical_memory(s->vram_base, s->vram_size,
  1171 + iomemtype);
  1172 +}
  1173 +
1165 #define PCI_VENDOR_ID_VMWARE 0x15ad 1174 #define PCI_VENDOR_ID_VMWARE 0x15ad
1166 #define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405 1175 #define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405
1167 #define PCI_DEVICE_ID_VMWARE_SVGA 0x0710 1176 #define PCI_DEVICE_ID_VMWARE_SVGA 0x0710
@@ -1207,6 +1216,8 @@ void pci_vmsvga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, @@ -1207,6 +1216,8 @@ void pci_vmsvga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
1207 1216
1208 pci_register_io_region(&s->card, 0, 0x10, 1217 pci_register_io_region(&s->card, 0, 0x10,
1209 PCI_ADDRESS_SPACE_IO, pci_vmsvga_map_ioport); 1218 PCI_ADDRESS_SPACE_IO, pci_vmsvga_map_ioport);
  1219 + pci_register_io_region(&s->card, 0, vga_ram_size,
  1220 + PCI_ADDRESS_SPACE_MEM_PREFETCH, pci_vmsvga_map_mem);
1210 1221
1211 vmsvga_init(&s->chip, ds, vga_ram_base, vga_ram_offset, vga_ram_size); 1222 vmsvga_init(&s->chip, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
1212 1223