linux/drivers/gpu/drm/vboxvideo/vboxvideo.h

/* SPDX-License-Identifier: MIT */
/* Copyright (C) 2006-2016 Oracle Corporation */

#ifndef __VBOXVIDEO_H__
#define __VBOXVIDEO_H__

#define VBOX_VIDEO_MAX_SCREENS

/*
 * The last 4096 bytes of the guest VRAM contains the generic info for all
 * DualView chunks: sizes and offsets of chunks. This is filled by miniport.
 *
 * Last 4096 bytes of each chunk contain chunk specific data: framebuffer info,
 * etc. This is used exclusively by the corresponding instance of a display
 * driver.
 *
 * The VRAM layout:
 *   Last 4096 bytes - Adapter information area.
 *   4096 bytes aligned miniport heap (value specified in the config rouded up).
 *   Slack - what left after dividing the VRAM.
 *   4096 bytes aligned framebuffers:
 *     last 4096 bytes of each framebuffer is the display information area.
 *
 * The Virtual Graphics Adapter information in the guest VRAM is stored by the
 * guest video driver using structures prepended by VBOXVIDEOINFOHDR.
 *
 * When the guest driver writes dword 0 to the VBE_DISPI_INDEX_VBOX_VIDEO
 * the host starts to process the info. The first element at the start of
 * the 4096 bytes region should be normally be a LINK that points to
 * actual information chain. That way the guest driver can have some
 * fixed layout of the information memory block and just rewrite
 * the link to point to relevant memory chain.
 *
 * The processing stops at the END element.
 *
 * The host can access the memory only when the port IO is processed.
 * All data that will be needed later must be copied from these 4096 bytes.
 * But other VRAM can be used by host until the mode is disabled.
 *
 * The guest driver writes dword 0xffffffff to the VBE_DISPI_INDEX_VBOX_VIDEO
 * to disable the mode.
 *
 * VBE_DISPI_INDEX_VBOX_VIDEO is used to read the configuration information
 * from the host and issue commands to the host.
 *
 * The guest writes the VBE_DISPI_INDEX_VBOX_VIDEO index register, the
 * following operations with the VBE data register can be performed:
 *
 * Operation            Result
 * write 16 bit value   NOP
 * read 16 bit value    count of monitors
 * write 32 bit value   set the vbox cmd value and the cmd processed by the host
 * read 32 bit value    result of the last vbox command is returned
 */

struct vbva_cmd_hdr {} __packed;

/*
 * The VBVA ring buffer is suitable for transferring large (< 2GB) amount of
 * data. For example big bitmaps which do not fit to the buffer.
 *
 * Guest starts writing to the buffer by initializing a record entry in the
 * records queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
 * written. As data is written to the ring buffer, the guest increases
 * free_offset.
 *
 * The host reads the records on flushes and processes all completed records.
 * When host encounters situation when only a partial record presents and
 * len_and_flags & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE -
 * VBVA_RING_BUFFER_THRESHOLD, the host fetched all record data and updates
 * data_offset. After that on each flush the host continues fetching the data
 * until the record is completed.
 */

#define VBVA_RING_BUFFER_SIZE
#define VBVA_RING_BUFFER_THRESHOLD

#define VBVA_MAX_RECORDS

#define VBVA_F_MODE_ENABLED
#define VBVA_F_MODE_VRDP
#define VBVA_F_MODE_VRDP_RESET
#define VBVA_F_MODE_VRDP_ORDER_MASK

#define VBVA_F_STATE_PROCESSING

#define VBVA_F_RECORD_PARTIAL

struct vbva_record {} __packed;

/*
 * The minimum HGSMI heap size is PAGE_SIZE (4096 bytes) and is a restriction of
 * the runtime heapsimple API. Use minimum 2 pages here, because the info area
 * also may contain other data (for example hgsmi_host_flags structure).
 */
#define VBVA_ADAPTER_INFORMATION_SIZE
#define VBVA_MIN_BUFFER_SIZE

/* The value for port IO to let the adapter to interpret the adapter memory. */
#define VBOX_VIDEO_DISABLE_ADAPTER_MEMORY

/* The value for port IO to let the adapter to interpret the adapter memory. */
#define VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY

/*
 * The value for port IO to let the adapter to interpret the display memory.
 * The display number is encoded in low 16 bits.
 */
#define VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE

struct vbva_host_flags {} __packed;

struct vbva_buffer {} __packed;

#define VBVA_MAX_RECORD_SIZE

/* guest->host commands */
#define VBVA_QUERY_CONF32
#define VBVA_SET_CONF32
#define VBVA_INFO_VIEW
#define VBVA_INFO_HEAP
#define VBVA_FLUSH
#define VBVA_INFO_SCREEN
#define VBVA_ENABLE
#define VBVA_MOUSE_POINTER_SHAPE
/* informs host about HGSMI caps. see vbva_caps below */
#define VBVA_INFO_CAPS
/* configures scanline, see VBVASCANLINECFG below */
#define VBVA_SCANLINE_CFG
/* requests scanline info, see VBVASCANLINEINFO below */
#define VBVA_SCANLINE_INFO
/* inform host about VBVA Command submission */
#define VBVA_CMDVBVA_SUBMIT
/* inform host about VBVA Command submission */
#define VBVA_CMDVBVA_FLUSH
/* G->H DMA command */
#define VBVA_CMDVBVA_CTL
/* Query most recent mode hints sent */
#define VBVA_QUERY_MODE_HINTS
/*
 * Report the guest virtual desktop position and size for mapping host and
 * guest pointer positions.
 */
