svga_reg.h 54 KB

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