github.com/linuxboot/fiano@v1.2.0/pkg/intel/metadata/cbnt/cbntbootpolicy/txt_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/cbntbootpolicy
    10  
    11  package cbntbootpolicy
    12  
    13  import (
    14  	"encoding/binary"
    15  	"fmt"
    16  	"io"
    17  	"strings"
    18  
    19  	"github.com/linuxboot/fiano/pkg/intel/metadata/cbnt"
    20  	"github.com/linuxboot/fiano/pkg/intel/metadata/common/pretty"
    21  )
    22  
    23  var (
    24  	// Just to avoid errors in "import" above in case if it wasn't used below
    25  	_ = binary.LittleEndian
    26  	_ = (fmt.Stringer)(nil)
    27  	_ = (io.Reader)(nil)
    28  	_ = pretty.Header
    29  	_ = strings.Join
    30  	_ = cbnt.StructInfo{}
    31  )
    32  
    33  // NewTXT returns a new instance of TXT with
    34  // all default values set.
    35  func NewTXT() *TXT {
    36  	s := &TXT{}
    37  	copy(s.StructInfo.ID[:], []byte(StructureIDTXT))
    38  	s.StructInfo.Version = 0x21
    39  	// Set through tag "default":
    40  	s.SInitMinSVNAuth = 0
    41  	// Set through tag "default":
    42  	s.PTTCMOSOffset0 = 126
    43  	// Set through tag "default":
    44  	s.PTTCMOSOffset1 = 127
    45  	// Set through tag "default":
    46  	s.ACPIBaseOffset = 0x400
    47  	// Set through tag "default":
    48  	s.PwrMBaseOffset = 0xFE000000
    49  	// Recursively initializing a child structure:
    50  	s.DigestList = *cbnt.NewHashList()
    51  	// Set through tag "required":
    52  	s.SegmentCount = 0
    53  	s.Rehash()
    54  	return s
    55  }
    56  
    57  // Validate (recursively) checks the structure if there are any unexpected
    58  // values. It returns an error if so.
    59  func (s *TXT) Validate() error {
    60  	// See tag "require"
    61  	for idx := range s.Reserved0 {
    62  		if s.Reserved0[idx] != 0 {
    63  			return fmt.Errorf("'Reserved0[%d]' is expected to be 0, but it is %v", idx, s.Reserved0[idx])
    64  		}
    65  	}
    66  	// See tag "require"
    67  	for idx := range s.SetNumber {
    68  		if s.SetNumber[idx] != 0 {
    69  			return fmt.Errorf("'SetNumber[%d]' is expected to be 0, but it is %v", idx, s.SetNumber[idx])
    70  		}
    71  	}
    72  	// See tag "require"
    73  	for idx := range s.Reserved1 {
    74  		if s.Reserved1[idx] != 0 {
    75  			return fmt.Errorf("'Reserved1[%d]' is expected to be 0, but it is %v", idx, s.Reserved1[idx])
    76  		}
    77  	}
    78  	// Recursively validating a child structure:
    79  	if err := s.DigestList.Validate(); err != nil {
    80  		return fmt.Errorf("error on field 'DigestList': %w", err)
    81  	}
    82  	// See tag "require"
    83  	for idx := range s.Reserved3 {
    84  		if s.Reserved3[idx] != 0 {
    85  			return fmt.Errorf("'Reserved3[%d]' is expected to be 0, but it is %v", idx, s.Reserved3[idx])
    86  		}
    87  	}
    88  	// See tag "require"
    89  	if s.SegmentCount != 0 {
    90  		return fmt.Errorf("field 'SegmentCount' expects value '0', but has %v", s.SegmentCount)
    91  	}
    92  
    93  	return nil
    94  }
    95  
    96  // StructureIDTXT is the StructureID (in terms of
    97  // the document #575623) of element 'TXT'.
    98  const StructureIDTXT = "__TXTS__"
    99  
   100  // GetStructInfo returns current value of StructInfo of the structure.
   101  //
   102  // StructInfo is a set of standard fields with presented in any element
   103  // ("element" in terms of document #575623).
   104  func (s *TXT) GetStructInfo() cbnt.StructInfo {
   105  	return s.StructInfo
   106  }
   107  
   108  // SetStructInfo sets new value of StructInfo to the structure.
   109  //
   110  // StructInfo is a set of standard fields with presented in any element
   111  // ("element" in terms of document #575623).
   112  func (s *TXT) SetStructInfo(newStructInfo cbnt.StructInfo) {
   113  	s.StructInfo = newStructInfo
   114  }
   115  
   116  // ReadFrom reads the TXT from 'r' in format defined in the document #575623.
   117  func (s *TXT) ReadFrom(r io.Reader) (int64, error) {
   118  	var totalN int64
   119  
   120  	err := binary.Read(r, binary.LittleEndian, &s.StructInfo)
   121  	if err != nil {
   122  		return totalN, fmt.Errorf("unable to read structure info at %d: %w", totalN, err)
   123  	}
   124  	totalN += int64(binary.Size(s.StructInfo))
   125  
   126  	n, err := s.ReadDataFrom(r)
   127  	if err != nil {
   128  		return totalN, fmt.Errorf("unable to read data: %w", err)
   129  	}
   130  	totalN += n
   131  
   132  	return totalN, nil
   133  }
   134  
   135  // ReadDataFrom reads the TXT from 'r' excluding StructInfo,
   136  // in format defined in the document #575623.
   137  func (s *TXT) ReadDataFrom(r io.Reader) (int64, error) {
   138  	totalN := int64(0)
   139  
   140  	// StructInfo (ManifestFieldType: structInfo)
   141  	{
   142  		// ReadDataFrom does not read Struct, use ReadFrom for that.
   143  	}
   144  
   145  	// Reserved0 (ManifestFieldType: arrayStatic)
   146  	{
   147  		n, err := 1, binary.Read(r, binary.LittleEndian, s.Reserved0[:])
   148  		if err != nil {
   149  			return totalN, fmt.Errorf("unable to read field 'Reserved0': %w", err)
   150  		}
   151  		totalN += int64(n)
   152  	}
   153  
   154  	// SetNumber (ManifestFieldType: arrayStatic)
   155  	{
   156  		n, err := 1, binary.Read(r, binary.LittleEndian, s.SetNumber[:])
   157  		if err != nil {
   158  			return totalN, fmt.Errorf("unable to read field 'SetNumber': %w", err)
   159  		}
   160  		totalN += int64(n)
   161  	}
   162  
   163  	// SInitMinSVNAuth (ManifestFieldType: endValue)
   164  	{
   165  		n, err := 1, binary.Read(r, binary.LittleEndian, &s.SInitMinSVNAuth)
   166  		if err != nil {
   167  			return totalN, fmt.Errorf("unable to read field 'SInitMinSVNAuth': %w", err)
   168  		}
   169  		totalN += int64(n)
   170  	}
   171  
   172  	// Reserved1 (ManifestFieldType: arrayStatic)
   173  	{
   174  		n, err := 1, binary.Read(r, binary.LittleEndian, s.Reserved1[:])
   175  		if err != nil {
   176  			return totalN, fmt.Errorf("unable to read field 'Reserved1': %w", err)
   177  		}
   178  		totalN += int64(n)
   179  	}
   180  
   181  	// ControlFlags (ManifestFieldType: endValue)
   182  	{
   183  		n, err := 4, binary.Read(r, binary.LittleEndian, &s.ControlFlags)
   184  		if err != nil {
   185  			return totalN, fmt.Errorf("unable to read field 'ControlFlags': %w", err)
   186  		}
   187  		totalN += int64(n)
   188  	}
   189  
   190  	// PwrDownInterval (ManifestFieldType: endValue)
   191  	{
   192  		n, err := 2, binary.Read(r, binary.LittleEndian, &s.PwrDownInterval)
   193  		if err != nil {
   194  			return totalN, fmt.Errorf("unable to read field 'PwrDownInterval': %w", err)
   195  		}
   196  		totalN += int64(n)
   197  	}
   198  
   199  	// PTTCMOSOffset0 (ManifestFieldType: endValue)
   200  	{
   201  		n, err := 1, binary.Read(r, binary.LittleEndian, &s.PTTCMOSOffset0)
   202  		if err != nil {
   203  			return totalN, fmt.Errorf("unable to read field 'PTTCMOSOffset0': %w", err)
   204  		}
   205  		totalN += int64(n)
   206  	}
   207  
   208  	// PTTCMOSOffset1 (ManifestFieldType: endValue)
   209  	{
   210  		n, err := 1, binary.Read(r, binary.LittleEndian, &s.PTTCMOSOffset1)
   211  		if err != nil {
   212  			return totalN, fmt.Errorf("unable to read field 'PTTCMOSOffset1': %w", err)
   213  		}
   214  		totalN += int64(n)
   215  	}
   216  
   217  	// ACPIBaseOffset (ManifestFieldType: endValue)
   218  	{
   219  		n, err := 2, binary.Read(r, binary.LittleEndian, &s.ACPIBaseOffset)
   220  		if err != nil {
   221  			return totalN, fmt.Errorf("unable to read field 'ACPIBaseOffset': %w", err)
   222  		}
   223  		totalN += int64(n)
   224  	}
   225  
   226  	// Reserved2 (ManifestFieldType: arrayStatic)
   227  	{
   228  		n, err := 2, binary.Read(r, binary.LittleEndian, s.Reserved2[:])
   229  		if err != nil {
   230  			return totalN, fmt.Errorf("unable to read field 'Reserved2': %w", err)
   231  		}
   232  		totalN += int64(n)
   233  	}
   234  
   235  	// PwrMBaseOffset (ManifestFieldType: endValue)
   236  	{
   237  		n, err := 4, binary.Read(r, binary.LittleEndian, &s.PwrMBaseOffset)
   238  		if err != nil {
   239  			return totalN, fmt.Errorf("unable to read field 'PwrMBaseOffset': %w", err)
   240  		}
   241  		totalN += int64(n)
   242  	}
   243  
   244  	// DigestList (ManifestFieldType: subStruct)
   245  	{
   246  		n, err := s.DigestList.ReadFrom(r)
   247  		if err != nil {
   248  			return totalN, fmt.Errorf("unable to read field 'DigestList': %w", err)
   249  		}
   250  		totalN += int64(n)
   251  	}
   252  
   253  	// Reserved3 (ManifestFieldType: arrayStatic)
   254  	{
   255  		n, err := 3, binary.Read(r, binary.LittleEndian, s.Reserved3[:])
   256  		if err != nil {
   257  			return totalN, fmt.Errorf("unable to read field 'Reserved3': %w", err)
   258  		}
   259  		totalN += int64(n)
   260  	}
   261  
   262  	// SegmentCount (ManifestFieldType: endValue)
   263  	{
   264  		n, err := 1, binary.Read(r, binary.LittleEndian, &s.SegmentCount)
   265  		if err != nil {
   266  			return totalN, fmt.Errorf("unable to read field 'SegmentCount': %w", err)
   267  		}
   268  		totalN += int64(n)
   269  	}
   270  
   271  	return totalN, nil
   272  }
   273  
   274  // RehashRecursive calls Rehash (see below) recursively.
   275  func (s *TXT) RehashRecursive() {
   276  	s.StructInfo.Rehash()
   277  	s.DigestList.Rehash()
   278  	s.Rehash()
   279  }
   280  
   281  // Rehash sets values which are calculated automatically depending on the rest
   282  // data. It is usually about the total size field of an element.
   283  func (s *TXT) Rehash() {
   284  	s.Variable0 = 0
   285  	s.ElementSize = uint16(s.TotalSize())
   286  }
   287  
   288  // WriteTo writes the TXT into 'w' in format defined in
   289  // the document #575623.
   290  func (s *TXT) WriteTo(w io.Writer) (int64, error) {
   291  	totalN := int64(0)
   292  	s.Rehash()
   293  
   294  	// StructInfo (ManifestFieldType: structInfo)
   295  	{
   296  		n, err := s.StructInfo.WriteTo(w)
   297  		if err != nil {
   298  			return totalN, fmt.Errorf("unable to write field 'StructInfo': %w", err)
   299  		}
   300  		totalN += int64(n)
   301  	}
   302  
   303  	// Reserved0 (ManifestFieldType: arrayStatic)
   304  	{
   305  		n, err := 1, binary.Write(w, binary.LittleEndian, s.Reserved0[:])
   306  		if err != nil {
   307  			return totalN, fmt.Errorf("unable to write field 'Reserved0': %w", err)
   308  		}
   309  		totalN += int64(n)
   310  	}
   311  
   312  	// SetNumber (ManifestFieldType: arrayStatic)
   313  	{
   314  		n, err := 1, binary.Write(w, binary.LittleEndian, s.SetNumber[:])
   315  		if err != nil {
   316  			return totalN, fmt.Errorf("unable to write field 'SetNumber': %w", err)
   317  		}
   318  		totalN += int64(n)
   319  	}
   320  
   321  	// SInitMinSVNAuth (ManifestFieldType: endValue)
   322  	{
   323  		n, err := 1, binary.Write(w, binary.LittleEndian, &s.SInitMinSVNAuth)
   324  		if err != nil {
   325  			return totalN, fmt.Errorf("unable to write field 'SInitMinSVNAuth': %w", err)
   326  		}
   327  		totalN += int64(n)
   328  	}
   329  
   330  	// Reserved1 (ManifestFieldType: arrayStatic)
   331  	{
   332  		n, err := 1, binary.Write(w, binary.LittleEndian, s.Reserved1[:])
   333  		if err != nil {
   334  			return totalN, fmt.Errorf("unable to write field 'Reserved1': %w", err)
   335  		}
   336  		totalN += int64(n)
   337  	}
   338  
   339  	// ControlFlags (ManifestFieldType: endValue)
   340  	{
   341  		n, err := 4, binary.Write(w, binary.LittleEndian, &s.ControlFlags)
   342  		if err != nil {
   343  			return totalN, fmt.Errorf("unable to write field 'ControlFlags': %w", err)
   344  		}
   345  		totalN += int64(n)
   346  	}
   347  
   348  	// PwrDownInterval (ManifestFieldType: endValue)
   349  	{
   350  		n, err := 2, binary.Write(w, binary.LittleEndian, &s.PwrDownInterval)
   351  		if err != nil {
   352  			return totalN, fmt.Errorf("unable to write field 'PwrDownInterval': %w", err)
   353  		}
   354  		totalN += int64(n)
   355  	}
   356  
   357  	// PTTCMOSOffset0 (ManifestFieldType: endValue)
   358  	{
   359  		n, err := 1, binary.Write(w, binary.LittleEndian, &s.PTTCMOSOffset0)
   360  		if err != nil {
   361  			return totalN, fmt.Errorf("unable to write field 'PTTCMOSOffset0': %w", err)
   362  		}
   363  		totalN += int64(n)
   364  	}
   365  
   366  	// PTTCMOSOffset1 (ManifestFieldType: endValue)
   367  	{
   368  		n, err := 1, binary.Write(w, binary.LittleEndian, &s.PTTCMOSOffset1)
   369  		if err != nil {
   370  			return totalN, fmt.Errorf("unable to write field 'PTTCMOSOffset1': %w", err)
   371  		}
   372  		totalN += int64(n)
   373  	}
   374  
   375  	// ACPIBaseOffset (ManifestFieldType: endValue)
   376  	{
   377  		n, err := 2, binary.Write(w, binary.LittleEndian, &s.ACPIBaseOffset)
   378  		if err != nil {
   379  			return totalN, fmt.Errorf("unable to write field 'ACPIBaseOffset': %w", err)
   380  		}
   381  		totalN += int64(n)
   382  	}
   383  
   384  	// Reserved2 (ManifestFieldType: arrayStatic)
   385  	{
   386  		n, err := 2, binary.Write(w, binary.LittleEndian, s.Reserved2[:])
   387  		if err != nil {
   388  			return totalN, fmt.Errorf("unable to write field 'Reserved2': %w", err)
   389  		}
   390  		totalN += int64(n)
   391  	}
   392  
   393  	// PwrMBaseOffset (ManifestFieldType: endValue)
   394  	{
   395  		n, err := 4, binary.Write(w, binary.LittleEndian, &s.PwrMBaseOffset)
   396  		if err != nil {
   397  			return totalN, fmt.Errorf("unable to write field 'PwrMBaseOffset': %w", err)
   398  		}
   399  		totalN += int64(n)
   400  	}
   401  
   402  	// DigestList (ManifestFieldType: subStruct)
   403  	{
   404  		n, err := s.DigestList.WriteTo(w)
   405  		if err != nil {
   406  			return totalN, fmt.Errorf("unable to write field 'DigestList': %w", err)
   407  		}
   408  		totalN += int64(n)
   409  	}
   410  
   411  	// Reserved3 (ManifestFieldType: arrayStatic)
   412  	{
   413  		n, err := 3, binary.Write(w, binary.LittleEndian, s.Reserved3[:])
   414  		if err != nil {
   415  			return totalN, fmt.Errorf("unable to write field 'Reserved3': %w", err)
   416  		}
   417  		totalN += int64(n)
   418  	}
   419  
   420  	// SegmentCount (ManifestFieldType: endValue)
   421  	{
   422  		n, err := 1, binary.Write(w, binary.LittleEndian, &s.SegmentCount)
   423  		if err != nil {
   424  			return totalN, fmt.Errorf("unable to write field 'SegmentCount': %w", err)
   425  		}
   426  		totalN += int64(n)
   427  	}
   428  
   429  	return totalN, nil
   430  }
   431  
   432  // StructInfoSize returns the size in bytes of the value of field StructInfo
   433  func (s *TXT) StructInfoTotalSize() uint64 {
   434  	return s.StructInfo.TotalSize()
   435  }
   436  
   437  // Reserved0Size returns the size in bytes of the value of field Reserved0
   438  func (s *TXT) Reserved0TotalSize() uint64 {
   439  	return 1
   440  }
   441  
   442  // SetNumberSize returns the size in bytes of the value of field SetNumber
   443  func (s *TXT) SetNumberTotalSize() uint64 {
   444  	return 1
   445  }
   446  
   447  // SInitMinSVNAuthSize returns the size in bytes of the value of field SInitMinSVNAuth
   448  func (s *TXT) SInitMinSVNAuthTotalSize() uint64 {
   449  	return 1
   450  }
   451  
   452  // Reserved1Size returns the size in bytes of the value of field Reserved1
   453  func (s *TXT) Reserved1TotalSize() uint64 {
   454  	return 1
   455  }
   456  
   457  // ControlFlagsSize returns the size in bytes of the value of field ControlFlags
   458  func (s *TXT) ControlFlagsTotalSize() uint64 {
   459  	return 4
   460  }
   461  
   462  // PwrDownIntervalSize returns the size in bytes of the value of field PwrDownInterval
   463  func (s *TXT) PwrDownIntervalTotalSize() uint64 {
   464  	return 2
   465  }
   466  
   467  // PTTCMOSOffset0Size returns the size in bytes of the value of field PTTCMOSOffset0
   468  func (s *TXT) PTTCMOSOffset0TotalSize() uint64 {
   469  	return 1
   470  }
   471  
   472  // PTTCMOSOffset1Size returns the size in bytes of the value of field PTTCMOSOffset1
   473  func (s *TXT) PTTCMOSOffset1TotalSize() uint64 {
   474  	return 1
   475  }
   476  
   477  // ACPIBaseOffsetSize returns the size in bytes of the value of field ACPIBaseOffset
   478  func (s *TXT) ACPIBaseOffsetTotalSize() uint64 {
   479  	return 2
   480  }
   481  
   482  // Reserved2Size returns the size in bytes of the value of field Reserved2
   483  func (s *TXT) Reserved2TotalSize() uint64 {
   484  	return 2
   485  }
   486  
   487  // PwrMBaseOffsetSize returns the size in bytes of the value of field PwrMBaseOffset
   488  func (s *TXT) PwrMBaseOffsetTotalSize() uint64 {
   489  	return 4
   490  }
   491  
   492  // DigestListSize returns the size in bytes of the value of field DigestList
   493  func (s *TXT) DigestListTotalSize() uint64 {
   494  	return s.DigestList.TotalSize()
   495  }
   496  
   497  // Reserved3Size returns the size in bytes of the value of field Reserved3
   498  func (s *TXT) Reserved3TotalSize() uint64 {
   499  	return 3
   500  }
   501  
   502  // SegmentCountSize returns the size in bytes of the value of field SegmentCount
   503  func (s *TXT) SegmentCountTotalSize() uint64 {
   504  	return 1
   505  }
   506  
   507  // StructInfoOffset returns the offset in bytes of field StructInfo
   508  func (s *TXT) StructInfoOffset() uint64 {
   509  	return 0
   510  }
   511  
   512  // Reserved0Offset returns the offset in bytes of field Reserved0
   513  func (s *TXT) Reserved0Offset() uint64 {
   514  	return s.StructInfoOffset() + s.StructInfoTotalSize()
   515  }
   516  
   517  // SetNumberOffset returns the offset in bytes of field SetNumber
   518  func (s *TXT) SetNumberOffset() uint64 {
   519  	return s.Reserved0Offset() + s.Reserved0TotalSize()
   520  }
   521  
   522  // SInitMinSVNAuthOffset returns the offset in bytes of field SInitMinSVNAuth
   523  func (s *TXT) SInitMinSVNAuthOffset() uint64 {
   524  	return s.SetNumberOffset() + s.SetNumberTotalSize()
   525  }
   526  
   527  // Reserved1Offset returns the offset in bytes of field Reserved1
   528  func (s *TXT) Reserved1Offset() uint64 {
   529  	return s.SInitMinSVNAuthOffset() + s.SInitMinSVNAuthTotalSize()
   530  }
   531  
   532  // ControlFlagsOffset returns the offset in bytes of field ControlFlags
   533  func (s *TXT) ControlFlagsOffset() uint64 {
   534  	return s.Reserved1Offset() + s.Reserved1TotalSize()
   535  }
   536  
   537  // PwrDownIntervalOffset returns the offset in bytes of field PwrDownInterval
   538  func (s *TXT) PwrDownIntervalOffset() uint64 {
   539  	return s.ControlFlagsOffset() + s.ControlFlagsTotalSize()
   540  }
   541  
   542  // PTTCMOSOffset0Offset returns the offset in bytes of field PTTCMOSOffset0
   543  func (s *TXT) PTTCMOSOffset0Offset() uint64 {
   544  	return s.PwrDownIntervalOffset() + s.PwrDownIntervalTotalSize()
   545  }
   546  
   547  // PTTCMOSOffset1Offset returns the offset in bytes of field PTTCMOSOffset1
   548  func (s *TXT) PTTCMOSOffset1Offset() uint64 {
   549  	return s.PTTCMOSOffset0Offset() + s.PTTCMOSOffset0TotalSize()
   550  }
   551  
   552  // ACPIBaseOffsetOffset returns the offset in bytes of field ACPIBaseOffset
   553  func (s *TXT) ACPIBaseOffsetOffset() uint64 {
   554  	return s.PTTCMOSOffset1Offset() + s.PTTCMOSOffset1TotalSize()
   555  }
   556  
   557  // Reserved2Offset returns the offset in bytes of field Reserved2
   558  func (s *TXT) Reserved2Offset() uint64 {
   559  	return s.ACPIBaseOffsetOffset() + s.ACPIBaseOffsetTotalSize()
   560  }
   561  
   562  // PwrMBaseOffsetOffset returns the offset in bytes of field PwrMBaseOffset
   563  func (s *TXT) PwrMBaseOffsetOffset() uint64 {
   564  	return s.Reserved2Offset() + s.Reserved2TotalSize()
   565  }
   566  
   567  // DigestListOffset returns the offset in bytes of field DigestList
   568  func (s *TXT) DigestListOffset() uint64 {
   569  	return s.PwrMBaseOffsetOffset() + s.PwrMBaseOffsetTotalSize()
   570  }
   571  
   572  // Reserved3Offset returns the offset in bytes of field Reserved3
   573  func (s *TXT) Reserved3Offset() uint64 {
   574  	return s.DigestListOffset() + s.DigestListTotalSize()
   575  }
   576  
   577  // SegmentCountOffset returns the offset in bytes of field SegmentCount
   578  func (s *TXT) SegmentCountOffset() uint64 {
   579  	return s.Reserved3Offset() + s.Reserved3TotalSize()
   580  }
   581  
   582  // Size returns the total size of the TXT.
   583  func (s *TXT) TotalSize() uint64 {
   584  	if s == nil {
   585  		return 0
   586  	}
   587  
   588  	var size uint64
   589  	size += s.StructInfoTotalSize()
   590  	size += s.Reserved0TotalSize()
   591  	size += s.SetNumberTotalSize()
   592  	size += s.SInitMinSVNAuthTotalSize()
   593  	size += s.Reserved1TotalSize()
   594  	size += s.ControlFlagsTotalSize()
   595  	size += s.PwrDownIntervalTotalSize()
   596  	size += s.PTTCMOSOffset0TotalSize()
   597  	size += s.PTTCMOSOffset1TotalSize()
   598  	size += s.ACPIBaseOffsetTotalSize()
   599  	size += s.Reserved2TotalSize()
   600  	size += s.PwrMBaseOffsetTotalSize()
   601  	size += s.DigestListTotalSize()
   602  	size += s.Reserved3TotalSize()
   603  	size += s.SegmentCountTotalSize()
   604  	return size
   605  }
   606  
   607  // PrettyString returns the content of the structure in an easy-to-read format.
   608  func (s *TXT) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string {
   609  	var lines []string
   610  	if withHeader {
   611  		lines = append(lines, pretty.Header(depth, "TXT", s))
   612  	}
   613  	if s == nil {
   614  		return strings.Join(lines, "\n")
   615  	}
   616  	// ManifestFieldType is structInfo
   617  	lines = append(lines, pretty.SubValue(depth+1, "Struct Info", "", &s.StructInfo, opts...)...)
   618  	// ManifestFieldType is arrayStatic
   619  	lines = append(lines, pretty.SubValue(depth+1, "Reserved 0", "", &s.Reserved0, opts...)...)
   620  	// ManifestFieldType is arrayStatic
   621  	lines = append(lines, pretty.SubValue(depth+1, "Set Number", "", &s.SetNumber, opts...)...)
   622  	// ManifestFieldType is endValue
   623  	lines = append(lines, pretty.SubValue(depth+1, "S Init Min SVN Auth", "", &s.SInitMinSVNAuth, opts...)...)
   624  	// ManifestFieldType is arrayStatic
   625  	lines = append(lines, pretty.SubValue(depth+1, "Reserved 1", "", &s.Reserved1, opts...)...)
   626  	// ManifestFieldType is endValue
   627  	lines = append(lines, pretty.SubValue(depth+1, "Control Flags", "", &s.ControlFlags, opts...)...)
   628  	// ManifestFieldType is endValue
   629  	lines = append(lines, pretty.SubValue(depth+1, "Pwr Down Interval", "", &s.PwrDownInterval, opts...)...)
   630  	// ManifestFieldType is endValue
   631  	lines = append(lines, pretty.SubValue(depth+1, "PTT CMOS Offset 0", "", &s.PTTCMOSOffset0, opts...)...)
   632  	// ManifestFieldType is endValue
   633  	lines = append(lines, pretty.SubValue(depth+1, "PTT CMOS Offset 1", "", &s.PTTCMOSOffset1, opts...)...)
   634  	// ManifestFieldType is endValue
   635  	lines = append(lines, pretty.SubValue(depth+1, "ACPI Base Offset", "", &s.ACPIBaseOffset, opts...)...)
   636  	// ManifestFieldType is arrayStatic
   637  	lines = append(lines, pretty.SubValue(depth+1, "Reserved 2", "", &s.Reserved2, opts...)...)
   638  	// ManifestFieldType is endValue
   639  	lines = append(lines, pretty.SubValue(depth+1, "ACPI MMIO Offset", "", &s.PwrMBaseOffset, opts...)...)
   640  	// ManifestFieldType is subStruct
   641  	lines = append(lines, pretty.SubValue(depth+1, "Digest List", "", &s.DigestList, opts...)...)
   642  	// ManifestFieldType is arrayStatic
   643  	lines = append(lines, pretty.SubValue(depth+1, "Reserved 3", "", &s.Reserved3, opts...)...)
   644  	// ManifestFieldType is endValue
   645  	lines = append(lines, pretty.SubValue(depth+1, "Segment Count", "", &s.SegmentCount, opts...)...)
   646  	if depth < 2 {
   647  		lines = append(lines, "")
   648  	}
   649  	return strings.Join(lines, "\n")
   650  }
   651  
   652  // PrettyString returns the bits of the flags in an easy-to-read format.
   653  func (v Duration16In5Sec) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string {
   654  	return v.String()
   655  }
   656  
   657  // TotalSize returns the total size measured through binary.Size.
   658  func (v Duration16In5Sec) TotalSize() uint64 {
   659  	return uint64(binary.Size(v))
   660  }
   661  
   662  // WriteTo writes the Duration16In5Sec into 'w' in binary format.
   663  func (v Duration16In5Sec) WriteTo(w io.Writer) (int64, error) {
   664  	return int64(v.TotalSize()), binary.Write(w, binary.LittleEndian, v)
   665  }
   666  
   667  // ReadFrom reads the Duration16In5Sec from 'r' in binary format.
   668  func (v Duration16In5Sec) ReadFrom(r io.Reader) (int64, error) {
   669  	return int64(v.TotalSize()), binary.Read(r, binary.LittleEndian, v)
   670  }