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-gpu-driver/blob/main/gsp/sysinfo.om # omega-gpu-driver aien-dev/omega-gpu-driver Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-gpu-driver / gsp / sysinfo.om` 709 lines ยท 21270 bytes Raw Blame History 1 note gsp/sysinfo.om: the GspSystemInfo payload of GSP_SET_SYSTEM_INFO (RPC 72, 936 bytes) in seeded Omega. 2 note Port of aien-dev/aienux PR #441 native/kernel/tools/ck_gsp_sysinfo_encode.c (encode, the fields 3 note table, the slurped-text rules). The 72 field offsets and sizes are that tool's table, which its 4 note nvhdr gate checks against NVIDIA's GspSystemInfo (open-gpu-kernel-modules 580.173.02, 5 note src/nvidia/generated/g_rpc-structures.h via gsp_static_config.h). Little endian, every byte not set is 0. 6 note Library unit: no main. Name prefix si / SI only. 7 note 8 note API (all state is in globals; a global can never be an argument): 9 note sireset load the table, clear values, seen marks, set order and siout. Call first. 10 note siseti k v set field k (0..71, the order below) to v; long code 11 note sisetn v set the field named sinam[0..sinl) to v; long code 12 note sitext n parse sitxt[0..n) as the C tool's "field value" lines; long code; the set 13 note order (siord[0..sinord)) lets a caller echo each accepted line 14 note siencode build siout[0..936) from every accepted field 15 note sinmk k copy field k's name into sinam/sinl 16 note siwhy e put the refusal text of code e into siwb[0..siwl) (the C tool's why string; 17 note for siseti/sisetn refusals the "line N: " prefix is left out) 18 note codes: 0 SIEOK; -1 SIEIDX index past 71 (API only); -2 SIEREP field repeated; -3 SIEFIT value 19 note does not fit the field; -4 SIEUNK unknown field; -5 SIENUM not a number; -6 SIEWANT line is not 20 note "field value"; -7 SIELONG line of 512 bytes or more; -8 SIEBIG text over 65536 bytes (.om only, the 21 note C slurps any size); -9 SIENIT sireset not called (.om only). 22 note A refused set leaves the field unset; a refused sitext ends at the refused line (lines before it 23 note stay set, as the C tool's partial echo shows), and the caller must not send siout then. 24 note 25 note Field sources for ogd on GB10 (VFIO userspace; nvidia.ko fill sites in open-gpu-kernel-modules 26 note 580.173.02; every NVIDIA path below is under src/nvidia/ unless it starts with kernel-open/). All 27 note fields are written by rpcGspSetSystemInfo_v17_00, src/kernel/vgpu/rpc.c:10493-10658. Window-1 28 note values (hex) and their DOCUMENTED/OBSERVED/INFERRED/ASSUMED tags are in aienux 29 note evidence/own-gpu-driver/rung2/system_info.txt. Source classes: 30 note CFG = the GPU's own PCI config space, read through the VFIO config region (index 7) 31 note RP = the upstream root port's config space (outside the VFIO group: sysfs config, read-only) 32 note CONST = fixed for GB10B / this host build, documented in the NVIDIA source 33 note OS = host kernel constant 34 note DRV = ogd's own allocation 35 note LIVE = only a live read on the running GPU gives it 36 note field src nvidia.ko fill site GB10 value 37 note gpuPhysAddr CFG rpc.c:10525 <- gpu_mgr.c:1967 <- osinit.c:738 0x24000000 38 note (nv->regs->cpu_address, BAR0 start, nv-pci.c:1500-1502); 39 note ogd: BAR0/BAR1 dwords 0x10/0x14 of the config region or the 40 note sysfs resource file. LIVE per boot (PCI assignment). 41 note gpuPhysFbAddr CONST rpc.c:10526 <- osinit.c:739 (nv->fb, no FB BAR) 0 42 note gpuPhysInstAddr CFG rpc.c:10527 <- gpu_mgr.c:1994 (BAR0 + 0x700000) 0x24700000 43 note gpuPhysIoAddr CONST rpc.c:10528 0 44 note nvDomainBusDeviceFunc CFG rpc.c:10529 <- osinit.c:764, osinit.c:144-147, 0xf00000100 45 note g_gpu_nvoc.h:502-507; ogd: the BDF it opened (000f:01:00.0) 46 note simAccessBufPhysAddr CONST rpc.c:10562-10569 (0 outside simulation) 0 47 note notifyOpSharedSurfacePhysAddr DRV rpc.c:10571-10578, kernel_gsp.c:3489-3526; ogd's IOVA of its 48 note notify-op page (IOMMU_MAP_DMA). LIVE per boot. 49 note pcieAtomicsOpMask RP rpc.c:10579 <- kernel_bif_gh100.c:620-642 (root port 0x7 50 note DevCap2 AtomicOp completer bits). INFERRED, needs RP read. 51 note consoleMemSize CONST rpc.c:10583 (no console reservation on GB10, UNKNOWN) 0 52 note maxUserVa OS rpc.c:10584 <- os.c:720 <- os-interface.c:1128-1131 0x1000000000000 53 note (TASK_SIZE; 48-bit VA arm64 kernel) 54 note pciConfigMirrorBase CONST rpc.c:10540 <- kernel_bif_gh100.c:593-604, bound to 0x92000 55 note GB10B at g_kernel_bif_nvoc.c:965-968 56 note pciConfigMirrorSize CONST same 0x1000 57 note PCIDeviceID CFG rpc.c:10533 <- kern_gpu_gb100.c:967 (config 0x00) 0x2e1210de 58 note PCISubDeviceID CFG rpc.c:10534 <- kern_gpu_gb100.c:959 (config 0x2c) 0x10de 59 note PCIRevisionID CFG rpc.c:10535 <- kern_gpu_gb100.c:950 (config 0x08) 0xa1 60 note pcieAtomicsCplDeviceCapMask CFG rpc.c:10581 <- kernel_bif_gb10b.c:30-60 (GPU DevCap2) 0 61 note oorArch CONST rpc.c:10530 <- gpu_mgr.c:1539 (OOR_ARCH_AARCH64) 3 62 note clPdbProperties RP rpc.c:10590 clSyncWithGsp, chipset.c:765 0x1088020c1 63 note (properties set while probing the root port). INFERRED. 64 note Chipset RP chipset.c:812 (nvcst.h:300, 0x22d1 -> CS_NVIDIA_T254) 0x106d 65 note bGpuBehindBridge RP rpc.c:10600-10604 0 66 note bFlrSupported CFG rpc.c:10555 <- kbifCacheFlrSupport_GH100 1 67 note kernel_bif_gh100.c:1099 (config 0x64 DevCap bit 28) 68 note b64bBar0Supported CFG rpc.c:10556 <- kbifCache64bBar0Support_GH100 1 69 note kernel_bif_gh100.c:1131 (BAR0 type bits) 70 note bMnocAvailable CONST rpc.c:10549 0 71 note chipsetL1ssEnable RP rpc.c:10552 (root port L1 PM substates) 0 72 note bUpstreamL0sUnsupported RP rpc.c:10600-10604 0 73 note bUpstreamL1Unsupported RP rpc.c:10600-10604 0 74 note bUpstreamL1PorSupported RP rpc.c:10600-10604 0 75 note bUpstreamL1PorMobileOnly RP rpc.c:10600-10604 0 76 note bSystemHasMux CONST rpc.c:10597 0 77 note upstreamAddressValid RP rpc.c:10605 1 78 note FHBBusInfo.deviceID .. revisionID RP chipset.c:813 (bus info chipset.c:335-338) 0x22d1, 0x10de 79 note chipsetIDInfo.deviceID .. rev RP chipset.c:814 0x22d1, 0x10de 80 note acpiMethodData.bValid CONST rpc.c:10596 <- acpi_common.c:1131 1 81 note acpiMethodData.dodMethodData.* CONST acpi_common.c:1134-1136 (_DOD absent: status 0xffff, 0xffff, 64 82 note acpiIdListLen = sizeof list) 83 note acpiMethodData.jt/capsMethodData CONST acpi_common.c (status of absent methods) 0x56, 0x56 84 note hypervisorType CONST rpc.c:10607 <- hypervisor.c:51,58 (OS_HYPERVISOR_UNKNOWN) 4 85 note virtualConfigBits, bIsPassthru CONST rpc.c:10608-10609 0 86 note sysTimerOffsetNs LIVE rpc.c:10622 <- timer_gb10b.c:52-77 (OS ns - PTIMER ns) 0 (UNKNOWN) 87 note needs a PTIMER read in the window, just before the send 88 note gspVFInfo.* CFG rpc.c:10612-10619 (no SR-IOV capability) 0 89 note bIsPrimary CONST rpc.c:10624 (UNKNOWN; console owner) 0 90 note bIsUnixHdmiFrlComplianceEnabled CONST rpc.c:10625 <- g_gpu_nvoc.c:350 1 91 note isGridBuild, gridBuildCsp CONST rpc.c:10629, :10631 0 92 note pcieConfigReg.linkCap CFG rpc.c:10559 (config 0x6c, PCIe Link Capabilities) 0x457901 93 note bPreserveVideoMemoryAllocations CONST rpc.c:10632 0 94 note bTdrEventSupported CONST rpc.c:10635 0 95 note bFeatureStretchVblankCapable CONST rpc.c:10640 0 96 note bEnableDynamicGranularityPageArrays CONST rpc.c:10585 0 97 note bClockBoostSupported CONST rpc.c:10647 0 98 note hostPageSize OS rpc.c:10593 <- os.c:4421 (os_page_size) 4096 99 note bIsCmcBasedHws CONST never assigned in 580.173.02 (stays 0) 0 100 note bGspNocatEnabled CONST rpc.c:10649-10652 (Windows only) 0 101 note bS0ixSupport CONST rpc.c:10627 0 102 note bWindowChannelAlwaysMapped CONST rpc.c:10641 <- g_kern_disp_nvoc.c:305 1 103 note Values only a live read gives: gpuPhysAddr/gpuPhysInstAddr (BAR assignment), the CFG ids, linkCap, 104 note FLR and BAR0-64-bit bits (config region), the RP fields (root-port config), sysTimerOffsetNs (PTIMER 105 note at send time) and notifyOpSharedSurfacePhysAddr (ogd's own DMA mapping). Nothing here reads them: 106 note the caller supplies every value. Nothing here has run on the chip. 107 const SINF ulong 72 108 const SISIZE ulong 936 109 note a line of 512 bytes or more is refused (the C tool's char buf[512]) 110 const SILINE ulong 512 111 note the text buffer: 65536 bytes (the C tool slurps any size; .om refuses more, SIEBIG) 112 const SITXMAX ulong 65536 113 const SIMAX64 ulong `18446744073709551615` 114 const SIEOK long 0 115 const SIEIDX long -1 116 const SIEREP long -2 117 const SIEFIT long -3 118 const SIEUNK long -4 119 const SIENUM long -5 120 const SIEWANT long -6 121 const SIELONG long -7 122 const SIEBIG long -8 123 const SIENIT long -9 124 note the 72 field names in table order, each followed by one space 125 text sinames "gpuPhysAddr gpuPhysFbAddr gpuPhysInstAddr gpuPhysIoAddr nvDomainBusDeviceFunc simAccessBufPhysAddr notifyOpSharedSurfacePhysAddr pcieAtomicsOpMask consoleMemSize maxUserVa pciConfigMirrorBase pciConfigMirrorSize PCIDeviceID PCISubDeviceID PCIRevisionID pcieAtomicsCplDeviceCapMask oorArch clPdbProperties Chipset bGpuBehindBridge bFlrSupported b64bBar0Supported bMnocAvailable chipsetL1ssEnable bUpstreamL0sUnsupported bUpstreamL1Unsupported bUpstreamL1PorSupported bUpstreamL1PorMobileOnly bSystemHasMux upstreamAddressValid FHBBusInfo.deviceID FHBBusInfo.vendorID FHBBusInfo.subdeviceID FHBBusInfo.subvendorID FHBBusInfo.revisionID chipsetIDInfo.deviceID chipsetIDInfo.vendorID chipsetIDInfo.subdeviceID chipsetIDInfo.subvendorID chipsetIDInfo.revisionID acpiMethodData.bValid acpiMethodData.dodMethodData.status acpiMethodData.dodMethodData.acpiIdListLen acpiMethodData.jtMethodData.status acpiMethodData.capsMethodData.status hypervisorType virtualConfigBits bIsPassthru sysTimerOffsetNs gspVFInfo.totalVFs gspVFInfo.firstVFOffset gspVFInfo.FirstVFBar0Address gspVFInfo.FirstVFBar1Address gspVFInfo.FirstVFBar2Address gspVFInfo.b64bitBar0 gspVFInfo.b64bitBar1 gspVFInfo.b64bitBar2 bIsPrimary bIsUnixHdmiFrlComplianceEnabled isGridBuild pcieConfigReg.linkCap gridBuildCsp bPreserveVideoMemoryAllocations bTdrEventSupported bFeatureStretchVblankCapable bEnableDynamicGranularityPageArrays bClockBoostSupported hostPageSize bIsCmcBasedHws bGspNocatEnabled bS0ixSupport bWindowChannelAlwaysMapped " 126 note refusal fragments, each ended by | (124): 0 "line " 1 " too long" 2 ": " 3 want 4 unknown field 127 note 5 "field " 6 " repeated" 7 " is not a number" 8 " does not fit " 9 " (" 10 " bytes)" 11 index 128 note 12 too big 13 not reset 129 text siwt "line | too long|: |want \"field value\"|unknown field |field | repeated| is not a number| does not fit | (| bytes)|field index out of range|text over 65536 bytes|sireset not called|" 130 global sioff ulong 72 131 global sisz ulong 72 132 global sival ulong 72 133 global siseen uchar 72 134 global siord ulong 72 135 global sinord ulong 1 136 global siout uchar 936 137 global sitxt uchar 65536 138 note name and value tokens of the current line (or of the last siseti/sisetn call) 139 global sinam uchar 128 140 global sinl ulong 1 141 global sivb uchar 128 142 global sivl ulong 1 143 note line number of the last refusal (0 = an API call), field index of the current line, parser cursor 144 global siline ulong 1 145 global sifld ulong 1 146 global sipos ulong 1 147 global sinv ulong 1 148 global siwb uchar 256 149 global siwl ulong 1 150 fn sireset to void 151 put sioff 0 0 152 put sisz 0 8 153 put sioff 1 8 154 put sisz 1 8 155 put sioff 2 16 156 put sisz 2 8 157 put sioff 3 24 158 put sisz 3 8 159 put sioff 4 32 160 put sisz 4 8 161 put sioff 5 40 162 put sisz 5 8 163 put sioff 6 48 164 put sisz 6 8 165 put sioff 7 56 166 put sisz 7 8 167 put sioff 8 64 168 put sisz 8 8 169 put sioff 9 72 170 put sisz 9 8 171 put sioff 10 80 172 put sisz 10 4 173 put sioff 11 84 174 put sisz 11 4 175 put sioff 12 88 176 put sisz 12 4 177 put sioff 13 92 178 put sisz 13 4 179 put sioff 14 96 180 put sisz 14 4 181 put sioff 15 100 182 put sisz 15 4 183 put sioff 16 104 184 put sisz 16 1 185 put sioff 17 112 186 put sisz 17 8 187 put sioff 18 120 188 put sisz 18 4 189 put sioff 19 124 190 put sisz 19 1 191 put sioff 20 125 192 put sisz 20 1 193 put sioff 21 126 194 put sisz 21 1 195 put sioff 22 127 196 put sisz 22 1 197 put sioff 23 128 198 put sisz 23 4 199 put sioff 24 132 200 put sisz 24 1 201 put sioff 25 133 202 put sisz 25 1 203 put sioff 26 134 204 put sisz 26 1 205 put sioff 27 135 206 put sisz 27 1 207 put sioff 28 136 208 put sisz 28 1 209 put sioff 29 137 210 put sisz 29 1 211 put sioff 30 138 212 put sisz 30 2 213 put sioff 31 140 214 put sisz 31 2 215 put sioff 32 142 216 put sisz 32 2 217 put sioff 33 144 218 put sisz 33 2 219 put sioff 34 146 220 put sisz 34 1 221 put sioff 35 148 222 put sisz 35 2 223 put sioff 36 150 224 put sisz 36 2 225 put sioff 37 152 226 put sisz 37 2 227 put sioff 38 154 228 put sisz 38 2 229 put sioff 39 156 230 put sisz 39 1 231 put sioff 40 160 232 put sisz 40 1 233 put sioff 41 164 234 put sisz 41 4 235 put sioff 42 168 236 put sisz 42 4 237 put sioff 43 236 238 put sisz 43 4 239 put sioff 44 828 240 put sisz 44 4 241 put sioff 45 836 242 put sisz 45 4 243 put sioff 46 840 244 put sisz 46 2 245 put sioff 47 842 246 put sisz 47 1 247 put sioff 48 848 248 put sisz 48 8 249 put sioff 49 856 250 put sisz 49 4 251 put sioff 50 860 252 put sisz 50 4 253 put sioff 51 864 254 put sisz 51 8 255 put sioff 52 872 256 put sisz 52 8 257 put sioff 53 880 258 put sisz 53 8 259 put sioff 54 888 260 put sisz 54 1 261 put sioff 55 889 262 put sisz 55 1 263 put sioff 56 890 264 put sisz 56 1 265 put sioff 57 896 266 put sisz 57 1 267 put sioff 58 897 268 put sisz 58 1 269 put sioff 59 898 270 put sisz 59 1 271 put sioff 60 900 272 put sisz 60 4 273 put sioff 61 904 274 put sisz 61 4 275 put sioff 62 908 276 put sisz 62 1 277 put sioff 63 909 278 put sisz 63 1 279 put sioff 64 910 280 put sisz 64 1 281 put sioff 65 911 282 put sisz 65 1 283 put sioff 66 912 284 put sisz 66 1 285 put sioff 67 920 286 put sisz 67 8 287 put sioff 68 928 288 put sisz 68 1 289 put sioff 69 929 290 put sisz 69 1 291 put sioff 70 930 292 put sisz 70 1 293 put sioff 71 931 294 put sisz 71 1 295 for k ulong SINF 296 put sival k 0 297 put siseen k 0 298 put siord k 0 299 end 300 for i ulong SISIZE 301 put siout i 0 302 end 303 put sinord 0 0 304 put siline 0 0 305 put sinl 0 0 306 put sivl 0 0 307 put siwl 0 0 308 end 309 note the field's value fits its size (8-byte fields take any value) 310 fn sifits k ulong v ulong to bool 311 sz = get sisz k 312 if lt sz 8 313 ret eq shr v mul sz 8 0 314 end 315 ret true 316 end 317 fn sistore k ulong v ulong to long 318 if ge k SINF 319 ret SIEIDX 320 end 321 if ne get siseen k 0 322 ret SIEREP 323 end 324 if not sifits k v 325 ret SIEFIT 326 end 327 put siseen k 1 328 put sival k v 329 n = get sinord 0 330 put siord n k 331 put sinord 0 add n 1 332 ret SIEOK 333 end 334 note name k into sinam/sinl 335 fn sinmk k ulong to void 336 w = ulong 0 337 o = ulong 0 338 for i ulong len sinames 339 c = get sinames i 340 if eq c 32 341 w = add w 1 342 else 343 if eq w k 344 put sinam o c 345 o = add o 1 346 end 347 end 348 end 349 put sinl 0 o 350 end 351 fn sieqat s ulong n ulong to bool 352 for j ulong n 353 if ne get sinames add s j get sinam j 354 ret false 355 end 356 end 357 ret true 358 end 359 note index of the field named sinam[0..sinl), SINF when none 360 fn silook to ulong 361 k = ulong 0 362 s = ulong 0 363 n = get sinl 0 364 for i ulong len sinames 365 if eq get sinames i 32 366 if eq sub i s n 367 if sieqat s n 368 ret k 369 end 370 end 371 k = add k 1 372 s = add i 1 373 end 374 end 375 ret SINF 376 end 377 note sivb[0..sivl) as "%#llx" of v (API path only) 378 fn sihexv v ulong to void 379 put sivb 0 48 380 if eq v 0 381 put sivl 0 1 382 ret 383 end 384 put sivb 1 120 385 nd = ulong 0 386 t = v 387 while ne t 0 bound 17 388 nd = add nd 1 389 t = shr t 4 390 end 391 for i ulong nd 392 d = and shr v mul sub sub nd i 1 4 15 393 if lt d 10 394 put sivb add i 2 uchar add d 48 395 else 396 put sivb add i 2 uchar add d 87 397 end 398 end 399 put sivl 0 add nd 2 400 end 401 fn siseti k ulong v ulong to long 402 put siline 0 0 403 if eq get sisz 0 0 404 ret SIENIT 405 end 406 if lt k SINF 407 sinmk k 408 put sifld 0 k 409 end 410 sihexv v 411 r = sistore k v 412 ret r 413 end 414 fn sisetn v ulong to long 415 put siline 0 0 416 if eq get sisz 0 0 417 ret SIENIT 418 end 419 k = silook 420 if eq k SINF 421 sihexv v 422 ret SIEUNK 423 end 424 r = siseti k v 425 ret r 426 end 427 fn siencode to void 428 for i ulong SISIZE 429 put siout i 0 430 end 431 for k ulong SINF 432 if ne get siseen k 0 433 v = get sival k 434 o = get sioff k 435 for b ulong get sisz k 436 put siout add o b uchar and shr v mul b 8 255 437 end 438 end 439 end 440 end 441 note C isspace: \t \n \v \f \r (9..13) and space (32) 442 fn siws c uchar to bool 443 ret or eq c 32 and ge c 9 le c 13 444 end 445 fn siskip b ulong to void 446 p = get sipos 0 447 while lt p b bound 600 448 if not siws get sitxt p 449 break 450 end 451 p = add p 1 452 end 453 put sipos 0 p 454 end 455 note one sscanf %127s token from sipos (which 0 = sinam, 1 = sivb, 2 = dropped); returns its length 456 fn sitk which ulong b ulong to ulong 457 p = get sipos 0 458 n = ulong 0 459 while and lt p b lt n 127 bound 600 460 c = get sitxt p 461 if siws c 462 break 463 end 464 if eq which 0 465 put sinam n c 466 end 467 if eq which 1 468 put sivb n c 469 end 470 n = add n 1 471 p = add p 1 472 end 473 put sipos 0 p 474 ret n 475 end 476 note strtoull digit value, 99 for a non-digit 477 fn sidig c uchar to ulong 478 if and ge c 48 le c 57 479 ret sub ulong c 48 480 end 481 if and ge c 97 le c 102 482 ret sub ulong c 87 483 end 484 if and ge c 65 le c 70 485 ret sub ulong c 55 486 end 487 ret 99 488 end 489 note sivb[0..sivl) as strtoull(val, &end, 0) with errno == 0, *end == 0 and val[0] != '-' -> sinv 490 fn sinum to bool 491 n = get sivl 0 492 if eq get sivb 0 45 493 ret false 494 end 495 i = ulong 0 496 if eq get sivb 0 43 497 i = 1 498 end 499 base = ulong 10 500 if lt i n 501 if eq get sivb i 48 502 base = 8 503 if lt add i 2 n 504 x = get sivb add i 1 505 if or eq x 120 eq x 88 506 if lt sidig get sivb add i 2 16 507 base = 16 508 i = add i 2 509 end 510 end 511 end 512 end 513 end 514 v = ulong 0 515 nd = ulong 0 516 ovf = false 517 while lt i n bound 200 518 d = sidig get sivb i 519 if ge d base 520 break 521 end 522 if gt v div sub SIMAX64 d base 523 ovf = true 524 else 525 v = add mul v base d 526 end 527 nd = add nd 1 528 i = add i 1 529 end 530 put sinv 0 v 531 ret and and gt nd 0 eq i n not ovf 532 end 533 note one line sitxt[a..b) after the # cut: 1 blank, else a code 534 fn sidoln a ulong b ulong to long 535 put sipos 0 a 536 siskip b 537 if eq get sipos 0 b 538 ret 1 539 end 540 put sinl 0 sitk 0 b 541 siskip b 542 if eq get sipos 0 b 543 ret SIEWANT 544 end 545 put sivl 0 sitk 1 b 546 siskip b 547 if ne get sipos 0 b 548 ret SIEWANT 549 end 550 k = silook 551 put sifld 0 k 552 if eq k SINF 553 ret SIEUNK 554 end 555 if ne get siseen k 0 556 ret SIEREP 557 end 558 if not sinum 559 ret SIENUM 560 end 561 r = sistore k get sinv 0 562 ret r 563 end 564 fn sieol p ulong m ulong to ulong 565 e = p 566 while lt e m bound 70000 567 if eq get sitxt e 10 568 break 569 end 570 e = add e 1 571 end 572 ret e 573 end 574 fn sihash p ulong e ulong to ulong 575 h = p 576 while lt h e bound 600 577 if eq get sitxt h 35 578 break 579 end 580 h = add h 1 581 end 582 ret h 583 end 584 fn sitext n ulong to long 585 put siline 0 0 586 if eq get sisz 0 0 587 ret SIENIT 588 end 589 if gt n SITXMAX 590 ret SIEBIG 591 end 592 note the C tool reads a NUL-terminated string: the text ends at the first NUL byte 593 m = n 594 for i ulong n 595 if eq get sitxt i 0 596 m = i 597 break 598 end 599 end 600 p = ulong 0 601 ln = ulong 0 602 while lt p m bound 70000 603 ln = add ln 1 604 put siline 0 ln 605 e = sieol p m 606 if ge sub e p SILINE 607 ret SIELONG 608 end 609 r = sidoln p sihash p e 610 if lt r 0 611 ret r 612 end 613 p = add e 1 614 end 615 put siline 0 0 616 ret SIEOK 617 end 618 fn siwc c uchar to void 619 n = get siwl 0 620 if lt n 256 621 put siwb n c 622 put siwl 0 add n 1 623 end 624 end 625 note fragment k of siwt 626 fn siwfr k ulong to void 627 w = ulong 0 628 for i ulong len siwt 629 c = get siwt i 630 if eq c 124 631 w = add w 1 632 else 633 if eq w k 634 siwc c 635 end 636 end 637 end 638 end 639 fn siwdec v ulong to void 640 d = ulong 1 641 while le d div v 10 bound 20 642 d = mul d 10 643 end 644 while ne d 0 bound 20 645 siwc uchar add rem div v d 10 48 646 d = div d 10 647 end 648 end 649 fn siwnam mx ulong to void 650 for i ulong get sinl 0 651 if lt i mx 652 siwc get sinam i 653 end 654 end 655 end 656 fn siwval mx ulong to void 657 for i ulong get sivl 0 658 if lt i mx 659 siwc get sivb i 660 end 661 end 662 end 663 note the refusal text of e (the C tool's why string) into siwb[0..siwl) 664 fn siwhy e long to void 665 put siwl 0 0 666 ln = get siline 0 667 if ne ln 0 668 siwfr 0 669 siwdec ln 670 if eq e SIELONG 671 siwfr 1 672 ret 673 end 674 siwfr 2 675 end 676 if eq e SIEWANT 677 siwfr 3 678 end 679 if eq e SIEUNK 680 siwfr 4 681 siwnam 128 682 end 683 if eq e SIEREP 684 siwfr 5 685 siwnam 128 686 siwfr 6 687 end 688 if eq e SIENUM 689 siwval 128 690 siwfr 7 691 end 692 if eq e SIEFIT 693 siwval 40 694 siwfr 8 695 siwnam 60 696 siwfr 9 697 siwdec get sisz get sifld 0 698 siwfr 10 699 end 700 if eq e SIEIDX 701 siwfr 11 702 end 703 if eq e SIEBIG 704 siwfr 12 705 end 706 if eq e SIENIT 707 siwfr 13 708 end 709 end