1bf215546Sopenharmony_ci1. Introduction
2bf215546Sopenharmony_ci
3bf215546Sopenharmony_cirules-ng is a package consisting of a database of nvidia GPU registers in XML
4bf215546Sopenharmony_ciformat, and tools made to parse this database and do useful work with it. It
5bf215546Sopenharmony_ciis in mostly usable state, but there are some annoyances that prevent its
6bf215546Sopenharmony_ciadoption as the home of all nouveau documentation.
7bf215546Sopenharmony_ci
8bf215546Sopenharmony_ciNote that this document and rules-ng understands "register" quite liberally as
9bf215546Sopenharmony_ci"anything that has an address and can have a value in it, written to it, or
10bf215546Sopenharmony_ciread to it". This includes conventional MMIO registers, as well as fields of
11bf215546Sopenharmony_cimemory structures and grobj methods.
12bf215546Sopenharmony_ci
13bf215546Sopenharmony_ciIts parsable XML format is supposed to solve three problems:
14bf215546Sopenharmony_ci
15bf215546Sopenharmony_ci - serve as actual documentation for the known registers: supports attaching
16bf215546Sopenharmony_ci   arbitrary text in <doc> tags and generating HTML for easy reading.
17bf215546Sopenharmony_ci - name -> hex translation: supports generating C headers that #define all
18bf215546Sopenharmony_ci   known registers, bitfields and enum values as C constants.
19bf215546Sopenharmony_ci - hex -> name translation: you tell it the address or address+value of a
20bf215546Sopenharmony_ci   register, and it decodes the address to its symbolic name, and the value to
21bf215546Sopenharmony_ci   its constituting bitfields, if any. Useful for decoding mmio-traces /
22bf215546Sopenharmony_ci   renouveau dumps, as well as standalone use.
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ciWhat's non-trivial about all this [ie. why rules-ng is not a long series of
25bf215546Sopenharmony_ciplain address - name - documentation tuples]:
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ci - The registers may be split into bitfields, each with a different purpose
28bf215546Sopenharmony_ci   and name [and separate documentation].
29bf215546Sopenharmony_ci - The registers/bitfields may accept values from a predefined set [enum],
30bf215546Sopenharmony_ci   each with a different meaning. Each value also has a name and
31bf215546Sopenharmony_ci   documentation.
32bf215546Sopenharmony_ci - The registers may come in multiple copies, forming arrays. They can also
33bf215546Sopenharmony_ci   form logical groups. And these groups can also come in multiple copies,
34bf215546Sopenharmony_ci   forming larger arrays... and you get a hierarchical structure.
35bf215546Sopenharmony_ci - There are multiple different GPU chipsets. The available register set
36bf215546Sopenharmony_ci   changed between these chipsets - sometimes only a few registers, sometimes
37bf215546Sopenharmony_ci   half the card was remade from scratch. More annoyingly, sometimes some
38bf215546Sopenharmony_ci   registers move from one place to another, but are otherwise unchanged.
39bf215546Sopenharmony_ci   Also [nvidia-specific], new grobj classes are sometimes really just new
40bf215546Sopenharmony_ci   revisions of a base class with a few methods changed. In both of these
41bf215546Sopenharmony_ci   cases, we want to avoid duplication as much as possible.
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci2. Proposed new XML format
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci2.1. General tags
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_ciRoot tag is <database>. There is one per the whole file and it should contain
48bf215546Sopenharmony_cieverything else.
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ci<brief> and <doc> are tags that can appear inside any other tag, and document
51bf215546Sopenharmony_ciwhatever it defines. <brief> is supposed to be a short one-line description
52bf215546Sopenharmony_cigiving a rough idea what a given item is for if no sufficiently descriptive
53bf215546Sopenharmony_ciname was used. <doc> can be of any length, can contain some html and html-like
54bf215546Sopenharmony_citags, and is supposed to describe a given item in as much detail as needed.
55bf215546Sopenharmony_ciThere should be at most one <doc> and at most one <brief> tag for any parent.
56bf215546Sopenharmony_ci
57bf215546Sopenharmony_ciTags that define top-level entities include:
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_ci <domain>: Declares an addressing space containing registers
60bf215546Sopenharmony_ci <group>: Declares a block of registers, expected to be included by one or
61bf215546Sopenharmony_ci          more <domain>s
62bf215546Sopenharmony_ci <bitset>: Declares a list of applicable bitfields for some register
63bf215546Sopenharmony_ci <enum>: Declares a list of related symbolic values. Can describe params to
64bf215546Sopenharmony_ci         a register/bitfield, or discriminate between card variants.
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_ciEach of these has an associated global name used to refer to them from other
67bf215546Sopenharmony_ciparts of database. As a convenience, and to allow related stuff to be kept
68bf215546Sopenharmony_citogether, the top-level entities are allowed to occur pretty much anywhere
69bf215546Sopenharmony_ciinside the XML file except inside <doc> tags. This implies no scoping,
70bf215546Sopenharmony_cihowever: the effect is the same as putting the entity right below <database>.
71bf215546Sopenharmony_ciIf two top-level elements of the same type and name are defined, they'll be
72bf215546Sopenharmony_cimerged into a single one, as if contents of one were written right after
73bf215546Sopenharmony_cicontents of the other. All attributes of the merged tags need to match.
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ciAnother top-level tag that can be used anywhere is the <import> tag. It's used
76bf215546Sopenharmony_cilike <import file="foo.xml"/> and makes all of foo.xml's definitions available
77bf215546Sopenharmony_cito the containing file. If a single file is <import>ed more than one time, all
78bf215546Sopenharmony_ci<import>s other than the first are ignored.
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_ci2.2. Domains
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_ciAll register definitions ultimately belong to a <domain>. <domain> is
83bf215546Sopenharmony_cibasically just a single address space. So we'll have a domain for the MMIO
84bf215546Sopenharmony_ciBAR, one for each type of memory structure we need to describe, a domain for
85bf215546Sopenharmony_cithe grobj/FIFO methods, and a domain for each indirect index-data pair used to
86bf215546Sopenharmony_ciaccess something useful. <domain> can have the following attributes:
87bf215546Sopenharmony_ci
88bf215546Sopenharmony_ci - name [required]: The name of the domain.
89bf215546Sopenharmony_ci - width [optional]: the size, in bits, of a single addressable unit. This is
90bf215546Sopenharmony_ci   8 by default for usual byte-addressable memory, but 32 can be useful
91bf215546Sopenharmony_ci   occasionally for indexed spaces of 32-bit cells. Values sane enough to
92bf215546Sopenharmony_ci   support for now include 8, 16, 32, 64.
93bf215546Sopenharmony_ci - size [optional]: total number of addressable units it spans. Can be
94bf215546Sopenharmony_ci   undefined if you don't know it or it doesn't make sense. As a special
95bf215546Sopenharmony_ci   exception to the merging rules, size attribute need not be specified on all
96bf215546Sopenharmony_ci   tags that will result in a merged domain: tags with size can be merged with
97bf215546Sopenharmony_ci   tags without size, resulting in merged domain that has size. Error only
98bf215546Sopenharmony_ci   happens when the merged domains both have sizes, and the sizes differ.
99bf215546Sopenharmony_ci - bare [optional]: if set to "no", all children items will have the domain
100bf215546Sopenharmony_ci   name prepended to their names. If set to "yes", such prefixing doesn't
101bf215546Sopenharmony_ci   happen. Default is "no".
102bf215546Sopenharmony_ci - prefix [optional]: selects the string that should be prepended to name
103bf215546Sopenharmony_ci   of every child item. The special value "none" means no prefix, and is the
104bf215546Sopenharmony_ci   default. All other values are looked up as <enum> names and, for each child
105bf215546Sopenharmony_ci   item, its name is prefixed with name of the earliest variant in the given
106bf215546Sopenharmony_ci   enum that supports given item.
107bf215546Sopenharmony_ci
108bf215546Sopenharmony_ci<domain name="NV_MMIO" size="0x1000000" prefix="chipset" bare="yes">
109bf215546Sopenharmony_ci	<reg32 offset="0" name="PMC_BOOT_0" />
110bf215546Sopenharmony_ci	<reg32 offset="4" name="PMC_BOOT_1" varset="chipset" variants="NV10-" />
111bf215546Sopenharmony_ci	<reg32 offset="0x100" name="PMC_INTR" />
112bf215546Sopenharmony_ci</domain>
113bf215546Sopenharmony_ci
114bf215546Sopenharmony_ciDescribes a space with 0x1000000 of 8-bit addressable cells. Cells 0-3 belong
115bf215546Sopenharmony_cito NV04_PMC_BOOT_0 register, 4-7 belong to NV10_PMC_BOOT_1 register,
116bf215546Sopenharmony_ci0x100-0x103 belong to NV04_PMC_INTR register, and remaining cells are either
117bf215546Sopenharmony_ciunused or unknown. The generated .h definitions are:
118bf215546Sopenharmony_ci
119bf215546Sopenharmony_ci#define NV_MMIO__SIZE		0x1000000
120bf215546Sopenharmony_ci#define NV04_PMC_BOOT_0		0
121bf215546Sopenharmony_ci#define NV10_PMC_BOOT_1		4
122bf215546Sopenharmony_ci#define NV04_PMC_INTR		0x100
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_ci<domain name="NV50_PFB_VM_TRAP" width="32" size="6">
125bf215546Sopenharmony_ci	<reg32 offset="0" name="STATUS" />
126bf215546Sopenharmony_ci	<reg32 offset="1" name="CHANNEL" />
127bf215546Sopenharmony_ci	<reg32 offset="2" name="UNK2" />
128bf215546Sopenharmony_ci	<reg32 offset="3" name="ADDRLOW" />
129bf215546Sopenharmony_ci	<reg32 offset="4" name="ADDRMID" />
130bf215546Sopenharmony_ci	<reg32 offset="5" name="ADDRHIGH" />
131bf215546Sopenharmony_ci</domain>
132bf215546Sopenharmony_ci
133bf215546Sopenharmony_ciDefines a 6-cell address space with each cell 32 bits in size and
134bf215546Sopenharmony_cicorresponding to a single register. Definitions are:
135bf215546Sopenharmony_ci
136bf215546Sopenharmony_ci#define NV50_PFB_VM_TRAP__SIZE		6
137bf215546Sopenharmony_ci#define NV50_PFB_VM_TRAP_STATUS		0
138bf215546Sopenharmony_ci#define NV50_PFB_VM_TRAP_CHANNEL	1
139bf215546Sopenharmony_ci#define NV50_PFB_VM_TRAP_UNK2		2
140bf215546Sopenharmony_ci#define NV50_PFB_VM_TRAP_ADDRLOW	3
141bf215546Sopenharmony_ci#define NV50_PFB_VM_TRAP_ADDRMID	4
142bf215546Sopenharmony_ci#define NV50_PFB_VM_TRAP_ADDRHIGH	5
143bf215546Sopenharmony_ci
144bf215546Sopenharmony_ci2.3. Registers
145bf215546Sopenharmony_ci
146bf215546Sopenharmony_ciWhat we really want all the time is defining registers. This is done with
147bf215546Sopenharmony_ci<reg8>, <reg16>, <reg32> or <reg64> tags. The register of course takes
148bf215546Sopenharmony_cireg_width / domain_width cells in the domain. It's an error to define a
149bf215546Sopenharmony_ciregister with smaller width than the domain it's in. The <reg*> attributes
150bf215546Sopenharmony_ciare:
151bf215546Sopenharmony_ci
152bf215546Sopenharmony_ci - name [required]: the name of the register
153bf215546Sopenharmony_ci - offset [required]: the offset of the register
154bf215546Sopenharmony_ci - access [optional]: "rw" [default], "r", or "w" to mark the register as
155bf215546Sopenharmony_ci   read-write, read-only, or write-only. Only makes sense for real MMIO
156bf215546Sopenharmony_ci   domains.
157bf215546Sopenharmony_ci - varset [optional]: the <enum> to choose from by the variant attribute.
158bf215546Sopenharmony_ci   Defaults to first <enum> used in currently active prefix.
159bf215546Sopenharmony_ci - variants [optional]: space-separated list of and variant ranges that this
160bf215546Sopenharmony_ci   register is present on. The items of this list can be:
161bf215546Sopenharmony_ci    - var1: a single variant
162bf215546Sopenharmony_ci    - var1-var2: all variants starting with var1 up to and including var2
163bf215546Sopenharmony_ci    - var1:var2: all variants starting with var1 up to, but not including var2
164bf215546Sopenharmony_ci    - :var1: all variants before var1
165bf215546Sopenharmony_ci    - -var1: all variants up to and including var1
166bf215546Sopenharmony_ci    - var1-: all variants starting from var1
167bf215546Sopenharmony_ci - type [optional]: How to interpret the contents of this register.
168bf215546Sopenharmony_ci    - "uint": unsigned decimal integer
169bf215546Sopenharmony_ci    - "int": signed decimal integer
170bf215546Sopenharmony_ci    - "hex": unsigned hexadecimal integer
171bf215546Sopenharmony_ci    - "float" IEEE 16-bit, 32-bit or 64-bit floating point format, depending
172bf215546Sopenharmony_ci      on register/bitfield size
173bf215546Sopenharmony_ci    - "boolean": a boolean value: 0 is false, 1 is true
174bf215546Sopenharmony_ci    - any defined enum name: value from that anum
175bf215546Sopenharmony_ci    - "enum": value from the inline <value> tags in this <reg*>
176bf215546Sopenharmony_ci    - any defined bitset name: value decoded further according to that bitset
177bf215546Sopenharmony_ci    - "bitset": value decoded further according to the inline <bitfield>
178bf215546Sopenharmony_ci      tags
179bf215546Sopenharmony_ci    - any defined domain name: value decoded as an offset in that domain
180bf215546Sopenharmony_ci   The default is "bitset" if there are inline <bitfield> tags present,
181bf215546Sopenharmony_ci   otherwise "enum" if there are inline <value> tags present, otherwise
182bf215546Sopenharmony_ci   "boolean" if this is a bitfield with width 1, otherwise "hex".
183bf215546Sopenharmony_ci - shr [optional]: the value in this register is the real value shifted right
184bf215546Sopenharmony_ci   by this many bits. Ie. for register with shr="12", register value 0x1234
185bf215546Sopenharmony_ci   should be interpreted as 0x1234000. May sound too specific, but happens
186bf215546Sopenharmony_ci   quite often in nvidia hardware.
187bf215546Sopenharmony_ci - length [optional]: if specified to be other than 1, the register is treated
188bf215546Sopenharmony_ci   as if it was enclosed in an anonymous <stripe> with corresponding length
189bf215546Sopenharmony_ci   and stride attributes, except the __ESIZE and __LEN stripe defines are
190bf215546Sopenharmony_ci   emitted with the register's name. If not specified, defaults to 1.
191bf215546Sopenharmony_ci - stride [optional]: the stride value to use if length is non-1. Defaults to
192bf215546Sopenharmony_ci   the register's size in cells.
193bf215546Sopenharmony_ci
194bf215546Sopenharmony_ciThe definitions emitted for a non-stripe register include only its offset and
195bf215546Sopenharmony_cishr value. Other informations are generally expected to be a part of code
196bf215546Sopenharmony_cilogic anyway:
197bf215546Sopenharmony_ci
198bf215546Sopenharmony_ci<reg32 offset="0x400784" name="PGRAPH_CTXCTL_SWAP" shr="12" />
199bf215546Sopenharmony_ci
200bf215546Sopenharmony_ciresults in
201bf215546Sopenharmony_ci
202bf215546Sopenharmony_ci#define PGRAPH_CTXCTL_SWAP	0x400784
203bf215546Sopenharmony_ci#define PGRAPH_CTXCTL_SWAP__SHR	12
204bf215546Sopenharmony_ci
205bf215546Sopenharmony_ciFor striped registers, __LEN and __ESIZE definitions like <stripe> are emitted
206bf215546Sopenharmony_citoo:
207bf215546Sopenharmony_ci
208bf215546Sopenharmony_ci<!-- in a 8-bit domain -->
209bf215546Sopenharmony_ci<reg32 offset="0x0600" name="NV50_COMPUTE_USER_PARAM" length="64" />
210bf215546Sopenharmony_ci
211bf215546Sopenharmony_ciresults in
212bf215546Sopenharmony_ci
213bf215546Sopenharmony_ci#define NV50_COMPUTE_USER_PARAM(i)	(0x600 + (i)*4)
214bf215546Sopenharmony_ci#define NV50_COMPUTE_USER_PARAM__LEN	64
215bf215546Sopenharmony_ci#define NV50_COMPUTE_USER_PARAM__ESIZE	4
216bf215546Sopenharmony_ci
217bf215546Sopenharmony_ciThe <reg*> tags can also contain either bitfield definitions, or enum value
218bf215546Sopenharmony_cidefinitions.
219bf215546Sopenharmony_ci
220bf215546Sopenharmony_ci2.4. Enums and variants
221bf215546Sopenharmony_ci
222bf215546Sopenharmony_ciEnum is, basically, a set of values. They're defined by <enum> tag with the
223bf215546Sopenharmony_cifollowing attributes:
224bf215546Sopenharmony_ci
225bf215546Sopenharmony_ci - name [required]: an identifying name.
226bf215546Sopenharmony_ci - inline [optional]: "yes" or "no", with "no" being the default. Selects if
227bf215546Sopenharmony_ci   this enum should emit its own definitions in .h file, or be inlined into
228bf215546Sopenharmony_ci   any <reg*> / <bitfield> definitions that reference it.
229bf215546Sopenharmony_ci - bare [optional]: only for no-inline enums, behaves like bare attribute
230bf215546Sopenharmony_ci   to <domain>
231bf215546Sopenharmony_ci - prefix [optional]: only for no-inline enums, behaves like prefix attribute
232bf215546Sopenharmony_ci   to <domain>.
233bf215546Sopenharmony_ci
234bf215546Sopenharmony_ciThe <enum> tag contains <value> tags with the following attributes:
235bf215546Sopenharmony_ci
236bf215546Sopenharmony_ci - name [required]: the name of the value
237bf215546Sopenharmony_ci - value [optional]: the value
238bf215546Sopenharmony_ci - varset [optional]: like in <reg*>
239bf215546Sopenharmony_ci - variants [optional]: like in <reg*>
240bf215546Sopenharmony_ci
241bf215546Sopenharmony_ciThe <enum>s are referenced from inside <reg*> and <bitfield> tags by setting
242bf215546Sopenharmony_cithe type attribute to the name of the enum. For single-use enums, the <value>
243bf215546Sopenharmony_citags can also be written directly inside <reg*> tag.
244bf215546Sopenharmony_ci
245bf215546Sopenharmony_ci<enum name="SURFACE_FORMAT" prefix="chipset">
246bf215546Sopenharmony_ci	<value value="6" name="A8R8G8B8" />
247bf215546Sopenharmony_ci	<value value="0x12" name="A8R8G8B8_RECT" variants="NV10-" />
248bf215546Sopenharmony_ci</enum>
249bf215546Sopenharmony_ci
250bf215546Sopenharmony_ci<enum name="gl_shade_model" inline="yes">
251bf215546Sopenharmony_ci	<value value="0x1d00" name="FLAT" />
252bf215546Sopenharmony_ci	<value value="0x1d01" name="SMOOTH" />
253bf215546Sopenharmony_ci</enum>
254bf215546Sopenharmony_ci
255bf215546Sopenharmony_ci<reg32 offset="0x1234" name="TEXTURE_FORMAT" type="SURFACE_FORMAT" />
256bf215546Sopenharmony_ci<reg32 offset="0x1238" name="SHADE_MODEL" type="gl_shade_model" />
257bf215546Sopenharmony_ci<reg32 offset="0x123c" name="PATTERN_SELECT">
258bf215546Sopenharmony_ci	<value value="1" name="MONO" />
259bf215546Sopenharmony_ci	<value value="2" name="COLOR" />
260bf215546Sopenharmony_ci</reg32>
261bf215546Sopenharmony_ci
262bf215546Sopenharmony_ciResult:
263bf215546Sopenharmony_ci
264bf215546Sopenharmony_ci#define NV04_SURFACE_FORMAT_A8R8G8B8		6
265bf215546Sopenharmony_ci#define NV04_SURFACE_FORMAT_A8R8G8B8_RECT	0x12
266bf215546Sopenharmony_ci#define TEXTURE_FORMAT				0x1234
267bf215546Sopenharmony_ci#define SHADE_MODEL				0x1238
268bf215546Sopenharmony_ci#define     SHADE_MODEL_FLAT			0x1d00
269bf215546Sopenharmony_ci#define     SHADE_MODEL_SMOOTH			0x1d01
270bf215546Sopenharmony_ci#define PATTERN_SELECT				0x123c
271bf215546Sopenharmony_ci#define     PATTERN_SELECT_MONO			1
272bf215546Sopenharmony_ci#define     PATTERN_SELECT_COLOR		2
273bf215546Sopenharmony_ci
274bf215546Sopenharmony_ciAnother use for enums is describing variants: slightly different versions of
275bf215546Sopenharmony_cicards, objects, etc. The varset and variant attributes of most tags allow
276bf215546Sopenharmony_cidefining items that are only present when you're dealing with something of the
277bf215546Sopenharmony_cimatching variant. The variant space is "multidimensional" - so you can have
278bf215546Sopenharmony_cia variant "dimension" representing what GPU chipset you're using at the
279bf215546Sopenharmony_cimoment, and another dimension representing what grobj class you're dealing
280bf215546Sopenharmony_ciwith [taken from another enum]. Both of these can be independent.
281bf215546Sopenharmony_ci
282bf215546Sopenharmony_ci<enum name="chipset">
283bf215546Sopenharmony_ci	<brief>The chipset of the card</brief>
284bf215546Sopenharmony_ci	<value name="NV04">
285bf215546Sopenharmony_ci		<brief>RIVA TNT</brief>
286bf215546Sopenharmony_ci	</value>
287bf215546Sopenharmony_ci	<value name="NV05">
288bf215546Sopenharmony_ci		<brief>RIVA TNT2</brief>
289bf215546Sopenharmony_ci	</value>
290bf215546Sopenharmony_ci	<value name="NV10">
291bf215546Sopenharmony_ci		<brief>GeForce 256</brief>
292bf215546Sopenharmony_ci	</value>
293bf215546Sopenharmony_ci	<value name="NV50">
294bf215546Sopenharmony_ci		<brief>G80: GeForce 8800 GTX, Tesla *870, ...</brief>
295bf215546Sopenharmony_ci	</value>
296bf215546Sopenharmony_ci	<value name="NV84">
297bf215546Sopenharmony_ci		<brief>G84: GeForce 8600 GT, ...</brief>
298bf215546Sopenharmony_ci	</value>
299bf215546Sopenharmony_ci	<value name="NVA0">
300bf215546Sopenharmony_ci		<brief>G200: GeForce 260 GTX, Tesla C1060, ...</brief>
301bf215546Sopenharmony_ci	</value>
302bf215546Sopenharmony_ci	<value name="NVA5">
303bf215546Sopenharmony_ci		<brief>GT216: GeForce GT 220</brief>
304bf215546Sopenharmony_ci	</value>
305bf215546Sopenharmony_ci</enum>
306bf215546Sopenharmony_ci
307bf215546Sopenharmony_ciIf enabled for a given domain, the name of the earliest variant to support
308bf215546Sopenharmony_cia given register / bitfield / value / whatever will be automatically prepended
309bf215546Sopenharmony_cito its name. For this purpose, "earliest" is defined as "comes first in the
310bf215546Sopenharmony_ciXML file".
311bf215546Sopenharmony_ci
312bf215546Sopenharmony_ci<enum>s used for this purpose can still be used as normal enums. And can even
313bf215546Sopenharmony_cihave variant-specific values referencing another <enum>. Example:
314bf215546Sopenharmony_ci
315bf215546Sopenharmony_ci<enum name="grobj-class" bare="yes" prefix="chipset">
316bf215546Sopenharmony_ci	<value name="MEMORY_TO_MEMORY_FORMAT" value="0x0039" variants=":NV50" />
317bf215546Sopenharmony_ci	<value name="MEMORY_TO_MEMORY_FORMAT" value="0x5039" variants="NV50-" />
318bf215546Sopenharmony_ci	<value name="2D" value="0x502d" variants="NV50-" />
319bf215546Sopenharmony_ci	<value name="TCL" value="0x5097" variants="NV50:NVA0" />
320bf215546Sopenharmony_ci	<value name="TCL" value="0x8297" variants="NV84" />
321bf215546Sopenharmony_ci	<value name="COMPUTE" value="0x50c0" variants="NV50-" />
322bf215546Sopenharmony_ci</enum>
323bf215546Sopenharmony_ci
324bf215546Sopenharmony_ciIn generated .h file, this will result in:
325bf215546Sopenharmony_ci
326bf215546Sopenharmony_ci#define NV04_MEMORY_TO_MEMORY_FORMAT	0x0039
327bf215546Sopenharmony_ci#define NV50_MEMORY_TO_MEMORY_FORMAT	0x5039
328bf215546Sopenharmony_ci#define NV50_2D				0x502d
329bf215546Sopenharmony_ci#define NV50_TCL			0x5097
330bf215546Sopenharmony_ci#define NV84_TCL			0x8297
331bf215546Sopenharmony_ci#define NV50_COMPUTE			0x50c0
332bf215546Sopenharmony_ci
333bf215546Sopenharmony_ci2.5. Bitfields
334bf215546Sopenharmony_ci
335bf215546Sopenharmony_ciOften, registers store not a single full-width value, but are split into
336bf215546Sopenharmony_cibitfields. Like values can be grouped in enums, bitfields can be called in
337bf215546Sopenharmony_cibitsets. The <bitset> tag has the same set of attributes as <enum> tag, and
338bf215546Sopenharmony_cicontains <bitfield> tags with the following attributes:
339bf215546Sopenharmony_ci
340bf215546Sopenharmony_ci - name [required]: name of the bitfield
341bf215546Sopenharmony_ci - low [required]: index of the lowest bit belonging to this bitfield. bits
342bf215546Sopenharmony_ci   are counted from 0, LSB-first.
343bf215546Sopenharmony_ci - high [required]: index of the highest bit belonging to this bitfield.
344bf215546Sopenharmony_ci - varset [optional]: like in <reg*>
345bf215546Sopenharmony_ci - variants [optional]: like in <reg*>
346bf215546Sopenharmony_ci - type [optional]: like in <reg*>
347bf215546Sopenharmony_ci - shr [optional]: like in <reg*>
348bf215546Sopenharmony_ci
349bf215546Sopenharmony_ciLike <value>s, <bitfield>s are also allowed to be written directly inside
350bf215546Sopenharmony_ci<reg*> tags.
351bf215546Sopenharmony_ci
352bf215546Sopenharmony_ci<bitfield>s themselves can contain <value>s. The defines generated for
353bf215546Sopenharmony_ci<bitfield>s include "name__MASK" equal to the bitmask corresponding to given
354bf215546Sopenharmony_cibitfield, "name__SHIFT" equal to the low attribute, "name__SHR" equal to
355bf215546Sopenharmony_cithe shr attribute [if defined]. Single-bit bitfields with type "boolean" are
356bf215546Sopenharmony_citreated specially, and get "name" defined to the bitmask instead. If the
357bf215546Sopenharmony_cibitfield contains any <value>s, <bitfield>s, or references an inlined
358bf215546Sopenharmony_cienum/bitset, defines for them are also generated, pre-shifted to the correct
359bf215546Sopenharmony_ciposition. Example:
360bf215546Sopenharmony_ci
361bf215546Sopenharmony_ci<enum name="nv03_operation" inline="yes">
362bf215546Sopenharmony_ci	<value value="0" name="SRCCOPY_AND" />	
363bf215546Sopenharmony_ci	<value value="1" name="ROP_AND" />	
364bf215546Sopenharmony_ci	<value value="2" name="BLEND_AND" />	
365bf215546Sopenharmony_ci	<value value="3" name="SRCCOPY" />	
366bf215546Sopenharmony_ci	<value value="4" name="SRCCOPY_PRE" />
367bf215546Sopenharmony_ci	<value value="5" name="BLEND_PRE" />
368bf215546Sopenharmony_ci</enum>
369bf215546Sopenharmony_ci
370bf215546Sopenharmony_ci<bitset name="NV04_GROBJ_1">
371bf215546Sopenharmony_ci	<bitfield high="7" low="0" name="GRCLASS" />
372bf215546Sopenharmony_ci	<bitfield high="12" low="12" name="CHROMA_KEY" />
373bf215546Sopenharmony_ci	<bitfield high="13" low="13" name="USER_CLIP" />
374bf215546Sopenharmony_ci	<bitfield high="14" low="14" name="SWIZZLE" />
375bf215546Sopenharmony_ci	<bitfield high="17" low="15" name="PATCH_CONFIG" type="nv03_operation" />
376bf215546Sopenharmony_ci	<!-- ... -->
377bf215546Sopenharmony_ci</bitset>
378bf215546Sopenharmony_ci
379bf215546Sopenharmony_ci<bitset name="xy16" inline="yes">
380bf215546Sopenharmony_ci	<bitfield high="15" low="0" name="X" />
381bf215546Sopenharmony_ci	<bitfield high="31" low="16" name="Y" />
382bf215546Sopenharmony_ci</bitset>
383bf215546Sopenharmony_ci
384bf215546Sopenharmony_ci<bitset name="nv50_vic" inline="yes">
385bf215546Sopenharmony_ci	<bitfield high="0" low="0" name="X"/>
386bf215546Sopenharmony_ci	<bitfield high="1" low="1" name="Y"/>
387bf215546Sopenharmony_ci	<bitfield high="2" low="2" name="Z"/>
388bf215546Sopenharmony_ci	<bitfield high="3" low="3" name="W"/>
389bf215546Sopenharmony_ci</bitset>
390bf215546Sopenharmony_ci
391bf215546Sopenharmony_ci<reg32 offset="0x40014c" name="PGRAPH_CTX_SWITCH_1" type="NV04_GROBJ_1" />
392bf215546Sopenharmony_ci
393bf215546Sopenharmony_ci<reg32 offset="0x0404" name="FORMAT">
394bf215546Sopenharmony_ci	<bitfield high="15" low="0" name="PITCH" />
395bf215546Sopenharmony_ci	<bitfield high="23" low="16" name="ORIGIN" />
396bf215546Sopenharmony_ci	<bitfield high="31" low="24" name="FILTER" />
397bf215546Sopenharmony_ci</reg32>
398bf215546Sopenharmony_ci
399bf215546Sopenharmony_ci<reg32 offset="0x040c" name="POINT" type="xy16" />
400bf215546Sopenharmony_ci
401bf215546Sopenharmony_ci<reg32 offset="0x1988" name="FP_INTERPOLANT_CTRL">
402bf215546Sopenharmony_ci	<bitfield name="UMASK" high="31" low="24" type="nv50_vic"/>
403bf215546Sopenharmony_ci	<bitfield name="COUNT_NONFLAT" high="23" low="16" type="int"/>
404bf215546Sopenharmony_ci	<bitfield name="OFFSET" high="15" low="8" type="int"/>
405bf215546Sopenharmony_ci	<bitfield name="COUNT" high="7" low="0" type="int"/>
406bf215546Sopenharmony_ci</reg32>
407bf215546Sopenharmony_ci
408bf215546Sopenharmony_ciResult:
409bf215546Sopenharmony_ci
410bf215546Sopenharmony_ci#define NV04_GROBJ_1_GRCLASS__MASK		0x000000ff
411bf215546Sopenharmony_ci#define NV04_GROBJ_1_GRCLASS__SHIFT		0
412bf215546Sopenharmony_ci#define NV04_GROBJ_1_CHROMA_KEY			0x00001000
413bf215546Sopenharmony_ci#define NV04_GROBJ_1_USER_CLIP			0x00002000
414bf215546Sopenharmony_ci#define NV04_GROBJ_1_SWIZZLE			0x00004000
415bf215546Sopenharmony_ci#define NV04_GROBJ_1_PATCH_CONFIG__MASK		0x00038000
416bf215546Sopenharmony_ci#define NV04_GROBJ_1_PATCH_CONFIG__SHIFT	15
417bf215546Sopenharmony_ci#define NV04_GROBJ_1_PATCH_CONFIG_SRCCOPY_AND	0x00000000
418bf215546Sopenharmony_ci#define NV04_GROBJ_1_PATCH_CONFIG_ROP_AND	0x00008000
419bf215546Sopenharmony_ci#define NV04_GROBJ_1_PATCH_CONFIG_BLEND_AND	0x00010000
420bf215546Sopenharmony_ci#define NV04_GROBJ_1_PATCH_CONFIG_SRCCOPY	0x00018000
421bf215546Sopenharmony_ci#define NV04_GROBJ_1_PATCH_CONFIG_SRCCOPY_PRE	0x00020000
422bf215546Sopenharmony_ci#define NV04_GROBJ_1_PATCH_CONFIG_BLEND_PRE	0x00028000
423bf215546Sopenharmony_ci
424bf215546Sopenharmony_ci#define PGRAPH_CTX_SWITCH_1			0x40014c
425bf215546Sopenharmony_ci
426bf215546Sopenharmony_ci#define FORMAT			0x0404
427bf215546Sopenharmony_ci#define FORMAT_PITCH__MASK	0x0000ffff
428bf215546Sopenharmony_ci#define FORMAT_PITCH__SHIFT	0
429bf215546Sopenharmony_ci#define FORMAT_ORIGIN__MASM	0x00ff0000
430bf215546Sopenharmony_ci#define FORMAT_ORIGIN__SHIFT	16
431bf215546Sopenharmony_ci#define FORMAT_FILTER__MASK	0xff000000
432bf215546Sopenharmony_ci#define FORMAT_FILTER__SHIFT	24
433bf215546Sopenharmony_ci
434bf215546Sopenharmony_ci#define POINT		0x040c
435bf215546Sopenharmony_ci#define POINT_X		0x0000ffff
436bf215546Sopenharmony_ci#define POINT_X__SHIFT		0
437bf215546Sopenharmony_ci#define POINT_Y		0xffff0000
438bf215546Sopenharmony_ci#define POINT_Y__SHIFT		16
439bf215546Sopenharmony_ci
440bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL				0x00001988
441bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_UMASK__MASK			0xff000000
442bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_UMASK__SHIFT		24
443bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_UMASK_X			0x01000000
444bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_UMASK_Y			0x02000000
445bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_UMASK_Z			0x04000000
446bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_UMASK_W			0x08000000
447bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_COUNT_NONFLAT__MASK		0x00ff0000
448bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_COUNT_NONFLAT__SHIFT	16
449bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_OFFSET__MASK		0x0000ff00
450bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_OFFSET__SHIFT		8
451bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_COUNT__MASK			0x000000ff
452bf215546Sopenharmony_ci#define FP_INTERPOLANT_CTRL_COUNT__SHIFT		0
453bf215546Sopenharmony_ci
454bf215546Sopenharmony_ci2.6. Arrays and stripes.
455bf215546Sopenharmony_ci
456bf215546Sopenharmony_ciSometimes you have multiple copies of a register. Sometimes you actually have
457bf215546Sopenharmony_cimultiple copies of a whole set of registers. And sometimes this set itself
458bf215546Sopenharmony_cicontains multiple copies of something. This is what <array>s are for. The
459bf215546Sopenharmony_ci<array> represents "length" units, each of size "stride" packed next to each
460bf215546Sopenharmony_ciother starting at "offset". Offsets of everything inside the array are
461bf215546Sopenharmony_cirelative to start of an element of the array. The <array> attributes include:
462bf215546Sopenharmony_ci
463bf215546Sopenharmony_ci - name [required]: name of the array, also used as prefix for all items
464bf215546Sopenharmony_ci   inside it
465bf215546Sopenharmony_ci - offset [required]: starting offset of the array.
466bf215546Sopenharmony_ci - stride [required]: size of a single element of the array, as well as the
467bf215546Sopenharmony_ci   difference between offsets of two neighboring elements
468bf215546Sopenharmony_ci - length [required]: Number of elements in the array
469bf215546Sopenharmony_ci - varset [optional]: As in <reg*>
470bf215546Sopenharmony_ci - variants [optional]: As in <reg*>
471bf215546Sopenharmony_ci
472bf215546Sopenharmony_ciThe definitions emitted for an array include:
473bf215546Sopenharmony_ci - name(i) defined to be the starting offset of element i, if length > 1
474bf215546Sopenharmony_ci - name defined to be the starting offset of arrayi, if length == 1
475bf215546Sopenharmony_ci - name__LEN defined to be the length of array
476bf215546Sopenharmony_ci - name__ESIZE defined to be the stride of array
477bf215546Sopenharmony_ci
478bf215546Sopenharmony_ciAlso, if length is not 1, definitions for all items inside the array that
479bf215546Sopenharmony_ciinvolve offsets become parameter-taking C macros that calculate the offset
480bf215546Sopenharmony_cibased on array index. For nested arrays, this macro takes as many arguments
481bf215546Sopenharmony_cias there are indices involved.
482bf215546Sopenharmony_ci
483bf215546Sopenharmony_ciIt's an error if an item inside an array doesn't fit inside the array element.
484bf215546Sopenharmony_ci
485bf215546Sopenharmony_ci<array offset="0x408000" name="PGRAPH_TP" stride="0x1000" length="8">
486bf215546Sopenharmony_ci	<array offset="0x200" name="MP" stride="0x80" length="2">
487bf215546Sopenharmony_ci		<!-- ... -->
488bf215546Sopenharmony_ci		<reg64 offset="0x70" name="TRAPPED_OPCODE" />
489bf215546Sopenharmony_ci		<!-- ... -->
490bf215546Sopenharmony_ci	</array>
491bf215546Sopenharmony_ci	<reg32 offset="0x314" name="MP_TRAP />
492bf215546Sopenharmony_ci	<!-- ... -->
493bf215546Sopenharmony_ci</array>
494bf215546Sopenharmony_ci
495bf215546Sopenharmony_ci#define PGRAPH_TP(i)				(0x408000+(i)*0x1000)
496bf215546Sopenharmony_ci#define PGRAPH_TP__LEN				8
497bf215546Sopenharmony_ci#define PGRAPH_TP__ESIZE			0x1000
498bf215546Sopenharmony_ci#define PGRAPH_TP_MP(i,j)			(0x408200+(i)*0x1000+(j)*0x80)
499bf215546Sopenharmony_ci#define PGRAPH_TP__LEN				2
500bf215546Sopenharmony_ci#define PGRAPH_TP__ESIZE			0x80
501bf215546Sopenharmony_ci#define PGRAPH_TP_MP_TRAPPED_OPCODE(i,j)	(0x408270+(i)*0x1000+(j)*0x80)
502bf215546Sopenharmony_ci
503bf215546Sopenharmony_ci<stripe>s are somewhat similar to arrays, but don't reserve space, merely say
504bf215546Sopenharmony_cithat all items inside come in "length" copies "stride" cells apart. As opposed
505bf215546Sopenharmony_cito <array>s, items can have offsets larger than stride, and offsets aren't
506bf215546Sopenharmony_ciautomatically assumed to be a part of <stripe> unless a <reg*> explicitely
507bf215546Sopenharmony_cihits that particular offset for some index. Also, <stripe>s of length 1 and
508bf215546Sopenharmony_cistride 0 can be used as generic container, for example to apply a variant set
509bf215546Sopenharmony_cior a prefix to a bigger set of elements. Attributes:
510bf215546Sopenharmony_ci
511bf215546Sopenharmony_ci - name [optional]: like in <array>. If not given, no prefixing happens, and
512bf215546Sopenharmony_ci   the defines for <stripe> itself aren't emitted.
513bf215546Sopenharmony_ci - offset [optional]: like <array>. Defaults to 0 if unspecified.
514bf215546Sopenharmony_ci - stride [optional]: the difference between offsets of items with indices i
515bf215546Sopenharmony_ci   and i+1. Or size of the <stripe> if it makes sense in that particular
516bf215546Sopenharmony_ci   context. Defaults to 0.
517bf215546Sopenharmony_ci - length [optional]: like in array. Defaults to 1.
518bf215546Sopenharmony_ci - varset [optional]: as in <reg*>
519bf215546Sopenharmony_ci - variants [optional]: as in <reg*>
520bf215546Sopenharmony_ci - prefix [optional]: as in <domain>, overrides parent's prefix option.
521bf215546Sopenharmony_ci
522bf215546Sopenharmony_ciDefinitions are emitted like for arrays, but:
523bf215546Sopenharmony_ci - if no name is given, the definitions for stripe itself won't be emitted
524bf215546Sopenharmony_ci - if length is 0, the length is assumed to be unknown or undefined. No __LEN
525bf215546Sopenharmony_ci   is emitted in this case.
526bf215546Sopenharmony_ci - if stride is 0, __ESIZE is not emitted
527bf215546Sopenharmony_ci - it's an error to have stride 0 with length different than 1
528bf215546Sopenharmony_ci
529bf215546Sopenharmony_ci
530bf215546Sopenharmony_ciExamples:
531bf215546Sopenharmony_ci
532bf215546Sopenharmony_ci<stripe name="PGRAPH" offset="0x400000" variants="NV04-NV05">
533bf215546Sopenharmony_ci	<reg32 offset="0x100" name="INTR" />
534bf215546Sopenharmony_ci	<reg32 offset="0x140" name="INTR_EN" />
535bf215546Sopenharmony_ci</stripe>
536bf215546Sopenharmony_ci
537bf215546Sopenharmony_ci<stripe name="PGRAPH" offset="0x400000" variants="NV50-">
538bf215546Sopenharmony_ci	<reg32 offset="0x100" name="INTR" />
539bf215546Sopenharmony_ci	<reg32 offset="0x108" name="TRAP" />
540bf215546Sopenharmony_ci	<reg32 offset="0x138" name="TRAP_EN" />
541bf215546Sopenharmony_ci	<reg32 offset="0x13c" name="INTR_EN" />
542bf215546Sopenharmony_ci</stripe>
543bf215546Sopenharmony_ci
544bf215546Sopenharmony_ciResults in:
545bf215546Sopenharmony_ci
546bf215546Sopenharmony_ci#define NV04_PGRAPH		0x400000
547bf215546Sopenharmony_ci#define NV04_PGRAPH_INTR	0x400100
548bf215546Sopenharmony_ci#define NV04_PGRAPH_INTR_EN	0x400140
549bf215546Sopenharmony_ci#define NV50_PGRAPH		0x400000
550bf215546Sopenharmony_ci#define NV50_PGRAPH_INTR	0x400100
551bf215546Sopenharmony_ci#define NV50_PGRAPH_TRAP	0x400108
552bf215546Sopenharmony_ci#define NV50_PGRAPH_TRAP_EN	0x400138
553bf215546Sopenharmony_ci#define NV50_PGRAPH_INTR_EN	0x40013c
554bf215546Sopenharmony_ci
555bf215546Sopenharmony_ci<stripe name="PVIDEO" offset="0x8000">
556bf215546Sopenharmony_ci	<stripe offset="0x900" stride="4" length="2">
557bf215546Sopenharmony_ci		<reg32 offset="0" name="BASE" />
558bf215546Sopenharmony_ci		<reg32 offset="8" name="LIMIT" />
559bf215546Sopenharmony_ci		<reg32 offset="0x10" name="LUMINANCE" />
560bf215546Sopenharmony_ci		<reg32 offset="0x18" name="CHROMINANCE" />
561bf215546Sopenharmony_ci		<!-- ... -->
562bf215546Sopenharmony_ci	</stripe>
563bf215546Sopenharmony_ci</stripe>
564bf215546Sopenharmony_ci
565bf215546Sopenharmony_ciResults in:
566bf215546Sopenharmony_ci
567bf215546Sopenharmony_ci#define PVIDEO_BASE		(0x8900+(i)*4)
568bf215546Sopenharmony_ci#define PVIDEO_LIMIT		(0x8908+(i)*4)
569bf215546Sopenharmony_ci#define PVIDEO_LUMINANCE	(0x8910+(i)*4)
570bf215546Sopenharmony_ci#define PVIDEO_CHROMINANCE	(0x8918+(i)*4)
571bf215546Sopenharmony_ci
572bf215546Sopenharmony_ci<domain name="NV_OBJECT" bare="yes">
573bf215546Sopenharmony_ci	<stripe name="OBJECT" prefix="chipset">
574bf215546Sopenharmony_ci		<reg32 offset="0x00" name="NAME" />
575bf215546Sopenharmony_ci		<reg32 offset="0x10" name="FENCE_ADDRESS_HIGH" variants="NV50-" />
576bf215546Sopenharmony_ci		<!-- more PFIFO methods -->
577bf215546Sopenharmony_ci	</stripe>
578bf215546Sopenharmony_ci	<stripe prefix="grobj-class">
579bf215546Sopenharmony_ci		<stripe variants="NV04_MEMORY_TO_MEMORY_FORMAT-NV05_MEMORY_TO_MEMORY_FORMAT">
580bf215546Sopenharmony_ci			<reg32 offset="0x200" name="LINEAR_IN" variants="NV50_MEMORY_TO_MEMORY_FORMAT" />
581bf215546Sopenharmony_ci			<reg32 offset="0x328" name="BUFFER_NOTIFY" />
582bf215546Sopenharmony_ci			<!-- more m2mf methods -->
583bf215546Sopenharmony_ci		</stripe>
584bf215546Sopenharmony_ci		<stripe variants="NV50_COMPUTE">
585bf215546Sopenharmony_ci			<reg32 offset="0x368" name="LAUNCH" />
586bf215546Sopenharmony_ci			<stripe name="GLOBAL" offset="0x400" stride="0x20" length="16">
587bf215546Sopenharmony_ci				<reg32 offset="0" name="ADDRESS_HIGH" />
588bf215546Sopenharmony_ci				<reg32 offset="4" name="ADDRESS_LOW" />
589bf215546Sopenharmony_ci				<reg32 offset="8" name="PITCH" />
590bf215546Sopenharmony_ci				<reg32 offset="0xc" name="LIMIT" />
591bf215546Sopenharmony_ci				<reg32 offset="0x10" name="MODE" />
592bf215546Sopenharmony_ci			</stripe>
593bf215546Sopenharmony_ci			<!-- more NV50_COMPUTE methods -->
594bf215546Sopenharmony_ci			<reg32 offset="0x0600" name="USER_PARAM" length="64" />
595bf215546Sopenharmony_ci		</stripe>
596bf215546Sopenharmony_ci	</stripe>
597bf215546Sopenharmony_ci</domain>
598bf215546Sopenharmony_ci
599bf215546Sopenharmony_ciResults in:
600bf215546Sopenharmony_ci
601bf215546Sopenharmony_ci#define NV01_OBJECT_NAME				0x00
602bf215546Sopenharmony_ci#define	NV50_OBJECT_FENCE_ADDRESS_HIGH			0x10
603bf215546Sopenharmony_ci#define NV50_MEMORY_TO_MEMORY_FORMAT_LINEAR_IN		0x200
604bf215546Sopenharmony_ci#define NV04_MEMORY_TO_MEMORY_FORMAT_BUFFER_NOTIFY	0x328
605bf215546Sopenharmony_ci#define NV50_COMPUTE_LAUNCH				0x368
606bf215546Sopenharmony_ci#define NV50_COMPUTE_GLOBAL				0x400
607bf215546Sopenharmony_ci#define NV50_COMPUTE_GLOBAL__LEN			16
608bf215546Sopenharmony_ci#define NV50_COMPUTE_GLOBAL__ESIZE			0x20
609bf215546Sopenharmony_ci#define NV50_COMPUTE_GLOBAL_ADDRESS_HIGH		(0x400 + (i)*0x20)
610bf215546Sopenharmony_ci#define NV50_COMPUTE_GLOBAL_ADDRESS_LOW			(0x404 + (i)*0x20)
611bf215546Sopenharmony_ci#define NV50_COMPUTE_GLOBAL_PITCH			(0x408 + (i)*0x20)
612bf215546Sopenharmony_ci#define NV50_COMPUTE_GLOBAL_LIMIT			(0x40c + (i)*0x20)
613bf215546Sopenharmony_ci#define NV50_COMPUTE_GLOBAL_MODE			(0x410 + (i)*0x20)
614bf215546Sopenharmony_ci#define NV50_COMPUTE_USER_PARAM(i)			(0x600 + (i)*4)
615bf215546Sopenharmony_ci#define NV50_COMPUTE_USER_PARAM__LEN			64
616bf215546Sopenharmony_ci#define NV50_COMPUTE_USER_PARAM__ESIZE			4
617bf215546Sopenharmony_ci
618bf215546Sopenharmony_ci2.7. Groups
619bf215546Sopenharmony_ci
620bf215546Sopenharmony_ciGroups are just sets of registers and/or arrays that can be copied-and-pasted
621bf215546Sopenharmony_citogether, when they're duplicated in several places in the same <domain>,
622bf215546Sopenharmony_citwo different <domain>s, or have different offsets for different variants.
623bf215546Sopenharmony_ci<group> and <use-group> only have the name attribute. <use-group> can appear
624bf215546Sopenharmony_ciwherever <reg*> can, including inside a <group>.
625bf215546Sopenharmony_ci
626bf215546Sopenharmony_ci<group name="nv50_mp">
627bf215546Sopenharmony_ci	<!-- ... -->
628bf215546Sopenharmony_ci	<reg64 offset="0x70" name="TRAPPED_OPCODE" />
629bf215546Sopenharmony_ci	<!-- ... -->
630bf215546Sopenharmony_ci</group>
631bf215546Sopenharmony_ci
632bf215546Sopenharmony_ci<array offset="0x408000" name="PGRAPH_TP" stride="0x1000" length="8" variants="NV50:NVA0">
633bf215546Sopenharmony_ci	<array offset="0x200" name="MP" stride="0x80" length="2">
634bf215546Sopenharmony_ci		<use-group name="nv50_mp" />
635bf215546Sopenharmony_ci	</array>
636bf215546Sopenharmony_ci	<!-- ... -->
637bf215546Sopenharmony_ci</array>
638bf215546Sopenharmony_ci<array offset="0x408000" name="PGRAPH_TP" stride="0x800" length="10" variants="NVA0-">
639bf215546Sopenharmony_ci	<array offset="0x100" name="MP" stride="0x80" length="4">
640bf215546Sopenharmony_ci		<use-group name="nv50_mp" />
641bf215546Sopenharmony_ci	</array>
642bf215546Sopenharmony_ci	<!-- ... -->
643bf215546Sopenharmony_ci</array>
644bf215546Sopenharmony_ci
645bf215546Sopenharmony_ciWill get you:
646bf215546Sopenharmony_ci
647bf215546Sopenharmony_ci#define NV50_PGRAPH_TP_MP_TRAPPED_OPCODE(i, j) 	(0x408270 + (i)*0x1000 + (j)*0x80)
648bf215546Sopenharmony_ci#define NVA0_PGRAPH_TP_MP_TRAPPED_OPCODE(i, j) 	(0x408170 + (i)*0x800 + (j)*0x80)
649bf215546Sopenharmony_ci
650bf215546Sopenharmony_ci3. The utilities.
651bf215546Sopenharmony_ci
652bf215546Sopenharmony_ciThe header generation utility will take a set of XML files and generate .h
653bf215546Sopenharmony_cifile with all of their definitions, as defined above.
654bf215546Sopenharmony_ci
655bf215546Sopenharmony_ciThe HTML generation utilty will take an XML file and generate HTML
656bf215546Sopenharmony_cidocumentation out of it. The documentation will include the <brief> and <doc>
657bf215546Sopenharmony_citags in some way, as well as information from all the attributes, in some easy
658bf215546Sopenharmony_cito read format. Some naming scheme for the HTML files should be decided, so
659bf215546Sopenharmony_cithat cross-refs to HTML documentation generated for <import>ed files will work
660bf215546Sopenharmony_cicorrectly if the generator is run in both.
661bf215546Sopenharmony_ci
662bf215546Sopenharmony_ciThe lookup utility will perform database lookups of the following types:
663bf215546Sopenharmony_ci
664bf215546Sopenharmony_ci - domain name, offset, access type, variant type[s] -> register name + array
665bf215546Sopenharmony_ci   indices if applicable
666bf215546Sopenharmony_ci - the above + register value -> same as above + decoded value. For registers
667bf215546Sopenharmony_ci   with bitfields, print all bitfields, and indicate if any bits not covered
668bf215546Sopenharmony_ci   by the bitfields are set to 1. For registers/bitfields with enum values,
669bf215546Sopenharmony_ci   print the matching one if any. For remaining registers/bitfields, print
670bf215546Sopenharmony_ci   according to type attribute.
671bf215546Sopenharmony_ci - bitset name + value -> decoded value, as above
672bf215546Sopenharmony_ci - enum name + value -> decoded value, as above
673bf215546Sopenharmony_ci
674bf215546Sopenharmony_ciThe mmio-parse utility will parse a mmio-trace file and apply the second kind
675bf215546Sopenharmony_ciof database lookups to all memory accesses matching a given range. Some
676bf215546Sopenharmony_cinv-specific hacks will be in order to automate the parsing: extract the
677bf215546Sopenharmony_cichipset from PMC_BOOT_0, figure out the mmio base from PCI config, etc.
678bf215546Sopenharmony_ci
679bf215546Sopenharmony_ciThe renouveau-parse utility will take contents of a PFIFO pushbuffer and
680bf215546Sopenharmony_cidecode them. The splitting to method,data pair will be done by nv-specific
681bf215546Sopenharmony_cicode, then the pair will be handed over to generic rules-ng lookup.
682bf215546Sopenharmony_ci
683bf215546Sopenharmony_ci4. Issues
684bf215546Sopenharmony_ci
685bf215546Sopenharmony_ci - Random typing-saving feature for bitfields: make high default to same value
686bf215546Sopenharmony_ci   as low, to have one less attribute for single-bit bitfields?
687bf215546Sopenharmony_ci
688bf215546Sopenharmony_ci - What about allowing nameless registers and/or bitfields? These are
689bf215546Sopenharmony_ci   supported by renouveau.xml and are used commonly to signify an unknown
690bf215546Sopenharmony_ci   register.
691bf215546Sopenharmony_ci
692bf215546Sopenharmony_ci - How about cross-ref links in <doc> tags?
693bf215546Sopenharmony_ci
694bf215546Sopenharmony_ci - <translation>: do we need them? Sounds awesome and useful, but as defined
695bf215546Sopenharmony_ci   by the old spec, they're quite limited. The only examples of straight
696bf215546Sopenharmony_ci   translations that I know of are the legacy VGA registers and
697bf215546Sopenharmony_ci   NV50_PFB_VM_TRAP. And NV01_PDAC, but I doubt anybody gives a damn about it.
698bf215546Sopenharmony_ci   This list is small enough to be just handled by nv-specific hacks in
699bf215546Sopenharmony_ci   mmio-trace parser if really needed.
700bf215546Sopenharmony_ci
701bf215546Sopenharmony_ci - Another thing that renouveau.xml does is disassembling NV20-NV40 shaders.
702bf215546Sopenharmony_ci   Do we want that in rules-ng? IMO we'd be better off hacking nv50dis to
703bf215546Sopenharmony_ci   support it...
704