github.com/linuxboot/fiano@v1.2.0/pkg/intel/metadata/cbnt/chipset_ac_module_information_nocodegen.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 // 9 // To avoid errors "type ChipsetACModuleInformation has no field or method ReadFrom" 10 // with a build tag "!manifestcodegen" 11 12 package cbnt 13 14 import ( 15 "bytes" 16 "encoding/binary" 17 "fmt" 18 "io" 19 ) 20 21 // ParseChipsetACModuleInformation parses Chipset AC Module Information Table according to the version 22 func ParseChipsetACModuleInformation(r io.Reader) (int64, ChipsetACModuleInformationV5, error) { 23 var result ChipsetACModuleInformationV5 24 total, err := result.Base.ReadFrom(r) 25 if !bytes.Equal(result.Base.UUID[:], chipsetACModuleInformationSignature) { 26 return 0, ChipsetACModuleInformationV5{}, fmt.Errorf( 27 "incorrect UUID [%x], expected: [%x]", result.Base.UUID, chipsetACModuleInformationSignature) 28 } 29 if err != nil { 30 return total, result, err 31 } 32 if result.Base.Version < 5 { 33 return total, result, nil 34 } 35 err = binary.Read(r, binary.LittleEndian, &result.TPMInfoList) 36 total += int64(binary.Size(result.TPMInfoList)) 37 return total, result, err 38 }