svga_reg.h 64 KB

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