svga_reg.h 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346
  1. /**********************************************************
  2. * Copyright 1998-2009 VMware, Inc. All rights reserved.
  3. *
  4. * Permission is hereby granted, free of charge, to any person
  5. * obtaining a copy of this software and associated documentation
  6. * files (the "Software"), to deal in the Software without
  7. * restriction, including without limitation the rights to use, copy,
  8. * modify, merge, publish, distribute, sublicense, and/or sell copies
  9. * of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  19. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  20. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. *
  24. **********************************************************/
  25. /*
  26. * svga_reg.h --
  27. *
  28. * Virtual hardware definitions for the VMware SVGA II device.
  29. */
  30. #ifndef _SVGA_REG_H_
  31. #define _SVGA_REG_H_
  32. /*
  33. * PCI device IDs.
  34. */
  35. #define PCI_VENDOR_ID_VMWARE 0x15AD
  36. #define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405
  37. /*
  38. * Legal values for the SVGA_REG_CURSOR_ON register in old-fashioned
  39. * cursor bypass mode. This is still supported, but no new guest
  40. * drivers should use it.
  41. */
  42. #define SVGA_CURSOR_ON_HIDE 0x0 /* Must be 0 to maintain backward compatibility */
  43. #define SVGA_CURSOR_ON_SHOW 0x1 /* Must be 1 to maintain backward compatibility */
  44. #define SVGA_CURSOR_ON_REMOVE_FROM_FB 0x2 /* Remove the cursor from the framebuffer because we need to see what's under it */
  45. #define SVGA_CURSOR_ON_RESTORE_TO_FB 0x3 /* Put the cursor back in the framebuffer so the user can see it */
  46. /*
  47. * The maximum framebuffer size that can traced for e.g. guests in VESA mode.
  48. * The changeMap in the monitor is proportional to this number. Therefore, we'd
  49. * like to keep it as small as possible to reduce monitor overhead (using
  50. * SVGA_VRAM_MAX_SIZE for this increases the size of the shared area by over
  51. * 4k!).
  52. *
  53. * NB: For compatibility reasons, this value must be greater than 0xff0000.
  54. * See bug 335072.
  55. */
  56. #define SVGA_FB_MAX_TRACEABLE_SIZE 0x1000000
  57. #define SVGA_MAX_PSEUDOCOLOR_DEPTH 8
  58. #define SVGA_MAX_PSEUDOCOLORS (1 << SVGA_MAX_PSEUDOCOLOR_DEPTH)
  59. #define SVGA_NUM_PALETTE_REGS (3 * SVGA_MAX_PSEUDOCOLORS)
  60. #define SVGA_MAGIC 0x900000UL
  61. #define SVGA_MAKE_ID(ver) (SVGA_MAGIC << 8 | (ver))
  62. /* Version 2 let the address of the frame buffer be unsigned on Win32 */
  63. #define SVGA_VERSION_2 2
  64. #define SVGA_ID_2 SVGA_MAKE_ID(SVGA_VERSION_2)
  65. /* Version 1 has new registers starting with SVGA_REG_CAPABILITIES so
  66. PALETTE_BASE has moved */
  67. #define SVGA_VERSION_1 1
  68. #define SVGA_ID_1 SVGA_MAKE_ID(SVGA_VERSION_1)
  69. /* Version 0 is the initial version */
  70. #define SVGA_VERSION_0 0
  71. #define SVGA_ID_0 SVGA_MAKE_ID(SVGA_VERSION_0)
  72. /* "Invalid" value for all SVGA IDs. (Version ID, screen object ID, surface ID...) */
  73. #define SVGA_ID_INVALID 0xFFFFFFFF
  74. /* Port offsets, relative to BAR0 */
  75. #define SVGA_INDEX_PORT 0x0
  76. #define SVGA_VALUE_PORT 0x1
  77. #define SVGA_BIOS_PORT 0x2
  78. #define SVGA_IRQSTATUS_PORT 0x8
  79. /*
  80. * Interrupt source flags for IRQSTATUS_PORT and IRQMASK.
  81. *
  82. * Interrupts are only supported when the
  83. * SVGA_CAP_IRQMASK capability is present.
  84. */
  85. #define SVGA_IRQFLAG_ANY_FENCE 0x1 /* Any fence was passed */
  86. #define SVGA_IRQFLAG_FIFO_PROGRESS 0x2 /* Made forward progress in the FIFO */
  87. #define SVGA_IRQFLAG_FENCE_GOAL 0x4 /* SVGA_FIFO_FENCE_GOAL reached */
  88. /*
  89. * Registers
  90. */
  91. enum {
  92. SVGA_REG_ID = 0,
  93. SVGA_REG_ENABLE = 1,
  94. SVGA_REG_WIDTH = 2,
  95. SVGA_REG_HEIGHT = 3,
  96. SVGA_REG_MAX_WIDTH = 4,
  97. SVGA_REG_MAX_HEIGHT = 5,
  98. SVGA_REG_DEPTH = 6,
  99. SVGA_REG_BITS_PER_PIXEL = 7, /* Current bpp in the guest */
  100. SVGA_REG_PSEUDOCOLOR = 8,
  101. SVGA_REG_RED_MASK = 9,
  102. SVGA_REG_GREEN_MASK = 10,
  103. SVGA_REG_BLUE_MASK = 11,
  104. SVGA_REG_BYTES_PER_LINE = 12,
  105. SVGA_REG_FB_START = 13, /* (Deprecated) */
  106. SVGA_REG_FB_OFFSET = 14,
  107. SVGA_REG_VRAM_SIZE = 15,
  108. SVGA_REG_FB_SIZE = 16,
  109. /* ID 0 implementation only had the above registers, then the palette */
  110. SVGA_REG_CAPABILITIES = 17,
  111. SVGA_REG_MEM_START = 18, /* (Deprecated) */
  112. SVGA_REG_MEM_SIZE = 19,
  113. SVGA_REG_CONFIG_DONE = 20, /* Set when memory area configured */
  114. SVGA_REG_SYNC = 21, /* See "FIFO Synchronization Registers" */
  115. SVGA_REG_BUSY = 22, /* See "FIFO Synchronization Registers" */
  116. SVGA_REG_GUEST_ID = 23, /* Set guest OS identifier */
  117. SVGA_REG_CURSOR_ID = 24, /* (Deprecated) */
  118. SVGA_REG_CURSOR_X = 25, /* (Deprecated) */
  119. SVGA_REG_CURSOR_Y = 26, /* (Deprecated) */
  120. SVGA_REG_CURSOR_ON = 27, /* (Deprecated) */
  121. SVGA_REG_HOST_BITS_PER_PIXEL = 28, /* (Deprecated) */
  122. SVGA_REG_SCRATCH_SIZE = 29, /* Number of scratch registers */
  123. SVGA_REG_MEM_REGS = 30, /* Number of FIFO registers */
  124. SVGA_REG_NUM_DISPLAYS = 31, /* (Deprecated) */
  125. SVGA_REG_PITCHLOCK = 32, /* Fixed pitch for all modes */
  126. SVGA_REG_IRQMASK = 33, /* Interrupt mask */
  127. /* Legacy multi-monitor support */
  128. SVGA_REG_NUM_GUEST_DISPLAYS = 34,/* Number of guest displays in X/Y direction */
  129. SVGA_REG_DISPLAY_ID = 35, /* Display ID for the following display attributes */
  130. SVGA_REG_DISPLAY_IS_PRIMARY = 36,/* Whether this is a primary display */
  131. SVGA_REG_DISPLAY_POSITION_X = 37,/* The display position x */
  132. SVGA_REG_DISPLAY_POSITION_Y = 38,/* The display position y */
  133. SVGA_REG_DISPLAY_WIDTH = 39, /* The display's width */
  134. SVGA_REG_DISPLAY_HEIGHT = 40, /* The display's height */
  135. /* See "Guest memory regions" below. */
  136. SVGA_REG_GMR_ID = 41,
  137. SVGA_REG_GMR_DESCRIPTOR = 42,
  138. SVGA_REG_GMR_MAX_IDS = 43,
  139. SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH = 44,
  140. SVGA_REG_TRACES = 45, /* Enable trace-based updates even when FIFO is on */
  141. SVGA_REG_TOP = 46, /* Must be 1 more than the last register */
  142. SVGA_PALETTE_BASE = 1024, /* Base of SVGA color map */
  143. /* Next 768 (== 256*3) registers exist for colormap */
  144. SVGA_SCRATCH_BASE = SVGA_PALETTE_BASE + SVGA_NUM_PALETTE_REGS
  145. /* Base of scratch registers */
  146. /* Next reg[SVGA_REG_SCRATCH_SIZE] registers exist for scratch usage:
  147. First 4 are reserved for VESA BIOS Extension; any remaining are for
  148. the use of the current SVGA driver. */
  149. };
  150. /*
  151. * Guest memory regions (GMRs):
  152. *
  153. * This is a new memory mapping feature available in SVGA devices
  154. * which have the SVGA_CAP_GMR bit set. Previously, there were two
  155. * fixed memory regions available with which to share data between the
  156. * device and the driver: the FIFO ('MEM') and the framebuffer. GMRs
  157. * are our name for an extensible way of providing arbitrary DMA
  158. * buffers for use between the driver and the SVGA device. They are a
  159. * new alternative to framebuffer memory, usable for both 2D and 3D
  160. * graphics operations.
  161. *
  162. * Since GMR mapping must be done synchronously with guest CPU
  163. * execution, we use a new pair of SVGA registers:
  164. *
  165. * SVGA_REG_GMR_ID --
  166. *
  167. * Read/write.
  168. * This register holds the 32-bit ID (a small positive integer)
  169. * of a GMR to create, delete, or redefine. Writing this register
  170. * has no side-effects.
  171. *
  172. * SVGA_REG_GMR_DESCRIPTOR --
  173. *
  174. * Write-only.
  175. * Writing this register will create, delete, or redefine the GMR
  176. * specified by the above ID register. If this register is zero,
  177. * the GMR is deleted. Any pointers into this GMR (including those
  178. * currently being processed by FIFO commands) will be
  179. * synchronously invalidated.
  180. *
  181. * If this register is nonzero, it must be the physical page
  182. * number (PPN) of a data structure which describes the physical
  183. * layout of the memory region this GMR should describe. The
  184. * descriptor structure will be read synchronously by the SVGA
  185. * device when this register is written. The descriptor need not
  186. * remain allocated for the lifetime of the GMR.
  187. *
  188. * The guest driver should write SVGA_REG_GMR_ID first, then
  189. * SVGA_REG_GMR_DESCRIPTOR.
  190. *
  191. * SVGA_REG_GMR_MAX_IDS --
  192. *
  193. * Read-only.
  194. * The SVGA device may choose to support a maximum number of
  195. * user-defined GMR IDs. This register holds the number of supported
  196. * IDs. (The maximum supported ID plus 1)
  197. *
  198. * SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH --
  199. *
  200. * Read-only.
  201. * The SVGA device may choose to put a limit on the total number
  202. * of SVGAGuestMemDescriptor structures it will read when defining
  203. * a single GMR.
  204. *
  205. * The descriptor structure is an array of SVGAGuestMemDescriptor
  206. * structures. Each structure may do one of three things:
  207. *
  208. * - Terminate the GMR descriptor list.
  209. * (ppn==0, numPages==0)
  210. *
  211. * - Add a PPN or range of PPNs to the GMR's virtual address space.
  212. * (ppn != 0, numPages != 0)
  213. *
  214. * - Provide the PPN of the next SVGAGuestMemDescriptor, in order to
  215. * support multi-page GMR descriptor tables without forcing the
  216. * driver to allocate physically contiguous memory.
  217. * (ppn != 0, numPages == 0)
  218. *
  219. * Note that each physical page of SVGAGuestMemDescriptor structures
  220. * can describe at least 2MB of guest memory. If the driver needs to
  221. * use more than one page of descriptor structures, it must use one of
  222. * its SVGAGuestMemDescriptors to point to an additional page. The
  223. * device will never automatically cross a page boundary.
  224. *
  225. * Once the driver has described a GMR, it is immediately available
  226. * for use via any FIFO command that uses an SVGAGuestPtr structure.
  227. * These pointers include a GMR identifier plus an offset into that
  228. * GMR.
  229. *
  230. * The driver must check the SVGA_CAP_GMR bit before using the GMR
  231. * registers.
  232. */
  233. /*
  234. * Special GMR IDs, allowing SVGAGuestPtrs to point to framebuffer
  235. * memory as well. In the future, these IDs could even be used to
  236. * allow legacy memory regions to be redefined by the guest as GMRs.
  237. *
  238. * Using the guest framebuffer (GFB) at BAR1 for general purpose DMA
  239. * is being phased out. Please try to use user-defined GMRs whenever
  240. * possible.
  241. */
  242. #define SVGA_GMR_NULL ((uint32) -1)
  243. #define SVGA_GMR_FRAMEBUFFER ((uint32) -2) // Guest Framebuffer (GFB)
  244. typedef
  245. struct SVGAGuestMemDescriptor {
  246. uint32 ppn;
  247. uint32 numPages;
  248. } SVGAGuestMemDescriptor;
  249. typedef
  250. struct SVGAGuestPtr {
  251. uint32 gmrId;
  252. uint32 offset;
  253. } SVGAGuestPtr;
  254. /*
  255. * SVGAGMRImageFormat --
  256. *
  257. * This is a packed representation of the source 2D image format
  258. * for a GMR-to-screen blit. Currently it is defined as an encoding
  259. * of the screen's color depth and bits-per-pixel, however, 16 bits
  260. * are reserved for future use to identify other encodings (such as
  261. * RGBA or higher-precision images).
  262. *
  263. * Currently supported formats:
  264. *
  265. * bpp depth Format Name
  266. * --- ----- -----------
  267. * 32 24 32-bit BGRX
  268. * 24 24 24-bit BGR
  269. * 16 16 RGB 5-6-5
  270. * 16 15 RGB 5-5-5
  271. *
  272. */
  273. typedef
  274. struct SVGAGMRImageFormat {
  275. union {
  276. struct {
  277. uint32 bitsPerPixel : 8;
  278. uint32 colorDepth : 8;
  279. uint32 reserved : 16; // Must be zero
  280. };
  281. uint32 value;
  282. };
  283. } SVGAGMRImageFormat;
  284. /*
  285. * SVGAColorBGRX --
  286. *
  287. * A 24-bit color format (BGRX), which does not depend on the
  288. * format of the legacy guest framebuffer (GFB) or the current
  289. * GMRFB state.
  290. */
  291. typedef
  292. struct SVGAColorBGRX {
  293. union {
  294. struct {
  295. uint32 b : 8;
  296. uint32 g : 8;
  297. uint32 r : 8;
  298. uint32 x : 8; // Unused
  299. };
  300. uint32 value;
  301. };
  302. } SVGAColorBGRX;
  303. /*
  304. * SVGASignedRect --
  305. * SVGASignedPoint --
  306. *
  307. * Signed rectangle and point primitives. These are used by the new
  308. * 2D primitives for drawing to Screen Objects, which can occupy a
  309. * signed virtual coordinate space.
  310. *
  311. * SVGASignedRect specifies a half-open interval: the (left, top)
  312. * pixel is part of the rectangle, but the (right, bottom) pixel is
  313. * not.
  314. */
  315. typedef
  316. struct SVGASignedRect {
  317. int32 left;
  318. int32 top;
  319. int32 right;
  320. int32 bottom;
  321. } SVGASignedRect;
  322. typedef
  323. struct SVGASignedPoint {
  324. int32 x;
  325. int32 y;
  326. } SVGASignedPoint;
  327. /*
  328. * Capabilities
  329. *
  330. * Note the holes in the bitfield. Missing bits have been deprecated,
  331. * and must not be reused. Those capabilities will never be reported
  332. * by new versions of the SVGA device.
  333. */
  334. #define SVGA_CAP_NONE 0x00000000
  335. #define SVGA_CAP_RECT_COPY 0x00000002
  336. #define SVGA_CAP_CURSOR 0x00000020
  337. #define SVGA_CAP_CURSOR_BYPASS 0x00000040 // Legacy (Use Cursor Bypass 3 instead)
  338. #define SVGA_CAP_CURSOR_BYPASS_2 0x00000080 // Legacy (Use Cursor Bypass 3 instead)
  339. #define SVGA_CAP_8BIT_EMULATION 0x00000100
  340. #define SVGA_CAP_ALPHA_CURSOR 0x00000200
  341. #define SVGA_CAP_3D 0x00004000
  342. #define SVGA_CAP_EXTENDED_FIFO 0x00008000
  343. #define SVGA_CAP_MULTIMON 0x00010000 // Legacy multi-monitor support
  344. #define SVGA_CAP_PITCHLOCK 0x00020000
  345. #define SVGA_CAP_IRQMASK 0x00040000
  346. #define SVGA_CAP_DISPLAY_TOPOLOGY 0x00080000 // Legacy multi-monitor support
  347. #define SVGA_CAP_GMR 0x00100000
  348. #define SVGA_CAP_TRACES 0x00200000
  349. /*
  350. * FIFO register indices.
  351. *
  352. * The FIFO is a chunk of device memory mapped into guest physmem. It
  353. * is always treated as 32-bit words.
  354. *
  355. * The guest driver gets to decide how to partition it between
  356. * - FIFO registers (there are always at least 4, specifying where the
  357. * following data area is and how much data it contains; there may be
  358. * more registers following these, depending on the FIFO protocol
  359. * version in use)
  360. * - FIFO data, written by the guest and slurped out by the VMX.
  361. * These indices are 32-bit word offsets into the FIFO.
  362. */
  363. enum {
  364. /*
  365. * Block 1 (basic registers): The originally defined FIFO registers.
  366. * These exist and are valid for all versions of the FIFO protocol.
  367. */
  368. SVGA_FIFO_MIN = 0,
  369. SVGA_FIFO_MAX, /* The distance from MIN to MAX must be at least 10K */
  370. SVGA_FIFO_NEXT_CMD,
  371. SVGA_FIFO_STOP,
  372. /*
  373. * Block 2 (extended registers): Mandatory registers for the extended
  374. * FIFO. These exist if the SVGA caps register includes
  375. * SVGA_CAP_EXTENDED_FIFO; some of them are valid only if their
  376. * associated capability bit is enabled.
  377. *
  378. * Note that when originally defined, SVGA_CAP_EXTENDED_FIFO implied
  379. * support only for (FIFO registers) CAPABILITIES, FLAGS, and FENCE.
  380. * This means that the guest has to test individually (in most cases
  381. * using FIFO caps) for the presence of registers after this; the VMX
  382. * can define "extended FIFO" to mean whatever it wants, and currently
  383. * won't enable it unless there's room for that set and much more.
  384. */
  385. SVGA_FIFO_CAPABILITIES = 4,
  386. SVGA_FIFO_FLAGS,
  387. // Valid with SVGA_FIFO_CAP_FENCE:
  388. SVGA_FIFO_FENCE,
  389. /*
  390. * Block 3a (optional extended registers): Additional registers for the
  391. * extended FIFO, whose presence isn't actually implied by
  392. * SVGA_CAP_EXTENDED_FIFO; these exist if SVGA_FIFO_MIN is high enough to
  393. * leave room for them.
  394. *
  395. * These in block 3a, the VMX currently considers mandatory for the
  396. * extended FIFO.
  397. */
  398. // Valid if exists (i.e. if extended FIFO enabled):
  399. SVGA_FIFO_3D_HWVERSION, /* See SVGA3dHardwareVersion in svga3d_reg.h */
  400. // Valid with SVGA_FIFO_CAP_PITCHLOCK:
  401. SVGA_FIFO_PITCHLOCK,
  402. // Valid with SVGA_FIFO_CAP_CURSOR_BYPASS_3:
  403. SVGA_FIFO_CURSOR_ON, /* Cursor bypass 3 show/hide register */
  404. SVGA_FIFO_CURSOR_X, /* Cursor bypass 3 x register */
  405. SVGA_FIFO_CURSOR_Y, /* Cursor bypass 3 y register */
  406. SVGA_FIFO_CURSOR_COUNT, /* Incremented when any of the other 3 change */
  407. SVGA_FIFO_CURSOR_LAST_UPDATED,/* Last time the host updated the cursor */
  408. // Valid with SVGA_FIFO_CAP_RESERVE:
  409. SVGA_FIFO_RESERVED, /* Bytes past NEXT_CMD with real contents */
  410. /*
  411. * Valid with SVGA_FIFO_CAP_SCREEN_OBJECT:
  412. *
  413. * By default this is SVGA_ID_INVALID, to indicate that the cursor
  414. * coordinates are specified relative to the virtual root. If this
  415. * is set to a specific screen ID, cursor position is reinterpreted
  416. * as a signed offset relative to that screen's origin. This is the
  417. * only way to place the cursor on a non-rooted screen.
  418. */
  419. SVGA_FIFO_CURSOR_SCREEN_ID,
  420. /*
  421. * XXX: The gap here, up until SVGA_FIFO_3D_CAPS, can be used for new
  422. * registers, but this must be done carefully and with judicious use of
  423. * capability bits, since comparisons based on SVGA_FIFO_MIN aren't
  424. * enough to tell you whether the register exists: we've shipped drivers
  425. * and products that used SVGA_FIFO_3D_CAPS but didn't know about some of
  426. * the earlier ones. The actual order of introduction was:
  427. * - PITCHLOCK
  428. * - 3D_CAPS
  429. * - CURSOR_* (cursor bypass 3)
  430. * - RESERVED
  431. * So, code that wants to know whether it can use any of the
  432. * aforementioned registers, or anything else added after PITCHLOCK and
  433. * before 3D_CAPS, needs to reason about something other than
  434. * SVGA_FIFO_MIN.
  435. */
  436. /*
  437. * 3D caps block space; valid with 3D hardware version >=
  438. * SVGA3D_HWVERSION_WS6_B1.
  439. */
  440. SVGA_FIFO_3D_CAPS = 32,
  441. SVGA_FIFO_3D_CAPS_LAST = 32 + 255,
  442. /*
  443. * End of VMX's current definition of "extended-FIFO registers".
  444. * Registers before here are always enabled/disabled as a block; either
  445. * the extended FIFO is enabled and includes all preceding registers, or
  446. * it's disabled entirely.
  447. *
  448. * Block 3b (truly optional extended registers): Additional registers for
  449. * the extended FIFO, which the VMX already knows how to enable and
  450. * disable with correct granularity.
  451. *
  452. * Registers after here exist if and only if the guest SVGA driver
  453. * sets SVGA_FIFO_MIN high enough to leave room for them.
  454. */
  455. // Valid if register exists:
  456. SVGA_FIFO_GUEST_3D_HWVERSION, /* Guest driver's 3D version */
  457. SVGA_FIFO_FENCE_GOAL, /* Matching target for SVGA_IRQFLAG_FENCE_GOAL */
  458. SVGA_FIFO_BUSY, /* See "FIFO Synchronization Registers" */
  459. /*
  460. * Always keep this last. This defines the maximum number of
  461. * registers we know about. At power-on, this value is placed in
  462. * the SVGA_REG_MEM_REGS register, and we expect the guest driver
  463. * to allocate this much space in FIFO memory for registers.
  464. */
  465. SVGA_FIFO_NUM_REGS
  466. };
  467. /*
  468. * Definition of registers included in extended FIFO support.
  469. *
  470. * The guest SVGA driver gets to allocate the FIFO between registers
  471. * and data. It must always allocate at least 4 registers, but old
  472. * drivers stopped there.
  473. *
  474. * The VMX will enable extended FIFO support if and only if the guest
  475. * left enough room for all registers defined as part of the mandatory
  476. * set for the extended FIFO.
  477. *
  478. * Note that the guest drivers typically allocate the FIFO only at
  479. * initialization time, not at mode switches, so it's likely that the
  480. * number of FIFO registers won't change without a reboot.
  481. *
  482. * All registers less than this value are guaranteed to be present if
  483. * svgaUser->fifo.extended is set. Any later registers must be tested
  484. * individually for compatibility at each use (in the VMX).
  485. *
  486. * This value is used only by the VMX, so it can change without
  487. * affecting driver compatibility; keep it that way?
  488. */
  489. #define SVGA_FIFO_EXTENDED_MANDATORY_REGS (SVGA_FIFO_3D_CAPS_LAST + 1)
  490. /*
  491. * FIFO Synchronization Registers
  492. *
  493. * This explains the relationship between the various FIFO
  494. * sync-related registers in IOSpace and in FIFO space.
  495. *
  496. * SVGA_REG_SYNC --
  497. *
  498. * The SYNC register can be used in two different ways by the guest:
  499. *
  500. * 1. If the guest wishes to fully sync (drain) the FIFO,
  501. * it will write once to SYNC then poll on the BUSY
  502. * register. The FIFO is sync'ed once BUSY is zero.
  503. *
  504. * 2. If the guest wants to asynchronously wake up the host,
  505. * it will write once to SYNC without polling on BUSY.
  506. * Ideally it will do this after some new commands have
  507. * been placed in the FIFO, and after reading a zero
  508. * from SVGA_FIFO_BUSY.
  509. *
  510. * (1) is the original behaviour that SYNC was designed to
  511. * support. Originally, a write to SYNC would implicitly
  512. * trigger a read from BUSY. This causes us to synchronously
  513. * process the FIFO.
  514. *
  515. * This behaviour has since been changed so that writing SYNC
  516. * will *not* implicitly cause a read from BUSY. Instead, it
  517. * makes a channel call which asynchronously wakes up the MKS
  518. * thread.
  519. *
  520. * New guests can use this new behaviour to implement (2)
  521. * efficiently. This lets guests get the host's attention
  522. * without waiting for the MKS to poll, which gives us much
  523. * better CPU utilization on SMP hosts and on UP hosts while
  524. * we're blocked on the host GPU.
  525. *
  526. * Old guests shouldn't notice the behaviour change. SYNC was
  527. * never guaranteed to process the entire FIFO, since it was
  528. * bounded to a particular number of CPU cycles. Old guests will
  529. * still loop on the BUSY register until the FIFO is empty.
  530. *
  531. * Writing to SYNC currently has the following side-effects:
  532. *
  533. * - Sets SVGA_REG_BUSY to TRUE (in the monitor)
  534. * - Asynchronously wakes up the MKS thread for FIFO processing
  535. * - The value written to SYNC is recorded as a "reason", for
  536. * stats purposes.
  537. *
  538. * If SVGA_FIFO_BUSY is available, drivers are advised to only
  539. * write to SYNC if SVGA_FIFO_BUSY is FALSE. Drivers should set
  540. * SVGA_FIFO_BUSY to TRUE after writing to SYNC. The MKS will
  541. * eventually set SVGA_FIFO_BUSY on its own, but this approach
  542. * lets the driver avoid sending multiple asynchronous wakeup
  543. * messages to the MKS thread.
  544. *
  545. * SVGA_REG_BUSY --
  546. *
  547. * This register is set to TRUE when SVGA_REG_SYNC is written,
  548. * and it reads as FALSE when the FIFO has been completely
  549. * drained.
  550. *
  551. * Every read from this register causes us to synchronously
  552. * process FIFO commands. There is no guarantee as to how many
  553. * commands each read will process.
  554. *
  555. * CPU time spent processing FIFO commands will be billed to
  556. * the guest.
  557. *
  558. * New drivers should avoid using this register unless they
  559. * need to guarantee that the FIFO is completely drained. It
  560. * is overkill for performing a sync-to-fence. Older drivers
  561. * will use this register for any type of synchronization.
  562. *
  563. * SVGA_FIFO_BUSY --
  564. *
  565. * This register is a fast way for the guest driver to check
  566. * whether the FIFO is already being processed. It reads and
  567. * writes at normal RAM speeds, with no monitor intervention.
  568. *
  569. * If this register reads as TRUE, the host is guaranteeing that
  570. * any new commands written into the FIFO will be noticed before
  571. * the MKS goes back to sleep.
  572. *
  573. * If this register reads as FALSE, no such guarantee can be
  574. * made.
  575. *
  576. * The guest should use this register to quickly determine
  577. * whether or not it needs to wake up the host. If the guest
  578. * just wrote a command or group of commands that it would like
  579. * the host to begin processing, it should:
  580. *
  581. * 1. Read SVGA_FIFO_BUSY. If it reads as TRUE, no further
  582. * action is necessary.
  583. *
  584. * 2. Write TRUE to SVGA_FIFO_BUSY. This informs future guest
  585. * code that we've already sent a SYNC to the host and we
  586. * don't need to send a duplicate.
  587. *
  588. * 3. Write a reason to SVGA_REG_SYNC. This will send an
  589. * asynchronous wakeup to the MKS thread.
  590. */
  591. /*
  592. * FIFO Capabilities
  593. *
  594. * Fence -- Fence register and command are supported
  595. * Accel Front -- Front buffer only commands are supported
  596. * Pitch Lock -- Pitch lock register is supported
  597. * Video -- SVGA Video overlay units are supported
  598. * Escape -- Escape command is supported
  599. *
  600. * XXX: Add longer descriptions for each capability, including a list
  601. * of the new features that each capability provides.
  602. *
  603. * SVGA_FIFO_CAP_SCREEN_OBJECT --
  604. *
  605. * Provides dynamic multi-screen rendering, for improved Unity and
  606. * multi-monitor modes. With Screen Object, the guest can
  607. * dynamically create and destroy 'screens', which can represent
  608. * Unity windows or virtual monitors. Screen Object also provides
  609. * strong guarantees that DMA operations happen only when
  610. * guest-initiated. Screen Object deprecates the BAR1 guest
  611. * framebuffer (GFB) and all commands that work only with the GFB.
  612. *
  613. * New registers:
  614. * FIFO_CURSOR_SCREEN_ID, VIDEO_DATA_GMRID, VIDEO_DST_SCREEN_ID
  615. *
  616. * New 2D commands:
  617. * DEFINE_SCREEN, DESTROY_SCREEN, DEFINE_GMRFB, BLIT_GMRFB_TO_SCREEN,
  618. * BLIT_SCREEN_TO_GMRFB, ANNOTATION_FILL, ANNOTATION_COPY
  619. *
  620. * New 3D commands:
  621. * BLIT_SURFACE_TO_SCREEN
  622. *
  623. * New guarantees:
  624. *
  625. * - The host will not read or write guest memory, including the GFB,
  626. * except when explicitly initiated by a DMA command.
  627. *
  628. * - All DMA, including legacy DMA like UPDATE and PRESENT_READBACK,
  629. * is guaranteed to complete before any subsequent FENCEs.
  630. *
  631. * - All legacy commands which affect a Screen (UPDATE, PRESENT,
  632. * PRESENT_READBACK) as well as new Screen blit commands will
  633. * all behave consistently as blits, and memory will be read
  634. * or written in FIFO order.
  635. *
  636. * For example, if you PRESENT from one SVGA3D surface to multiple
  637. * places on the screen, the data copied will always be from the
  638. * SVGA3D surface at the time the PRESENT was issued in the FIFO.
  639. * This was not necessarily true on devices without Screen Object.
  640. *
  641. * This means that on devices that support Screen Object, the
  642. * PRESENT_READBACK command should not be necessary unless you
  643. * actually want to read back the results of 3D rendering into
  644. * system memory. (And for that, the BLIT_SCREEN_TO_GMRFB
  645. * command provides a strict superset of functionality.)
  646. *
  647. * - When a screen is resized, either using Screen Object commands or
  648. * legacy multimon registers, its contents are preserved.
  649. */
  650. #define SVGA_FIFO_CAP_NONE 0
  651. #define SVGA_FIFO_CAP_FENCE (1<<0)
  652. #define SVGA_FIFO_CAP_ACCELFRONT (1<<1)
  653. #define SVGA_FIFO_CAP_PITCHLOCK (1<<2)
  654. #define SVGA_FIFO_CAP_VIDEO (1<<3)
  655. #define SVGA_FIFO_CAP_CURSOR_BYPASS_3 (1<<4)
  656. #define SVGA_FIFO_CAP_ESCAPE (1<<5)
  657. #define SVGA_FIFO_CAP_RESERVE (1<<6)
  658. #define SVGA_FIFO_CAP_SCREEN_OBJECT (1<<7)
  659. /*
  660. * FIFO Flags
  661. *
  662. * Accel Front -- Driver should use front buffer only commands
  663. */
  664. #define SVGA_FIFO_FLAG_NONE 0
  665. #define SVGA_FIFO_FLAG_ACCELFRONT (1<<0)
  666. #define SVGA_FIFO_FLAG_RESERVED (1<<31) // Internal use only
  667. /*
  668. * FIFO reservation sentinel value
  669. */
  670. #define SVGA_FIFO_RESERVED_UNKNOWN 0xffffffff
  671. /*
  672. * Video overlay support
  673. */
  674. #define SVGA_NUM_OVERLAY_UNITS 32
  675. /*
  676. * Video capabilities that the guest is currently using
  677. */
  678. #define SVGA_VIDEO_FLAG_COLORKEY 0x0001
  679. /*
  680. * Offsets for the video overlay registers
  681. */
  682. enum {
  683. SVGA_VIDEO_ENABLED = 0,
  684. SVGA_VIDEO_FLAGS,
  685. SVGA_VIDEO_DATA_OFFSET,
  686. SVGA_VIDEO_FORMAT,
  687. SVGA_VIDEO_COLORKEY,
  688. SVGA_VIDEO_SIZE, // Deprecated
  689. SVGA_VIDEO_WIDTH,
  690. SVGA_VIDEO_HEIGHT,
  691. SVGA_VIDEO_SRC_X,
  692. SVGA_VIDEO_SRC_Y,
  693. SVGA_VIDEO_SRC_WIDTH,
  694. SVGA_VIDEO_SRC_HEIGHT,
  695. SVGA_VIDEO_DST_X, // Signed int32
  696. SVGA_VIDEO_DST_Y, // Signed int32
  697. SVGA_VIDEO_DST_WIDTH,
  698. SVGA_VIDEO_DST_HEIGHT,
  699. SVGA_VIDEO_PITCH_1,
  700. SVGA_VIDEO_PITCH_2,
  701. SVGA_VIDEO_PITCH_3,
  702. SVGA_VIDEO_DATA_GMRID, // Optional, defaults to SVGA_GMR_FRAMEBUFFER
  703. SVGA_VIDEO_DST_SCREEN_ID, // Optional, defaults to virtual coords (SVGA_ID_INVALID)
  704. SVGA_VIDEO_NUM_REGS
  705. };
  706. /*
  707. * SVGA Overlay Units
  708. *
  709. * width and height relate to the entire source video frame.
  710. * srcX, srcY, srcWidth and srcHeight represent subset of the source
  711. * video frame to be displayed.
  712. */
  713. typedef struct SVGAOverlayUnit {
  714. uint32 enabled;
  715. uint32 flags;
  716. uint32 dataOffset;
  717. uint32 format;
  718. uint32 colorKey;
  719. uint32 size;
  720. uint32 width;
  721. uint32 height;
  722. uint32 srcX;
  723. uint32 srcY;
  724. uint32 srcWidth;
  725. uint32 srcHeight;
  726. int32 dstX;
  727. int32 dstY;
  728. uint32 dstWidth;
  729. uint32 dstHeight;
  730. uint32 pitches[3];
  731. uint32 dataGMRId;
  732. uint32 dstScreenId;
  733. } SVGAOverlayUnit;
  734. /*
  735. * SVGAScreenObject --
  736. *
  737. * This is a new way to represent a guest's multi-monitor screen or
  738. * Unity window. Screen objects are only supported if the
  739. * SVGA_FIFO_CAP_SCREEN_OBJECT capability bit is set.
  740. *
  741. * If Screen Objects are supported, they can be used to fully
  742. * replace the functionality provided by the framebuffer registers
  743. * (SVGA_REG_WIDTH, HEIGHT, etc.) and by SVGA_CAP_DISPLAY_TOPOLOGY.
  744. *
  745. * The screen object is a struct with guaranteed binary
  746. * compatibility. New flags can be added, and the struct may grow,
  747. * but existing fields must retain their meaning.
  748. *
  749. */
  750. #define SVGA_SCREEN_HAS_ROOT (1 << 0) // Screen is present in the virtual coord space
  751. #define SVGA_SCREEN_IS_PRIMARY (1 << 1) // Guest considers this screen to be 'primary'
  752. #define SVGA_SCREEN_FULLSCREEN_HINT (1 << 2) // Guest is running a fullscreen app here
  753. typedef
  754. struct SVGAScreenObject {
  755. uint32 structSize; // sizeof(SVGAScreenObject)
  756. uint32 id;
  757. uint32 flags;
  758. struct {
  759. uint32 width;
  760. uint32 height;
  761. } size;
  762. struct {
  763. int32 x;
  764. int32 y;
  765. } root; // Only used if SVGA_SCREEN_HAS_ROOT is set.
  766. } SVGAScreenObject;
  767. /*
  768. * Commands in the command FIFO:
  769. *
  770. * Command IDs defined below are used for the traditional 2D FIFO
  771. * communication (not all commands are available for all versions of the
  772. * SVGA FIFO protocol).
  773. *
  774. * Note the holes in the command ID numbers: These commands have been
  775. * deprecated, and the old IDs must not be reused.
  776. *
  777. * Command IDs from 1000 to 1999 are reserved for use by the SVGA3D
  778. * protocol.
  779. *
  780. * Each command's parameters are described by the comments and
  781. * structs below.
  782. */
  783. typedef enum {
  784. SVGA_CMD_INVALID_CMD = 0,
  785. SVGA_CMD_UPDATE = 1,
  786. SVGA_CMD_RECT_COPY = 3,
  787. SVGA_CMD_DEFINE_CURSOR = 19,
  788. SVGA_CMD_DEFINE_ALPHA_CURSOR = 22,
  789. SVGA_CMD_UPDATE_VERBOSE = 25,
  790. SVGA_CMD_FRONT_ROP_FILL = 29,
  791. SVGA_CMD_FENCE = 30,
  792. SVGA_CMD_ESCAPE = 33,
  793. SVGA_CMD_DEFINE_SCREEN = 34,
  794. SVGA_CMD_DESTROY_SCREEN = 35,
  795. SVGA_CMD_DEFINE_GMRFB = 36,
  796. SVGA_CMD_BLIT_GMRFB_TO_SCREEN = 37,
  797. SVGA_CMD_BLIT_SCREEN_TO_GMRFB = 38,
  798. SVGA_CMD_ANNOTATION_FILL = 39,
  799. SVGA_CMD_ANNOTATION_COPY = 40,
  800. SVGA_CMD_MAX
  801. } SVGAFifoCmdId;
  802. #define SVGA_CMD_MAX_ARGS 64
  803. /*
  804. * SVGA_CMD_UPDATE --
  805. *
  806. * This is a DMA transfer which copies from the Guest Framebuffer
  807. * (GFB) at BAR1 + SVGA_REG_FB_OFFSET to any screens which
  808. * intersect with the provided virtual rectangle.
  809. *
  810. * This command does not support using arbitrary guest memory as a
  811. * data source- it only works with the pre-defined GFB memory.
  812. * This command also does not support signed virtual coordinates.
  813. * If you have defined screens (using SVGA_CMD_DEFINE_SCREEN) with
  814. * negative root x/y coordinates, the negative portion of those
  815. * screens will not be reachable by this command.
  816. *
  817. * This command is not necessary when using framebuffer
  818. * traces. Traces are automatically enabled if the SVGA FIFO is
  819. * disabled, and you may explicitly enable/disable traces using
  820. * SVGA_REG_TRACES. With traces enabled, any write to the GFB will
  821. * automatically act as if a subsequent SVGA_CMD_UPDATE was issued.
  822. *
  823. * Traces and SVGA_CMD_UPDATE are the only supported ways to render
  824. * pseudocolor screen updates. The newer Screen Object commands
  825. * only support true color formats.
  826. *
  827. * Availability:
  828. * Always available.
  829. */
  830. typedef
  831. struct {
  832. uint32 x;
  833. uint32 y;
  834. uint32 width;
  835. uint32 height;
  836. } SVGAFifoCmdUpdate;
  837. /*
  838. * SVGA_CMD_RECT_COPY --
  839. *
  840. * Perform a rectangular DMA transfer from one area of the GFB to
  841. * another, and copy the result to any screens which intersect it.
  842. *
  843. * Availability:
  844. * SVGA_CAP_RECT_COPY
  845. */
  846. typedef
  847. struct {
  848. uint32 srcX;
  849. uint32 srcY;
  850. uint32 destX;
  851. uint32 destY;
  852. uint32 width;
  853. uint32 height;
  854. } SVGAFifoCmdRectCopy;
  855. /*
  856. * SVGA_CMD_DEFINE_CURSOR --
  857. *
  858. * Provide a new cursor image, as an AND/XOR mask.
  859. *
  860. * The recommended way to position the cursor overlay is by using
  861. * the SVGA_FIFO_CURSOR_* registers, supported by the
  862. * SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.
  863. *
  864. * Availability:
  865. * SVGA_CAP_CURSOR
  866. */
  867. typedef
  868. struct {
  869. uint32 id; // Reserved, must be zero.
  870. uint32 hotspotX;
  871. uint32 hotspotY;
  872. uint32 width;
  873. uint32 height;
  874. uint32 andMaskDepth; // Value must be 1 or equal to BITS_PER_PIXEL
  875. uint32 xorMaskDepth; // Value must be 1 or equal to BITS_PER_PIXEL
  876. /*
  877. * Followed by scanline data for AND mask, then XOR mask.
  878. * Each scanline is padded to a 32-bit boundary.
  879. */
  880. } SVGAFifoCmdDefineCursor;
  881. /*
  882. * SVGA_CMD_DEFINE_ALPHA_CURSOR --
  883. *
  884. * Provide a new cursor image, in 32-bit BGRA format.
  885. *
  886. * The recommended way to position the cursor overlay is by using
  887. * the SVGA_FIFO_CURSOR_* registers, supported by the
  888. * SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.
  889. *
  890. * Availability:
  891. * SVGA_CAP_ALPHA_CURSOR
  892. */
  893. typedef
  894. struct {
  895. uint32 id; // Reserved, must be zero.
  896. uint32 hotspotX;
  897. uint32 hotspotY;
  898. uint32 width;
  899. uint32 height;
  900. /* Followed by scanline data */
  901. } SVGAFifoCmdDefineAlphaCursor;
  902. /*
  903. * SVGA_CMD_UPDATE_VERBOSE --
  904. *
  905. * Just like SVGA_CMD_UPDATE, but also provide a per-rectangle
  906. * 'reason' value, an opaque cookie which is used by internal
  907. * debugging tools. Third party drivers should not use this
  908. * command.
  909. *
  910. * Availability:
  911. * SVGA_CAP_EXTENDED_FIFO
  912. */
  913. typedef
  914. struct {
  915. uint32 x;
  916. uint32 y;
  917. uint32 width;
  918. uint32 height;
  919. uint32 reason;
  920. } SVGAFifoCmdUpdateVerbose;
  921. /*
  922. * SVGA_CMD_FRONT_ROP_FILL --
  923. *
  924. * This is a hint which tells the SVGA device that the driver has
  925. * just filled a rectangular region of the GFB with a solid
  926. * color. Instead of reading these pixels from the GFB, the device
  927. * can assume that they all equal 'color'. This is primarily used
  928. * for remote desktop protocols.
  929. *
  930. * Availability:
  931. * SVGA_FIFO_CAP_ACCELFRONT
  932. */
  933. #define SVGA_ROP_COPY 0x03
  934. typedef
  935. struct {
  936. uint32 color; // In the same format as the GFB
  937. uint32 x;
  938. uint32 y;
  939. uint32 width;
  940. uint32 height;
  941. uint32 rop; // Must be SVGA_ROP_COPY
  942. } SVGAFifoCmdFrontRopFill;
  943. /*
  944. * SVGA_CMD_FENCE --
  945. *
  946. * Insert a synchronization fence. When the SVGA device reaches
  947. * this command, it will copy the 'fence' value into the
  948. * SVGA_FIFO_FENCE register. It will also compare the fence against
  949. * SVGA_FIFO_FENCE_GOAL. If the fence matches the goal and the
  950. * SVGA_IRQFLAG_FENCE_GOAL interrupt is enabled, the device will
  951. * raise this interrupt.
  952. *
  953. * Availability:
  954. * SVGA_FIFO_FENCE for this command,
  955. * SVGA_CAP_IRQMASK for SVGA_FIFO_FENCE_GOAL.
  956. */
  957. typedef
  958. struct {
  959. uint32 fence;
  960. } SVGAFifoCmdFence;
  961. /*
  962. * SVGA_CMD_ESCAPE --
  963. *
  964. * Send an extended or vendor-specific variable length command.
  965. * This is used for video overlay, third party plugins, and
  966. * internal debugging tools. See svga_escape.h
  967. *
  968. * Availability:
  969. * SVGA_FIFO_CAP_ESCAPE
  970. */
  971. typedef
  972. struct {
  973. uint32 nsid;
  974. uint32 size;
  975. /* followed by 'size' bytes of data */
  976. } SVGAFifoCmdEscape;
  977. /*
  978. * SVGA_CMD_DEFINE_SCREEN --
  979. *
  980. * Define or redefine an SVGAScreenObject. See the description of
  981. * SVGAScreenObject above. The video driver is responsible for
  982. * generating new screen IDs. They should be small positive
  983. * integers. The virtual device will have an implementation
  984. * specific upper limit on the number of screen IDs
  985. * supported. Drivers are responsible for recycling IDs. The first
  986. * valid ID is zero.
  987. *
  988. * - Interaction with other registers:
  989. *
  990. * For backwards compatibility, when the GFB mode registers (WIDTH,
  991. * HEIGHT, PITCHLOCK, BITS_PER_PIXEL) are modified, the SVGA device
  992. * deletes all screens other than screen #0, and redefines screen
  993. * #0 according to the specified mode. Drivers that use
  994. * SVGA_CMD_DEFINE_SCREEN should destroy or redefine screen #0.
  995. *
  996. * If you use screen objects, do not use the legacy multi-mon
  997. * registers (SVGA_REG_NUM_GUEST_DISPLAYS, SVGA_REG_DISPLAY_*).
  998. *
  999. * Availability:
  1000. * SVGA_FIFO_CAP_SCREEN_OBJECT
  1001. */
  1002. typedef
  1003. struct {
  1004. SVGAScreenObject screen; // Variable-length according to version
  1005. } SVGAFifoCmdDefineScreen;
  1006. /*
  1007. * SVGA_CMD_DESTROY_SCREEN --
  1008. *
  1009. * Destroy an SVGAScreenObject. Its ID is immediately available for
  1010. * re-use.
  1011. *
  1012. * Availability:
  1013. * SVGA_FIFO_CAP_SCREEN_OBJECT
  1014. */
  1015. typedef
  1016. struct {
  1017. uint32 screenId;
  1018. } SVGAFifoCmdDestroyScreen;
  1019. /*
  1020. * SVGA_CMD_DEFINE_GMRFB --
  1021. *
  1022. * This command sets a piece of SVGA device state called the
  1023. * Guest Memory Region Framebuffer, or GMRFB. The GMRFB is a
  1024. * piece of light-weight state which identifies the location and
  1025. * format of an image in guest memory or in BAR1. The GMRFB has
  1026. * an arbitrary size, and it doesn't need to match the geometry
  1027. * of the GFB or any screen object.
  1028. *
  1029. * The GMRFB can be redefined as often as you like. You could
  1030. * always use the same GMRFB, you could redefine it before
  1031. * rendering from a different guest screen, or you could even
  1032. * redefine it before every blit.
  1033. *
  1034. * There are multiple ways to use this command. The simplest way is
  1035. * to use it to move the framebuffer either to elsewhere in the GFB
  1036. * (BAR1) memory region, or to a user-defined GMR. This lets a
  1037. * driver use a framebuffer allocated entirely out of normal system
  1038. * memory, which we encourage.
  1039. *
  1040. * Another way to use this command is to set up a ring buffer of
  1041. * updates in GFB memory. If a driver wants to ensure that no
  1042. * frames are skipped by the SVGA device, it is important that the
  1043. * driver not modify the source data for a blit until the device is
  1044. * done processing the command. One efficient way to accomplish
  1045. * this is to use a ring of small DMA buffers. Each buffer is used
  1046. * for one blit, then we move on to the next buffer in the
  1047. * ring. The FENCE mechanism is used to protect each buffer from
  1048. * re-use until the device is finished with that buffer's
  1049. * corresponding blit.
  1050. *
  1051. * This command does not affect the meaning of SVGA_CMD_UPDATE.
  1052. * UPDATEs always occur from the legacy GFB memory area. This
  1053. * command has no support for pseudocolor GMRFBs. Currently only
  1054. * true-color 15, 16, and 24-bit depths are supported. Future
  1055. * devices may expose capabilities for additional framebuffer
  1056. * formats.
  1057. *
  1058. * The default GMRFB value is undefined. Drivers must always send
  1059. * this command at least once before performing any blit from the
  1060. * GMRFB.
  1061. *
  1062. * Availability:
  1063. * SVGA_FIFO_CAP_SCREEN_OBJECT
  1064. */
  1065. typedef
  1066. struct {
  1067. SVGAGuestPtr ptr;
  1068. uint32 bytesPerLine;
  1069. SVGAGMRImageFormat format;
  1070. } SVGAFifoCmdDefineGMRFB;
  1071. /*
  1072. * SVGA_CMD_BLIT_GMRFB_TO_SCREEN --
  1073. *
  1074. * This is a guest-to-host blit. It performs a DMA operation to
  1075. * copy a rectangular region of pixels from the current GMRFB to
  1076. * one or more Screen Objects.
  1077. *
  1078. * The destination coordinate may be specified relative to a
  1079. * screen's origin (if a screen ID is specified) or relative to the
  1080. * virtual coordinate system's origin (if the screen ID is
  1081. * SVGA_ID_INVALID). The actual destination may span zero or more
  1082. * screens, in the case of a virtual destination rect or a rect
  1083. * which extends off the edge of the specified screen.
  1084. *
  1085. * This command writes to the screen's "base layer": the underlying
  1086. * framebuffer which exists below any cursor or video overlays. No
  1087. * action is necessary to explicitly hide or update any overlays
  1088. * which exist on top of the updated region.
  1089. *
  1090. * The SVGA device is guaranteed to finish reading from the GMRFB
  1091. * by the time any subsequent FENCE commands are reached.
  1092. *
  1093. * This command consumes an annotation. See the
  1094. * SVGA_CMD_ANNOTATION_* commands for details.
  1095. *
  1096. * Availability:
  1097. * SVGA_FIFO_CAP_SCREEN_OBJECT
  1098. */
  1099. typedef
  1100. struct {
  1101. SVGASignedPoint srcOrigin;
  1102. SVGASignedRect destRect;
  1103. uint32 destScreenId;
  1104. } SVGAFifoCmdBlitGMRFBToScreen;
  1105. /*
  1106. * SVGA_CMD_BLIT_SCREEN_TO_GMRFB --
  1107. *
  1108. * This is a host-to-guest blit. It performs a DMA operation to
  1109. * copy a rectangular region of pixels from a single Screen Object
  1110. * back to the current GMRFB.
  1111. *
  1112. * Usage note: This command should be used rarely. It will
  1113. * typically be inefficient, but it is necessary for some types of
  1114. * synchronization between 3D (GPU) and 2D (CPU) rendering into
  1115. * overlapping areas of a screen.
  1116. *
  1117. * The source coordinate is specified relative to a screen's
  1118. * origin. The provided screen ID must be valid. If any parameters
  1119. * are invalid, the resulting pixel values are undefined.
  1120. *
  1121. * This command reads the screen's "base layer". Overlays like
  1122. * video and cursor are not included, but any data which was sent
  1123. * using a blit-to-screen primitive will be available, no matter
  1124. * whether the data's original source was the GMRFB or the 3D
  1125. * acceleration hardware.
  1126. *
  1127. * Note that our guest-to-host blits and host-to-guest blits aren't
  1128. * symmetric in their current implementation. While the parameters
  1129. * are identical, host-to-guest blits are a lot less featureful.
  1130. * They do not support clipping: If the source parameters don't
  1131. * fully fit within a screen, the blit fails. They must originate
  1132. * from exactly one screen. Virtual coordinates are not directly
  1133. * supported.
  1134. *
  1135. * Host-to-guest blits do support the same set of GMRFB formats
  1136. * offered by guest-to-host blits.
  1137. *
  1138. * The SVGA device is guaranteed to finish writing to the GMRFB by
  1139. * the time any subsequent FENCE commands are reached.
  1140. *
  1141. * Availability:
  1142. * SVGA_FIFO_CAP_SCREEN_OBJECT
  1143. */
  1144. typedef
  1145. struct {
  1146. SVGASignedPoint destOrigin;
  1147. SVGASignedRect srcRect;
  1148. uint32 srcScreenId;
  1149. } SVGAFifoCmdBlitScreenToGMRFB;
  1150. /*
  1151. * SVGA_CMD_ANNOTATION_FILL --
  1152. *
  1153. * This is a blit annotation. This command stores a small piece of
  1154. * device state which is consumed by the next blit-to-screen
  1155. * command. The state is only cleared by commands which are
  1156. * specifically documented as consuming an annotation. Other
  1157. * commands (such as ESCAPEs for debugging) may intervene between
  1158. * the annotation and its associated blit.
  1159. *
  1160. * This annotation is a promise about the contents of the next
  1161. * blit: The video driver is guaranteeing that all pixels in that
  1162. * blit will have the same value, specified here as a color in
  1163. * SVGAColorBGRX format.
  1164. *
  1165. * The SVGA device can still render the blit correctly even if it
  1166. * ignores this annotation, but the annotation may allow it to
  1167. * perform the blit more efficiently, for example by ignoring the
  1168. * source data and performing a fill in hardware.
  1169. *
  1170. * This annotation is most important for performance when the
  1171. * user's display is being remoted over a network connection.
  1172. *
  1173. * Availability:
  1174. * SVGA_FIFO_CAP_SCREEN_OBJECT
  1175. */
  1176. typedef
  1177. struct {
  1178. SVGAColorBGRX color;
  1179. } SVGAFifoCmdAnnotationFill;
  1180. /*
  1181. * SVGA_CMD_ANNOTATION_COPY --
  1182. *
  1183. * This is a blit annotation. See SVGA_CMD_ANNOTATION_FILL for more
  1184. * information about annotations.
  1185. *
  1186. * This annotation is a promise about the contents of the next
  1187. * blit: The video driver is guaranteeing that all pixels in that
  1188. * blit will have the same value as those which already exist at an
  1189. * identically-sized region on the same or a different screen.
  1190. *
  1191. * Note that the source pixels for the COPY in this annotation are
  1192. * sampled before applying the anqnotation's associated blit. They
  1193. * are allowed to overlap with the blit's destination pixels.
  1194. *
  1195. * The copy source rectangle is specified the same way as the blit
  1196. * destination: it can be a rectangle which spans zero or more
  1197. * screens, specified relative to either a screen or to the virtual
  1198. * coordinate system's origin. If the source rectangle includes
  1199. * pixels which are not from exactly one screen, the results are
  1200. * undefined.
  1201. *
  1202. * Availability:
  1203. * SVGA_FIFO_CAP_SCREEN_OBJECT
  1204. */
  1205. typedef
  1206. struct {
  1207. SVGASignedPoint srcOrigin;
  1208. uint32 srcScreenId;
  1209. } SVGAFifoCmdAnnotationCopy;
  1210. #endif