#ifndef _SVGA_REG_H_
#define _SVGA_REG_H_
#define INCLUDE_ALLOW_USERLEVEL
#define INCLUDE_ALLOW_MONITOR
#include "includeCheck.h"
#include "svga_limits.h"
#define SVGA_MAX_WIDTH 2360
#define SVGA_MAX_HEIGHT 1770
#define SVGA_MAX_BITS_PER_PIXEL 32
#define PAGE_SHIFT 12
#define SVGA_FB_MAX_SIZE \
((((SVGA_MAX_WIDTH * SVGA_MAX_HEIGHT * \
SVGA_MAX_BITS_PER_PIXEL / 8) >> PAGE_SHIFT) + 1) << PAGE_SHIFT)
#if SVGA_FB_MAX_SIZE > SVGA_VRAM_SIZE
#error "Bad SVGA maximum sizes"
#endif
#define SVGA_MAX_PSEUDOCOLOR_DEPTH 8
#define SVGA_MAX_PSEUDOCOLORS (1 << SVGA_MAX_PSEUDOCOLOR_DEPTH)
#define SVGA_MAGIC 0x900000
#define SVGA_MAKE_ID(ver) (SVGA_MAGIC << 8 | (ver))
#define SVGA_VERSION_2 2
#define SVGA_ID_2 SVGA_MAKE_ID(SVGA_VERSION_2)
#define SVGA_VERSION_1 1
#define SVGA_ID_1 SVGA_MAKE_ID(SVGA_VERSION_1)
#define SVGA_VERSION_0 0
#define SVGA_ID_0 SVGA_MAKE_ID(SVGA_VERSION_0)
#define SVGA_ID_INVALID 0xFFFFFFFF
#define SVGA_OLD_PALETTE_BASE 17
#define SVGA_LEGACY_BASE_PORT 0x4560
#define SVGA_INDEX_PORT 0x0
#define SVGA_VALUE_PORT 0x1
#define SVGA_BIOS_PORT 0x2
#define SVGA_NUM_PORTS 0x3
#define SVGA_LEGACY_ACCEL_PORT 0x3
#define SVGA_CURSOR_ON_HIDE 0x0
#define SVGA_CURSOR_ON_SHOW 0x1
#define SVGA_CURSOR_ON_REMOVE_FROM_FB 0x2
#define SVGA_CURSOR_ON_RESTORE_TO_FB 0x3
enum {
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,
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,
SVGA_REG_CAPABILITIES = 17,
SVGA_REG_MEM_START = 18,
SVGA_REG_MEM_SIZE = 19,
SVGA_REG_CONFIG_DONE = 20,
SVGA_REG_SYNC = 21,
SVGA_REG_BUSY = 22,
SVGA_REG_GUEST_ID = 23,
SVGA_REG_CURSOR_ID = 24,
SVGA_REG_CURSOR_X = 25,
SVGA_REG_CURSOR_Y = 26,
SVGA_REG_CURSOR_ON = 27,
SVGA_REG_HOST_BITS_PER_PIXEL = 28,
SVGA_REG_TOP = 30,
SVGA_PALETTE_BASE = 1024
};
#define SVGA_CAP_NONE 0x0000
#define SVGA_CAP_RECT_FILL 0x0001
#define SVGA_CAP_RECT_COPY 0x0002
#define SVGA_CAP_RECT_PAT_FILL 0x0004
#define SVGA_CAP_LEGACY_OFFSCREEN 0x0008
#define SVGA_CAP_RASTER_OP 0x0010
#define SVGA_CAP_CURSOR 0x0020
#define SVGA_CAP_CURSOR_BYPASS 0x0040
#define SVGA_CAP_CURSOR_BYPASS_2 0x0080
#define SVGA_CAP_8BIT_EMULATION 0x0100
#define SVGA_CAP_ALPHA_CURSOR 0x0200
#define SVGA_CAP_GLYPH 0x0400
#define SVGA_CAP_GLYPH_CLIPPING 0x0800
#define SVGA_CAP_OFFSCREEN_1 0x1000
#define SVGA_CAP_ALPHA_BLEND 0x2000
#define SVGA_ROP_CLEAR 0x00
#define SVGA_ROP_AND 0x01
#define SVGA_ROP_AND_REVERSE 0x02
#define SVGA_ROP_COPY 0x03
#define SVGA_ROP_AND_INVERTED 0x04
#define SVGA_ROP_NOOP 0x05
#define SVGA_ROP_XOR 0x06
#define SVGA_ROP_OR 0x07
#define SVGA_ROP_NOR 0x08
#define SVGA_ROP_EQUIV 0x09
#define SVGA_ROP_INVERT 0x0a
#define SVGA_ROP_OR_REVERSE 0x0b
#define SVGA_ROP_COPY_INVERTED 0x0c
#define SVGA_ROP_OR_INVERTED 0x0d
#define SVGA_ROP_NAND 0x0e
#define SVGA_ROP_SET 0x0f
#define SVGA_ROP_UNSUPPORTED 0x10
#define SVGA_NUM_SUPPORTED_ROPS 16
#define SVGA_ROP_ALL (MASK(SVGA_NUM_SUPPORTED_ROPS))
#define SVGA_IS_VALID_ROP(rop) (rop >= 0 && rop < SVGA_NUM_SUPPORTED_ROPS)
#define SVGA_BLENDOP_CLEAR 0
#define SVGA_BLENDOP_SRC 1
#define SVGA_BLENDOP_DST 2
#define SVGA_BLENDOP_OVER 3
#define SVGA_BLENDOP_OVER_REVERSE 4
#define SVGA_BLENDOP_IN 5
#define SVGA_BLENDOP_IN_REVERSE 6
#define SVGA_BLENDOP_OUT 7
#define SVGA_BLENDOP_OUT_REVERSE 8
#define SVGA_BLENDOP_ATOP 9
#define SVGA_BLENDOP_ATOP_REVERSE 10
#define SVGA_BLENDOP_XOR 11
#define SVGA_BLENDOP_ADD 12
#define SVGA_BLENDOP_SATURATE 13
#define SVGA_NUM_BLENDOPS 14
#define SVGA_IS_VALID_BLENDOP(op) (op >= 0 && op < SVGA_NUM_BLENDOPS)
#define SVGA_BLENDFLAG_CONSTANT_SOURCE_ALPHA 0x01
#define SVGA_BLENDFLAG_CONSTANT_DEST_ALPHA 0x02
#define SVGA_NUM_BLENDFLAGS 2
#define SVGA_BLENDFLAG_ALL (MASK(SVGA_NUM_BLENDFLAGS))
#define SVGA_IS_VALID_BLENDFLAG(flag) ((flag & ~SVGA_BLENDFLAG_ALL) == 0)
#define SVGA_FIFO_MIN 0
#define SVGA_FIFO_MAX 1
#define SVGA_FIFO_NEXT_CMD 2
#define SVGA_FIFO_STOP 3
#define SVGA_FIFO_USER_DEFINED 4
#define SVGA_MAX_ID 499
#define SVGA_BITMAP_SIZE(w,h) ((((w)+31) >> 5) * (h))
#define SVGA_BITMAP_SCANLINE_SIZE(w) (( (w)+31 ) >> 5)
#define SVGA_PIXMAP_SIZE(w,h,bpp) ((( ((w)*(bpp))+31 ) >> 5) * (h))
#define SVGA_PIXMAP_SCANLINE_SIZE(w,bpp) (( ((w)*(bpp))+31 ) >> 5)
#define SVGA_GLYPH_SIZE(w,h) ((((((w) + 7) >> 3) * (h)) + 3) >> 2)
#define SVGA_GLYPH_SCANLINE_SIZE(w) (((w) + 7) >> 3)
#define SVGA_VRAM_WIDTH_HEIGHT(width /* out */, height /* out */) { \
uint32 pitch = svga->reg[SVGA_REG_BYTES_PER_LINE]; \
width = (pitch * 8) / ((svga->reg[SVGA_REG_BITS_PER_PIXEL] + 7) & ~7); \
height = (svga->reg[SVGA_REG_VRAM_SIZE] - \
svga->reg[SVGA_REG_FB_OFFSET]) / pitch; \
}
#define SVGA_BITMAP_INCREMENT(w) ((( (w)+31 ) >> 5) * sizeof (uint32))
#define SVGA_PIXMAP_INCREMENT(w,bpp) ((( ((w)*(bpp))+31 ) >> 5) * sizeof (uint32))
#define SVGA_COLOR_TRANSPARENT (~0)
#define SVGA_CMD_INVALID_CMD 0
#define SVGA_CMD_UPDATE 1
#define SVGA_CMD_RECT_FILL 2
#define SVGA_CMD_RECT_COPY 3
#define SVGA_CMD_DEFINE_BITMAP 4
#define SVGA_CMD_DEFINE_BITMAP_SCANLINE 5
#define SVGA_CMD_DEFINE_PIXMAP 6
#define SVGA_CMD_DEFINE_PIXMAP_SCANLINE 7
#define SVGA_CMD_RECT_BITMAP_FILL 8
#define SVGA_CMD_RECT_PIXMAP_FILL 9
#define SVGA_CMD_RECT_BITMAP_COPY 10
#define SVGA_CMD_RECT_PIXMAP_COPY 11
#define SVGA_CMD_FREE_OBJECT 12
#define SVGA_CMD_RECT_ROP_FILL 13
#define SVGA_CMD_RECT_ROP_COPY 14
#define SVGA_CMD_RECT_ROP_BITMAP_FILL 15
#define SVGA_CMD_RECT_ROP_PIXMAP_FILL 16
#define SVGA_CMD_RECT_ROP_BITMAP_COPY 17
#define SVGA_CMD_RECT_ROP_PIXMAP_COPY 18
#define SVGA_CMD_DEFINE_CURSOR 19
#define SVGA_CMD_DISPLAY_CURSOR 20
#define SVGA_CMD_MOVE_CURSOR 21
#define SVGA_CMD_DEFINE_ALPHA_CURSOR 22
#define SVGA_CMD_DRAW_GLYPH 23
#define SVGA_CMD_DRAW_GLYPH_CLIPPED 24
#define SVGA_CMD_UPDATE_VERBOSE 25
#define SVGA_CMD_SURFACE_FILL 26
#define SVGA_CMD_SURFACE_COPY 27
#define SVGA_CMD_SURFACE_ALPHA_BLEND 28
#define SVGA_CMD_MAX 29
#define SVGA_CMD_MAX_ARGS 12
enum {
SVGA_SYNC_INVALIDREASON = 0,
SVGA_SYNC_GENERIC = 1,
SVGA_SYNC_FIFOFULL = 2,
SVGA_SYNC_FB_WRITE = 3,
SVGA_SYNC_FB_BITBLT = 4,
SVGA_SYNC_FB_COPYBITS = 5,
SVGA_SYNC_FB_FILLPATH = 6,
SVGA_SYNC_FB_LINETO = 7,
SVGA_SYNC_FB_PAINT = 8,
SVGA_SYNC_FB_STRETCHBLT = 9,
SVGA_SYNC_FB_STROKEFILL = 10,
SVGA_SYNC_FB_STROKE = 11,
SVGA_SYNC_FB_TEXTOUT = 12,
SVGA_SYNC_FB_ALPHABLEND = 13,
SVGA_SYNC_FB_GRADIENT = 14,
SVGA_SYNC_FB_PLGBLT = 15,
SVGA_SYNC_FB_STRETCHROP = 16,
SVGA_SYNC_FB_TRANSPARENT = 17,
SVGA_SYNC_FB_NEWCURSOR = 18,
SVGA_SYNC_FB_SYNCSURFACE = 19,
SVGA_SYNC_FB_NUM_REASONS
};
#endif