Path: blob/21.2-virgl/src/freedreno/registers/rules-ng-ng.txt
8366 views
1. Introduction12rules-ng is a package consisting of a database of nvidia GPU registers in XML3format, and tools made to parse this database and do useful work with it. It4is in mostly usable state, but there are some annoyances that prevent its5adoption as the home of all nouveau documentation.67Note that this document and rules-ng understands "register" quite liberally as8"anything that has an address and can have a value in it, written to it, or9read to it". This includes conventional MMIO registers, as well as fields of10memory structures and grobj methods.1112Its parsable XML format is supposed to solve three problems:1314- serve as actual documentation for the known registers: supports attaching15arbitrary text in <doc> tags and generating HTML for easy reading.16- name -> hex translation: supports generating C headers that #define all17known registers, bitfields and enum values as C constants.18- hex -> name translation: you tell it the address or address+value of a19register, and it decodes the address to its symbolic name, and the value to20its constituting bitfields, if any. Useful for decoding mmio-traces /21renouveau dumps, as well as standalone use.2223What's non-trivial about all this [ie. why rules-ng is not a long series of24plain address - name - documentation tuples]:2526- The registers may be split into bitfields, each with a different purpose27and name [and separate documentation].28- The registers/bitfields may accept values from a predefined set [enum],29each with a different meaning. Each value also has a name and30documentation.31- The registers may come in multiple copies, forming arrays. They can also32form logical groups. And these groups can also come in multiple copies,33forming larger arrays... and you get a hierarchical structure.34- There are multiple different GPU chipsets. The available register set35changed between these chipsets - sometimes only a few registers, sometimes36half the card was remade from scratch. More annoyingly, sometimes some37registers move from one place to another, but are otherwise unchanged.38Also [nvidia-specific], new grobj classes are sometimes really just new39revisions of a base class with a few methods changed. In both of these40cases, we want to avoid duplication as much as possible.41422. Proposed new XML format43442.1. General tags4546Root tag is <database>. There is one per the whole file and it should contain47everything else.4849<brief> and <doc> are tags that can appear inside any other tag, and document50whatever it defines. <brief> is supposed to be a short one-line description51giving a rough idea what a given item is for if no sufficiently descriptive52name was used. <doc> can be of any length, can contain some html and html-like53tags, and is supposed to describe a given item in as much detail as needed.54There should be at most one <doc> and at most one <brief> tag for any parent.5556Tags that define top-level entities include:5758<domain>: Declares an addressing space containing registers59<group>: Declares a block of registers, expected to be included by one or60more <domain>s61<bitset>: Declares a list of applicable bitfields for some register62<enum>: Declares a list of related symbolic values. Can describe params to63a register/bitfield, or discriminate between card variants.6465Each of these has an associated global name used to refer to them from other66parts of database. As a convenience, and to allow related stuff to be kept67together, the top-level entities are allowed to occur pretty much anywhere68inside the XML file except inside <doc> tags. This implies no scoping,69however: the effect is the same as putting the entity right below <database>.70If two top-level elements of the same type and name are defined, they'll be71merged into a single one, as if contents of one were written right after72contents of the other. All attributes of the merged tags need to match.7374Another top-level tag that can be used anywhere is the <import> tag. It's used75like <import file="foo.xml"/> and makes all of foo.xml's definitions available76to the containing file. If a single file is <import>ed more than one time, all77<import>s other than the first are ignored.78792.2. Domains8081All register definitions ultimately belong to a <domain>. <domain> is82basically just a single address space. So we'll have a domain for the MMIO83BAR, one for each type of memory structure we need to describe, a domain for84the grobj/FIFO methods, and a domain for each indirect index-data pair used to85access something useful. <domain> can have the following attributes:8687- name [required]: The name of the domain.88- width [optional]: the size, in bits, of a single addressable unit. This is898 by default for usual byte-addressable memory, but 32 can be useful90occasionally for indexed spaces of 32-bit cells. Values sane enough to91support for now include 8, 16, 32, 64.92- size [optional]: total number of addressable units it spans. Can be93undefined if you don't know it or it doesn't make sense. As a special94exception to the merging rules, size attribute need not be specified on all95tags that will result in a merged domain: tags with size can be merged with96tags without size, resulting in merged domain that has size. Error only97happens when the merged domains both have sizes, and the sizes differ.98- bare [optional]: if set to "no", all children items will have the domain99name prepended to their names. If set to "yes", such prefixing doesn't100happen. Default is "no".101- prefix [optional]: selects the string that should be prepended to name102of every child item. The special value "none" means no prefix, and is the103default. All other values are looked up as <enum> names and, for each child104item, its name is prefixed with name of the earliest variant in the given105enum that supports given item.106107<domain name="NV_MMIO" size="0x1000000" prefix="chipset" bare="yes">108<reg32 offset="0" name="PMC_BOOT_0" />109<reg32 offset="4" name="PMC_BOOT_1" varset="chipset" variants="NV10-" />110<reg32 offset="0x100" name="PMC_INTR" />111</domain>112113Describes a space with 0x1000000 of 8-bit addressable cells. Cells 0-3 belong114to NV04_PMC_BOOT_0 register, 4-7 belong to NV10_PMC_BOOT_1 register,1150x100-0x103 belong to NV04_PMC_INTR register, and remaining cells are either116unused or unknown. The generated .h definitions are:117118#define NV_MMIO__SIZE 0x1000000119#define NV04_PMC_BOOT_0 0120#define NV10_PMC_BOOT_1 4121#define NV04_PMC_INTR 0x100122123<domain name="NV50_PFB_VM_TRAP" width="32" size="6">124<reg32 offset="0" name="STATUS" />125<reg32 offset="1" name="CHANNEL" />126<reg32 offset="2" name="UNK2" />127<reg32 offset="3" name="ADDRLOW" />128<reg32 offset="4" name="ADDRMID" />129<reg32 offset="5" name="ADDRHIGH" />130</domain>131132Defines a 6-cell address space with each cell 32 bits in size and133corresponding to a single register. Definitions are:134135#define NV50_PFB_VM_TRAP__SIZE 6136#define NV50_PFB_VM_TRAP_STATUS 0137#define NV50_PFB_VM_TRAP_CHANNEL 1138#define NV50_PFB_VM_TRAP_UNK2 2139#define NV50_PFB_VM_TRAP_ADDRLOW 3140#define NV50_PFB_VM_TRAP_ADDRMID 4141#define NV50_PFB_VM_TRAP_ADDRHIGH 51421432.3. Registers144145What we really want all the time is defining registers. This is done with146<reg8>, <reg16>, <reg32> or <reg64> tags. The register of course takes147reg_width / domain_width cells in the domain. It's an error to define a148register with smaller width than the domain it's in. The <reg*> attributes149are:150151- name [required]: the name of the register152- offset [required]: the offset of the register153- access [optional]: "rw" [default], "r", or "w" to mark the register as154read-write, read-only, or write-only. Only makes sense for real MMIO155domains.156- varset [optional]: the <enum> to choose from by the variant attribute.157Defaults to first <enum> used in currently active prefix.158- variants [optional]: space-separated list of and variant ranges that this159register is present on. The items of this list can be:160- var1: a single variant161- var1-var2: all variants starting with var1 up to and including var2162- var1:var2: all variants starting with var1 up to, but not including var2163- :var1: all variants before var1164- -var1: all variants up to and including var1165- var1-: all variants starting from var1166- type [optional]: How to interpret the contents of this register.167- "uint": unsigned decimal integer168- "int": signed decimal integer169- "hex": unsigned hexadecimal integer170- "float" IEEE 16-bit, 32-bit or 64-bit floating point format, depending171on register/bitfield size172- "boolean": a boolean value: 0 is false, 1 is true173- any defined enum name: value from that anum174- "enum": value from the inline <value> tags in this <reg*>175- any defined bitset name: value decoded further according to that bitset176- "bitset": value decoded further according to the inline <bitfield>177tags178- any defined domain name: value decoded as an offset in that domain179The default is "bitset" if there are inline <bitfield> tags present,180otherwise "enum" if there are inline <value> tags present, otherwise181"boolean" if this is a bitfield with width 1, otherwise "hex".182- shr [optional]: the value in this register is the real value shifted right183by this many bits. Ie. for register with shr="12", register value 0x1234184should be interpreted as 0x1234000. May sound too specific, but happens185quite often in nvidia hardware.186- length [optional]: if specified to be other than 1, the register is treated187as if it was enclosed in an anonymous <stripe> with corresponding length188and stride attributes, except the __ESIZE and __LEN stripe defines are189emitted with the register's name. If not specified, defaults to 1.190- stride [optional]: the stride value to use if length is non-1. Defaults to191the register's size in cells.192193The definitions emitted for a non-stripe register include only its offset and194shr value. Other informations are generally expected to be a part of code195logic anyway:196197<reg32 offset="0x400784" name="PGRAPH_CTXCTL_SWAP" shr="12" />198199results in200201#define PGRAPH_CTXCTL_SWAP 0x400784202#define PGRAPH_CTXCTL_SWAP__SHR 12203204For striped registers, __LEN and __ESIZE definitions like <stripe> are emitted205too:206207<!-- in a 8-bit domain -->208<reg32 offset="0x0600" name="NV50_COMPUTE_USER_PARAM" length="64" />209210results in211212#define NV50_COMPUTE_USER_PARAM(i) (0x600 + (i)*4)213#define NV50_COMPUTE_USER_PARAM__LEN 64214#define NV50_COMPUTE_USER_PARAM__ESIZE 4215216The <reg*> tags can also contain either bitfield definitions, or enum value217definitions.2182192.4. Enums and variants220221Enum is, basically, a set of values. They're defined by <enum> tag with the222following attributes:223224- name [required]: an identifying name.225- inline [optional]: "yes" or "no", with "no" being the default. Selects if226this enum should emit its own definitions in .h file, or be inlined into227any <reg*> / <bitfield> definitions that reference it.228- bare [optional]: only for no-inline enums, behaves like bare attribute229to <domain>230- prefix [optional]: only for no-inline enums, behaves like prefix attribute231to <domain>.232233The <enum> tag contains <value> tags with the following attributes:234235- name [required]: the name of the value236- value [optional]: the value237- varset [optional]: like in <reg*>238- variants [optional]: like in <reg*>239240The <enum>s are referenced from inside <reg*> and <bitfield> tags by setting241the type attribute to the name of the enum. For single-use enums, the <value>242tags can also be written directly inside <reg*> tag.243244<enum name="SURFACE_FORMAT" prefix="chipset">245<value value="6" name="A8R8G8B8" />246<value value="0x12" name="A8R8G8B8_RECT" variants="NV10-" />247</enum>248249<enum name="gl_shade_model" inline="yes">250<value value="0x1d00" name="FLAT" />251<value value="0x1d01" name="SMOOTH" />252</enum>253254<reg32 offset="0x1234" name="TEXTURE_FORMAT" type="SURFACE_FORMAT" />255<reg32 offset="0x1238" name="SHADE_MODEL" type="gl_shade_model" />256<reg32 offset="0x123c" name="PATTERN_SELECT">257<value value="1" name="MONO" />258<value value="2" name="COLOR" />259</reg32>260261Result:262263#define NV04_SURFACE_FORMAT_A8R8G8B8 6264#define NV04_SURFACE_FORMAT_A8R8G8B8_RECT 0x12265#define TEXTURE_FORMAT 0x1234266#define SHADE_MODEL 0x1238267#define SHADE_MODEL_FLAT 0x1d00268#define SHADE_MODEL_SMOOTH 0x1d01269#define PATTERN_SELECT 0x123c270#define PATTERN_SELECT_MONO 1271#define PATTERN_SELECT_COLOR 2272273Another use for enums is describing variants: slightly different versions of274cards, objects, etc. The varset and variant attributes of most tags allow275defining items that are only present when you're dealing with something of the276matching variant. The variant space is "multidimensional" - so you can have277a variant "dimension" representing what GPU chipset you're using at the278moment, and another dimension representing what grobj class you're dealing279with [taken from another enum]. Both of these can be independent.280281<enum name="chipset">282<brief>The chipset of the card</brief>283<value name="NV04">284<brief>RIVA TNT</brief>285</value>286<value name="NV05">287<brief>RIVA TNT2</brief>288</value>289<value name="NV10">290<brief>GeForce 256</brief>291</value>292<value name="NV50">293<brief>G80: GeForce 8800 GTX, Tesla *870, ...</brief>294</value>295<value name="NV84">296<brief>G84: GeForce 8600 GT, ...</brief>297</value>298<value name="NVA0">299<brief>G200: GeForce 260 GTX, Tesla C1060, ...</brief>300</value>301<value name="NVA5">302<brief>GT216: GeForce GT 220</brief>303</value>304</enum>305306If enabled for a given domain, the name of the earliest variant to support307a given register / bitfield / value / whatever will be automatically prepended308to its name. For this purpose, "earliest" is defined as "comes first in the309XML file".310311<enum>s used for this purpose can still be used as normal enums. And can even312have variant-specific values referencing another <enum>. Example:313314<enum name="grobj-class" bare="yes" prefix="chipset">315<value name="MEMORY_TO_MEMORY_FORMAT" value="0x0039" variants=":NV50" />316<value name="MEMORY_TO_MEMORY_FORMAT" value="0x5039" variants="NV50-" />317<value name="2D" value="0x502d" variants="NV50-" />318<value name="TCL" value="0x5097" variants="NV50:NVA0" />319<value name="TCL" value="0x8297" variants="NV84" />320<value name="COMPUTE" value="0x50c0" variants="NV50-" />321</enum>322323In generated .h file, this will result in:324325#define NV04_MEMORY_TO_MEMORY_FORMAT 0x0039326#define NV50_MEMORY_TO_MEMORY_FORMAT 0x5039327#define NV50_2D 0x502d328#define NV50_TCL 0x5097329#define NV84_TCL 0x8297330#define NV50_COMPUTE 0x50c03313322.5. Bitfields333334Often, registers store not a single full-width value, but are split into335bitfields. Like values can be grouped in enums, bitfields can be called in336bitsets. The <bitset> tag has the same set of attributes as <enum> tag, and337contains <bitfield> tags with the following attributes:338339- name [required]: name of the bitfield340- low [required]: index of the lowest bit belonging to this bitfield. bits341are counted from 0, LSB-first.342- high [required]: index of the highest bit belonging to this bitfield.343- varset [optional]: like in <reg*>344- variants [optional]: like in <reg*>345- type [optional]: like in <reg*>346- shr [optional]: like in <reg*>347348Like <value>s, <bitfield>s are also allowed to be written directly inside349<reg*> tags.350351<bitfield>s themselves can contain <value>s. The defines generated for352<bitfield>s include "name__MASK" equal to the bitmask corresponding to given353bitfield, "name__SHIFT" equal to the low attribute, "name__SHR" equal to354the shr attribute [if defined]. Single-bit bitfields with type "boolean" are355treated specially, and get "name" defined to the bitmask instead. If the356bitfield contains any <value>s, <bitfield>s, or references an inlined357enum/bitset, defines for them are also generated, pre-shifted to the correct358position. Example:359360<enum name="nv03_operation" inline="yes">361<value value="0" name="SRCCOPY_AND" />362<value value="1" name="ROP_AND" />363<value value="2" name="BLEND_AND" />364<value value="3" name="SRCCOPY" />365<value value="4" name="SRCCOPY_PRE" />366<value value="5" name="BLEND_PRE" />367</enum>368369<bitset name="NV04_GROBJ_1">370<bitfield high="7" low="0" name="GRCLASS" />371<bitfield high="12" low="12" name="CHROMA_KEY" />372<bitfield high="13" low="13" name="USER_CLIP" />373<bitfield high="14" low="14" name="SWIZZLE" />374<bitfield high="17" low="15" name="PATCH_CONFIG" type="nv03_operation" />375<!-- ... -->376</bitset>377378<bitset name="xy16" inline="yes">379<bitfield high="15" low="0" name="X" />380<bitfield high="31" low="16" name="Y" />381</bitset>382383<bitset name="nv50_vic" inline="yes">384<bitfield high="0" low="0" name="X"/>385<bitfield high="1" low="1" name="Y"/>386<bitfield high="2" low="2" name="Z"/>387<bitfield high="3" low="3" name="W"/>388</bitset>389390<reg32 offset="0x40014c" name="PGRAPH_CTX_SWITCH_1" type="NV04_GROBJ_1" />391392<reg32 offset="0x0404" name="FORMAT">393<bitfield high="15" low="0" name="PITCH" />394<bitfield high="23" low="16" name="ORIGIN" />395<bitfield high="31" low="24" name="FILTER" />396</reg32>397398<reg32 offset="0x040c" name="POINT" type="xy16" />399400<reg32 offset="0x1988" name="FP_INTERPOLANT_CTRL">401<bitfield name="UMASK" high="31" low="24" type="nv50_vic"/>402<bitfield name="COUNT_NONFLAT" high="23" low="16" type="int"/>403<bitfield name="OFFSET" high="15" low="8" type="int"/>404<bitfield name="COUNT" high="7" low="0" type="int"/>405</reg32>406407Result:408409#define NV04_GROBJ_1_GRCLASS__MASK 0x000000ff410#define NV04_GROBJ_1_GRCLASS__SHIFT 0411#define NV04_GROBJ_1_CHROMA_KEY 0x00001000412#define NV04_GROBJ_1_USER_CLIP 0x00002000413#define NV04_GROBJ_1_SWIZZLE 0x00004000414#define NV04_GROBJ_1_PATCH_CONFIG__MASK 0x00038000415#define NV04_GROBJ_1_PATCH_CONFIG__SHIFT 15416#define NV04_GROBJ_1_PATCH_CONFIG_SRCCOPY_AND 0x00000000417#define NV04_GROBJ_1_PATCH_CONFIG_ROP_AND 0x00008000418#define NV04_GROBJ_1_PATCH_CONFIG_BLEND_AND 0x00010000419#define NV04_GROBJ_1_PATCH_CONFIG_SRCCOPY 0x00018000420#define NV04_GROBJ_1_PATCH_CONFIG_SRCCOPY_PRE 0x00020000421#define NV04_GROBJ_1_PATCH_CONFIG_BLEND_PRE 0x00028000422423#define PGRAPH_CTX_SWITCH_1 0x40014c424425#define FORMAT 0x0404426#define FORMAT_PITCH__MASK 0x0000ffff427#define FORMAT_PITCH__SHIFT 0428#define FORMAT_ORIGIN__MASM 0x00ff0000429#define FORMAT_ORIGIN__SHIFT 16430#define FORMAT_FILTER__MASK 0xff000000431#define FORMAT_FILTER__SHIFT 24432433#define POINT 0x040c434#define POINT_X 0x0000ffff435#define POINT_X__SHIFT 0436#define POINT_Y 0xffff0000437#define POINT_Y__SHIFT 16438439#define FP_INTERPOLANT_CTRL 0x00001988440#define FP_INTERPOLANT_CTRL_UMASK__MASK 0xff000000441#define FP_INTERPOLANT_CTRL_UMASK__SHIFT 24442#define FP_INTERPOLANT_CTRL_UMASK_X 0x01000000443#define FP_INTERPOLANT_CTRL_UMASK_Y 0x02000000444#define FP_INTERPOLANT_CTRL_UMASK_Z 0x04000000445#define FP_INTERPOLANT_CTRL_UMASK_W 0x08000000446#define FP_INTERPOLANT_CTRL_COUNT_NONFLAT__MASK 0x00ff0000447#define FP_INTERPOLANT_CTRL_COUNT_NONFLAT__SHIFT 16448#define FP_INTERPOLANT_CTRL_OFFSET__MASK 0x0000ff00449#define FP_INTERPOLANT_CTRL_OFFSET__SHIFT 8450#define FP_INTERPOLANT_CTRL_COUNT__MASK 0x000000ff451#define FP_INTERPOLANT_CTRL_COUNT__SHIFT 04524532.6. Arrays and stripes.454455Sometimes you have multiple copies of a register. Sometimes you actually have456multiple copies of a whole set of registers. And sometimes this set itself457contains multiple copies of something. This is what <array>s are for. The458<array> represents "length" units, each of size "stride" packed next to each459other starting at "offset". Offsets of everything inside the array are460relative to start of an element of the array. The <array> attributes include:461462- name [required]: name of the array, also used as prefix for all items463inside it464- offset [required]: starting offset of the array.465- stride [required]: size of a single element of the array, as well as the466difference between offsets of two neighboring elements467- length [required]: Number of elements in the array468- varset [optional]: As in <reg*>469- variants [optional]: As in <reg*>470471The definitions emitted for an array include:472- name(i) defined to be the starting offset of element i, if length > 1473- name defined to be the starting offset of arrayi, if length == 1474- name__LEN defined to be the length of array475- name__ESIZE defined to be the stride of array476477Also, if length is not 1, definitions for all items inside the array that478involve offsets become parameter-taking C macros that calculate the offset479based on array index. For nested arrays, this macro takes as many arguments480as there are indices involved.481482It's an error if an item inside an array doesn't fit inside the array element.483484<array offset="0x408000" name="PGRAPH_TP" stride="0x1000" length="8">485<array offset="0x200" name="MP" stride="0x80" length="2">486<!-- ... -->487<reg64 offset="0x70" name="TRAPPED_OPCODE" />488<!-- ... -->489</array>490<reg32 offset="0x314" name="MP_TRAP />491<!-- ... -->492</array>493494#define PGRAPH_TP(i) (0x408000+(i)*0x1000)495#define PGRAPH_TP__LEN 8496#define PGRAPH_TP__ESIZE 0x1000497#define PGRAPH_TP_MP(i,j) (0x408200+(i)*0x1000+(j)*0x80)498#define PGRAPH_TP__LEN 2499#define PGRAPH_TP__ESIZE 0x80500#define PGRAPH_TP_MP_TRAPPED_OPCODE(i,j) (0x408270+(i)*0x1000+(j)*0x80)501502<stripe>s are somewhat similar to arrays, but don't reserve space, merely say503that all items inside come in "length" copies "stride" cells apart. As opposed504to <array>s, items can have offsets larger than stride, and offsets aren't505automatically assumed to be a part of <stripe> unless a <reg*> explicitely506hits that particular offset for some index. Also, <stripe>s of length 1 and507stride 0 can be used as generic container, for example to apply a variant set508or a prefix to a bigger set of elements. Attributes:509510- name [optional]: like in <array>. If not given, no prefixing happens, and511the defines for <stripe> itself aren't emitted.512- offset [optional]: like <array>. Defaults to 0 if unspecified.513- stride [optional]: the difference between offsets of items with indices i514and i+1. Or size of the <stripe> if it makes sense in that particular515context. Defaults to 0.516- length [optional]: like in array. Defaults to 1.517- varset [optional]: as in <reg*>518- variants [optional]: as in <reg*>519- prefix [optional]: as in <domain>, overrides parent's prefix option.520521Definitions are emitted like for arrays, but:522- if no name is given, the definitions for stripe itself won't be emitted523- if length is 0, the length is assumed to be unknown or undefined. No __LEN524is emitted in this case.525- if stride is 0, __ESIZE is not emitted526- it's an error to have stride 0 with length different than 1527528529Examples:530531<stripe name="PGRAPH" offset="0x400000" variants="NV04-NV05">532<reg32 offset="0x100" name="INTR" />533<reg32 offset="0x140" name="INTR_EN" />534</stripe>535536<stripe name="PGRAPH" offset="0x400000" variants="NV50-">537<reg32 offset="0x100" name="INTR" />538<reg32 offset="0x108" name="TRAP" />539<reg32 offset="0x138" name="TRAP_EN" />540<reg32 offset="0x13c" name="INTR_EN" />541</stripe>542543Results in:544545#define NV04_PGRAPH 0x400000546#define NV04_PGRAPH_INTR 0x400100547#define NV04_PGRAPH_INTR_EN 0x400140548#define NV50_PGRAPH 0x400000549#define NV50_PGRAPH_INTR 0x400100550#define NV50_PGRAPH_TRAP 0x400108551#define NV50_PGRAPH_TRAP_EN 0x400138552#define NV50_PGRAPH_INTR_EN 0x40013c553554<stripe name="PVIDEO" offset="0x8000">555<stripe offset="0x900" stride="4" length="2">556<reg32 offset="0" name="BASE" />557<reg32 offset="8" name="LIMIT" />558<reg32 offset="0x10" name="LUMINANCE" />559<reg32 offset="0x18" name="CHROMINANCE" />560<!-- ... -->561</stripe>562</stripe>563564Results in:565566#define PVIDEO_BASE (0x8900+(i)*4)567#define PVIDEO_LIMIT (0x8908+(i)*4)568#define PVIDEO_LUMINANCE (0x8910+(i)*4)569#define PVIDEO_CHROMINANCE (0x8918+(i)*4)570571<domain name="NV_OBJECT" bare="yes">572<stripe name="OBJECT" prefix="chipset">573<reg32 offset="0x00" name="NAME" />574<reg32 offset="0x10" name="FENCE_ADDRESS_HIGH" variants="NV50-" />575<!-- more PFIFO methods -->576</stripe>577<stripe prefix="grobj-class">578<stripe variants="NV04_MEMORY_TO_MEMORY_FORMAT-NV05_MEMORY_TO_MEMORY_FORMAT">579<reg32 offset="0x200" name="LINEAR_IN" variants="NV50_MEMORY_TO_MEMORY_FORMAT" />580<reg32 offset="0x328" name="BUFFER_NOTIFY" />581<!-- more m2mf methods -->582</stripe>583<stripe variants="NV50_COMPUTE">584<reg32 offset="0x368" name="LAUNCH" />585<stripe name="GLOBAL" offset="0x400" stride="0x20" length="16">586<reg32 offset="0" name="ADDRESS_HIGH" />587<reg32 offset="4" name="ADDRESS_LOW" />588<reg32 offset="8" name="PITCH" />589<reg32 offset="0xc" name="LIMIT" />590<reg32 offset="0x10" name="MODE" />591</stripe>592<!-- more NV50_COMPUTE methods -->593<reg32 offset="0x0600" name="USER_PARAM" length="64" />594</stripe>595</stripe>596</domain>597598Results in:599600#define NV01_OBJECT_NAME 0x00601#define NV50_OBJECT_FENCE_ADDRESS_HIGH 0x10602#define NV50_MEMORY_TO_MEMORY_FORMAT_LINEAR_IN 0x200603#define NV04_MEMORY_TO_MEMORY_FORMAT_BUFFER_NOTIFY 0x328604#define NV50_COMPUTE_LAUNCH 0x368605#define NV50_COMPUTE_GLOBAL 0x400606#define NV50_COMPUTE_GLOBAL__LEN 16607#define NV50_COMPUTE_GLOBAL__ESIZE 0x20608#define NV50_COMPUTE_GLOBAL_ADDRESS_HIGH (0x400 + (i)*0x20)609#define NV50_COMPUTE_GLOBAL_ADDRESS_LOW (0x404 + (i)*0x20)610#define NV50_COMPUTE_GLOBAL_PITCH (0x408 + (i)*0x20)611#define NV50_COMPUTE_GLOBAL_LIMIT (0x40c + (i)*0x20)612#define NV50_COMPUTE_GLOBAL_MODE (0x410 + (i)*0x20)613#define NV50_COMPUTE_USER_PARAM(i) (0x600 + (i)*4)614#define NV50_COMPUTE_USER_PARAM__LEN 64615#define NV50_COMPUTE_USER_PARAM__ESIZE 46166172.7. Groups618619Groups are just sets of registers and/or arrays that can be copied-and-pasted620together, when they're duplicated in several places in the same <domain>,621two different <domain>s, or have different offsets for different variants.622<group> and <use-group> only have the name attribute. <use-group> can appear623wherever <reg*> can, including inside a <group>.624625<group name="nv50_mp">626<!-- ... -->627<reg64 offset="0x70" name="TRAPPED_OPCODE" />628<!-- ... -->629</group>630631<array offset="0x408000" name="PGRAPH_TP" stride="0x1000" length="8" variants="NV50:NVA0">632<array offset="0x200" name="MP" stride="0x80" length="2">633<use-group name="nv50_mp" />634</array>635<!-- ... -->636</array>637<array offset="0x408000" name="PGRAPH_TP" stride="0x800" length="10" variants="NVA0-">638<array offset="0x100" name="MP" stride="0x80" length="4">639<use-group name="nv50_mp" />640</array>641<!-- ... -->642</array>643644Will get you:645646#define NV50_PGRAPH_TP_MP_TRAPPED_OPCODE(i, j) (0x408270 + (i)*0x1000 + (j)*0x80)647#define NVA0_PGRAPH_TP_MP_TRAPPED_OPCODE(i, j) (0x408170 + (i)*0x800 + (j)*0x80)6486493. The utilities.650651The header generation utility will take a set of XML files and generate .h652file with all of their definitions, as defined above.653654The HTML generation utilty will take an XML file and generate HTML655documentation out of it. The documentation will include the <brief> and <doc>656tags in some way, as well as information from all the attributes, in some easy657to read format. Some naming scheme for the HTML files should be decided, so658that cross-refs to HTML documentation generated for <import>ed files will work659correctly if the generator is run in both.660661The lookup utility will perform database lookups of the following types:662663- domain name, offset, access type, variant type[s] -> register name + array664indices if applicable665- the above + register value -> same as above + decoded value. For registers666with bitfields, print all bitfields, and indicate if any bits not covered667by the bitfields are set to 1. For registers/bitfields with enum values,668print the matching one if any. For remaining registers/bitfields, print669according to type attribute.670- bitset name + value -> decoded value, as above671- enum name + value -> decoded value, as above672673The mmio-parse utility will parse a mmio-trace file and apply the second kind674of database lookups to all memory accesses matching a given range. Some675nv-specific hacks will be in order to automate the parsing: extract the676chipset from PMC_BOOT_0, figure out the mmio base from PCI config, etc.677678The renouveau-parse utility will take contents of a PFIFO pushbuffer and679decode them. The splitting to method,data pair will be done by nv-specific680code, then the pair will be handed over to generic rules-ng lookup.6816824. Issues683684- Random typing-saving feature for bitfields: make high default to same value685as low, to have one less attribute for single-bit bitfields?686687- What about allowing nameless registers and/or bitfields? These are688supported by renouveau.xml and are used commonly to signify an unknown689register.690691- How about cross-ref links in <doc> tags?692693- <translation>: do we need them? Sounds awesome and useful, but as defined694by the old spec, they're quite limited. The only examples of straight695translations that I know of are the legacy VGA registers and696NV50_PFB_VM_TRAP. And NV01_PDAC, but I doubt anybody gives a damn about it.697This list is small enough to be just handled by nv-specific hacks in698mmio-trace parser if really needed.699700- Another thing that renouveau.xml does is disassembling NV20-NV40 shaders.701Do we want that in rules-ng? IMO we'd be better off hacking nv50dis to702support it...703704705