svga_reg.h 53 KB

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