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/aienux/store/store_v1.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 / aienux / store / store_v1.om` 625 lines ยท 15169 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note aienux/store/store_v1.om: Pure-Omega System Store v1 format primitives (ADR 0015). 3 note Faithful OM-2 library (no om2 line, no fn main) converted from upstream aienux 4 note native/store/store_v1.{h,c} (byte-identical to crates/aienos-kernel/src/store/v1.rs). 5 note Compose with: si/directives/om2.om aienux/store/store_v1.om ... om/tls/sha2.om 6 7 const SV1_UNIT ulong 4096 8 const SV1_MAX_CATALOG_ENTRIES ulong 4096 9 const SV1_CATALOG_HEADER ulong 16 10 const SV1_CATALOG_ENTRY ulong 64 11 const SV1_MAX_OBJECT_BYTES ulong `67108864` 12 const SV1_MAX_OBJECT_UNITS ulong 16384 13 const SV1_MAX_TX_OBJECTS ulong 256 14 const SV1_MAX_TX_UNITS ulong 32768 15 const SV1_MAX_REGION_UNITS ulong `4294967296` 16 const SV1_KIND_CATALOG ushort 1 17 const SV1_KIND_COMMIT ushort 2 18 const SV1_VERSION ushort 1 19 const SV1_COMMIT_BYTES ulong 200 20 const SV1_SB_CRC_OFFSET ulong 168 21 const SV1_SB_RESERVED_OFFSET ulong 172 22 const SV1_MAX_CATALOG_UNITS ulong 65 23 const SV1_U64_MAX ulong 0xffffffffffffffff 24 25 note FormatError codes (matching store_v1.h / v1.rs) 26 const SV1_OK int 0 27 const SV1_E_INVALID_LENGTH int -1 28 const SV1_E_INVALID_OBJECT int -2 29 const SV1_E_OBJECT_TOO_LARGE int -3 30 const SV1_E_LENGTH_OVERFLOW int -4 31 const SV1_E_MALFORMED_DESCRIPTOR int -5 32 const SV1_E_OUT_OF_BOUNDS int -6 33 const SV1_E_OVERLAP int -7 34 const SV1_E_CATALOG_TOO_LARGE int -8 35 const SV1_E_CATALOG_ORDER int -9 36 const SV1_E_DUPLICATE_OBJECT int -10 37 const SV1_E_BAD_CATALOG_MAGIC int -11 38 const SV1_E_UNSUPPORTED_VERSION int -12 39 const SV1_E_MALFORMED_COMMIT int -13 40 const SV1_E_MALFORMED_SUPERBLOCK int -14 41 const SV1_E_BAD_SUPERBLOCK_MAGIC int -15 42 const SV1_E_BAD_SUPERBLOCK_CRC int -16 43 const SV1_E_NONZERO_RESERVED int -17 44 const SV1_E_WRONG_SUPERBLOCK_SLOT int -18 45 const SV1_E_UNSUPPORTED_FEATURES int -19 46 const SV1_E_INTEGRITY int -20 47 const SV1_E_INVALID_GENERATION int -21 48 const SV1_E_CONFLICTING_ROOTS int -22 49 const SV1_E_INCONSISTENT_HISTORY int -23 50 const SV1_E_ARG int -24 51 52 text sv1_obj_dom "AIENOS-STORE-OBJECT-V1" 53 text sv1_cat_magic "AIENCAT1" 54 text sv1_cmt_magic "AIENCMT1" 55 text sv1_sb_magic "AIENSTR1" 56 57 note ---- Byte and comparison helpers ---- 58 59 fn sv1_put16 buf edit uchar * off ulong v ushort to void 60 put buf off uchar and v 0xff 61 put buf add off 1 uchar and shr v 8 0xff 62 end 63 64 fn sv1_put32 buf edit uchar * off ulong v uint to void 65 put buf off uchar and v 0xff 66 put buf add off 1 uchar and shr v 8 0xff 67 put buf add off 2 uchar and shr v 16 0xff 68 put buf add off 3 uchar and shr v 24 0xff 69 end 70 71 fn sv1_put64 buf edit uchar * off ulong v ulong to void 72 for i ulong 8 unroll 73 put buf add off i uchar and shr v mul i 8 0xff 74 end 75 end 76 77 fn sv1_get16 buf view uchar * off ulong to ushort 78 b0 = ushort get buf off 79 b1 = ushort get buf add off 1 80 ret or b0 shl b1 8 81 end 82 83 fn sv1_get32 buf view uchar * off ulong to uint 84 b0 = uint get buf off 85 b1 = uint get buf add off 1 86 b2 = uint get buf add off 2 87 b3 = uint get buf add off 3 88 ret or or b0 shl b1 8 or shl b2 16 shl b3 24 89 end 90 91 fn sv1_get64 buf view uchar * off ulong to ulong 92 v = ulong 0 93 for i ulong 8 unroll 94 b = ulong get buf add off i 95 v = or v shl b mul i 8 96 end 97 ret v 98 end 99 100 fn sv1_equal a view uchar * b view uchar * to bool 101 if ne len a len b 102 ret false 103 end 104 cnt = len a 105 i = ulong 0 106 while lt i cnt bound 266240 107 if ne get a i get b i 108 ret false 109 end 110 i = add i 1 111 end 112 ret true 113 end 114 115 fn sv1_all_zero buf view uchar * off ulong cnt ulong to bool 116 i = ulong 0 117 while lt i cnt bound 266240 118 if ne get buf add off i 0 119 ret false 120 end 121 i = add i 1 122 end 123 ret true 124 end 125 126 fn sv1_cmp_id a view uchar * aoff ulong b view uchar * boff ulong to int 127 for i ulong 32 128 va = get a add aoff i 129 vb = get b add boff i 130 if lt va vb 131 ret -1 132 end 133 if gt va vb 134 ret 1 135 end 136 end 137 ret 0 138 end 139 140 note ---- CRC-32C (Castagnoli, reflected 0x82f63b78) ---- 141 142 fn sv1_crc32c buf view uchar * off ulong cnt ulong to uint 143 crc = uint 0xffffffff 144 i = ulong 0 145 while lt i cnt bound 65536 146 crc = xor crc uint get buf add off i 147 for k ulong 8 unroll 148 bit = and crc 1 149 mask = sub uint 0 bit 150 crc = xor shr crc 1 and 0x82f63b78 mask 151 end 152 i = add i 1 153 end 154 ret xor crc 0xffffffff 155 end 156 157 fn sv1_sb_crc buf view uchar * off ulong to uint 158 crc = uint 0xffffffff 159 for i ulong 4096 160 b = uint 0 161 if or lt i SV1_SB_CRC_OFFSET ge i add SV1_SB_CRC_OFFSET 4 162 b = uint get buf add off i 163 end 164 crc = xor crc b 165 for k ulong 8 unroll 166 bit = and crc 1 167 mask = sub uint 0 bit 168 crc = xor shr crc 1 and 0x82f63b78 mask 169 end 170 end 171 ret xor crc 0xffffffff 172 end 173 174 fn sv1_superblock_crc_ok buf view uchar * off ulong to bool 175 ret eq sv1_sb_crc buf off sv1_get32 buf add off SV1_SB_CRC_OFFSET 176 end 177 178 note ---- ObjectId and unit count ---- 179 180 fn sv1_unit_count byte_len ulong dst edit uint 1 to int 181 if eq byte_len 0 182 ret SV1_E_INVALID_OBJECT 183 end 184 if gt byte_len SV1_MAX_OBJECT_BYTES 185 ret SV1_E_OBJECT_TOO_LARGE 186 end 187 u = div add byte_len sub SV1_UNIT 1 SV1_UNIT 188 if gt u SV1_MAX_OBJECT_UNITS 189 ret SV1_E_OBJECT_TOO_LARGE 190 end 191 put dst 0 uint u 192 ret SV1_OK 193 end 194 195 fn sv1_object_id_begin ctx edit ulong 40 kind ushort ver ushort byte_len ulong to int 196 if or eq kind 0 or eq ver 0 eq byte_len 0 197 ret SV1_E_INVALID_OBJECT 198 end 199 if gt byte_len SV1_MAX_OBJECT_BYTES 200 ret SV1_E_OBJECT_TOO_LARGE 201 end 202 z1 = new uchar 1 0 203 d = new uchar 12 0 204 sv1_put16 d 0 kind 205 sv1_put16 d 2 ver 206 sv1_put64 d 4 byte_len 207 sha256_init ctx 208 sha256_update ctx sv1_obj_dom 209 sha256_update ctx z1 210 sha256_update ctx d 211 ret SV1_OK 212 end 213 214 fn sv1_object_id kind ushort ver ushort data view uchar * dst edit uchar 32 to int 215 ctx = new ulong 40 0 216 e = sv1_object_id_begin ctx kind ver len data 217 if ne e SV1_OK 218 ret e 219 end 220 sha256_update ctx data 221 sha256_final ctx dst 222 ret SV1_OK 223 end 224 225 fn sv1_validate_extent id view uchar 32 kind ushort ver ushort byte_len ulong ext view uchar * to int 226 u = new uint 1 0 227 e = sv1_unit_count byte_len u 228 if ne e SV1_OK 229 ret e 230 end 231 if ne len ext mul ulong get u 0 SV1_UNIT 232 ret SV1_E_INVALID_LENGTH 233 end 234 if not sv1_all_zero ext byte_len sub len ext byte_len 235 ret SV1_E_NONZERO_RESERVED 236 end 237 got = new uchar 32 0 238 e = sv1_object_id kind ver part ext 0 byte_len got 239 if ne e SV1_OK 240 ret e 241 end 242 if not sv1_equal got id 243 ret SV1_E_INTEGRITY 244 end 245 ret SV1_OK 246 end 247 248 note ---- CatalogEntry (canonical 64-byte wire record) ---- 249 note Layout: 0..32 object_id | 32 kind u16 | 34 version u16 | 36 first_unit u64 250 note 44 byte_length u64 | 52 unit_count u32 | 56 flags u16 | 58..64 zero 251 252 fn sv1_entry_validate_shape ent view uchar * off ulong to int 253 kind = sv1_get16 ent add off 32 254 ver = sv1_get16 ent add off 34 255 blen = sv1_get64 ent add off 44 256 ucnt = sv1_get32 ent add off 52 257 fl = sv1_get16 ent add off 56 258 if or lt kind 3 or eq ver 0 ne fl 0 259 ret SV1_E_MALFORMED_DESCRIPTOR 260 end 261 if not sv1_all_zero ent add off 58 6 262 ret SV1_E_NONZERO_RESERVED 263 end 264 u = new uint 1 0 265 r = sv1_unit_count blen u 266 if ne r SV1_OK 267 ret r 268 end 269 if ne get u 0 ucnt 270 ret SV1_E_MALFORMED_DESCRIPTOR 271 end 272 ret SV1_OK 273 end 274 275 fn sv1_entry_validate_bounds ent view uchar * off ulong reg_units ulong cat_first ulong hw ulong to int 276 r = sv1_entry_validate_shape ent off 277 if ne r SV1_OK 278 ret r 279 end 280 if or lt reg_units 4 or gt reg_units SV1_MAX_REGION_UNITS or lt hw 4 gt hw reg_units 281 ret SV1_E_OUT_OF_BOUNDS 282 end 283 fu = sv1_get64 ent add off 36 284 uc = ulong sv1_get32 ent add off 52 285 if gt fu sub SV1_U64_MAX uc 286 ret SV1_E_LENGTH_OVERFLOW 287 end 288 eu = add fu uc 289 if or lt fu 2 gt eu cat_first 290 ret SV1_E_OUT_OF_BOUNDS 291 end 292 if or gt eu hw gt eu reg_units 293 ret SV1_E_OUT_OF_BOUNDS 294 end 295 ret SV1_OK 296 end 297 298 note ---- Catalog helpers ---- 299 300 fn sv1_catalog_len n ulong to ulong 301 ret add SV1_CATALOG_HEADER mul n SV1_CATALOG_ENTRY 302 end 303 304 fn sv1_commit_validate_gen buf view uchar * off ulong gen ulong pgen ulong to int 305 if eq gen 1 306 if ne pgen 0 307 ret SV1_E_INVALID_GENERATION 308 end 309 if not sv1_all_zero buf add off 72 32 310 ret SV1_E_INVALID_GENERATION 311 end 312 if not sv1_all_zero buf add off 104 32 313 ret SV1_E_INVALID_GENERATION 314 end 315 ret SV1_OK 316 end 317 if eq pgen SV1_U64_MAX 318 ret SV1_E_INVALID_GENERATION 319 end 320 if ne add pgen 1 gen 321 ret SV1_E_INVALID_GENERATION 322 end 323 if sv1_all_zero buf add off 72 32 324 ret SV1_E_INVALID_GENERATION 325 end 326 if sv1_all_zero buf add off 104 32 327 ret SV1_E_INVALID_GENERATION 328 end 329 ret SV1_OK 330 end 331 332 fn sv1_commit_validate_cat buf view uchar * off ulong reg_u ulong to int 333 cat_fu = sv1_get64 buf add off 168 334 cat_bl = sv1_get64 buf add off 176 335 cat_uc = sv1_get32 buf add off 184 336 cat_ec = sv1_get32 buf add off 188 337 if or gt ulong cat_ec SV1_MAX_CATALOG_ENTRIES ne cat_bl sv1_catalog_len ulong cat_ec 338 ret SV1_E_MALFORMED_COMMIT 339 end 340 u = new uint 1 0 341 r = sv1_unit_count cat_bl u 342 if ne r SV1_OK 343 ret r 344 end 345 if ne get u 0 cat_uc 346 ret SV1_E_MALFORMED_COMMIT 347 end 348 if gt cat_fu sub SV1_U64_MAX ulong cat_uc 349 ret SV1_E_LENGTH_OVERFLOW 350 end 351 eu = add cat_fu ulong cat_uc 352 hw = sv1_get64 buf add off 192 353 if or lt cat_fu 2 ge eu reg_u 354 ret SV1_E_MALFORMED_COMMIT 355 end 356 if or ne hw add eu 1 gt hw reg_u 357 ret SV1_E_MALFORMED_COMMIT 358 end 359 ret SV1_OK 360 end 361 362 fn sv1_commit_validate buf view uchar * off ulong to int 363 if not sv1_equal part buf off 8 sv1_cmt_magic 364 ret SV1_E_MALFORMED_COMMIT 365 end 366 if or ne sv1_get16 buf add off 8 1 ne sv1_get16 buf add off 10 ushort SV1_COMMIT_BYTES 367 ret SV1_E_UNSUPPORTED_VERSION 368 end 369 if or ne sv1_get16 buf add off 12 1 ne sv1_get16 buf add off 14 0 370 ret SV1_E_UNSUPPORTED_VERSION 371 end 372 if or ne sv1_get64 buf add off 16 0 ne sv1_get64 buf add off 24 0 373 ret SV1_E_UNSUPPORTED_FEATURES 374 end 375 reg_u = sv1_get64 buf add off 48 376 gen = sv1_get64 buf add off 56 377 if or lt reg_u 4 or gt reg_u SV1_MAX_REGION_UNITS eq gen 0 378 ret SV1_E_MALFORMED_COMMIT 379 end 380 rc = sv1_commit_validate_cat buf off reg_u 381 if ne rc SV1_OK 382 ret rc 383 end 384 pgen = sv1_get64 buf add off 64 385 ret sv1_commit_validate_gen buf off gen pgen 386 end 387 388 fn sv1_commit_identifies_pred cur view uchar 200 prev view uchar 200 prev_id view uchar 32 to bool 389 gen = sv1_get64 cur 56 390 pgen = sv1_get64 prev 56 391 if or eq gen 0 ne sub gen 1 pgen 392 ret false 393 end 394 if ne sv1_get64 cur 64 pgen 395 ret false 396 end 397 if not sv1_equal part cur 72 32 prev_id 398 ret false 399 end 400 if not sv1_equal part cur 104 32 part prev 136 32 401 ret false 402 end 403 if not sv1_equal part cur 32 16 part prev 32 16 404 ret false 405 end 406 if ne sv1_get64 cur 48 sv1_get64 prev 48 407 ret false 408 end 409 if lt sv1_get64 cur 168 sv1_get64 prev 192 410 ret false 411 end 412 ret true 413 end 414 415 note ---- Superblock (4096-byte canonical wire format) ---- 416 417 fn sv1_sb_validate_cat buf view uchar * off ulong hw ulong to int 418 cmu = sv1_get64 buf add off 96 419 cat_fu = sv1_get64 buf add off 136 420 cat_bl = sv1_get64 buf add off 144 421 cat_uc = sv1_get32 buf add off 152 422 cat_ec = sv1_get32 buf add off 156 423 if gt cat_fu sub SV1_U64_MAX ulong cat_uc 424 ret SV1_E_LENGTH_OVERFLOW 425 end 426 eu = add cat_fu ulong cat_uc 427 if or gt ulong cat_ec SV1_MAX_CATALOG_ENTRIES ne cat_bl sv1_catalog_len ulong cat_ec 428 ret SV1_E_MALFORMED_SUPERBLOCK 429 end 430 u = new uint 1 0 431 r = sv1_unit_count cat_bl u 432 if ne r SV1_OK 433 ret r 434 end 435 if or ne get u 0 cat_uc lt cat_fu 2 436 ret SV1_E_MALFORMED_SUPERBLOCK 437 end 438 if ne eu cmu 439 ret SV1_E_MALFORMED_SUPERBLOCK 440 end 441 if eq cmu SV1_U64_MAX 442 ret SV1_E_MALFORMED_SUPERBLOCK 443 end 444 if ne add cmu 1 hw 445 ret SV1_E_MALFORMED_SUPERBLOCK 446 end 447 ret SV1_OK 448 end 449 450 fn sv1_sb_validate_shape buf view uchar * off ulong to int 451 slot = sv1_get32 buf add off 44 452 reg_u = sv1_get64 buf add off 48 453 gen = sv1_get64 buf add off 56 454 hw = sv1_get64 buf add off 160 455 if or gt slot 1 or lt reg_u 4 gt reg_u SV1_MAX_REGION_UNITS 456 ret SV1_E_MALFORMED_SUPERBLOCK 457 end 458 if or eq gen 0 or gt hw reg_u lt hw 4 459 ret SV1_E_MALFORMED_SUPERBLOCK 460 end 461 ret sv1_sb_validate_cat buf off hw 462 end 463 464 fn sv1_superblock_decode buf view uchar * off ulong exp_slot uint to int 465 if not sv1_equal part buf off 8 sv1_sb_magic 466 ret SV1_E_BAD_SUPERBLOCK_MAGIC 467 end 468 if not sv1_superblock_crc_ok buf off 469 ret SV1_E_BAD_SUPERBLOCK_CRC 470 end 471 if not sv1_all_zero buf add off SV1_SB_RESERVED_OFFSET sub SV1_UNIT SV1_SB_RESERVED_OFFSET 472 ret SV1_E_NONZERO_RESERVED 473 end 474 if or ne sv1_get16 buf add off 8 1 ne sv1_get16 buf add off 10 0 475 ret SV1_E_UNSUPPORTED_VERSION 476 end 477 if or ne sv1_get64 buf add off 12 0 ne sv1_get64 buf add off 20 0 478 ret SV1_E_UNSUPPORTED_FEATURES 479 end 480 slot = sv1_get32 buf add off 44 481 if or ne slot exp_slot gt slot 1 482 ret SV1_E_WRONG_SUPERBLOCK_SLOT 483 end 484 ret sv1_sb_validate_shape buf off 485 end 486 487 fn sv1_superblock_validate_commit sb view uchar 4096 cid view uchar 32 cmt view uchar 200 to int 488 if not sv1_equal part sb 64 32 cid 489 ret SV1_E_MALFORMED_SUPERBLOCK 490 end 491 if not sv1_equal part sb 28 16 part cmt 32 16 492 ret SV1_E_MALFORMED_SUPERBLOCK 493 end 494 if ne sv1_get64 sb 48 sv1_get64 cmt 48 495 ret SV1_E_MALFORMED_SUPERBLOCK 496 end 497 if ne sv1_get64 sb 56 sv1_get64 cmt 56 498 ret SV1_E_MALFORMED_SUPERBLOCK 499 end 500 if not sv1_equal part sb 104 32 part cmt 136 32 501 ret SV1_E_MALFORMED_SUPERBLOCK 502 end 503 if ne sv1_get64 sb 136 sv1_get64 cmt 168 504 ret SV1_E_MALFORMED_SUPERBLOCK 505 end 506 if ne sv1_get64 sb 144 sv1_get64 cmt 176 507 ret SV1_E_MALFORMED_SUPERBLOCK 508 end 509 if ne sv1_get32 sb 152 sv1_get32 cmt 184 510 ret SV1_E_MALFORMED_SUPERBLOCK 511 end 512 if ne sv1_get32 sb 156 sv1_get32 cmt 188 513 ret SV1_E_MALFORMED_SUPERBLOCK 514 end 515 hw = sv1_get64 sb 160 516 if ne hw sv1_get64 cmt 192 517 ret SV1_E_MALFORMED_SUPERBLOCK 518 end 519 cmu = sv1_get64 sb 96 520 cat_fu = sv1_get64 sb 136 521 cat_uc = ulong sv1_get32 sb 152 522 if or eq cmu SV1_U64_MAX ne add cmu 1 hw 523 ret SV1_E_MALFORMED_SUPERBLOCK 524 end 525 if or gt cat_fu sub SV1_U64_MAX cat_uc ne add cat_fu cat_uc cmu 526 ret SV1_E_MALFORMED_SUPERBLOCK 527 end 528 ret SV1_OK 529 end 530 531 fn sv1_superblock_equivalent a view uchar 4096 b view uchar 4096 to bool 532 if not sv1_equal part a 28 16 part b 28 16 533 ret false 534 end 535 if ne sv1_get64 a 48 sv1_get64 b 48 536 ret false 537 end 538 if ne sv1_get64 a 56 sv1_get64 b 56 539 ret false 540 end 541 ret sv1_equal part a 64 32 part b 64 32 542 end 543 544 note ---- Genesis units 0..3 (16384 bytes) ---- 545 546 fn sv1_genesis_units uuid view uchar 16 reg_units ulong dst edit uchar 16384 to int 547 if or lt reg_units 4 gt reg_units SV1_MAX_REGION_UNITS 548 ret SV1_E_MALFORMED_COMMIT 549 end 550 for i ulong 16384 551 put dst i 0 552 end 553 note Unit 2: empty catalog (16 bytes) 554 u2 = ulong 8192 555 for i ulong 8 556 put dst add u2 i get sv1_cat_magic i 557 end 558 sv1_put16 dst add u2 8 1 559 sv1_put16 dst add u2 10 ushort SV1_CATALOG_ENTRY 560 sv1_put32 dst add u2 12 0 561 cat_id = new uchar 32 0 562 r = sv1_object_id SV1_KIND_CATALOG SV1_VERSION part dst u2 16 cat_id 563 if ne r SV1_OK 564 ret r 565 end 566 note Unit 3: genesis commit record (200 bytes) 567 u3 = ulong 12288 568 for i ulong 8 569 put dst add u3 i get sv1_cmt_magic i 570 end 571 sv1_put16 dst add u3 8 1 572 sv1_put16 dst add u3 10 ushort SV1_COMMIT_BYTES 573 sv1_put16 dst add u3 12 1 574 sv1_put16 dst add u3 14 0 575 for i ulong 16 576 put dst add u3 add 32 i get uuid i 577 end 578 sv1_put64 dst add u3 48 reg_units 579 sv1_put64 dst add u3 56 1 580 sv1_put64 dst add u3 64 0 581 for i ulong 32 582 put dst add u3 add 136 i get cat_id i 583 end 584 sv1_put64 dst add u3 168 2 585 sv1_put64 dst add u3 176 16 586 sv1_put32 dst add u3 184 1 587 sv1_put32 dst add u3 188 0 588 sv1_put64 dst add u3 192 4 589 r = sv1_commit_validate dst u3 590 if ne r SV1_OK 591 ret r 592 end 593 cmt_id = new uchar 32 0 594 r = sv1_object_id SV1_KIND_COMMIT SV1_VERSION part dst u3 SV1_COMMIT_BYTES cmt_id 595 if ne r SV1_OK 596 ret r 597 end 598 note Unit 0: superblock A (slot 0) 599 for i ulong 8 600 put dst i get sv1_sb_magic i 601 end 602 sv1_put16 dst 8 1 603 sv1_put16 dst 10 0 604 for i ulong 16 605 put dst add 28 i get uuid i 606 end 607 sv1_put32 dst 44 0 608 sv1_put64 dst 48 reg_units 609 sv1_put64 dst 56 1 610 for i ulong 32 611 put dst add 64 i get cmt_id i 612 end 613 sv1_put64 dst 96 3 614 for i ulong 32 615 put dst add 104 i get cat_id i 616 end 617 sv1_put64 dst 136 2 618 sv1_put64 dst 144 16 619 sv1_put32 dst 152 1 620 sv1_put32 dst 156 0 621 sv1_put64 dst 160 4 622 crc = sv1_sb_crc dst 0 623 sv1_put32 dst SV1_SB_CRC_OFFSET crc 624 ret sv1_superblock_decode dst 0 0 625 end