Commit 3016d80bff9ba63e67c1b18798180b2a9ffb58c0
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 | 60 | int vram_size; |
61 | 61 | #endif |
62 | 62 | uint8_t *vram; |
63 | + target_phys_addr_t vram_base; | |
63 | 64 | |
64 | 65 | int index; |
65 | 66 | int scratch_size; |
... | ... | @@ -644,7 +645,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) |
644 | 645 | return ((s->depth + 7) >> 3) * s->new_width; |
645 | 646 | |
646 | 647 | case SVGA_REG_FB_START: |
647 | - return SVGA_MEM_BASE; | |
648 | + return s->vram_base; | |
648 | 649 | |
649 | 650 | case SVGA_REG_FB_OFFSET: |
650 | 651 | return 0x0; |
... | ... | @@ -671,7 +672,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) |
671 | 672 | return caps; |
672 | 673 | |
673 | 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 | 677 | case SVGA_REG_MEM_SIZE: |
677 | 678 | return SVGA_FIFO_SIZE; |
... | ... | @@ -961,7 +962,7 @@ static void vmsvga_text_update(void *opaque, console_ch_t *chardata) |
961 | 962 | static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr) |
962 | 963 | { |
963 | 964 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
964 | - addr -= SVGA_MEM_BASE; | |
965 | + addr -= s->vram_base; | |
965 | 966 | if (addr < s->fb_size) |
966 | 967 | return *(uint8_t *) (s->ds->data + addr); |
967 | 968 | else |
... | ... | @@ -971,7 +972,7 @@ static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr) |
971 | 972 | static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr) |
972 | 973 | { |
973 | 974 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
974 | - addr -= SVGA_MEM_BASE; | |
975 | + addr -= s->vram_base; | |
975 | 976 | if (addr < s->fb_size) |
976 | 977 | return *(uint16_t *) (s->ds->data + addr); |
977 | 978 | else |
... | ... | @@ -981,7 +982,7 @@ static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr) |
981 | 982 | static uint32_t vmsvga_vram_readl(void *opaque, target_phys_addr_t addr) |
982 | 983 | { |
983 | 984 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
984 | - addr -= SVGA_MEM_BASE; | |
985 | + addr -= s->vram_base; | |
985 | 986 | if (addr < s->fb_size) |
986 | 987 | return *(uint32_t *) (s->ds->data + addr); |
987 | 988 | else |
... | ... | @@ -992,7 +993,7 @@ static void vmsvga_vram_writeb(void *opaque, target_phys_addr_t addr, |
992 | 993 | uint32_t value) |
993 | 994 | { |
994 | 995 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
995 | - addr -= SVGA_MEM_BASE; | |
996 | + addr -= s->vram_base; | |
996 | 997 | if (addr < s->fb_size) |
997 | 998 | *(uint8_t *) (s->ds->data + addr) = value; |
998 | 999 | else |
... | ... | @@ -1003,7 +1004,7 @@ static void vmsvga_vram_writew(void *opaque, target_phys_addr_t addr, |
1003 | 1004 | uint32_t value) |
1004 | 1005 | { |
1005 | 1006 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
1006 | - addr -= SVGA_MEM_BASE; | |
1007 | + addr -= s->vram_base; | |
1007 | 1008 | if (addr < s->fb_size) |
1008 | 1009 | *(uint16_t *) (s->ds->data + addr) = value; |
1009 | 1010 | else |
... | ... | @@ -1014,7 +1015,7 @@ static void vmsvga_vram_writel(void *opaque, target_phys_addr_t addr, |
1014 | 1015 | uint32_t value) |
1015 | 1016 | { |
1016 | 1017 | struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; |
1017 | - addr -= SVGA_MEM_BASE; | |
1018 | + addr -= s->vram_base; | |
1018 | 1019 | if (addr < s->fb_size) |
1019 | 1020 | *(uint32_t *) (s->ds->data + addr) = value; |
1020 | 1021 | else |
... | ... | @@ -1089,7 +1090,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds, |
1089 | 1090 | uint8_t *vga_ram_base, unsigned long vga_ram_offset, |
1090 | 1091 | int vga_ram_size) |
1091 | 1092 | { |
1092 | - int iomemtype; | |
1093 | 1093 | s->ds = ds; |
1094 | 1094 | s->vram = vga_ram_base; |
1095 | 1095 | s->vram_size = vga_ram_size; |
... | ... | @@ -1099,15 +1099,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds, |
1099 | 1099 | |
1100 | 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 | 1102 | graphic_console_init(ds, vmsvga_update_display, |
1112 | 1103 | vmsvga_invalidate_display, vmsvga_screen_dump, |
1113 | 1104 | vmsvga_text_update, s); |
... | ... | @@ -1162,6 +1153,24 @@ static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num, |
1162 | 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 | 1174 | #define PCI_VENDOR_ID_VMWARE 0x15ad |
1166 | 1175 | #define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405 |
1167 | 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 | 1216 | |
1208 | 1217 | pci_register_io_region(&s->card, 0, 0x10, |
1209 | 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 | 1222 | vmsvga_init(&s->chip, ds, vga_ram_base, vga_ram_offset, vga_ram_size); |
1212 | 1223 | ... | ... |