github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/pkg/mei/mkhihdr_linux.go (about) 1 // Copyright 2020 the u-root 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 package mei 6 7 // MKHIHdr is the header for every MKHI command, see 8 // https://github.com/coreboot/coreboot/blob/b8b8ec832360ada5a313f10938bb6cfc310a11eb/src/soc/intel/common/block/include/intelblocks/cse.h#L64 9 type mkhiHdr [4]byte 10 11 // GroupID returns the 8-bit mkhi_hdr.group_id field 12 func (mh mkhiHdr) GroupID() uint8 { 13 return mh[0] 14 } 15 16 // SetGroupID sets the GroupID field 17 func (mh *mkhiHdr) SetGroupID(v uint8) { 18 mh[0] = v 19 } 20 21 // Command returns the 7-bit mkhi_hdr.command field 22 func (mh mkhiHdr) Command() uint8 { 23 return mh[1] & 0x7f 24 } 25 26 // SetCommand sets the Command field. Only the first 7 bits will be used 27 func (mh *mkhiHdr) SetCommand(v uint8) { 28 mh[1] = v & 0x7f 29 } 30 31 // IsResponse returns the 1-bit mkhi_hdr.is_resp field as boolean 32 func (mh mkhiHdr) IsResponse() bool { 33 return mh[1]&0x80 == 0x80 34 } 35 36 // SetIsResponse sets the IsResponse field 37 func (mh *mkhiHdr) SetIsResponse(v bool) { 38 if v { 39 mh[1] |= 0x80 40 } else { 41 mh[1] &= ^byte(0x80) 42 } 43 } 44 45 // RSVD returns the 8-bit mkhi_hdr.rsvd field 46 func (mh mkhiHdr) RSVD() uint8 { 47 return mh[2] 48 } 49 50 // SetRSVD sets the RSVD field 51 func (mh *mkhiHdr) SetRSVD(v uint8) { 52 mh[2] = v 53 } 54 55 // Result returns the 8-bit mkhi_hdr.result field 56 func (mh mkhiHdr) Result() uint8 { 57 return mh[3] 58 } 59 60 // SetResult sets the Result field 61 func (mh *mkhiHdr) SetResult(v uint8) { 62 mh[3] = v 63 }