#define VBVA_REPORT_INPUT_MAPPING
/* Report the guest cursor position and query the host position. */
#define VBVA_CURSOR_POSITION

/* host->guest commands */
#define VBVAHG_EVENT
#define VBVAHG_DISPLAY_CUSTOM

/* vbva_conf32::index */
#define VBOX_VBVA_CONF32_MONITOR_COUNT
#define VBOX_VBVA_CONF32_HOST_HEAP_SIZE
/*
 * Returns VINF_SUCCESS if the host can report mode hints via VBVA.
 * Set value to VERR_NOT_SUPPORTED before calling.
 */
#define VBOX_VBVA_CONF32_MODE_HINT_REPORTING
/*
 * Returns VINF_SUCCESS if the host can report guest cursor enabled status via
 * VBVA.  Set value to VERR_NOT_SUPPORTED before calling.
 */
#define VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING
/*
 * Returns the currently available host cursor capabilities.  Available if
 * VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING returns success.
 */
#define VBOX_VBVA_CONF32_CURSOR_CAPABILITIES
/* Returns the supported flags in vbva_infoscreen.flags. */
#define VBOX_VBVA_CONF32_SCREEN_FLAGS
/* Returns the max size of VBVA record. */
#define VBOX_VBVA_CONF32_MAX_RECORD_SIZE

struct vbva_conf32 {} __packed;

/* Reserved for historical reasons. */
#define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED0
/*
 * Guest cursor capability: can the host show a hardware cursor at the host
 * pointer location?
 */
#define VBOX_VBVA_CURSOR_CAPABILITY_HARDWARE
/* Reserved for historical reasons. */
#define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED2
/* Reserved for historical reasons.  Must always be unset. */
#define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED3
/* Reserved for historical reasons. */
#define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED4
/* Reserved for historical reasons. */
#define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED5

struct vbva_infoview {} __packed;

struct vbva_flush {} __packed;

/* vbva_infoscreen.flags */
#define VBVA_SCREEN_F_NONE
#define VBVA_SCREEN_F_ACTIVE
/*
 * The virtual monitor has been disabled by the guest and should be removed
 * by the host and ignored for purposes of pointer position calculation.
 */
#define VBVA_SCREEN_F_DISABLED
/*
 * The virtual monitor has been blanked by the guest and should be blacked
 * out by the host using width, height, etc values from the vbva_infoscreen
 * request.
 */
#define VBVA_SCREEN_F_BLANK
/*
 * The virtual monitor has been blanked by the guest and should be blacked
 * out by the host using the previous mode values for width. height, etc.
 */
#define VBVA_SCREEN_F_BLANK2

struct vbva_infoscreen {} __packed;

/* vbva_enable.flags */
#define VBVA_F_NONE
#define VBVA_F_ENABLE
#define VBVA_F_DISABLE
/* extended VBVA to be used with WDDM */
#define VBVA_F_EXTENDED
/* vbva offset is absolute VRAM offset */
#define VBVA_F_ABSOFFSET

struct vbva_enable {} __packed;

struct vbva_enable_ex {} __packed;

struct vbva_mouse_pointer_shape {} __packed;

/* pointer is visible */
#define VBOX_MOUSE_POINTER_VISIBLE
/* pointer has alpha channel */
#define VBOX_MOUSE_POINTER_ALPHA
/* pointerData contains new pointer shape */
#define VBOX_MOUSE_POINTER_SHAPE

/*
 * The guest driver can handle asynch guest cmd completion by reading the
 * command offset from io port.
 */
#define VBVACAPS_COMPLETEGCMD_BY_IOREAD
/* the guest driver can handle video adapter IRQs */
#define VBVACAPS_IRQ
/* The guest can read video mode hints sent via VBVA. */
#define VBVACAPS_VIDEO_MODE_HINTS
/* The guest can switch to a software cursor on demand. */
#define VBVACAPS_DISABLE_CURSOR_INTEGRATION
/* The guest does not depend on host handling the VBE registers. */
#define VBVACAPS_USE_VBVA_ONLY

struct vbva_caps {} __packed;

/* Query the most recent mode hints received from the host. */
struct vbva_query_mode_hints {} __packed;

/*
 * Structure in which a mode hint is returned. The guest allocates an array
 * of these immediately after the vbva_query_mode_hints structure.
 * To accommodate future extensions, the vbva_query_mode_hints structure
 * specifies the size of the vbva_modehint structures allocated by the guest,
 * and the host only fills out structure elements which fit into that size. The
 * host should fill any unused members (e.g. dx, dy) or structure space on the
 * end with ~0. The whole structure can legally be set to ~0 to skip a screen.
 */
struct vbva_modehint {} __packed;

#define VBVAMODEHINT_MAGIC

/*
 * Report the rectangle relative to which absolute pointer events should be
 * expressed. This information remains valid until the next VBVA resize event
 * for any screen, at which time it is reset to the bounding rectangle of all
 * virtual screens and must be re-set.
 */
struct vbva_report_input_mapping {} __packed;

/*
 * Report the guest cursor position and query the host one. The host may wish
 * to use the guest information to re-position its own cursor (though this is
 * currently unlikely).
 */
struct vbva_cursor_position {} __packed;

#endif