From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KIzLO-0001sh-60 for qemu-devel@nongnu.org; Wed, 16 Jul 2008 01:14:26 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KIzLL-0001qP-U8 for qemu-devel@nongnu.org; Wed, 16 Jul 2008 01:14:24 -0400 Received: from [199.232.76.173] (port=50188 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KIzLL-0001ps-Es for qemu-devel@nongnu.org; Wed, 16 Jul 2008 01:14:23 -0400 Received: from savannah.gnu.org ([199.232.41.3]:41049 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KIytC-0001ML-NX for qemu-devel@nongnu.org; Wed, 16 Jul 2008 00:45:19 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KIyt6-0008Gi-NG for qemu-devel@nongnu.org; Wed, 16 Jul 2008 04:45:12 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KIyt6-0008Ge-D8 for qemu-devel@nongnu.org; Wed, 16 Jul 2008 04:45:12 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Wed, 16 Jul 2008 04:45:12 +0000 Subject: [Qemu-devel] [4874] Properly byte-swap values in VMware SVGA (malc). Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4874 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4874 Author: balrog Date: 2008-07-16 04:45:12 +0000 (Wed, 16 Jul 2008) Log Message: ----------- Properly byte-swap values in VMware SVGA (malc). Makes PPC host happy. Also use the right type for a memory offset. Modified Paths: -------------- trunk/hw/vmware_vga.c Modified: trunk/hw/vmware_vga.c =================================================================== --- trunk/hw/vmware_vga.c 2008-07-16 04:38:32 UTC (rev 4873) +++ trunk/hw/vmware_vga.c 2008-07-16 04:45:12 UTC (rev 4874) @@ -483,6 +483,8 @@ } #endif +#define CMD(f) le32_to_cpu(s->cmd->f) + static inline int vmsvga_fifo_empty(struct vmsvga_state_s *s) { if (!s->config || !s->enable) @@ -490,15 +492,20 @@ return (s->cmd->next_cmd == s->cmd->stop); } -static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) +static inline uint32_t vmsvga_fifo_read_raw(struct vmsvga_state_s *s) { - uint32_t cmd = s->fifo[s->cmd->stop >> 2]; - s->cmd->stop += 4; - if (s->cmd->stop >= s->cmd->max) + uint32_t cmd = s->fifo[CMD(stop) >> 2]; + s->cmd->stop = cpu_to_le32(CMD(stop) + 4); + if (CMD(stop) >= CMD(max)) s->cmd->stop = s->cmd->min; return cmd; } +static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) +{ + return le32_to_cpu(vmsvga_fifo_read_raw(s)); +} + static void vmsvga_fifo_run(struct vmsvga_state_s *s) { uint32_t cmd, colour; @@ -552,9 +559,9 @@ vmsvga_fifo_read(s); cursor.bpp = vmsvga_fifo_read(s); for (args = 0; args < SVGA_BITMAP_SIZE(x, y); args ++) - cursor.mask[args] = vmsvga_fifo_read(s); + cursor.mask[args] = vmsvga_fifo_read_raw(s); for (args = 0; args < SVGA_PIXMAP_SIZE(x, y, cursor.bpp); args ++) - cursor.image[args] = vmsvga_fifo_read(s); + cursor.image[args] = vmsvga_fifo_read_raw(s); #ifdef HW_MOUSE_ACCEL vmsvga_cursor_define(s, &cursor); break; @@ -788,14 +795,14 @@ if (value) { s->fifo = (uint32_t *) &s->vram[s->vram_size - SVGA_FIFO_SIZE]; /* Check range and alignment. */ - if ((s->cmd->min | s->cmd->max | - s->cmd->next_cmd | s->cmd->stop) & 3) + if ((CMD(min) | CMD(max) | + CMD(next_cmd) | CMD(stop)) & 3) break; - if (s->cmd->min < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) + if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) break; - if (s->cmd->max > SVGA_FIFO_SIZE) + if (CMD(max) > SVGA_FIFO_SIZE) break; - if (s->cmd->max < s->cmd->min + 10 * 1024) + if (CMD(max) < CMD(min) + 10 * 1024) break; } s->config = !!value; @@ -1189,7 +1196,7 @@ { struct pci_vmsvga_state_s *d = (struct pci_vmsvga_state_s *) pci_dev; struct vmsvga_state_s *s = &d->chip; - int iomemtype; + ram_addr_t iomemtype; s->vram_base = addr; #ifdef DIRECT_VRAM