-
Notifications
You must be signed in to change notification settings - Fork 394
/
efiDppHardware.go
77 lines (64 loc) · 1.77 KB
/
efiDppHardware.go
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
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright 2020 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// SPDX-License-Identifier: BSD-3-Clause
//
package boot
import (
"fmt"
)
// EfiDppHwSubType is the dpp subtype for hardware.
type EfiDppHwSubType EfiDevPathProtoSubType
const (
DppHTypePCI EfiDppHwSubType = iota + 1
DppHTypePCCARD
DppHTypeMMap
DppHTypeVendor
DppHTypeCtrl
DppHTypeBMC
)
var efiDppHwSubTypeStrings = map[EfiDppHwSubType]string{
DppHTypePCI: "PCI",
DppHTypePCCARD: "PCCARD",
DppHTypeMMap: "MMap",
DppHTypeVendor: "Vendor",
DppHTypeCtrl: "Control",
DppHTypeBMC: "BMC",
}
func (e EfiDppHwSubType) String() string {
if s, ok := efiDppHwSubTypeStrings[e]; ok {
return s
}
return fmt.Sprintf("UNKNOWN-0x%x", uint8(e))
}
// DppHwPci is the struct in EfiDevicePathProtocol for DppHTypePCI
type DppHwPci struct {
Hdr EfiDevicePathProtocolHdr
Function, Device uint8
}
var _ EfiDevicePathProtocol = (*DppHwPci)(nil)
// Parses input into a DppHwPci struct.
func ParseDppHwPci(h EfiDevicePathProtocolHdr, b []byte) (*DppHwPci, error) {
if len(b) != 2 {
return nil, ErrParse
}
return &DppHwPci{
Hdr: h,
Function: b[0],
Device: b[1],
}, nil
}
func (e *DppHwPci) Header() EfiDevicePathProtocolHdr { return e.Hdr }
// ProtoSubTypeStr returns the subtype as human readable.
func (e *DppHwPci) ProtoSubTypeStr() string {
return EfiDppHwSubType(e.Hdr.ProtoSubType).String()
}
func (e *DppHwPci) String() string {
return fmt.Sprintf("PCI(0x%x,0x%x)", e.Function, e.Device)
}
// Resolver returns a nil EfiPathSegmentResolver and ErrUnimpl. See the comment
// associated with ErrUnimpl.
func (e *DppHwPci) Resolver() (EfiPathSegmentResolver, error) {
return nil, ErrUnimpl
}