interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / evidence / a64efi-dgx-spark-20261112 / pciid.om

155 lines · 2991 bytes Raw Blame History
1note pciid.om: first contact with the machine's NVIDIA devices from Omega with no operating system and
2note no NVIDIA software: through the firmware's PCI I/O protocol (UEFI 2.10 14.4) read each device's
3note configuration header; for a display-class NVIDIA device whose memory decoding is on, read the two
4note identity registers of BAR 0 (offsets 0 and 0xA00). Read only. The lines go to the console and to
5note \OLLM\GPUID.TXT. Needs efirt.om before it (efbs, efguid, efhg, efh, the efi word).
6global gpb uchar 64
7global gpo uchar 4096
8global gpn ulong 1
9text gptx "pciio handles nv seg.bus.dev.fn id cmd class bar0 boot0 boot42 memory decoding off, registers not readno PCI I/O protocol, status "
10text gpfile "\\OLLM\\GPUID.TXT"
11
12fn gpc b ulong to void
13n = get gpn 0
14if lt n 4000
15put gpo n uchar b
16put gpn 0 add n 1
17end
18end
19
20note gps: n bytes of gptx from offset o
21fn gps o ulong n ulong to void
22i = ulong 0
23while lt i n
24gpc ulong get gptx add o i
25i = add i 1
26end
27end
28
29note gph: v as w hex digits
30fn gph v ulong w ulong to void
31i = ulong 0
32while lt i w
33d = and shr v mul sub sub w 1 i 4 15
34if lt d 10
35gpc add 48 d
36else
37gpc add 87 d
38end
39i = add i 1
40end
41end
42
43note gploc: "nv seg.bus.dev.fn " and the location of PCI I/O instance pio
44fn gploc pio ulong to void
45loc = fwadr gpb 32 32
46gl = fwld add pio 112 8
47s = fwcall gl pio loc add loc 8 add loc 16 add loc 24 0
48gps 14 18
49gph fwld loc 8 4
50gpc 46
51gph fwld add loc 8 8 2
52gpc 46
53gph fwld add loc 16 8 2
54gpc 46
55gph fwld add loc 24 8 1
56end
57
58note gpreg: one 32-bit register of BAR 0 at offset r, or ? when the read fails
59fn gpreg pio ulong r ulong to void
60mr = fwld add pio 16 8
61reg = fwadr gpb 0 8
62s = fwcall mr pio 2 0 r 1 reg
63if eq s 0
64gph fwld reg 4 8
65else
66gpc 63
67end
68end
69
70note gpdev: one PCI I/O handle; a line when it is an NVIDIA device
71fn gpdev h ulong to void
72g = efguid 5522935658814222848 11097520664359398558
73o = fwadr efh 56 8
74hp = fwld add efbs 152 8
75s = fwcall hp h g o 0 0 0
76if ne s 0
77ret
78end
79pio = efhg 56
80cfg = fwadr gpb 0 32
81rd = fwld add pio 48 8
82s = fwcall rd pio 2 0 8 cfg 0
83if ne s 0
84ret
85end
86id = fwld cfg 4
87if ne and id 65535 4318
88ret
89end
90cmd = fwld add cfg 4 2
91cls = shr fwld add cfg 8 4 8
92bar = fwld add cfg 16 4
93gploc pio
94gps 32 4
95gph id 8
96gps 36 5
97gph cmd 4
98gps 41 7
99gph cls 6
100gps 48 6
101gph bar 8
102if eq shr cls 16 3
103if ne and cmd 2 0
104gps 54 7
105gpreg pio 0
106gps 61 8
107gpreg pio 2560
108else
109gps 69 40
110end
111end
112gpc 10
113end
114
115fn gpci to void
116put gpn 0 0
117bs = efbs
118g = efguid 5522935658814222848 11097520664359398558
119c = fwadr efh 32 8
120o = fwadr efh 24 8
121lb = fwld add bs 312 8
122s = fwcall lb 2 g 0 c o 0
123if ne s 0
124gps 109 28
125gph s 16
126gpc 10
127else
128n = efhg 32
129buf = efhg 24
130gps 0 14
131gph n 4
132gpc 10
133i = ulong 0
134while lt i n
135gpdev fwld add buf mul i 8 8
136i = add i 1
137end
138x = fwcall fwld add bs 72 8 buf 0 0 0 0 0
139end
140m = get gpn 0
141r = efi 13 0 gpo 0 m
142k = len gpfile
143for j ulong k
144put gpb j get gpfile j
145end
146r = efi 12 65281 gpb 0 k
147r = efi 12 65283 gpo 0 m
148r = efi 12 65284 gpo 0 0
149end
150
151fn main to int
152r = ocmain
153gpci
154ret r
155end