svga_reg.h 69 KB

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