1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
package device
import (
"encoding/binary"
"io"
"log"
"github.com/foxboron/go-uefi/efi/util"
)
// Subtypes of Messaging Device Path
// Section 10.3.4
const (
_ DevicePathSubType = iota
_
_
_
_
MessagingUSB
_
_
_
_
MessagingVendor
)
type USBMessagingDevicePath struct {
EFIDevicePath
USBParentPortNumber uint8
Interface uint8
}
func (u USBMessagingDevicePath) Format() string {
return "No format"
}
type VendorMessagingDevicePath struct {
EFIDevicePath
Guid util.EFIGUID
}
func (v VendorMessagingDevicePath) Format() string {
return "No format"
}
func ParseMessagingDevicePath(f io.Reader, efi *EFIDevicePath) EFIDevicePaths {
switch efi.SubType {
case MessagingUSB:
u := USBMessagingDevicePath{EFIDevicePath: *efi}
for _, d := range []interface{}{&u.USBParentPortNumber, &u.Interface} {
if err := binary.Read(f, binary.LittleEndian, d); err != nil {
log.Fatalf("Couldn't parse USB Messaging Device Path: %s", err)
}
}
return u
case MessagingVendor:
m := VendorMessagingDevicePath{EFIDevicePath: *efi}
if err := binary.Read(f, binary.LittleEndian, &m.Guid); err != nil {
log.Fatalf("Could not parse Vendor Messaging Device Path: %s", err)
}
default:
log.Printf("Not implemented MessagingDevicePath type: %x\n", efi.SubType)
}
return nil
}
|