svga_reg.h 64 KB

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