mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 14:38:47 +00:00
GP102 mining SKU, cloned from 0x1b06 (same arch 0x13 impl 0x02). Provenance sha256 recomputed; generate_hardware.py asserts and generated.rs counters bumped 1128->1129, 449->450. Verified on silicon: bringup lvl0/lvl3 pass on 0000:02:00.0.
23 lines
1.9 KiB
Python
23 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate no-allocation hardware lookup tables from hash-pinned recovered fixtures."""
|
|
from pathlib import Path
|
|
import hashlib,json,sys
|
|
R=Path(__file__).resolve().parents[1];D=R/'abi/hardware';p=json.loads((D/'provenance.json').read_text())
|
|
assert p['original_elf_sha256']=='5269a23ffba19a17fe16f076463e7ad4151254659441d1711bee6c6221ff6f4b'
|
|
for name,digest in p['fixtures'].items():assert hashlib.sha256((D/name).read_bytes()).hexdigest()==digest,name
|
|
matrix=json.loads((D/'product-matrix.json').read_text());rows=matrix['rows'];assert len(rows)==1129;assert len({r["devid"] for r in rows})==450
|
|
q=lambda x:json.dumps(x,ensure_ascii=True)
|
|
lines=['// Generated by tools/generate_hardware.py; do not edit.','use super::{Product, Route, Legacy, ChipTuple};','pub static PRODUCTS: [Product; 1129] = [']
|
|
for r in rows:
|
|
route={'proprietary_pre_turing':'Proprietary','open_and_proprietary_gsp':'BothGsp','open_only':'OpenOnly'}[r['kernel_route']]
|
|
sub=lambda k:'Some('+r[k].lower()+')' if k in r else 'None'
|
|
lines.append(f'Product {{ device: {r["devid"].lower()}, subvendor: {sub("subvendorid")}, subdevice: {sub("subdevid")}, name: {q(r["name"])}, route: Route::{route} }},')
|
|
lines+= ['];','pub static LEGACY: [Legacy; 1388] = [']
|
|
for r in json.loads((D/'pci-blacklist.json').read_text()):lines.append(f'Legacy {{ device: {r["device"]}, subvendor: {r["subvendor"]}, subdevice: {r["subdevice"]}, branch: {r["branch"]} }},')
|
|
lines+= ['];','pub static CHIPS: [ChipTuple; 113] = [']
|
|
for r in json.loads((D/'chip-tuples.json').read_text())['tuples']:lines.append(f'ChipTuple {{ architecture: {r["architecture"]}, implementation: {r["implementation"]}, soc: {r["soc_combined"]} }},')
|
|
lines+= ['];'];out='\n'.join(lines)+'\n';dest=R/'src/nvidia/src/hardware/generated.rs'
|
|
if '--check' in sys.argv:assert dest.read_text()==out,'generated hardware tables stale'
|
|
else:dest.write_text(out)
|
|
print('hardware tables verified:1129products,450IDs,1388blacklist records,113chip tuples')
|