2007-04-02 03:10:46 +02:00
|
|
|
/*
|
|
|
|
* QEMU VMware-SVGA "chipset".
|
|
|
|
*
|
|
|
|
* Copyright (c) 2007 Andrzej Zaborowski <balrog@zabor.org>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
2007-11-17 18:14:51 +01:00
|
|
|
#include "hw.h"
|
2009-12-11 06:47:44 +01:00
|
|
|
#include "loader.h"
|
2007-11-17 18:14:51 +01:00
|
|
|
#include "console.h"
|
|
|
|
#include "pci.h"
|
2009-11-11 13:59:56 +01:00
|
|
|
#include "vmware_vga.h"
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
#define VERBOSE
|
|
|
|
#undef DIRECT_VRAM
|
|
|
|
#define HW_RECT_ACCEL
|
|
|
|
#define HW_FILL_ACCEL
|
|
|
|
#define HW_MOUSE_ACCEL
|
|
|
|
|
|
|
|
# include "vga_int.h"
|
|
|
|
|
|
|
|
struct vmsvga_state_s {
|
2009-05-03 21:25:16 +02:00
|
|
|
VGACommonState vga;
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int invalidated;
|
|
|
|
int depth;
|
|
|
|
int bypp;
|
|
|
|
int enable;
|
|
|
|
int config;
|
|
|
|
struct {
|
|
|
|
int id;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int on;
|
|
|
|
} cursor;
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
target_phys_addr_t vram_base;
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
int index;
|
|
|
|
int scratch_size;
|
|
|
|
uint32_t *scratch;
|
|
|
|
int new_width;
|
|
|
|
int new_height;
|
|
|
|
uint32_t guest;
|
|
|
|
uint32_t svgaid;
|
|
|
|
uint32_t wred;
|
|
|
|
uint32_t wgreen;
|
|
|
|
uint32_t wblue;
|
|
|
|
int syncing;
|
|
|
|
int fb_size;
|
|
|
|
|
2009-12-17 23:08:06 +01:00
|
|
|
ram_addr_t fifo_offset;
|
|
|
|
uint8_t *fifo_ptr;
|
|
|
|
unsigned int fifo_size;
|
|
|
|
target_phys_addr_t fifo_base;
|
|
|
|
|
2007-04-02 03:10:46 +02:00
|
|
|
union {
|
|
|
|
uint32_t *fifo;
|
|
|
|
struct __attribute__((__packed__)) {
|
|
|
|
uint32_t min;
|
|
|
|
uint32_t max;
|
|
|
|
uint32_t next_cmd;
|
|
|
|
uint32_t stop;
|
|
|
|
/* Add registers here when adding capabilities. */
|
|
|
|
uint32_t fifo[0];
|
|
|
|
} *cmd;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define REDRAW_FIFO_LEN 512
|
|
|
|
struct vmsvga_rect_s {
|
|
|
|
int x, y, w, h;
|
|
|
|
} redraw_fifo[REDRAW_FIFO_LEN];
|
|
|
|
int redraw_fifo_first, redraw_fifo_last;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pci_vmsvga_state_s {
|
|
|
|
PCIDevice card;
|
|
|
|
struct vmsvga_state_s chip;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SVGA_MAGIC 0x900000UL
|
|
|
|
#define SVGA_MAKE_ID(ver) (SVGA_MAGIC << 8 | (ver))
|
|
|
|
#define SVGA_ID_0 SVGA_MAKE_ID(0)
|
|
|
|
#define SVGA_ID_1 SVGA_MAKE_ID(1)
|
|
|
|
#define SVGA_ID_2 SVGA_MAKE_ID(2)
|
|
|
|
|
|
|
|
#define SVGA_LEGACY_BASE_PORT 0x4560
|
|
|
|
#define SVGA_INDEX_PORT 0x0
|
|
|
|
#define SVGA_VALUE_PORT 0x1
|
|
|
|
#define SVGA_BIOS_PORT 0x2
|
|
|
|
|
|
|
|
#define SVGA_VERSION_2
|
|
|
|
|
|
|
|
#ifdef SVGA_VERSION_2
|
|
|
|
# define SVGA_ID SVGA_ID_2
|
|
|
|
# define SVGA_IO_BASE SVGA_LEGACY_BASE_PORT
|
|
|
|
# define SVGA_IO_MUL 1
|
|
|
|
# define SVGA_FIFO_SIZE 0x10000
|
|
|
|
# define SVGA_PCI_DEVICE_ID PCI_DEVICE_ID_VMWARE_SVGA2
|
|
|
|
#else
|
|
|
|
# define SVGA_ID SVGA_ID_1
|
|
|
|
# define SVGA_IO_BASE SVGA_LEGACY_BASE_PORT
|
|
|
|
# define SVGA_IO_MUL 4
|
|
|
|
# define SVGA_FIFO_SIZE 0x10000
|
|
|
|
# define SVGA_PCI_DEVICE_ID PCI_DEVICE_ID_VMWARE_SVGA
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum {
|
|
|
|
/* ID 0, 1 and 2 registers */
|
|
|
|
SVGA_REG_ID = 0,
|
|
|
|
SVGA_REG_ENABLE = 1,
|
|
|
|
SVGA_REG_WIDTH = 2,
|
|
|
|
SVGA_REG_HEIGHT = 3,
|
|
|
|
SVGA_REG_MAX_WIDTH = 4,
|
|
|
|
SVGA_REG_MAX_HEIGHT = 5,
|
|
|
|
SVGA_REG_DEPTH = 6,
|
|
|
|
SVGA_REG_BITS_PER_PIXEL = 7, /* Current bpp in the guest */
|
|
|
|
SVGA_REG_PSEUDOCOLOR = 8,
|
|
|
|
SVGA_REG_RED_MASK = 9,
|
|
|
|
SVGA_REG_GREEN_MASK = 10,
|
|
|
|
SVGA_REG_BLUE_MASK = 11,
|
|
|
|
SVGA_REG_BYTES_PER_LINE = 12,
|
|
|
|
SVGA_REG_FB_START = 13,
|
|
|
|
SVGA_REG_FB_OFFSET = 14,
|
|
|
|
SVGA_REG_VRAM_SIZE = 15,
|
|
|
|
SVGA_REG_FB_SIZE = 16,
|
|
|
|
|
|
|
|
/* ID 1 and 2 registers */
|
|
|
|
SVGA_REG_CAPABILITIES = 17,
|
|
|
|
SVGA_REG_MEM_START = 18, /* Memory for command FIFO */
|
|
|
|
SVGA_REG_MEM_SIZE = 19,
|
|
|
|
SVGA_REG_CONFIG_DONE = 20, /* Set when memory area configured */
|
|
|
|
SVGA_REG_SYNC = 21, /* Write to force synchronization */
|
|
|
|
SVGA_REG_BUSY = 22, /* Read to check if sync is done */
|
|
|
|
SVGA_REG_GUEST_ID = 23, /* Set guest OS identifier */
|
|
|
|
SVGA_REG_CURSOR_ID = 24, /* ID of cursor */
|
|
|
|
SVGA_REG_CURSOR_X = 25, /* Set cursor X position */
|
|
|
|
SVGA_REG_CURSOR_Y = 26, /* Set cursor Y position */
|
|
|
|
SVGA_REG_CURSOR_ON = 27, /* Turn cursor on/off */
|
|
|
|
SVGA_REG_HOST_BITS_PER_PIXEL = 28, /* Current bpp in the host */
|
|
|
|
SVGA_REG_SCRATCH_SIZE = 29, /* Number of scratch registers */
|
|
|
|
SVGA_REG_MEM_REGS = 30, /* Number of FIFO registers */
|
|
|
|
SVGA_REG_NUM_DISPLAYS = 31, /* Number of guest displays */
|
|
|
|
SVGA_REG_PITCHLOCK = 32, /* Fixed pitch for all modes */
|
|
|
|
|
|
|
|
SVGA_PALETTE_BASE = 1024, /* Base of SVGA color map */
|
|
|
|
SVGA_PALETTE_END = SVGA_PALETTE_BASE + 767,
|
|
|
|
SVGA_SCRATCH_BASE = SVGA_PALETTE_BASE + 768,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SVGA_CAP_NONE 0
|
|
|
|
#define SVGA_CAP_RECT_FILL (1 << 0)
|
|
|
|
#define SVGA_CAP_RECT_COPY (1 << 1)
|
|
|
|
#define SVGA_CAP_RECT_PAT_FILL (1 << 2)
|
|
|
|
#define SVGA_CAP_LEGACY_OFFSCREEN (1 << 3)
|
|
|
|
#define SVGA_CAP_RASTER_OP (1 << 4)
|
|
|
|
#define SVGA_CAP_CURSOR (1 << 5)
|
|
|
|
#define SVGA_CAP_CURSOR_BYPASS (1 << 6)
|
|
|
|
#define SVGA_CAP_CURSOR_BYPASS_2 (1 << 7)
|
|
|
|
#define SVGA_CAP_8BIT_EMULATION (1 << 8)
|
|
|
|
#define SVGA_CAP_ALPHA_CURSOR (1 << 9)
|
|
|
|
#define SVGA_CAP_GLYPH (1 << 10)
|
|
|
|
#define SVGA_CAP_GLYPH_CLIPPING (1 << 11)
|
|
|
|
#define SVGA_CAP_OFFSCREEN_1 (1 << 12)
|
|
|
|
#define SVGA_CAP_ALPHA_BLEND (1 << 13)
|
|
|
|
#define SVGA_CAP_3D (1 << 14)
|
|
|
|
#define SVGA_CAP_EXTENDED_FIFO (1 << 15)
|
|
|
|
#define SVGA_CAP_MULTIMON (1 << 16)
|
|
|
|
#define SVGA_CAP_PITCHLOCK (1 << 17)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIFO offsets (seen as an array of 32-bit words)
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
/*
|
|
|
|
* The original defined FIFO offsets
|
|
|
|
*/
|
|
|
|
SVGA_FIFO_MIN = 0,
|
|
|
|
SVGA_FIFO_MAX, /* The distance from MIN to MAX must be at least 10K */
|
|
|
|
SVGA_FIFO_NEXT_CMD,
|
|
|
|
SVGA_FIFO_STOP,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Additional offsets added as of SVGA_CAP_EXTENDED_FIFO
|
|
|
|
*/
|
|
|
|
SVGA_FIFO_CAPABILITIES = 4,
|
|
|
|
SVGA_FIFO_FLAGS,
|
|
|
|
SVGA_FIFO_FENCE,
|
|
|
|
SVGA_FIFO_3D_HWVERSION,
|
|
|
|
SVGA_FIFO_PITCHLOCK,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SVGA_FIFO_CAP_NONE 0
|
|
|
|
#define SVGA_FIFO_CAP_FENCE (1 << 0)
|
|
|
|
#define SVGA_FIFO_CAP_ACCELFRONT (1 << 1)
|
|
|
|
#define SVGA_FIFO_CAP_PITCHLOCK (1 << 2)
|
|
|
|
|
|
|
|
#define SVGA_FIFO_FLAG_NONE 0
|
|
|
|
#define SVGA_FIFO_FLAG_ACCELFRONT (1 << 0)
|
|
|
|
|
|
|
|
/* These values can probably be changed arbitrarily. */
|
|
|
|
#define SVGA_SCRATCH_SIZE 0x8000
|
|
|
|
#define SVGA_MAX_WIDTH 2360
|
|
|
|
#define SVGA_MAX_HEIGHT 1770
|
|
|
|
|
|
|
|
#ifdef VERBOSE
|
|
|
|
# define GUEST_OS_BASE 0x5001
|
|
|
|
static const char *vmsvga_guest_id[] = {
|
2007-05-13 15:26:49 +02:00
|
|
|
[0x00] = "Dos",
|
|
|
|
[0x01] = "Windows 3.1",
|
|
|
|
[0x02] = "Windows 95",
|
|
|
|
[0x03] = "Windows 98",
|
|
|
|
[0x04] = "Windows ME",
|
|
|
|
[0x05] = "Windows NT",
|
|
|
|
[0x06] = "Windows 2000",
|
|
|
|
[0x07] = "Linux",
|
|
|
|
[0x08] = "OS/2",
|
2009-03-07 16:32:56 +01:00
|
|
|
[0x09] = "an unknown OS",
|
2007-05-13 15:26:49 +02:00
|
|
|
[0x0a] = "BSD",
|
|
|
|
[0x0b] = "Whistler",
|
2009-03-07 16:32:56 +01:00
|
|
|
[0x0c] = "an unknown OS",
|
|
|
|
[0x0d] = "an unknown OS",
|
|
|
|
[0x0e] = "an unknown OS",
|
|
|
|
[0x0f] = "an unknown OS",
|
|
|
|
[0x10] = "an unknown OS",
|
|
|
|
[0x11] = "an unknown OS",
|
|
|
|
[0x12] = "an unknown OS",
|
|
|
|
[0x13] = "an unknown OS",
|
|
|
|
[0x14] = "an unknown OS",
|
2007-05-13 15:26:49 +02:00
|
|
|
[0x15] = "Windows 2003",
|
2007-04-02 03:10:46 +02:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum {
|
|
|
|
SVGA_CMD_INVALID_CMD = 0,
|
|
|
|
SVGA_CMD_UPDATE = 1,
|
|
|
|
SVGA_CMD_RECT_FILL = 2,
|
|
|
|
SVGA_CMD_RECT_COPY = 3,
|
|
|
|
SVGA_CMD_DEFINE_BITMAP = 4,
|
|
|
|
SVGA_CMD_DEFINE_BITMAP_SCANLINE = 5,
|
|
|
|
SVGA_CMD_DEFINE_PIXMAP = 6,
|
|
|
|
SVGA_CMD_DEFINE_PIXMAP_SCANLINE = 7,
|
|
|
|
SVGA_CMD_RECT_BITMAP_FILL = 8,
|
|
|
|
SVGA_CMD_RECT_PIXMAP_FILL = 9,
|
|
|
|
SVGA_CMD_RECT_BITMAP_COPY = 10,
|
|
|
|
SVGA_CMD_RECT_PIXMAP_COPY = 11,
|
|
|
|
SVGA_CMD_FREE_OBJECT = 12,
|
|
|
|
SVGA_CMD_RECT_ROP_FILL = 13,
|
|
|
|
SVGA_CMD_RECT_ROP_COPY = 14,
|
|
|
|
SVGA_CMD_RECT_ROP_BITMAP_FILL = 15,
|
|
|
|
SVGA_CMD_RECT_ROP_PIXMAP_FILL = 16,
|
|
|
|
SVGA_CMD_RECT_ROP_BITMAP_COPY = 17,
|
|
|
|
SVGA_CMD_RECT_ROP_PIXMAP_COPY = 18,
|
|
|
|
SVGA_CMD_DEFINE_CURSOR = 19,
|
|
|
|
SVGA_CMD_DISPLAY_CURSOR = 20,
|
|
|
|
SVGA_CMD_MOVE_CURSOR = 21,
|
|
|
|
SVGA_CMD_DEFINE_ALPHA_CURSOR = 22,
|
|
|
|
SVGA_CMD_DRAW_GLYPH = 23,
|
|
|
|
SVGA_CMD_DRAW_GLYPH_CLIPPED = 24,
|
|
|
|
SVGA_CMD_UPDATE_VERBOSE = 25,
|
|
|
|
SVGA_CMD_SURFACE_FILL = 26,
|
|
|
|
SVGA_CMD_SURFACE_COPY = 27,
|
|
|
|
SVGA_CMD_SURFACE_ALPHA_BLEND = 28,
|
|
|
|
SVGA_CMD_FRONT_ROP_FILL = 29,
|
|
|
|
SVGA_CMD_FENCE = 30,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Legal values for the SVGA_REG_CURSOR_ON register in cursor bypass mode */
|
|
|
|
enum {
|
|
|
|
SVGA_CURSOR_ON_HIDE = 0,
|
|
|
|
SVGA_CURSOR_ON_SHOW = 1,
|
|
|
|
SVGA_CURSOR_ON_REMOVE_FROM_FB = 2,
|
|
|
|
SVGA_CURSOR_ON_RESTORE_TO_FB = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void vmsvga_update_rect(struct vmsvga_state_s *s,
|
|
|
|
int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
#ifndef DIRECT_VRAM
|
2008-03-06 21:43:34 +01:00
|
|
|
int line;
|
|
|
|
int bypl;
|
|
|
|
int width;
|
|
|
|
int start;
|
|
|
|
uint8_t *src;
|
|
|
|
uint8_t *dst;
|
|
|
|
|
|
|
|
if (x + w > s->width) {
|
|
|
|
fprintf(stderr, "%s: update width too large x: %d, w: %d\n",
|
|
|
|
__FUNCTION__, x, w);
|
|
|
|
x = MIN(x, s->width);
|
|
|
|
w = s->width - x;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (y + h > s->height) {
|
|
|
|
fprintf(stderr, "%s: update height too large y: %d, h: %d\n",
|
|
|
|
__FUNCTION__, y, h);
|
|
|
|
y = MIN(y, s->height);
|
|
|
|
h = s->height - y;
|
|
|
|
}
|
|
|
|
|
|
|
|
line = h;
|
|
|
|
bypl = s->bypp * s->width;
|
|
|
|
width = s->bypp * w;
|
|
|
|
start = s->bypp * x + bypl * y;
|
2009-05-03 21:25:16 +02:00
|
|
|
src = s->vga.vram_ptr + start;
|
|
|
|
dst = ds_get_data(s->vga.ds) + start;
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
for (; line > 0; line --, src += bypl, dst += bypl)
|
|
|
|
memcpy(dst, src, width);
|
|
|
|
#endif
|
|
|
|
|
2009-05-03 21:25:16 +02:00
|
|
|
dpy_update(s->vga.ds, x, y, w, h);
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void vmsvga_update_screen(struct vmsvga_state_s *s)
|
|
|
|
{
|
|
|
|
#ifndef DIRECT_VRAM
|
2009-05-03 21:25:16 +02:00
|
|
|
memcpy(ds_get_data(s->vga.ds), s->vga.vram_ptr, s->bypp * s->width * s->height);
|
2007-04-02 03:10:46 +02:00
|
|
|
#endif
|
|
|
|
|
2009-05-03 21:25:16 +02:00
|
|
|
dpy_update(s->vga.ds, 0, 0, s->width, s->height);
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DIRECT_VRAM
|
|
|
|
# define vmsvga_update_rect_delayed vmsvga_update_rect
|
|
|
|
#else
|
|
|
|
static inline void vmsvga_update_rect_delayed(struct vmsvga_state_s *s,
|
|
|
|
int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
struct vmsvga_rect_s *rect = &s->redraw_fifo[s->redraw_fifo_last ++];
|
|
|
|
s->redraw_fifo_last &= REDRAW_FIFO_LEN - 1;
|
|
|
|
rect->x = x;
|
|
|
|
rect->y = y;
|
|
|
|
rect->w = w;
|
|
|
|
rect->h = h;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline void vmsvga_update_rect_flush(struct vmsvga_state_s *s)
|
|
|
|
{
|
|
|
|
struct vmsvga_rect_s *rect;
|
|
|
|
if (s->invalidated) {
|
|
|
|
s->redraw_fifo_first = s->redraw_fifo_last;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Overlapping region updates can be optimised out here - if someone
|
|
|
|
* knows a smart algorithm to do that, please share. */
|
|
|
|
while (s->redraw_fifo_first != s->redraw_fifo_last) {
|
|
|
|
rect = &s->redraw_fifo[s->redraw_fifo_first ++];
|
|
|
|
s->redraw_fifo_first &= REDRAW_FIFO_LEN - 1;
|
|
|
|
vmsvga_update_rect(s, rect->x, rect->y, rect->w, rect->h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HW_RECT_ACCEL
|
|
|
|
static inline void vmsvga_copy_rect(struct vmsvga_state_s *s,
|
|
|
|
int x0, int y0, int x1, int y1, int w, int h)
|
|
|
|
{
|
|
|
|
# ifdef DIRECT_VRAM
|
2008-11-24 20:29:13 +01:00
|
|
|
uint8_t *vram = ds_get_data(s->ds);
|
2007-04-02 03:10:46 +02:00
|
|
|
# else
|
2009-05-03 21:25:16 +02:00
|
|
|
uint8_t *vram = s->vga.vram_ptr;
|
2007-04-02 03:10:46 +02:00
|
|
|
# endif
|
|
|
|
int bypl = s->bypp * s->width;
|
|
|
|
int width = s->bypp * w;
|
|
|
|
int line = h;
|
|
|
|
uint8_t *ptr[2];
|
|
|
|
|
|
|
|
# ifdef DIRECT_VRAM
|
|
|
|
if (s->ds->dpy_copy)
|
2009-01-16 20:04:14 +01:00
|
|
|
qemu_console_copy(s->ds, x0, y0, x1, y1, w, h);
|
2007-04-02 03:10:46 +02:00
|
|
|
else
|
|
|
|
# endif
|
|
|
|
{
|
|
|
|
if (y1 > y0) {
|
|
|
|
ptr[0] = vram + s->bypp * x0 + bypl * (y0 + h - 1);
|
|
|
|
ptr[1] = vram + s->bypp * x1 + bypl * (y1 + h - 1);
|
|
|
|
for (; line > 0; line --, ptr[0] -= bypl, ptr[1] -= bypl)
|
|
|
|
memmove(ptr[1], ptr[0], width);
|
|
|
|
} else {
|
|
|
|
ptr[0] = vram + s->bypp * x0 + bypl * y0;
|
|
|
|
ptr[1] = vram + s->bypp * x1 + bypl * y1;
|
|
|
|
for (; line > 0; line --, ptr[0] += bypl, ptr[1] += bypl)
|
|
|
|
memmove(ptr[1], ptr[0], width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vmsvga_update_rect_delayed(s, x1, y1, w, h);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HW_FILL_ACCEL
|
|
|
|
static inline void vmsvga_fill_rect(struct vmsvga_state_s *s,
|
|
|
|
uint32_t c, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
# ifdef DIRECT_VRAM
|
2008-11-24 20:29:13 +01:00
|
|
|
uint8_t *vram = ds_get_data(s->ds);
|
2007-04-02 03:10:46 +02:00
|
|
|
# else
|
2009-05-03 21:25:16 +02:00
|
|
|
uint8_t *vram = s->vga.vram_ptr;
|
2007-04-02 03:10:46 +02:00
|
|
|
# endif
|
|
|
|
int bypp = s->bypp;
|
|
|
|
int bypl = bypp * s->width;
|
|
|
|
int width = bypp * w;
|
|
|
|
int line = h;
|
|
|
|
int column;
|
|
|
|
uint8_t *fst = vram + bypp * x + bypl * y;
|
|
|
|
uint8_t *dst;
|
|
|
|
uint8_t *src;
|
|
|
|
uint8_t col[4];
|
|
|
|
|
|
|
|
# ifdef DIRECT_VRAM
|
|
|
|
if (s->ds->dpy_fill)
|
|
|
|
s->ds->dpy_fill(s->ds, x, y, w, h, c);
|
|
|
|
else
|
|
|
|
# endif
|
|
|
|
{
|
|
|
|
col[0] = c;
|
|
|
|
col[1] = c >> 8;
|
|
|
|
col[2] = c >> 16;
|
|
|
|
col[3] = c >> 24;
|
|
|
|
|
|
|
|
if (line --) {
|
|
|
|
dst = fst;
|
|
|
|
src = col;
|
|
|
|
for (column = width; column > 0; column --) {
|
|
|
|
*(dst ++) = *(src ++);
|
|
|
|
if (src - col == bypp)
|
|
|
|
src = col;
|
|
|
|
}
|
|
|
|
dst = fst;
|
|
|
|
for (; line > 0; line --) {
|
|
|
|
dst += bypl;
|
|
|
|
memcpy(dst, fst, width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vmsvga_update_rect_delayed(s, x, y, w, h);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct vmsvga_cursor_definition_s {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int id;
|
|
|
|
int bpp;
|
|
|
|
int hot_x;
|
|
|
|
int hot_y;
|
|
|
|
uint32_t mask[1024];
|
2009-12-17 23:08:11 +01:00
|
|
|
uint32_t image[4096];
|
2007-04-02 03:10:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#define SVGA_BITMAP_SIZE(w, h) ((((w) + 31) >> 5) * (h))
|
|
|
|
#define SVGA_PIXMAP_SIZE(w, h, bpp) (((((w) * (bpp)) + 31) >> 5) * (h))
|
|
|
|
|
|
|
|
#ifdef HW_MOUSE_ACCEL
|
|
|
|
static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
|
|
|
|
struct vmsvga_cursor_definition_s *c)
|
|
|
|
{
|
2010-05-21 11:54:33 +02:00
|
|
|
QEMUCursor *qc;
|
|
|
|
int i, pixels;
|
|
|
|
|
|
|
|
qc = cursor_alloc(c->width, c->height);
|
|
|
|
qc->hot_x = c->hot_x;
|
|
|
|
qc->hot_y = c->hot_y;
|
|
|
|
switch (c->bpp) {
|
|
|
|
case 1:
|
|
|
|
cursor_set_mono(qc, 0xffffff, 0x000000, (void*)c->image,
|
|
|
|
1, (void*)c->mask);
|
|
|
|
#ifdef DEBUG
|
|
|
|
cursor_print_ascii_art(qc, "vmware/mono");
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
/* fill alpha channel from mask, set color to zero */
|
|
|
|
cursor_set_mono(qc, 0x000000, 0x000000, (void*)c->mask,
|
|
|
|
1, (void*)c->mask);
|
|
|
|
/* add in rgb values */
|
|
|
|
pixels = c->width * c->height;
|
|
|
|
for (i = 0; i < pixels; i++) {
|
|
|
|
qc->data[i] |= c->image[i] & 0xffffff;
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
cursor_print_ascii_art(qc, "vmware/32bit");
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "%s: unhandled bpp %d, using fallback cursor\n",
|
|
|
|
__FUNCTION__, c->bpp);
|
|
|
|
cursor_put(qc);
|
|
|
|
qc = cursor_builtin_left_ptr();
|
|
|
|
}
|
2007-04-02 03:10:46 +02:00
|
|
|
|
2009-05-03 21:25:16 +02:00
|
|
|
if (s->vga.ds->cursor_define)
|
2010-05-21 11:54:33 +02:00
|
|
|
s->vga.ds->cursor_define(qc);
|
|
|
|
cursor_put(qc);
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-07-16 06:45:12 +02:00
|
|
|
#define CMD(f) le32_to_cpu(s->cmd->f)
|
|
|
|
|
2010-09-10 02:23:31 +02:00
|
|
|
static inline int vmsvga_fifo_length(struct vmsvga_state_s *s)
|
2007-04-02 03:10:46 +02:00
|
|
|
{
|
2010-09-10 02:23:31 +02:00
|
|
|
int num;
|
2007-04-02 03:10:46 +02:00
|
|
|
if (!s->config || !s->enable)
|
2010-09-10 02:23:31 +02:00
|
|
|
return 0;
|
|
|
|
num = CMD(next_cmd) - CMD(stop);
|
|
|
|
if (num < 0)
|
|
|
|
num += CMD(max) - CMD(min);
|
|
|
|
return num >> 2;
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
2008-07-16 06:45:12 +02:00
|
|
|
static inline uint32_t vmsvga_fifo_read_raw(struct vmsvga_state_s *s)
|
2007-04-02 03:10:46 +02:00
|
|
|
{
|
2008-07-16 06:45:12 +02:00
|
|
|
uint32_t cmd = s->fifo[CMD(stop) >> 2];
|
|
|
|
s->cmd->stop = cpu_to_le32(CMD(stop) + 4);
|
|
|
|
if (CMD(stop) >= CMD(max))
|
2007-04-02 03:10:46 +02:00
|
|
|
s->cmd->stop = s->cmd->min;
|
|
|
|
return cmd;
|
|
|
|
}
|
|
|
|
|
2008-07-16 06:45:12 +02:00
|
|
|
static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s)
|
|
|
|
{
|
|
|
|
return le32_to_cpu(vmsvga_fifo_read_raw(s));
|
|
|
|
}
|
|
|
|
|
2007-04-02 03:10:46 +02:00
|
|
|
static void vmsvga_fifo_run(struct vmsvga_state_s *s)
|
|
|
|
{
|
|
|
|
uint32_t cmd, colour;
|
2010-09-10 02:23:31 +02:00
|
|
|
int args, len;
|
2007-04-02 03:10:46 +02:00
|
|
|
int x, y, dx, dy, width, height;
|
|
|
|
struct vmsvga_cursor_definition_s cursor;
|
2010-09-10 02:23:31 +02:00
|
|
|
uint32_t cmd_start;
|
|
|
|
|
|
|
|
len = vmsvga_fifo_length(s);
|
|
|
|
while (len > 0) {
|
|
|
|
/* May need to go back to the start of the command if incomplete */
|
|
|
|
cmd_start = s->cmd->stop;
|
|
|
|
|
2007-04-02 03:10:46 +02:00
|
|
|
switch (cmd = vmsvga_fifo_read(s)) {
|
|
|
|
case SVGA_CMD_UPDATE:
|
|
|
|
case SVGA_CMD_UPDATE_VERBOSE:
|
2010-09-10 02:23:31 +02:00
|
|
|
len -= 5;
|
|
|
|
if (len < 0)
|
|
|
|
goto rewind;
|
|
|
|
|
2007-04-02 03:10:46 +02:00
|
|
|
x = vmsvga_fifo_read(s);
|
|
|
|
y = vmsvga_fifo_read(s);
|
|
|
|
width = vmsvga_fifo_read(s);
|
|
|
|
height = vmsvga_fifo_read(s);
|
|
|
|
vmsvga_update_rect_delayed(s, x, y, width, height);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_CMD_RECT_FILL:
|
2010-09-10 02:23:31 +02:00
|
|
|
len -= 6;
|
|
|
|
if (len < 0)
|
|
|
|
goto rewind;
|
|
|
|
|
2007-04-02 03:10:46 +02:00
|
|
|
colour = vmsvga_fifo_read(s);
|
|
|
|
x = vmsvga_fifo_read(s);
|
|
|
|
y = vmsvga_fifo_read(s);
|
|
|
|
width = vmsvga_fifo_read(s);
|
|
|
|
height = vmsvga_fifo_read(s);
|
|
|
|
#ifdef HW_FILL_ACCEL
|
|
|
|
vmsvga_fill_rect(s, colour, x, y, width, height);
|
|
|
|
break;
|
|
|
|
#else
|
2010-09-10 02:23:31 +02:00
|
|
|
args = 0;
|
2007-04-02 03:10:46 +02:00
|
|
|
goto badcmd;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case SVGA_CMD_RECT_COPY:
|
2010-09-10 02:23:31 +02:00
|
|
|
len -= 7;
|
|
|
|
if (len < 0)
|
|
|
|
goto rewind;
|
|
|
|
|
2007-04-02 03:10:46 +02:00
|
|
|
x = vmsvga_fifo_read(s);
|
|
|
|
y = vmsvga_fifo_read(s);
|
|
|
|
dx = vmsvga_fifo_read(s);
|
|
|
|
dy = vmsvga_fifo_read(s);
|
|
|
|
width = vmsvga_fifo_read(s);
|
|
|
|
height = vmsvga_fifo_read(s);
|
|
|
|
#ifdef HW_RECT_ACCEL
|
|
|
|
vmsvga_copy_rect(s, x, y, dx, dy, width, height);
|
|
|
|
break;
|
|
|
|
#else
|
2010-09-10 02:23:31 +02:00
|
|
|
args = 0;
|
2007-04-02 03:10:46 +02:00
|
|
|
goto badcmd;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case SVGA_CMD_DEFINE_CURSOR:
|
2010-09-10 02:23:31 +02:00
|
|
|
len -= 8;
|
|
|
|
if (len < 0)
|
|
|
|
goto rewind;
|
|
|
|
|
2007-04-02 03:10:46 +02:00
|
|
|
cursor.id = vmsvga_fifo_read(s);
|
|
|
|
cursor.hot_x = vmsvga_fifo_read(s);
|
|
|
|
cursor.hot_y = vmsvga_fifo_read(s);
|
|
|
|
cursor.width = x = vmsvga_fifo_read(s);
|
|
|
|
cursor.height = y = vmsvga_fifo_read(s);
|
|
|
|
vmsvga_fifo_read(s);
|
|
|
|
cursor.bpp = vmsvga_fifo_read(s);
|
2010-01-06 05:43:34 +01:00
|
|
|
|
2010-09-10 02:23:31 +02:00
|
|
|
args = SVGA_BITMAP_SIZE(x, y) + SVGA_PIXMAP_SIZE(x, y, cursor.bpp);
|
2010-09-10 02:30:04 +02:00
|
|
|
if (SVGA_BITMAP_SIZE(x, y) > sizeof cursor.mask ||
|
|
|
|
SVGA_PIXMAP_SIZE(x, y, cursor.bpp) > sizeof cursor.image)
|
|
|
|
goto badcmd;
|
2010-09-10 02:23:31 +02:00
|
|
|
|
|
|
|
len -= args;
|
|
|
|
if (len < 0)
|
|
|
|
goto rewind;
|
2010-01-06 05:43:34 +01:00
|
|
|
|
2007-04-02 03:10:46 +02:00
|
|
|
for (args = 0; args < SVGA_BITMAP_SIZE(x, y); args ++)
|
2008-07-16 06:45:12 +02:00
|
|
|
cursor.mask[args] = vmsvga_fifo_read_raw(s);
|
2007-04-02 03:10:46 +02:00
|
|
|
for (args = 0; args < SVGA_PIXMAP_SIZE(x, y, cursor.bpp); args ++)
|
2008-07-16 06:45:12 +02:00
|
|
|
cursor.image[args] = vmsvga_fifo_read_raw(s);
|
2007-04-02 03:10:46 +02:00
|
|
|
#ifdef HW_MOUSE_ACCEL
|
|
|
|
vmsvga_cursor_define(s, &cursor);
|
|
|
|
break;
|
|
|
|
#else
|
|
|
|
args = 0;
|
|
|
|
goto badcmd;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Other commands that we at least know the number of arguments
|
|
|
|
* for so we can avoid FIFO desync if driver uses them illegally.
|
|
|
|
*/
|
|
|
|
case SVGA_CMD_DEFINE_ALPHA_CURSOR:
|
2010-09-10 02:23:31 +02:00
|
|
|
len -= 6;
|
|
|
|
if (len < 0)
|
|
|
|
goto rewind;
|
|
|
|
|
2007-04-02 03:10:46 +02:00
|
|
|
vmsvga_fifo_read(s);
|
|
|
|
vmsvga_fifo_read(s);
|
|
|
|
vmsvga_fifo_read(s);
|
|
|
|
x = vmsvga_fifo_read(s);
|
|
|
|
y = vmsvga_fifo_read(s);
|
|
|
|
args = x * y;
|
|
|
|
goto badcmd;
|
|
|
|
case SVGA_CMD_RECT_ROP_FILL:
|
|
|
|
args = 6;
|
|
|
|
goto badcmd;
|
|
|
|
case SVGA_CMD_RECT_ROP_COPY:
|
|
|
|
args = 7;
|
|
|
|
goto badcmd;
|
|
|
|
case SVGA_CMD_DRAW_GLYPH_CLIPPED:
|
2010-09-10 02:23:31 +02:00
|
|
|
len -= 4;
|
|
|
|
if (len < 0)
|
|
|
|
goto rewind;
|
|
|
|
|
2007-04-02 03:10:46 +02:00
|
|
|
vmsvga_fifo_read(s);
|
|
|
|
vmsvga_fifo_read(s);
|
|
|
|
args = 7 + (vmsvga_fifo_read(s) >> 2);
|
|
|
|
goto badcmd;
|
|
|
|
case SVGA_CMD_SURFACE_ALPHA_BLEND:
|
|
|
|
args = 12;
|
|
|
|
goto badcmd;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Other commands that are not listed as depending on any
|
|
|
|
* CAPABILITIES bits, but are not described in the README either.
|
|
|
|
*/
|
|
|
|
case SVGA_CMD_SURFACE_FILL:
|
|
|
|
case SVGA_CMD_SURFACE_COPY:
|
|
|
|
case SVGA_CMD_FRONT_ROP_FILL:
|
|
|
|
case SVGA_CMD_FENCE:
|
|
|
|
case SVGA_CMD_INVALID_CMD:
|
|
|
|
break; /* Nop */
|
|
|
|
|
|
|
|
default:
|
2010-09-10 02:23:31 +02:00
|
|
|
args = 0;
|
2007-04-02 03:10:46 +02:00
|
|
|
badcmd:
|
2010-09-10 02:23:31 +02:00
|
|
|
len -= args;
|
|
|
|
if (len < 0)
|
|
|
|
goto rewind;
|
2007-04-02 03:10:46 +02:00
|
|
|
while (args --)
|
|
|
|
vmsvga_fifo_read(s);
|
|
|
|
printf("%s: Unknown command 0x%02x in SVGA command FIFO\n",
|
|
|
|
__FUNCTION__, cmd);
|
|
|
|
break;
|
2010-09-10 02:23:31 +02:00
|
|
|
|
|
|
|
rewind:
|
|
|
|
s->cmd->stop = cmd_start;
|
|
|
|
break;
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
2010-09-10 02:23:31 +02:00
|
|
|
}
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
s->syncing = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t vmsvga_index_read(void *opaque, uint32_t address)
|
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
return s->index;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vmsvga_index_write(void *opaque, uint32_t address, uint32_t index)
|
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
s->index = index;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
|
|
|
|
{
|
|
|
|
uint32_t caps;
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
switch (s->index) {
|
|
|
|
case SVGA_REG_ID:
|
|
|
|
return s->svgaid;
|
|
|
|
|
|
|
|
case SVGA_REG_ENABLE:
|
|
|
|
return s->enable;
|
|
|
|
|
|
|
|
case SVGA_REG_WIDTH:
|
|
|
|
return s->width;
|
|
|
|
|
|
|
|
case SVGA_REG_HEIGHT:
|
|
|
|
return s->height;
|
|
|
|
|
|
|
|
case SVGA_REG_MAX_WIDTH:
|
|
|
|
return SVGA_MAX_WIDTH;
|
|
|
|
|
|
|
|
case SVGA_REG_MAX_HEIGHT:
|
2007-05-13 15:26:49 +02:00
|
|
|
return SVGA_MAX_HEIGHT;
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
case SVGA_REG_DEPTH:
|
|
|
|
return s->depth;
|
|
|
|
|
|
|
|
case SVGA_REG_BITS_PER_PIXEL:
|
|
|
|
return (s->depth + 7) & ~7;
|
|
|
|
|
|
|
|
case SVGA_REG_PSEUDOCOLOR:
|
|
|
|
return 0x0;
|
|
|
|
|
|
|
|
case SVGA_REG_RED_MASK:
|
|
|
|
return s->wred;
|
|
|
|
case SVGA_REG_GREEN_MASK:
|
|
|
|
return s->wgreen;
|
|
|
|
case SVGA_REG_BLUE_MASK:
|
|
|
|
return s->wblue;
|
|
|
|
|
|
|
|
case SVGA_REG_BYTES_PER_LINE:
|
|
|
|
return ((s->depth + 7) >> 3) * s->new_width;
|
|
|
|
|
|
|
|
case SVGA_REG_FB_START:
|
2008-03-06 21:28:49 +01:00
|
|
|
return s->vram_base;
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
case SVGA_REG_FB_OFFSET:
|
|
|
|
return 0x0;
|
|
|
|
|
|
|
|
case SVGA_REG_VRAM_SIZE:
|
2009-12-17 23:08:06 +01:00
|
|
|
return s->vga.vram_size;
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
case SVGA_REG_FB_SIZE:
|
|
|
|
return s->fb_size;
|
|
|
|
|
|
|
|
case SVGA_REG_CAPABILITIES:
|
|
|
|
caps = SVGA_CAP_NONE;
|
|
|
|
#ifdef HW_RECT_ACCEL
|
|
|
|
caps |= SVGA_CAP_RECT_COPY;
|
|
|
|
#endif
|
|
|
|
#ifdef HW_FILL_ACCEL
|
|
|
|
caps |= SVGA_CAP_RECT_FILL;
|
|
|
|
#endif
|
|
|
|
#ifdef HW_MOUSE_ACCEL
|
2009-05-03 21:25:16 +02:00
|
|
|
if (s->vga.ds->mouse_set)
|
2007-04-02 03:10:46 +02:00
|
|
|
caps |= SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 |
|
|
|
|
SVGA_CAP_CURSOR_BYPASS;
|
|
|
|
#endif
|
|
|
|
return caps;
|
|
|
|
|
|
|
|
case SVGA_REG_MEM_START:
|
2009-12-17 23:08:06 +01:00
|
|
|
return s->fifo_base;
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
case SVGA_REG_MEM_SIZE:
|
2009-12-17 23:08:06 +01:00
|
|
|
return s->fifo_size;
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
case SVGA_REG_CONFIG_DONE:
|
|
|
|
return s->config;
|
|
|
|
|
|
|
|
case SVGA_REG_SYNC:
|
|
|
|
case SVGA_REG_BUSY:
|
|
|
|
return s->syncing;
|
|
|
|
|
|
|
|
case SVGA_REG_GUEST_ID:
|
|
|
|
return s->guest;
|
|
|
|
|
|
|
|
case SVGA_REG_CURSOR_ID:
|
|
|
|
return s->cursor.id;
|
|
|
|
|
|
|
|
case SVGA_REG_CURSOR_X:
|
|
|
|
return s->cursor.x;
|
|
|
|
|
|
|
|
case SVGA_REG_CURSOR_Y:
|
|
|
|
return s->cursor.x;
|
|
|
|
|
|
|
|
case SVGA_REG_CURSOR_ON:
|
|
|
|
return s->cursor.on;
|
|
|
|
|
|
|
|
case SVGA_REG_HOST_BITS_PER_PIXEL:
|
|
|
|
return (s->depth + 7) & ~7;
|
|
|
|
|
|
|
|
case SVGA_REG_SCRATCH_SIZE:
|
|
|
|
return s->scratch_size;
|
|
|
|
|
|
|
|
case SVGA_REG_MEM_REGS:
|
|
|
|
case SVGA_REG_NUM_DISPLAYS:
|
|
|
|
case SVGA_REG_PITCHLOCK:
|
|
|
|
case SVGA_PALETTE_BASE ... SVGA_PALETTE_END:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (s->index >= SVGA_SCRATCH_BASE &&
|
|
|
|
s->index < SVGA_SCRATCH_BASE + s->scratch_size)
|
|
|
|
return s->scratch[s->index - SVGA_SCRATCH_BASE];
|
|
|
|
printf("%s: Bad register %02x\n", __FUNCTION__, s->index);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
|
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
switch (s->index) {
|
|
|
|
case SVGA_REG_ID:
|
|
|
|
if (value == SVGA_ID_2 || value == SVGA_ID_1 || value == SVGA_ID_0)
|
|
|
|
s->svgaid = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_ENABLE:
|
2007-05-13 15:26:49 +02:00
|
|
|
s->enable = value;
|
|
|
|
s->config &= !!value;
|
2007-04-02 03:10:46 +02:00
|
|
|
s->width = -1;
|
|
|
|
s->height = -1;
|
|
|
|
s->invalidated = 1;
|
2009-05-03 21:25:16 +02:00
|
|
|
s->vga.invalidate(&s->vga);
|
2009-12-17 23:08:10 +01:00
|
|
|
if (s->enable) {
|
2010-09-10 02:30:04 +02:00
|
|
|
s->fb_size = ((s->depth + 7) >> 3) * s->new_width * s->new_height;
|
|
|
|
vga_dirty_log_stop(&s->vga);
|
|
|
|
} else {
|
|
|
|
vga_dirty_log_start(&s->vga);
|
|
|
|
}
|
2007-04-02 03:10:46 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_WIDTH:
|
|
|
|
s->new_width = value;
|
|
|
|
s->invalidated = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_HEIGHT:
|
|
|
|
s->new_height = value;
|
|
|
|
s->invalidated = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_DEPTH:
|
|
|
|
case SVGA_REG_BITS_PER_PIXEL:
|
|
|
|
if (value != s->depth) {
|
|
|
|
printf("%s: Bad colour depth: %i bits\n", __FUNCTION__, value);
|
|
|
|
s->config = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_CONFIG_DONE:
|
|
|
|
if (value) {
|
2009-12-17 23:08:06 +01:00
|
|
|
s->fifo = (uint32_t *) s->fifo_ptr;
|
2007-04-02 03:10:46 +02:00
|
|
|
/* Check range and alignment. */
|
2008-07-16 06:45:12 +02:00
|
|
|
if ((CMD(min) | CMD(max) |
|
|
|
|
CMD(next_cmd) | CMD(stop)) & 3)
|
2007-04-02 03:10:46 +02:00
|
|
|
break;
|
2008-07-16 06:45:12 +02:00
|
|
|
if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo)
|
2007-04-02 03:10:46 +02:00
|
|
|
break;
|
2008-07-16 06:45:12 +02:00
|
|
|
if (CMD(max) > SVGA_FIFO_SIZE)
|
2007-04-02 03:10:46 +02:00
|
|
|
break;
|
2008-07-16 06:45:12 +02:00
|
|
|
if (CMD(max) < CMD(min) + 10 * 1024)
|
2007-04-02 03:10:46 +02:00
|
|
|
break;
|
|
|
|
}
|
2007-05-13 15:26:49 +02:00
|
|
|
s->config = !!value;
|
2007-04-02 03:10:46 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_SYNC:
|
|
|
|
s->syncing = 1;
|
|
|
|
vmsvga_fifo_run(s); /* Or should we just wait for update_display? */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_GUEST_ID:
|
|
|
|
s->guest = value;
|
|
|
|
#ifdef VERBOSE
|
|
|
|
if (value >= GUEST_OS_BASE && value < GUEST_OS_BASE +
|
2008-12-22 21:33:55 +01:00
|
|
|
ARRAY_SIZE(vmsvga_guest_id))
|
2007-04-02 03:10:46 +02:00
|
|
|
printf("%s: guest runs %s.\n", __FUNCTION__,
|
|
|
|
vmsvga_guest_id[value - GUEST_OS_BASE]);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_CURSOR_ID:
|
|
|
|
s->cursor.id = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_CURSOR_X:
|
|
|
|
s->cursor.x = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_CURSOR_Y:
|
|
|
|
s->cursor.y = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_CURSOR_ON:
|
|
|
|
s->cursor.on |= (value == SVGA_CURSOR_ON_SHOW);
|
|
|
|
s->cursor.on &= (value != SVGA_CURSOR_ON_HIDE);
|
|
|
|
#ifdef HW_MOUSE_ACCEL
|
2009-05-03 21:25:16 +02:00
|
|
|
if (s->vga.ds->mouse_set && value <= SVGA_CURSOR_ON_SHOW)
|
|
|
|
s->vga.ds->mouse_set(s->cursor.x, s->cursor.y, s->cursor.on);
|
2007-04-02 03:10:46 +02:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVGA_REG_MEM_REGS:
|
|
|
|
case SVGA_REG_NUM_DISPLAYS:
|
|
|
|
case SVGA_REG_PITCHLOCK:
|
|
|
|
case SVGA_PALETTE_BASE ... SVGA_PALETTE_END:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (s->index >= SVGA_SCRATCH_BASE &&
|
|
|
|
s->index < SVGA_SCRATCH_BASE + s->scratch_size) {
|
|
|
|
s->scratch[s->index - SVGA_SCRATCH_BASE] = value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printf("%s: Bad register %02x\n", __FUNCTION__, s->index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t vmsvga_bios_read(void *opaque, uint32_t address)
|
|
|
|
{
|
|
|
|
printf("%s: what are we supposed to return?\n", __FUNCTION__);
|
|
|
|
return 0xcafe;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vmsvga_bios_write(void *opaque, uint32_t address, uint32_t data)
|
|
|
|
{
|
|
|
|
printf("%s: what are we supposed to do with (%08x)?\n",
|
|
|
|
__FUNCTION__, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void vmsvga_size(struct vmsvga_state_s *s)
|
|
|
|
{
|
|
|
|
if (s->new_width != s->width || s->new_height != s->height) {
|
|
|
|
s->width = s->new_width;
|
|
|
|
s->height = s->new_height;
|
2009-05-03 21:25:16 +02:00
|
|
|
qemu_console_resize(s->vga.ds, s->width, s->height);
|
2007-04-02 03:10:46 +02:00
|
|
|
s->invalidated = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vmsvga_update_display(void *opaque)
|
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
if (!s->enable) {
|
2009-05-03 21:25:16 +02:00
|
|
|
s->vga.update(&s->vga);
|
2007-04-02 03:10:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
vmsvga_size(s);
|
|
|
|
|
|
|
|
vmsvga_fifo_run(s);
|
|
|
|
vmsvga_update_rect_flush(s);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is it more efficient to look at vram VGA-dirty bits or wait
|
|
|
|
* for the driver to issue SVGA_CMD_UPDATE?
|
|
|
|
*/
|
|
|
|
if (s->invalidated) {
|
|
|
|
s->invalidated = 0;
|
|
|
|
vmsvga_update_screen(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vmsvga_reset(struct vmsvga_state_s *s)
|
|
|
|
{
|
|
|
|
s->index = 0;
|
|
|
|
s->enable = 0;
|
|
|
|
s->config = 0;
|
|
|
|
s->width = -1;
|
|
|
|
s->height = -1;
|
|
|
|
s->svgaid = SVGA_ID;
|
2009-12-17 23:08:09 +01:00
|
|
|
s->depth = ds_get_bits_per_pixel(s->vga.ds);
|
|
|
|
s->bypp = ds_get_bytes_per_pixel(s->vga.ds);
|
2007-04-02 03:10:46 +02:00
|
|
|
s->cursor.on = 0;
|
|
|
|
s->redraw_fifo_first = 0;
|
|
|
|
s->redraw_fifo_last = 0;
|
|
|
|
switch (s->depth) {
|
|
|
|
case 8:
|
|
|
|
s->wred = 0x00000007;
|
|
|
|
s->wgreen = 0x00000038;
|
|
|
|
s->wblue = 0x000000c0;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
s->wred = 0x0000001f;
|
|
|
|
s->wgreen = 0x000003e0;
|
|
|
|
s->wblue = 0x00007c00;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
s->wred = 0x0000001f;
|
|
|
|
s->wgreen = 0x000007e0;
|
|
|
|
s->wblue = 0x0000f800;
|
|
|
|
break;
|
|
|
|
case 24:
|
2007-05-13 15:26:49 +02:00
|
|
|
s->wred = 0x00ff0000;
|
2007-04-02 03:10:46 +02:00
|
|
|
s->wgreen = 0x0000ff00;
|
2007-05-13 15:26:49 +02:00
|
|
|
s->wblue = 0x000000ff;
|
2007-04-02 03:10:46 +02:00
|
|
|
break;
|
|
|
|
case 32:
|
2007-05-13 15:26:49 +02:00
|
|
|
s->wred = 0x00ff0000;
|
2007-04-02 03:10:46 +02:00
|
|
|
s->wgreen = 0x0000ff00;
|
2007-05-13 15:26:49 +02:00
|
|
|
s->wblue = 0x000000ff;
|
2007-04-02 03:10:46 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
s->syncing = 0;
|
2009-12-17 23:08:10 +01:00
|
|
|
|
|
|
|
vga_dirty_log_start(&s->vga);
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void vmsvga_invalidate_display(void *opaque)
|
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
if (!s->enable) {
|
2009-05-03 21:25:16 +02:00
|
|
|
s->vga.invalidate(&s->vga);
|
2007-04-02 03:10:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
s->invalidated = 1;
|
|
|
|
}
|
|
|
|
|
2007-05-13 15:26:49 +02:00
|
|
|
/* save the vga display in a PPM image even if no display is
|
|
|
|
available */
|
2007-04-02 03:10:46 +02:00
|
|
|
static void vmsvga_screen_dump(void *opaque, const char *filename)
|
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
if (!s->enable) {
|
2009-05-03 21:25:16 +02:00
|
|
|
s->vga.screen_dump(&s->vga, filename);
|
2007-04-02 03:10:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-13 15:26:49 +02:00
|
|
|
if (s->depth == 32) {
|
2009-01-16 20:07:10 +01:00
|
|
|
DisplaySurface *ds = qemu_create_displaysurface_from(s->width,
|
2009-05-03 21:25:16 +02:00
|
|
|
s->height, 32, ds_get_linesize(s->vga.ds), s->vga.vram_ptr);
|
2009-01-16 20:07:10 +01:00
|
|
|
ppm_save(filename, ds);
|
|
|
|
qemu_free(ds);
|
2007-05-13 15:26:49 +02:00
|
|
|
}
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
|
2008-02-10 17:33:14 +01:00
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2008-02-10 17:33:14 +01:00
|
|
|
|
2009-05-03 21:25:16 +02:00
|
|
|
if (s->vga.text_update)
|
|
|
|
s->vga.text_update(&s->vga, chardata);
|
2008-02-10 17:33:14 +01:00
|
|
|
}
|
|
|
|
|
2007-04-02 03:10:46 +02:00
|
|
|
#ifdef DIRECT_VRAM
|
2009-10-01 23:12:16 +02:00
|
|
|
static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr)
|
2007-04-02 03:10:46 +02:00
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
if (addr < s->fb_size)
|
2008-11-24 20:29:13 +01:00
|
|
|
return *(uint8_t *) (ds_get_data(s->ds) + addr);
|
2007-04-02 03:10:46 +02:00
|
|
|
else
|
2009-04-10 04:24:36 +02:00
|
|
|
return *(uint8_t *) (s->vram_ptr + addr);
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static uint32_t vmsvga_vram_readw(void *opaque, target_phys_addr_t addr)
|
2007-04-02 03:10:46 +02:00
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
if (addr < s->fb_size)
|
2008-11-24 20:29:13 +01:00
|
|
|
return *(uint16_t *) (ds_get_data(s->ds) + addr);
|
2007-04-02 03:10:46 +02:00
|
|
|
else
|
2009-04-10 04:24:36 +02:00
|
|
|
return *(uint16_t *) (s->vram_ptr + addr);
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static uint32_t vmsvga_vram_readl(void *opaque, target_phys_addr_t addr)
|
2007-04-02 03:10:46 +02:00
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
if (addr < s->fb_size)
|
2008-11-24 20:29:13 +01:00
|
|
|
return *(uint32_t *) (ds_get_data(s->ds) + addr);
|
2007-04-02 03:10:46 +02:00
|
|
|
else
|
2009-04-10 04:24:36 +02:00
|
|
|
return *(uint32_t *) (s->vram_ptr + addr);
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static void vmsvga_vram_writeb(void *opaque, target_phys_addr_t addr,
|
2007-04-02 03:10:46 +02:00
|
|
|
uint32_t value)
|
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
if (addr < s->fb_size)
|
2008-11-24 20:29:13 +01:00
|
|
|
*(uint8_t *) (ds_get_data(s->ds) + addr) = value;
|
2007-04-02 03:10:46 +02:00
|
|
|
else
|
2009-04-10 04:24:36 +02:00
|
|
|
*(uint8_t *) (s->vram_ptr + addr) = value;
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static void vmsvga_vram_writew(void *opaque, target_phys_addr_t addr,
|
2007-04-02 03:10:46 +02:00
|
|
|
uint32_t value)
|
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
if (addr < s->fb_size)
|
2008-11-24 20:29:13 +01:00
|
|
|
*(uint16_t *) (ds_get_data(s->ds) + addr) = value;
|
2007-04-02 03:10:46 +02:00
|
|
|
else
|
2009-04-10 04:24:36 +02:00
|
|
|
*(uint16_t *) (s->vram_ptr + addr) = value;
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static void vmsvga_vram_writel(void *opaque, target_phys_addr_t addr,
|
2007-04-02 03:10:46 +02:00
|
|
|
uint32_t value)
|
|
|
|
{
|
2009-10-14 17:49:08 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
if (addr < s->fb_size)
|
2008-11-24 20:29:13 +01:00
|
|
|
*(uint32_t *) (ds_get_data(s->ds) + addr) = value;
|
2007-04-02 03:10:46 +02:00
|
|
|
else
|
2009-04-10 04:24:36 +02:00
|
|
|
*(uint32_t *) (s->vram_ptr + addr) = value;
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
2009-08-25 20:29:31 +02:00
|
|
|
static CPUReadMemoryFunc * const vmsvga_vram_read[] = {
|
2007-04-02 03:10:46 +02:00
|
|
|
vmsvga_vram_readb,
|
|
|
|
vmsvga_vram_readw,
|
|
|
|
vmsvga_vram_readl,
|
|
|
|
};
|
|
|
|
|
2009-08-25 20:29:31 +02:00
|
|
|
static CPUWriteMemoryFunc * const vmsvga_vram_write[] = {
|
2007-04-02 03:10:46 +02:00
|
|
|
vmsvga_vram_writeb,
|
|
|
|
vmsvga_vram_writew,
|
|
|
|
vmsvga_vram_writel,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2009-10-14 19:30:22 +02:00
|
|
|
static int vmsvga_post_load(void *opaque, int version_id)
|
2007-04-02 03:10:46 +02:00
|
|
|
{
|
2009-10-14 19:30:22 +02:00
|
|
|
struct vmsvga_state_s *s = opaque;
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
s->invalidated = 1;
|
|
|
|
if (s->config)
|
2009-12-17 23:08:06 +01:00
|
|
|
s->fifo = (uint32_t *) s->fifo_ptr;
|
2007-04-02 03:10:46 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-04 21:44:44 +01:00
|
|
|
static const VMStateDescription vmstate_vmware_vga_internal = {
|
2009-10-14 19:30:22 +02:00
|
|
|
.name = "vmware_vga_internal",
|
|
|
|
.version_id = 0,
|
|
|
|
.minimum_version_id = 0,
|
|
|
|
.minimum_version_id_old = 0,
|
|
|
|
.post_load = vmsvga_post_load,
|
|
|
|
.fields = (VMStateField []) {
|
|
|
|
VMSTATE_INT32_EQUAL(depth, struct vmsvga_state_s),
|
|
|
|
VMSTATE_INT32(enable, struct vmsvga_state_s),
|
|
|
|
VMSTATE_INT32(config, struct vmsvga_state_s),
|
|
|
|
VMSTATE_INT32(cursor.id, struct vmsvga_state_s),
|
|
|
|
VMSTATE_INT32(cursor.x, struct vmsvga_state_s),
|
|
|
|
VMSTATE_INT32(cursor.y, struct vmsvga_state_s),
|
|
|
|
VMSTATE_INT32(cursor.on, struct vmsvga_state_s),
|
|
|
|
VMSTATE_INT32(index, struct vmsvga_state_s),
|
|
|
|
VMSTATE_VARRAY_INT32(scratch, struct vmsvga_state_s,
|
|
|
|
scratch_size, 0, vmstate_info_uint32, uint32_t),
|
|
|
|
VMSTATE_INT32(new_width, struct vmsvga_state_s),
|
|
|
|
VMSTATE_INT32(new_height, struct vmsvga_state_s),
|
|
|
|
VMSTATE_UINT32(guest, struct vmsvga_state_s),
|
|
|
|
VMSTATE_UINT32(svgaid, struct vmsvga_state_s),
|
|
|
|
VMSTATE_INT32(syncing, struct vmsvga_state_s),
|
|
|
|
VMSTATE_INT32(fb_size, struct vmsvga_state_s),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-12-04 21:44:44 +01:00
|
|
|
static const VMStateDescription vmstate_vmware_vga = {
|
2009-10-14 19:30:22 +02:00
|
|
|
.name = "vmware_vga",
|
|
|
|
.version_id = 0,
|
|
|
|
.minimum_version_id = 0,
|
|
|
|
.minimum_version_id_old = 0,
|
|
|
|
.fields = (VMStateField []) {
|
|
|
|
VMSTATE_PCI_DEVICE(card, struct pci_vmsvga_state_s),
|
|
|
|
VMSTATE_STRUCT(chip, struct pci_vmsvga_state_s, 0,
|
|
|
|
vmstate_vmware_vga_internal, struct vmsvga_state_s),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-04-10 04:24:36 +02:00
|
|
|
static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
|
2007-04-02 03:10:46 +02:00
|
|
|
{
|
|
|
|
s->scratch_size = SVGA_SCRATCH_SIZE;
|
2009-10-14 18:16:51 +02:00
|
|
|
s->scratch = qemu_malloc(s->scratch_size * 4);
|
2007-04-02 03:10:46 +02:00
|
|
|
|
2009-12-17 23:08:09 +01:00
|
|
|
s->vga.ds = graphic_console_init(vmsvga_update_display,
|
|
|
|
vmsvga_invalidate_display,
|
|
|
|
vmsvga_screen_dump,
|
|
|
|
vmsvga_text_update, s);
|
|
|
|
|
2009-08-23 19:00:58 +02:00
|
|
|
|
2009-12-17 23:08:06 +01:00
|
|
|
s->fifo_size = SVGA_FIFO_SIZE;
|
2010-06-25 19:09:35 +02:00
|
|
|
s->fifo_offset = qemu_ram_alloc(NULL, "vmsvga.fifo", s->fifo_size);
|
2009-12-17 23:08:06 +01:00
|
|
|
s->fifo_ptr = qemu_get_ram_ptr(s->fifo_offset);
|
|
|
|
|
2009-08-24 18:42:47 +02:00
|
|
|
vga_common_init(&s->vga, vga_ram_size);
|
|
|
|
vga_init(&s->vga);
|
2010-06-25 19:09:07 +02:00
|
|
|
vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);
|
2008-07-16 06:31:20 +02:00
|
|
|
|
2009-12-17 23:08:10 +01:00
|
|
|
vmsvga_reset(s);
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
|
|
|
|
2008-01-14 02:52:52 +01:00
|
|
|
static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num,
|
2009-10-30 13:21:08 +01:00
|
|
|
pcibus_t addr, pcibus_t size, int type)
|
2008-01-14 02:52:52 +01:00
|
|
|
{
|
|
|
|
struct pci_vmsvga_state_s *d = (struct pci_vmsvga_state_s *) pci_dev;
|
|
|
|
struct vmsvga_state_s *s = &d->chip;
|
|
|
|
|
|
|
|
register_ioport_read(addr + SVGA_IO_MUL * SVGA_INDEX_PORT,
|
|
|
|
1, 4, vmsvga_index_read, s);
|
|
|
|
register_ioport_write(addr + SVGA_IO_MUL * SVGA_INDEX_PORT,
|
|
|
|
1, 4, vmsvga_index_write, s);
|
|
|
|
register_ioport_read(addr + SVGA_IO_MUL * SVGA_VALUE_PORT,
|
|
|
|
1, 4, vmsvga_value_read, s);
|
|
|
|
register_ioport_write(addr + SVGA_IO_MUL * SVGA_VALUE_PORT,
|
|
|
|
1, 4, vmsvga_value_write, s);
|
|
|
|
register_ioport_read(addr + SVGA_IO_MUL * SVGA_BIOS_PORT,
|
|
|
|
1, 4, vmsvga_bios_read, s);
|
|
|
|
register_ioport_write(addr + SVGA_IO_MUL * SVGA_BIOS_PORT,
|
|
|
|
1, 4, vmsvga_bios_write, s);
|
|
|
|
}
|
|
|
|
|
2008-03-06 21:28:49 +01:00
|
|
|
static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
|
2009-10-30 13:21:08 +01:00
|
|
|
pcibus_t addr, pcibus_t size, int type)
|
2008-03-06 21:28:49 +01:00
|
|
|
{
|
|
|
|
struct pci_vmsvga_state_s *d = (struct pci_vmsvga_state_s *) pci_dev;
|
|
|
|
struct vmsvga_state_s *s = &d->chip;
|
2009-10-01 23:12:16 +02:00
|
|
|
ram_addr_t iomemtype;
|
2008-03-06 21:28:49 +01:00
|
|
|
|
|
|
|
s->vram_base = addr;
|
|
|
|
#ifdef DIRECT_VRAM
|
2009-06-14 10:38:51 +02:00
|
|
|
iomemtype = cpu_register_io_memory(vmsvga_vram_read,
|
2010-12-08 12:05:37 +01:00
|
|
|
vmsvga_vram_write, s, DEVICE_NATIVE_ENDIAN);
|
2008-03-06 21:28:49 +01:00
|
|
|
#else
|
2009-05-03 21:25:16 +02:00
|
|
|
iomemtype = s->vga.vram_offset | IO_MEM_RAM;
|
2008-03-06 21:28:49 +01:00
|
|
|
#endif
|
2009-05-03 21:25:16 +02:00
|
|
|
cpu_register_physical_memory(s->vram_base, s->vga.vram_size,
|
2008-03-06 21:28:49 +01:00
|
|
|
iomemtype);
|
2009-12-17 23:08:08 +01:00
|
|
|
|
|
|
|
s->vga.map_addr = addr;
|
|
|
|
s->vga.map_end = addr + s->vga.vram_size;
|
2009-12-17 23:08:10 +01:00
|
|
|
vga_dirty_log_restart(&s->vga);
|
2008-03-06 21:28:49 +01:00
|
|
|
}
|
|
|
|
|
2009-12-17 23:08:06 +01:00
|
|
|
static void pci_vmsvga_map_fifo(PCIDevice *pci_dev, int region_num,
|
|
|
|
pcibus_t addr, pcibus_t size, int type)
|
|
|
|
{
|
|
|
|
struct pci_vmsvga_state_s *d = (struct pci_vmsvga_state_s *) pci_dev;
|
|
|
|
struct vmsvga_state_s *s = &d->chip;
|
|
|
|
ram_addr_t iomemtype;
|
|
|
|
|
|
|
|
s->fifo_base = addr;
|
|
|
|
iomemtype = s->fifo_offset | IO_MEM_RAM;
|
|
|
|
cpu_register_physical_memory(s->fifo_base, s->fifo_size,
|
|
|
|
iomemtype);
|
|
|
|
}
|
|
|
|
|
2009-08-14 10:36:05 +02:00
|
|
|
static int pci_vmsvga_initfn(PCIDevice *dev)
|
2007-04-02 03:10:46 +02:00
|
|
|
{
|
2009-07-28 18:18:00 +02:00
|
|
|
struct pci_vmsvga_state_s *s =
|
|
|
|
DO_UPCAST(struct pci_vmsvga_state_s, card, dev);
|
2007-04-02 03:10:46 +02:00
|
|
|
|
2009-12-10 17:51:49 +01:00
|
|
|
s->card.config[PCI_CACHE_LINE_SIZE] = 0x08; /* Cache line size */
|
|
|
|
s->card.config[PCI_LATENCY_TIMER] = 0x40; /* Latency timer */
|
|
|
|
s->card.config[PCI_INTERRUPT_LINE] = 0xff; /* End */
|
2007-04-02 03:10:46 +02:00
|
|
|
|
2009-06-14 10:38:53 +02:00
|
|
|
pci_register_bar(&s->card, 0, 0x10,
|
2009-10-30 13:21:03 +01:00
|
|
|
PCI_BASE_ADDRESS_SPACE_IO, pci_vmsvga_map_ioport);
|
2009-06-14 10:38:53 +02:00
|
|
|
pci_register_bar(&s->card, 1, VGA_RAM_SIZE,
|
2009-10-30 13:21:03 +01:00
|
|
|
PCI_BASE_ADDRESS_MEM_PREFETCH, pci_vmsvga_map_mem);
|
2008-01-14 02:52:52 +01:00
|
|
|
|
2009-12-17 23:08:06 +01:00
|
|
|
pci_register_bar(&s->card, 2, SVGA_FIFO_SIZE,
|
2010-09-10 02:30:04 +02:00
|
|
|
PCI_BASE_ADDRESS_MEM_PREFETCH, pci_vmsvga_map_fifo);
|
2009-12-17 23:08:06 +01:00
|
|
|
|
2009-05-13 18:56:25 +02:00
|
|
|
vmsvga_init(&s->chip, VGA_RAM_SIZE);
|
2007-04-02 03:10:46 +02:00
|
|
|
|
2010-11-17 12:06:44 +01:00
|
|
|
if (!dev->rom_bar) {
|
|
|
|
/* compatibility with pc-0.13 and older */
|
|
|
|
vga_init_vbe(&s->chip.vga);
|
|
|
|
}
|
|
|
|
|
2009-08-14 10:36:05 +02:00
|
|
|
return 0;
|
2007-04-02 03:10:46 +02:00
|
|
|
}
|
2009-07-28 18:18:00 +02:00
|
|
|
|
|
|
|
static PCIDeviceInfo vmsvga_info = {
|
2009-12-09 17:07:53 +01:00
|
|
|
.qdev.name = "vmware-svga",
|
2009-07-28 18:18:00 +02:00
|
|
|
.qdev.size = sizeof(struct pci_vmsvga_state_s),
|
2009-12-02 12:36:46 +01:00
|
|
|
.qdev.vmsd = &vmstate_vmware_vga,
|
2011-01-06 15:14:39 +01:00
|
|
|
.no_hotplug = 1,
|
2009-07-28 18:18:00 +02:00
|
|
|
.init = pci_vmsvga_initfn,
|
2010-05-06 11:14:11 +02:00
|
|
|
.romfile = "vgabios-vmware.bin",
|
2011-05-25 03:58:04 +02:00
|
|
|
|
|
|
|
.vendor_id = PCI_VENDOR_ID_VMWARE,
|
|
|
|
.device_id = SVGA_PCI_DEVICE_ID,
|
|
|
|
.class_id = PCI_CLASS_DISPLAY_VGA,
|
|
|
|
.subsystem_vendor_id = PCI_VENDOR_ID_VMWARE,
|
|
|
|
.subsystem_id = SVGA_PCI_DEVICE_ID,
|
2009-07-28 18:18:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static void vmsvga_register(void)
|
|
|
|
{
|
|
|
|
pci_qdev_register(&vmsvga_info);
|
|
|
|
}
|
|
|
|
device_init(vmsvga_register);
|