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