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 / gpu / driver / gsp / seqcore.om

178 lines · 4065 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note gsp/seqcore.om: Falcon/RISC-V core opcodes 5..8 for GSP_RUN_CPU_SEQUENCER (0x1002).
3note Implements sqcorefn(op) for gsp/seq.om & gsp/dispatch.om over gsprd/gspwr/gsppause.
4note Source of record: NVIDIA open-gpu-kernel-modules 580.173.02 GB20B HALs:
5note kernel_gsp.c:5403-5432, g_kernel_gsp_nvoc.c:1045,1091,
6note kernel_gsp_gb100.c:50-87 (kgspResetHw_GB100), kernel_gsp_gh100.c:108-150 (kgspResetHw_GH100),
7note kernel_gsp_ga102.c:136-200 (kgspExecuteSequencerCommand_GA102),
8note kernel_falcon_tu102.c:236-269 (kflcnStartCpu_TU102, kflcnDisableCtxReq_TU102),
9note gb20b/dev_gsp.h, tu102/dev_falcon_v4.h, gb202/dev_riscv_pri.h.
10note Library unit, no fn main. Compose after gsp/mmio.om (or mmio_bm.om) and gsp/seq.om.
11
12const SCFALCTL ulong 1114368
13const SCFALCTLA ulong 1114416
14const SCFALDMA ulong 1114380
15const SCFALENG ulong 1115072
16const SCRSTPLM ulong 1115076
17const SCFBIFCTL ulong 1115684
18const SCBCRCTL ulong 1119848
19const SCSECCTL ulong 8651008
20const SCSECCTLA ulong 8651056
21const SCBSISCR14 ulong 1147128
22
23const SCSTART ulong 2
24const SCHALT ulong 16
25const SCALIASEN ulong 64
26const SCPLMLVL0 ulong 17
27const SCRSTMSK ulong 1792
28const SCRSTDEAS ulong 512
29const SCSCRUB ulong 4096
30const SCNOCTX ulong 128
31const SCBCRVAL ulong 273
32const SCSTG3DN ulong 67108864
33
34global sccount ulong 4
35global sclibospa ulong 1
36global scappver ulong 1
37
38fn sccfg libospa ulong appver ulong to void
39put sclibospa 0 libospa
40put scappver 0 appver
41end
42
43fn scwaitval off ulong mask ulong want ulong budget ulong to bool
44n = budget
45if eq n 0
46n = 1
47end
48for i ulong add n 1
49if eq and gsprd off mask want
50ret true
51end
52if lt i n
53gsppause
54end
55end
56ret false
57end
58
59fn scwaitset off ulong mask ulong budget ulong to bool
60n = budget
61if eq n 0
62n = 1
63end
64for i ulong add n 1
65if ne and gsprd off mask 0
66ret true
67end
68if lt i n
69gsppause
70end
71end
72ret false
73end
74
75note kflcnStartCpu_TU102: check CPUCTL.ALIAS_EN (bit 6); write STARTCPU=2 to ALIAS if set, else CPUCTL.
76fn scstartflcn ctl ulong alias ulong to void
77if ne and gsprd ctl SCALIASEN 0
78gspwr alias SCSTART
79else
80gspwr ctl SCSTART
81end
82end
83
84note kgspResetHw_GB100 -> kgspResetHw_GH100 + kflcnWaitForResetToFinish_GA102
85fn scresethw to long
86b = get sqbud 0
87if not scwaitval SCRSTPLM SCPLMLVL0 SCPLMLVL0 b
88ret -1
89end
90gspwr SCFALENG 1
91if not scwaitval SCFALENG SCRSTMSK 0 b
92ret -1
93end
94gspwr SCFALENG 0
95if not scwaitval SCFALENG SCRSTMSK SCRSTDEAS b
96ret -1
97end
98if not scwaitval GHWCFG2 SCSCRUB 0 b
99ret -1
100end
101ret 0
102end
103
104note Opcode 5: CORE_RESET (kgspResetHw_GB100 + kflcnWaitForResetToFinish + kflcnDisableCtxReq_TU102)
105fn sccorerst to long
106r = scresethw
107if ne r 0
108ret r
109end
110fb = gsprd SCFBIFCTL
111gspwr SCFBIFCTL or fb SCNOCTX
112gspwr SCFALDMA 0
113put sccount 0 add get sccount 0 1
114ret 0
115end
116
117note Opcode 6: CORE_START (kflcnStartCpu_TU102 on GSP)
118fn sccorestr to long
119scstartflcn SCFALCTL SCFALCTLA
120put sccount 1 add get sccount 1 1
121ret 0
122end
123
124note Opcode 7: CORE_WAIT_FOR_HALT (kflcnWaitForHalt on GSP)
125fn sccorehlt to long
126if not scwaitset SCFALCTL SCHALT get sqbud 0
127ret -1
128end
129put sccount 2 add get sccount 2 1
130ret 0
131end
132
133note Opcode 8: CORE_RESUME (kgspExecuteSequencerCommand_GA102):
134note 1. kflcnResetIntoRiscv_GA102(GSP) + RISCV_BCR_CTRL = 0x111
135note 2. kgspProgramLibosBootArgsAddr_TU102 (GSP MAILBOX0/1 = libosArgsPA)
136note 3. kflcnStartCpu(SEC2)
137note 4. Poll BSI_SECURE_SCRATCH_14 bit 26 (BOOT_STAGE_3_HANDOFF_VALUE_DONE) + SEC2 MAILBOX0 == 0
138note 5. Write GSP FALCON_OS = appVersion + verify RISCV_CPUCTL.ACTIVE_STAT
139fn sccorersm to long
140b = get sqbud 0
141r = scresethw
142if ne r 0
143ret r
144end
145gspwr SCBCRCTL SCBCRVAL
146pa = get sclibospa 0
147gspwr GMB0 and pa M32
148gspwr GMB1 shr pa 32
149scstartflcn SCSECCTL SCSECCTLA
150if not scwaitset SCBSISCR14 SCSTG3DN b
151ret -1
152end
153if ne gsprd S2MB0 0
154ret -1
155end
156gspwr GOS get scappver 0
157if eq and gsprd GCPUCTL CPUACT 0
158ret -1
159end
160put sccount 3 add get sccount 3 1
161ret 0
162end
163
164fn sqcorefn op ulong to long
165if eq op 5
166ret sccorerst
167end
168if eq op 6
169ret sccorestr
170end
171if eq op 7
172ret sccorehlt
173end
174if eq op 8
175ret sccorersm
176end
177ret -1
178end