github.com/linuxboot/fiano@v1.2.0/pkg/intel/metadata/cbnt/chipset_ac_module_information_manifestcodegen.go (about) 1 // Copyright 2017-2021 the LinuxBoot Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build !manifestcodegen 6 // +build !manifestcodegen 7 8 // Code generated by "menifestcodegen". DO NOT EDIT. 9 // To reproduce: go run github.com/linuxboot/fiano/pkg/intel/metadata/common/manifestcodegen/cmd/manifestcodegen github.com/linuxboot/fiano/pkg/intel/metadata/cbnt 10 11 package cbnt 12 13 import ( 14 "encoding/binary" 15 "fmt" 16 "io" 17 "strings" 18 19 "github.com/linuxboot/fiano/pkg/intel/metadata/common/pretty" 20 ) 21 22 var ( 23 // Just to avoid errors in "import" above in case if it wasn't used below 24 _ = binary.LittleEndian 25 _ = (fmt.Stringer)(nil) 26 _ = (io.Reader)(nil) 27 _ = pretty.Header 28 _ = strings.Join 29 ) 30 31 // NewChipsetACModuleInformation returns a new instance of ChipsetACModuleInformation with 32 // all default values set. 33 func NewChipsetACModuleInformation() *ChipsetACModuleInformation { 34 s := &ChipsetACModuleInformation{} 35 s.Rehash() 36 return s 37 } 38 39 // Validate (recursively) checks the structure if there are any unexpected 40 // values. It returns an error if so. 41 func (s *ChipsetACModuleInformation) Validate() error { 42 43 return nil 44 } 45 46 // ReadFrom reads the ChipsetACModuleInformation from 'r' in format defined in the document #575623. 47 func (s *ChipsetACModuleInformation) ReadFrom(r io.Reader) (int64, error) { 48 totalN := int64(0) 49 50 // UUID (ManifestFieldType: arrayStatic) 51 { 52 n, err := 16, binary.Read(r, binary.LittleEndian, s.UUID[:]) 53 if err != nil { 54 return totalN, fmt.Errorf("unable to read field 'UUID': %w", err) 55 } 56 totalN += int64(n) 57 } 58 59 // ChipsetACMType (ManifestFieldType: endValue) 60 { 61 n, err := 1, binary.Read(r, binary.LittleEndian, &s.ChipsetACMType) 62 if err != nil { 63 return totalN, fmt.Errorf("unable to read field 'ChipsetACMType': %w", err) 64 } 65 totalN += int64(n) 66 } 67 68 // Version (ManifestFieldType: endValue) 69 { 70 n, err := 1, binary.Read(r, binary.LittleEndian, &s.Version) 71 if err != nil { 72 return totalN, fmt.Errorf("unable to read field 'Version': %w", err) 73 } 74 totalN += int64(n) 75 } 76 77 // Length (ManifestFieldType: endValue) 78 { 79 n, err := 2, binary.Read(r, binary.LittleEndian, &s.Length) 80 if err != nil { 81 return totalN, fmt.Errorf("unable to read field 'Length': %w", err) 82 } 83 totalN += int64(n) 84 } 85 86 // ChipsetIDList (ManifestFieldType: endValue) 87 { 88 n, err := 4, binary.Read(r, binary.LittleEndian, &s.ChipsetIDList) 89 if err != nil { 90 return totalN, fmt.Errorf("unable to read field 'ChipsetIDList': %w", err) 91 } 92 totalN += int64(n) 93 } 94 95 // OsSinitDataVer (ManifestFieldType: endValue) 96 { 97 n, err := 4, binary.Read(r, binary.LittleEndian, &s.OsSinitDataVer) 98 if err != nil { 99 return totalN, fmt.Errorf("unable to read field 'OsSinitDataVer': %w", err) 100 } 101 totalN += int64(n) 102 } 103 104 // MinMleHeaderVer (ManifestFieldType: endValue) 105 { 106 n, err := 4, binary.Read(r, binary.LittleEndian, &s.MinMleHeaderVer) 107 if err != nil { 108 return totalN, fmt.Errorf("unable to read field 'MinMleHeaderVer': %w", err) 109 } 110 totalN += int64(n) 111 } 112 113 // Capabilities (ManifestFieldType: endValue) 114 { 115 n, err := 4, binary.Read(r, binary.LittleEndian, &s.Capabilities) 116 if err != nil { 117 return totalN, fmt.Errorf("unable to read field 'Capabilities': %w", err) 118 } 119 totalN += int64(n) 120 } 121 122 // AcmVersion (ManifestFieldType: endValue) 123 { 124 n, err := 1, binary.Read(r, binary.LittleEndian, &s.AcmVersion) 125 if err != nil { 126 return totalN, fmt.Errorf("unable to read field 'AcmVersion': %w", err) 127 } 128 totalN += int64(n) 129 } 130 131 // AcmRevision (ManifestFieldType: arrayStatic) 132 { 133 n, err := 3, binary.Read(r, binary.LittleEndian, s.AcmRevision[:]) 134 if err != nil { 135 return totalN, fmt.Errorf("unable to read field 'AcmRevision': %w", err) 136 } 137 totalN += int64(n) 138 } 139 140 // ProcessorIDList (ManifestFieldType: endValue) 141 { 142 n, err := 4, binary.Read(r, binary.LittleEndian, &s.ProcessorIDList) 143 if err != nil { 144 return totalN, fmt.Errorf("unable to read field 'ProcessorIDList': %w", err) 145 } 146 totalN += int64(n) 147 } 148 149 return totalN, nil 150 } 151 152 // RehashRecursive calls Rehash (see below) recursively. 153 func (s *ChipsetACModuleInformation) RehashRecursive() { 154 s.Rehash() 155 } 156 157 // Rehash sets values which are calculated automatically depending on the rest 158 // data. It is usually about the total size field of an element. 159 func (s *ChipsetACModuleInformation) Rehash() { 160 } 161 162 // WriteTo writes the ChipsetACModuleInformation into 'w' in format defined in 163 // the document #575623. 164 func (s *ChipsetACModuleInformation) WriteTo(w io.Writer) (int64, error) { 165 totalN := int64(0) 166 s.Rehash() 167 168 // UUID (ManifestFieldType: arrayStatic) 169 { 170 n, err := 16, binary.Write(w, binary.LittleEndian, s.UUID[:]) 171 if err != nil { 172 return totalN, fmt.Errorf("unable to write field 'UUID': %w", err) 173 } 174 totalN += int64(n) 175 } 176 177 // ChipsetACMType (ManifestFieldType: endValue) 178 { 179 n, err := 1, binary.Write(w, binary.LittleEndian, &s.ChipsetACMType) 180 if err != nil { 181 return totalN, fmt.Errorf("unable to write field 'ChipsetACMType': %w", err) 182 } 183 totalN += int64(n) 184 } 185 186 // Version (ManifestFieldType: endValue) 187 { 188 n, err := 1, binary.Write(w, binary.LittleEndian, &s.Version) 189 if err != nil { 190 return totalN, fmt.Errorf("unable to write field 'Version': %w", err) 191 } 192 totalN += int64(n) 193 } 194 195 // Length (ManifestFieldType: endValue) 196 { 197 n, err := 2, binary.Write(w, binary.LittleEndian, &s.Length) 198 if err != nil { 199 return totalN, fmt.Errorf("unable to write field 'Length': %w", err) 200 } 201 totalN += int64(n) 202 } 203 204 // ChipsetIDList (ManifestFieldType: endValue) 205 { 206 n, err := 4, binary.Write(w, binary.LittleEndian, &s.ChipsetIDList) 207 if err != nil { 208 return totalN, fmt.Errorf("unable to write field 'ChipsetIDList': %w", err) 209 } 210 totalN += int64(n) 211 } 212 213 // OsSinitDataVer (ManifestFieldType: endValue) 214 { 215 n, err := 4, binary.Write(w, binary.LittleEndian, &s.OsSinitDataVer) 216 if err != nil { 217 return totalN, fmt.Errorf("unable to write field 'OsSinitDataVer': %w", err) 218 } 219 totalN += int64(n) 220 } 221 222 // MinMleHeaderVer (ManifestFieldType: endValue) 223 { 224 n, err := 4, binary.Write(w, binary.LittleEndian, &s.MinMleHeaderVer) 225 if err != nil { 226 return totalN, fmt.Errorf("unable to write field 'MinMleHeaderVer': %w", err) 227 } 228 totalN += int64(n) 229 } 230 231 // Capabilities (ManifestFieldType: endValue) 232 { 233 n, err := 4, binary.Write(w, binary.LittleEndian, &s.Capabilities) 234 if err != nil { 235 return totalN, fmt.Errorf("unable to write field 'Capabilities': %w", err) 236 } 237 totalN += int64(n) 238 } 239 240 // AcmVersion (ManifestFieldType: endValue) 241 { 242 n, err := 1, binary.Write(w, binary.LittleEndian, &s.AcmVersion) 243 if err != nil { 244 return totalN, fmt.Errorf("unable to write field 'AcmVersion': %w", err) 245 } 246 totalN += int64(n) 247 } 248 249 // AcmRevision (ManifestFieldType: arrayStatic) 250 { 251 n, err := 3, binary.Write(w, binary.LittleEndian, s.AcmRevision[:]) 252 if err != nil { 253 return totalN, fmt.Errorf("unable to write field 'AcmRevision': %w", err) 254 } 255 totalN += int64(n) 256 } 257 258 // ProcessorIDList (ManifestFieldType: endValue) 259 { 260 n, err := 4, binary.Write(w, binary.LittleEndian, &s.ProcessorIDList) 261 if err != nil { 262 return totalN, fmt.Errorf("unable to write field 'ProcessorIDList': %w", err) 263 } 264 totalN += int64(n) 265 } 266 267 return totalN, nil 268 } 269 270 // UUIDSize returns the size in bytes of the value of field UUID 271 func (s *ChipsetACModuleInformation) UUIDTotalSize() uint64 { 272 return 16 273 } 274 275 // ChipsetACMTypeSize returns the size in bytes of the value of field ChipsetACMType 276 func (s *ChipsetACModuleInformation) ChipsetACMTypeTotalSize() uint64 { 277 return 1 278 } 279 280 // VersionSize returns the size in bytes of the value of field Version 281 func (s *ChipsetACModuleInformation) VersionTotalSize() uint64 { 282 return 1 283 } 284 285 // LengthSize returns the size in bytes of the value of field Length 286 func (s *ChipsetACModuleInformation) LengthTotalSize() uint64 { 287 return 2 288 } 289 290 // ChipsetIDListSize returns the size in bytes of the value of field ChipsetIDList 291 func (s *ChipsetACModuleInformation) ChipsetIDListTotalSize() uint64 { 292 return 4 293 } 294 295 // OsSinitDataVerSize returns the size in bytes of the value of field OsSinitDataVer 296 func (s *ChipsetACModuleInformation) OsSinitDataVerTotalSize() uint64 { 297 return 4 298 } 299 300 // MinMleHeaderVerSize returns the size in bytes of the value of field MinMleHeaderVer 301 func (s *ChipsetACModuleInformation) MinMleHeaderVerTotalSize() uint64 { 302 return 4 303 } 304 305 // CapabilitiesSize returns the size in bytes of the value of field Capabilities 306 func (s *ChipsetACModuleInformation) CapabilitiesTotalSize() uint64 { 307 return 4 308 } 309 310 // AcmVersionSize returns the size in bytes of the value of field AcmVersion 311 func (s *ChipsetACModuleInformation) AcmVersionTotalSize() uint64 { 312 return 1 313 } 314 315 // AcmRevisionSize returns the size in bytes of the value of field AcmRevision 316 func (s *ChipsetACModuleInformation) AcmRevisionTotalSize() uint64 { 317 return 3 318 } 319 320 // ProcessorIDListSize returns the size in bytes of the value of field ProcessorIDList 321 func (s *ChipsetACModuleInformation) ProcessorIDListTotalSize() uint64 { 322 return 4 323 } 324 325 // UUIDOffset returns the offset in bytes of field UUID 326 func (s *ChipsetACModuleInformation) UUIDOffset() uint64 { 327 return 0 328 } 329 330 // ChipsetACMTypeOffset returns the offset in bytes of field ChipsetACMType 331 func (s *ChipsetACModuleInformation) ChipsetACMTypeOffset() uint64 { 332 return s.UUIDOffset() + s.UUIDTotalSize() 333 } 334 335 // VersionOffset returns the offset in bytes of field Version 336 func (s *ChipsetACModuleInformation) VersionOffset() uint64 { 337 return s.ChipsetACMTypeOffset() + s.ChipsetACMTypeTotalSize() 338 } 339 340 // LengthOffset returns the offset in bytes of field Length 341 func (s *ChipsetACModuleInformation) LengthOffset() uint64 { 342 return s.VersionOffset() + s.VersionTotalSize() 343 } 344 345 // ChipsetIDListOffset returns the offset in bytes of field ChipsetIDList 346 func (s *ChipsetACModuleInformation) ChipsetIDListOffset() uint64 { 347 return s.LengthOffset() + s.LengthTotalSize() 348 } 349 350 // OsSinitDataVerOffset returns the offset in bytes of field OsSinitDataVer 351 func (s *ChipsetACModuleInformation) OsSinitDataVerOffset() uint64 { 352 return s.ChipsetIDListOffset() + s.ChipsetIDListTotalSize() 353 } 354 355 // MinMleHeaderVerOffset returns the offset in bytes of field MinMleHeaderVer 356 func (s *ChipsetACModuleInformation) MinMleHeaderVerOffset() uint64 { 357 return s.OsSinitDataVerOffset() + s.OsSinitDataVerTotalSize() 358 } 359 360 // CapabilitiesOffset returns the offset in bytes of field Capabilities 361 func (s *ChipsetACModuleInformation) CapabilitiesOffset() uint64 { 362 return s.MinMleHeaderVerOffset() + s.MinMleHeaderVerTotalSize() 363 } 364 365 // AcmVersionOffset returns the offset in bytes of field AcmVersion 366 func (s *ChipsetACModuleInformation) AcmVersionOffset() uint64 { 367 return s.CapabilitiesOffset() + s.CapabilitiesTotalSize() 368 } 369 370 // AcmRevisionOffset returns the offset in bytes of field AcmRevision 371 func (s *ChipsetACModuleInformation) AcmRevisionOffset() uint64 { 372 return s.AcmVersionOffset() + s.AcmVersionTotalSize() 373 } 374 375 // ProcessorIDListOffset returns the offset in bytes of field ProcessorIDList 376 func (s *ChipsetACModuleInformation) ProcessorIDListOffset() uint64 { 377 return s.AcmRevisionOffset() + s.AcmRevisionTotalSize() 378 } 379 380 // Size returns the total size of the ChipsetACModuleInformation. 381 func (s *ChipsetACModuleInformation) TotalSize() uint64 { 382 if s == nil { 383 return 0 384 } 385 386 var size uint64 387 size += s.UUIDTotalSize() 388 size += s.ChipsetACMTypeTotalSize() 389 size += s.VersionTotalSize() 390 size += s.LengthTotalSize() 391 size += s.ChipsetIDListTotalSize() 392 size += s.OsSinitDataVerTotalSize() 393 size += s.MinMleHeaderVerTotalSize() 394 size += s.CapabilitiesTotalSize() 395 size += s.AcmVersionTotalSize() 396 size += s.AcmRevisionTotalSize() 397 size += s.ProcessorIDListTotalSize() 398 return size 399 } 400 401 // PrettyString returns the content of the structure in an easy-to-read format. 402 func (s *ChipsetACModuleInformation) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string { 403 var lines []string 404 if withHeader { 405 lines = append(lines, pretty.Header(depth, "Chipset AC Module Information", s)) 406 } 407 if s == nil { 408 return strings.Join(lines, "\n") 409 } 410 // ManifestFieldType is arrayStatic 411 lines = append(lines, pretty.SubValue(depth+1, "UUID", "", &s.UUID, opts...)...) 412 // ManifestFieldType is endValue 413 lines = append(lines, pretty.SubValue(depth+1, "Chipset ACM Type", "", &s.ChipsetACMType, opts...)...) 414 // ManifestFieldType is endValue 415 lines = append(lines, pretty.SubValue(depth+1, "Version", "", &s.Version, opts...)...) 416 // ManifestFieldType is endValue 417 lines = append(lines, pretty.SubValue(depth+1, "Length", "", &s.Length, opts...)...) 418 // ManifestFieldType is endValue 419 lines = append(lines, pretty.SubValue(depth+1, "Chipset ID List", "", &s.ChipsetIDList, opts...)...) 420 // ManifestFieldType is endValue 421 lines = append(lines, pretty.SubValue(depth+1, "Os Sinit Data Ver", "", &s.OsSinitDataVer, opts...)...) 422 // ManifestFieldType is endValue 423 lines = append(lines, pretty.SubValue(depth+1, "Min Mle Header Ver", "", &s.MinMleHeaderVer, opts...)...) 424 // ManifestFieldType is endValue 425 lines = append(lines, pretty.SubValue(depth+1, "Capabilities", "", &s.Capabilities, opts...)...) 426 // ManifestFieldType is endValue 427 lines = append(lines, pretty.SubValue(depth+1, "Acm Version", "", &s.AcmVersion, opts...)...) 428 // ManifestFieldType is arrayStatic 429 lines = append(lines, pretty.SubValue(depth+1, "Acm Revision", "", &s.AcmRevision, opts...)...) 430 // ManifestFieldType is endValue 431 lines = append(lines, pretty.SubValue(depth+1, "Processor ID List", "", &s.ProcessorIDList, opts...)...) 432 if depth < 2 { 433 lines = append(lines, "") 434 } 435 return strings.Join(lines, "\n") 436 } 437 438 // NewChipsetACModuleInformationV5 returns a new instance of ChipsetACModuleInformationV5 with 439 // all default values set. 440 func NewChipsetACModuleInformationV5() *ChipsetACModuleInformationV5 { 441 s := &ChipsetACModuleInformationV5{} 442 // Recursively initializing a child structure: 443 s.Base = *NewChipsetACModuleInformation() 444 s.Rehash() 445 return s 446 } 447 448 // Validate (recursively) checks the structure if there are any unexpected 449 // values. It returns an error if so. 450 func (s *ChipsetACModuleInformationV5) Validate() error { 451 // Recursively validating a child structure: 452 if err := s.Base.Validate(); err != nil { 453 return fmt.Errorf("error on field 'Base': %w", err) 454 } 455 456 return nil 457 } 458 459 // ReadFrom reads the ChipsetACModuleInformationV5 from 'r' in format defined in the document #575623. 460 func (s *ChipsetACModuleInformationV5) ReadFrom(r io.Reader) (int64, error) { 461 totalN := int64(0) 462 463 // Base (ManifestFieldType: subStruct) 464 { 465 n, err := s.Base.ReadFrom(r) 466 if err != nil { 467 return totalN, fmt.Errorf("unable to read field 'Base': %w", err) 468 } 469 totalN += int64(n) 470 } 471 472 // TPMInfoList (ManifestFieldType: endValue) 473 { 474 n, err := 4, binary.Read(r, binary.LittleEndian, &s.TPMInfoList) 475 if err != nil { 476 return totalN, fmt.Errorf("unable to read field 'TPMInfoList': %w", err) 477 } 478 totalN += int64(n) 479 } 480 481 return totalN, nil 482 } 483 484 // RehashRecursive calls Rehash (see below) recursively. 485 func (s *ChipsetACModuleInformationV5) RehashRecursive() { 486 s.Base.Rehash() 487 s.Rehash() 488 } 489 490 // Rehash sets values which are calculated automatically depending on the rest 491 // data. It is usually about the total size field of an element. 492 func (s *ChipsetACModuleInformationV5) Rehash() { 493 } 494 495 // WriteTo writes the ChipsetACModuleInformationV5 into 'w' in format defined in 496 // the document #575623. 497 func (s *ChipsetACModuleInformationV5) WriteTo(w io.Writer) (int64, error) { 498 totalN := int64(0) 499 s.Rehash() 500 501 // Base (ManifestFieldType: subStruct) 502 { 503 n, err := s.Base.WriteTo(w) 504 if err != nil { 505 return totalN, fmt.Errorf("unable to write field 'Base': %w", err) 506 } 507 totalN += int64(n) 508 } 509 510 // TPMInfoList (ManifestFieldType: endValue) 511 { 512 n, err := 4, binary.Write(w, binary.LittleEndian, &s.TPMInfoList) 513 if err != nil { 514 return totalN, fmt.Errorf("unable to write field 'TPMInfoList': %w", err) 515 } 516 totalN += int64(n) 517 } 518 519 return totalN, nil 520 } 521 522 // BaseSize returns the size in bytes of the value of field Base 523 func (s *ChipsetACModuleInformationV5) BaseTotalSize() uint64 { 524 return s.Base.TotalSize() 525 } 526 527 // TPMInfoListSize returns the size in bytes of the value of field TPMInfoList 528 func (s *ChipsetACModuleInformationV5) TPMInfoListTotalSize() uint64 { 529 return 4 530 } 531 532 // BaseOffset returns the offset in bytes of field Base 533 func (s *ChipsetACModuleInformationV5) BaseOffset() uint64 { 534 return 0 535 } 536 537 // TPMInfoListOffset returns the offset in bytes of field TPMInfoList 538 func (s *ChipsetACModuleInformationV5) TPMInfoListOffset() uint64 { 539 return s.BaseOffset() + s.BaseTotalSize() 540 } 541 542 // Size returns the total size of the ChipsetACModuleInformationV5. 543 func (s *ChipsetACModuleInformationV5) TotalSize() uint64 { 544 if s == nil { 545 return 0 546 } 547 548 var size uint64 549 size += s.BaseTotalSize() 550 size += s.TPMInfoListTotalSize() 551 return size 552 } 553 554 // PrettyString returns the content of the structure in an easy-to-read format. 555 func (s *ChipsetACModuleInformationV5) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string { 556 var lines []string 557 if withHeader { 558 lines = append(lines, pretty.Header(depth, "Chipset AC Module Information V 5", s)) 559 } 560 if s == nil { 561 return strings.Join(lines, "\n") 562 } 563 // ManifestFieldType is subStruct 564 lines = append(lines, pretty.SubValue(depth+1, "Base", "", &s.Base, opts...)...) 565 // ManifestFieldType is endValue 566 lines = append(lines, pretty.SubValue(depth+1, "TPM Info List", "", &s.TPMInfoList, opts...)...) 567 if depth < 2 { 568 lines = append(lines, "") 569 } 570 return strings.Join(lines, "\n") 571 }