Commit ff9cf2cbe4fb8e865dc0e2371cedbcd7fbec8aad

Authored by balrog
1 parent 931ea435

Properly byte-swap values in VMware SVGA (malc).

Makes PPC host happy.  Also use the right type for a memory offset.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4874 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 19 additions and 12 deletions
hw/vmware_vga.c
... ... @@ -483,6 +483,8 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
483 483 }
484 484 #endif
485 485  
  486 +#define CMD(f) le32_to_cpu(s->cmd->f)
  487 +
486 488 static inline int vmsvga_fifo_empty(struct vmsvga_state_s *s)
487 489 {
488 490 if (!s->config || !s->enable)
... ... @@ -490,15 +492,20 @@ static inline int vmsvga_fifo_empty(struct vmsvga_state_s *s)
490 492 return (s->cmd->next_cmd == s->cmd->stop);
491 493 }
492 494  
493   -static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s)
  495 +static inline uint32_t vmsvga_fifo_read_raw(struct vmsvga_state_s *s)
494 496 {
495   - uint32_t cmd = s->fifo[s->cmd->stop >> 2];
496   - s->cmd->stop += 4;
497   - if (s->cmd->stop >= s->cmd->max)
  497 + uint32_t cmd = s->fifo[CMD(stop) >> 2];
  498 + s->cmd->stop = cpu_to_le32(CMD(stop) + 4);
  499 + if (CMD(stop) >= CMD(max))
498 500 s->cmd->stop = s->cmd->min;
499 501 return cmd;
500 502 }
501 503  
  504 +static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s)
  505 +{
  506 + return le32_to_cpu(vmsvga_fifo_read_raw(s));
  507 +}
  508 +
502 509 static void vmsvga_fifo_run(struct vmsvga_state_s *s)
503 510 {
504 511 uint32_t cmd, colour;
... ... @@ -552,9 +559,9 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s)
552 559 vmsvga_fifo_read(s);
553 560 cursor.bpp = vmsvga_fifo_read(s);
554 561 for (args = 0; args < SVGA_BITMAP_SIZE(x, y); args ++)
555   - cursor.mask[args] = vmsvga_fifo_read(s);
  562 + cursor.mask[args] = vmsvga_fifo_read_raw(s);
556 563 for (args = 0; args < SVGA_PIXMAP_SIZE(x, y, cursor.bpp); args ++)
557   - cursor.image[args] = vmsvga_fifo_read(s);
  564 + cursor.image[args] = vmsvga_fifo_read_raw(s);
558 565 #ifdef HW_MOUSE_ACCEL
559 566 vmsvga_cursor_define(s, &cursor);
560 567 break;
... ... @@ -788,14 +795,14 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
788 795 if (value) {
789 796 s->fifo = (uint32_t *) &s->vram[s->vram_size - SVGA_FIFO_SIZE];
790 797 /* Check range and alignment. */
791   - if ((s->cmd->min | s->cmd->max |
792   - s->cmd->next_cmd | s->cmd->stop) & 3)
  798 + if ((CMD(min) | CMD(max) |
  799 + CMD(next_cmd) | CMD(stop)) & 3)
793 800 break;
794   - if (s->cmd->min < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo)
  801 + if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo)
795 802 break;
796   - if (s->cmd->max > SVGA_FIFO_SIZE)
  803 + if (CMD(max) > SVGA_FIFO_SIZE)
797 804 break;
798   - if (s->cmd->max < s->cmd->min + 10 * 1024)
  805 + if (CMD(max) < CMD(min) + 10 * 1024)
799 806 break;
800 807 }
801 808 s->config = !!value;
... ... @@ -1189,7 +1196,7 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
1189 1196 {
1190 1197 struct pci_vmsvga_state_s *d = (struct pci_vmsvga_state_s *) pci_dev;
1191 1198 struct vmsvga_state_s *s = &d->chip;
1192   - int iomemtype;
  1199 + ram_addr_t iomemtype;
1193 1200  
1194 1201 s->vram_base = addr;
1195 1202 #ifdef DIRECT_VRAM
... ...