svga_reg.h 64 KB

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