Documentation
¶
Overview ¶
Package boot manipulates UEFI boot variables, and can identify and mount the volume referenced by a boot var.
Index ¶
- Constants
- Variables
- func AllBootVars() uefivars.EfiVars
- func BootEntryFilter(uuid, name string) bool
- func BootVarFilter(uuid, name string) bool
- func IsBootEntry(e uefivars.EfiVar) bool
- type BootCurrentVar
- type BootEntryVar
- type BootEntryVars
- type DppAcpiDevPath
- type DppAcpiExDevPath
- type DppHwPci
- type DppMediaFilePath
- type DppMediaHDD
- type DppMediaPIWGFF
- type DppMediaPIWGFV
- type DppMsgATAPI
- type DppMsgMAC
- type EfiDevPathEnd
- type EfiDevPathProtoSubType
- type EfiDevPathProtoType
- type EfiDevPathRaw
- type EfiDevicePathProtocol
- type EfiDevicePathProtocolHdr
- type EfiDevicePathProtocolList
- type EfiDppACPISubType
- type EfiDppEndSubType
- type EfiDppHwSubType
- type EfiDppMediaSubType
- type EfiDppMsgSubType
- type EfiLoadOption
- type EfiPathSegmentResolver
- type HddResolver
- type PathResolver
Constants ¶
const (
BootUUID = "8be4df61-93ca-11d2-aa0d-00e098032b8c"
)
Variables ¶
var ( Verbose bool ErrParse = errors.New("parse error") ErrNotFound = errors.New("described device not found") // ErrUnimpl is returned when we do not implement the Device Path // Protocol entry type, because the Device Path Protocol is used for // more than boot entries. Some types aren't suitable for boot entries, // so a resolver doesn't make sense. // // There are probably others which can be used for boot entries, but are // not implemented simply because they have not been needed yet. ErrUnimpl = errors.New("not implemented") )
Functions ¶
func AllBootVars ¶
AllBootVars returns all uefi vars that use the boot UUID and whose names begin with Boot.
These include:
- BootXXXX (individual boot entries, XXXX is hex)
- BootCurrent (marks whichever BootXXXX entry was used this boot)
- BootOptionSupport
- BootNext (can specify a particular entry to use next boot)
- BootOrder (the order in which entries are tried)
func BootEntryFilter ¶
A VarNameFilter passing boot entries. These are a subset of the vars returned by BootVarFilter.
func BootVarFilter ¶
A VarNameFilter passing boot-related vars. These are a superset of those returned by BootEntryFilter.
func IsBootEntry ¶
IsBootEntry returns true if the given var is a boot entry.
Types ¶
type BootCurrentVar ¶
BootCurrentVar represents the UEFI BootCurrent var.
func BootCurrent ¶
func BootCurrent(vars uefivars.EfiVars) *BootCurrentVar
BootCurrent returns the BootCurrent var, if any, from the given list.
func ReadBootCurrent ¶
func ReadBootCurrent() *BootCurrentVar
ReadBootCurrent reads and returns the BootCurrent var.
type BootEntryVar ¶
type BootEntryVar struct {
Number uint16 // from the var name
EfiLoadOption
}
BootEntryVar is a boot entry. It will have the name BootXXXX where XXXX is hexadecimal.
func BootVar ¶
func BootVar(v uefivars.EfiVar) (b *BootEntryVar)
BootVar decodes an efivar as a boot entry. use IsBootEntry() to screen first.
func ReadBootVar ¶
func ReadBootVar(num uint16) (*BootEntryVar, error)
Gets BootXXXX var, if it exists
func ReadCurrentBootVar ¶
func ReadCurrentBootVar() (*BootEntryVar, error)
Reads BootCurrent, and from there gets the BootXXXX var referenced.
func (BootEntryVar) String ¶
func (b BootEntryVar) String() string
type BootEntryVars ¶
type BootEntryVars []*BootEntryVar
func AllBootEntryVars ¶
func AllBootEntryVars() BootEntryVars
AllBootEntryVars returns list of boot entries (BootXXXX). Note that BootCurrent, BootOptionSupport, BootNext, BootOrder, etc do not count as boot entries.
func BootEntries ¶
func BootEntries(vars uefivars.EfiVars) (bootvars BootEntryVars)
BootEntries takes a list of efi vars and parses any that are boot entries, returning a list of them.
type DppAcpiDevPath ¶
type DppAcpiDevPath struct {
Hdr EfiDevicePathProtocolHdr
HID, UID []byte // both length 4; not sure of endianness
}
DppAcpiDevPath is an acpi device path.
func ParseDppAcpiDevPath ¶
func ParseDppAcpiDevPath(h EfiDevicePathProtocolHdr, b []byte) (*DppAcpiDevPath, error)
ParseDppAcpiDevPath parses input into a DppAcpiDevPath.
func (*DppAcpiDevPath) Header ¶
func (e *DppAcpiDevPath) Header() EfiDevicePathProtocolHdr
func (*DppAcpiDevPath) ProtoSubTypeStr ¶
func (e *DppAcpiDevPath) ProtoSubTypeStr() string
ProtoSubTypeStr returns the subtype as human readable.
func (*DppAcpiDevPath) Resolver ¶
func (e *DppAcpiDevPath) Resolver() (EfiPathSegmentResolver, error)
Resolver returns a nil EfiPathSegmentResolver and ErrUnimpl. See the comment associated with ErrUnimpl.
func (*DppAcpiDevPath) String ¶
func (e *DppAcpiDevPath) String() string
type DppAcpiExDevPath ¶
type DppAcpiExDevPath struct {
Hdr EfiDevicePathProtocolHdr
HID, UID, CID []byte // all length 4; not sure of endianness
HIDSTR, UIDSTR, CIDSTR string
}
DppAcpiExDevPath is an expanded dpp acpi device path.
func ParseDppAcpiExDevPath ¶
func ParseDppAcpiExDevPath(h EfiDevicePathProtocolHdr, b []byte) (*DppAcpiExDevPath, error)
ParseDppAcpiExDevPath parses input into a DppAcpiExDevPath.
func (*DppAcpiExDevPath) Header ¶
func (e *DppAcpiExDevPath) Header() EfiDevicePathProtocolHdr
func (*DppAcpiExDevPath) ProtoSubTypeStr ¶
func (e *DppAcpiExDevPath) ProtoSubTypeStr() string
ProtoSubTypeStr returns the subtype as human readable.
func (*DppAcpiExDevPath) Resolver ¶
func (e *DppAcpiExDevPath) Resolver() (EfiPathSegmentResolver, error)
Resolver returns a nil EfiPathSegmentResolver and ErrUnimpl. See the comment associated with ErrUnimpl.
func (*DppAcpiExDevPath) String ¶
func (e *DppAcpiExDevPath) String() string
type DppHwPci ¶
type DppHwPci struct {
Hdr EfiDevicePathProtocolHdr
Function, Device uint8
}
DppHwPci is the struct in EfiDevicePathProtocol for DppHTypePCI
func ParseDppHwPci ¶
func ParseDppHwPci(h EfiDevicePathProtocolHdr, b []byte) (*DppHwPci, error)
Parses input into a DppHwPci struct.
func (*DppHwPci) Header ¶
func (e *DppHwPci) Header() EfiDevicePathProtocolHdr
func (*DppHwPci) ProtoSubTypeStr ¶
ProtoSubTypeStr returns the subtype as human readable.
func (*DppHwPci) Resolver ¶
func (e *DppHwPci) Resolver() (EfiPathSegmentResolver, error)
Resolver returns a nil EfiPathSegmentResolver and ErrUnimpl. See the comment associated with ErrUnimpl.
type DppMediaFilePath ¶
type DppMediaFilePath struct {
Hdr EfiDevicePathProtocolHdr
PathNameDecoded string // stored as utf16
}
DppMediaFilePath is a struct in EfiDevicePathProtocol for DppMTypeFilePath.
If multiple are included in a load option, the docs say to concatenate them.
func ParseDppMediaFilePath ¶
func ParseDppMediaFilePath(h EfiDevicePathProtocolHdr, b []byte) (*DppMediaFilePath, error)
func (*DppMediaFilePath) Header ¶
func (e *DppMediaFilePath) Header() EfiDevicePathProtocolHdr
func (*DppMediaFilePath) ProtoSubTypeStr ¶
func (e *DppMediaFilePath) ProtoSubTypeStr() string
ProtoSubTypeStr returns the subtype as human readable.
func (*DppMediaFilePath) Resolver ¶
func (e *DppMediaFilePath) Resolver() (EfiPathSegmentResolver, error)
Resolver returns an EfiPathSegmentResolver decoding the DppMediaFilePath.
func (*DppMediaFilePath) String ¶
func (e *DppMediaFilePath) String() string
type DppMediaHDD ¶
type DppMediaHDD struct {
Hdr EfiDevicePathProtocolHdr
PartNum uint32 // index into partition table for MBR or GPT; 0 indicates entire disk
PartStart uint64 // starting LBA. only used for MBR?
PartSize uint64 // size in LB's. only used for MBR?
PartSig uefivars.MixedGUID // format determined by SigType below. unused bytes must be 0x0.
PartFmt uint8 // 0x01 for MBR, 0x02 for GPT
SigType uint8 // 0x00 - none; 0x01 - 32bit MBR sig (@ 0x1b8); 0x02 - GUID
}
DppMediaHDD is the struct in EfiDevicePathProtocol for DppMTypeHdd
func ParseDppMediaHdd ¶
func ParseDppMediaHdd(h EfiDevicePathProtocolHdr, b []byte) (*DppMediaHDD, error)
ParseDppMediaHdd parses input into a DppMediaHDD struct.
func (*DppMediaHDD) Header ¶
func (e *DppMediaHDD) Header() EfiDevicePathProtocolHdr
func (*DppMediaHDD) ProtoSubTypeStr ¶
func (e *DppMediaHDD) ProtoSubTypeStr() string
ProtoSubTypeStr returns the subtype as human readable.
func (*DppMediaHDD) Resolver ¶
func (e *DppMediaHDD) Resolver() (EfiPathSegmentResolver, error)
Resolver returns an EfiPathSegmentResolver which can find and mount the partition described by DppMediaHDD.
func (*DppMediaHDD) String ¶
func (e *DppMediaHDD) String() string
type DppMediaPIWGFF ¶
type DppMediaPIWGFF struct {
Hdr EfiDevicePathProtocolHdr
Ff []byte
}
struct in EfiDevicePathProtocol for DppMTypePIWGFF
func ParseDppMediaPIWGFF ¶
func ParseDppMediaPIWGFF(h EfiDevicePathProtocolHdr, b []byte) (*DppMediaPIWGFF, error)
ParseDppMediaPIWGFF parses the input into a DppMediaPIWGFF.
func (*DppMediaPIWGFF) Header ¶
func (e *DppMediaPIWGFF) Header() EfiDevicePathProtocolHdr
func (*DppMediaPIWGFF) ProtoSubTypeStr ¶
func (e *DppMediaPIWGFF) ProtoSubTypeStr() string
ProtoSubTypeStr returns the subtype as human readable.
func (*DppMediaPIWGFF) Resolver ¶
func (e *DppMediaPIWGFF) Resolver() (EfiPathSegmentResolver, error)
Resolver returns a nil EfiPathSegmentResolver and ErrUnimpl. See the comment associated with ErrUnimpl.
func (*DppMediaPIWGFF) String ¶
func (e *DppMediaPIWGFF) String() string
type DppMediaPIWGFV ¶
type DppMediaPIWGFV struct {
Hdr EfiDevicePathProtocolHdr
Fv []byte
}
struct in EfiDevicePathProtocol for DppMTypePIWGFV
func ParseDppMediaPIWGFV ¶
func ParseDppMediaPIWGFV(h EfiDevicePathProtocolHdr, b []byte) (*DppMediaPIWGFV, error)
ParseDppMediaPIWGFV parses input into a DppMediaPIWGFV.
func (*DppMediaPIWGFV) Header ¶
func (e *DppMediaPIWGFV) Header() EfiDevicePathProtocolHdr
func (*DppMediaPIWGFV) ProtoSubTypeStr ¶
func (e *DppMediaPIWGFV) ProtoSubTypeStr() string
ProtoSubTypeStr returns the subtype as human readable.
func (*DppMediaPIWGFV) Resolver ¶
func (e *DppMediaPIWGFV) Resolver() (EfiPathSegmentResolver, error)
Resolver returns a nil EfiPathSegmentResolver and ErrUnimpl. See the comment associated with ErrUnimpl.
func (*DppMediaPIWGFV) String ¶
func (e *DppMediaPIWGFV) String() string
type DppMsgATAPI ¶
type DppMsgATAPI struct {
Hdr EfiDevicePathProtocolHdr
Primary, Master bool
LUN uint16
}
DppMsgATAPI is a struct describing an atapi dpp message. pg 293
func ParseDppMsgATAPI ¶
func ParseDppMsgATAPI(h EfiDevicePathProtocolHdr, b []byte) (*DppMsgATAPI, error)
ParseDppMsgATAPI parses input into a DppMsgATAPI.
func (*DppMsgATAPI) Header ¶
func (e *DppMsgATAPI) Header() EfiDevicePathProtocolHdr
func (*DppMsgATAPI) ProtoSubTypeStr ¶
func (e *DppMsgATAPI) ProtoSubTypeStr() string
ProtoSubTypeStr returns the subtype as human readable.
func (*DppMsgATAPI) Resolver ¶
func (e *DppMsgATAPI) Resolver() (EfiPathSegmentResolver, error)
Resolver returns a nil EfiPathSegmentResolver and ErrUnimpl. See the comment associated with ErrUnimpl.
func (*DppMsgATAPI) String ¶
func (e *DppMsgATAPI) String() string
type DppMsgMAC ¶
type DppMsgMAC struct {
Hdr EfiDevicePathProtocolHdr
Mac [32]byte // 0-padded
IfType uint8 // RFC3232; seems ethernet is 6
}
DppMsgMAC contains a MAC address. pg 300
func ParseDppMsgMAC ¶
func ParseDppMsgMAC(h EfiDevicePathProtocolHdr, b []byte) (*DppMsgMAC, error)
ParseDppMsgMAC parses input into a DppMsgMAC.
func (*DppMsgMAC) Header ¶
func (e *DppMsgMAC) Header() EfiDevicePathProtocolHdr
func (*DppMsgMAC) ProtoSubTypeStr ¶
ProtoSubTypeStr returns the subtype as human readable.
func (*DppMsgMAC) Resolver ¶
func (e *DppMsgMAC) Resolver() (EfiPathSegmentResolver, error)
Resolver returns a nil EfiPathSegmentResolver and ErrUnimpl. See the comment associated with ErrUnimpl.
type EfiDevPathEnd ¶
type EfiDevPathEnd struct {
Hdr EfiDevicePathProtocolHdr
}
EfiDevPathEnd marks end of EfiDevicePathProtocol.
func (*EfiDevPathEnd) Header ¶
func (e *EfiDevPathEnd) Header() EfiDevicePathProtocolHdr
func (*EfiDevPathEnd) ProtoSubTypeStr ¶
func (e *EfiDevPathEnd) ProtoSubTypeStr() string
ProtoSubTypeStr returns the subtype as human readable.
func (*EfiDevPathEnd) Resolver ¶
func (e *EfiDevPathEnd) Resolver() (EfiPathSegmentResolver, error)
func (*EfiDevPathEnd) String ¶
func (e *EfiDevPathEnd) String() string
type EfiDevPathProtoSubType ¶
type EfiDevPathProtoSubType uint8
EfiDevPathProtoSubType is a dpp subtype in the spec. We only define media and end subtypes; others exist in spec.
type EfiDevPathProtoType ¶
type EfiDevPathProtoType uint8
const ( DppTypeHw EfiDevPathProtoType = iota + 1 // 0x01, pg 288 DppTypeACPI // 0x02, pg 290 DppTypeMessaging // 0x03, pg 293 DppTypeMedia // 0x04, pg 319 DppTypeBBS // 0x05, pg 287 DppTypeEnd EfiDevPathProtoType = 0x7f )
func (EfiDevPathProtoType) String ¶
func (e EfiDevPathProtoType) String() string
type EfiDevPathRaw ¶
type EfiDevPathRaw struct {
Hdr EfiDevicePathProtocolHdr
Raw []byte
}
func (*EfiDevPathRaw) Header ¶
func (e *EfiDevPathRaw) Header() EfiDevicePathProtocolHdr
func (*EfiDevPathRaw) ProtoSubTypeStr ¶
func (e *EfiDevPathRaw) ProtoSubTypeStr() string
ProtoSubTypeStr returns the subtype as human readable.
func (*EfiDevPathRaw) Resolver ¶
func (e *EfiDevPathRaw) Resolver() (EfiPathSegmentResolver, error)
func (*EfiDevPathRaw) String ¶
func (e *EfiDevPathRaw) String() string
type EfiDevicePathProtocol ¶
type EfiDevicePathProtocol interface {
// Header returns the EfiDevicePathProtocolHdr.
Header() EfiDevicePathProtocolHdr
// ProtoSubTypeStr returns the subtype as human readable.
ProtoSubTypeStr() string
// String returns the path as human readable.
String() string
// Resolver returns an EfiPathSegmentResolver. In the case of filesystems,
// this locates and mounts the device.
Resolver() (EfiPathSegmentResolver, error)
}
EfiDevicePathProtocol identifies a device path.
type EfiDevicePathProtocolHdr ¶
type EfiDevicePathProtocolHdr struct {
ProtoType EfiDevPathProtoType
ProtoSubType EfiDevPathProtoSubType
Length uint16
}
EfiDevicePathProtocolHdr is three one-byte fields that all DevicePathProtocol entries begin with.
typedef struct _EFI_DEVICE_PATH_PROTOCOL {
UINT8 Type;
UINT8 SubType;
UINT8 Length[2];
} EFI_DEVICE_PATH_PROTOCOL;
It seems that the only relevant Type (for booting) is media.
https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_A_Feb14.pdf pg 286 +
type EfiDevicePathProtocolList ¶
type EfiDevicePathProtocolList []EfiDevicePathProtocol
func ParseFilePathList ¶
func ParseFilePathList(in []byte) (EfiDevicePathProtocolList, error)
ParseFilePathList decodes a FilePathList as found in a boot var.
func (EfiDevicePathProtocolList) String ¶
func (list EfiDevicePathProtocolList) String() string
type EfiDppACPISubType ¶
type EfiDppACPISubType EfiDevPathProtoSubType
EfiDppACPISubType is the dpp subtype for ACPI.
const ( DppAcpiTypeDevPath EfiDppACPISubType = iota + 1 DppAcpiTypeExpandedDevPath DppAcpiTypeADR DppAcpiTypeNVDIMM )
func (EfiDppACPISubType) String ¶
func (e EfiDppACPISubType) String() string
type EfiDppEndSubType ¶
type EfiDppEndSubType EfiDevPathProtoSubType
EfiDppEndSubType defines the end of a device path protocol sequence.
const ( // DppTypeEnd, pg 287-288 DppETypeEndStartNew EfiDppEndSubType = 0x01 // only for DppTypeHw? DppETypeEndEntire EfiDppEndSubType = 0xff )
func (EfiDppEndSubType) String ¶
func (e EfiDppEndSubType) String() string
type EfiDppHwSubType ¶
type EfiDppHwSubType EfiDevPathProtoSubType
EfiDppHwSubType is the dpp subtype for hardware.
const ( DppHTypePCI EfiDppHwSubType = iota + 1 DppHTypePCCARD DppHTypeMMap DppHTypeVendor DppHTypeCtrl DppHTypeBMC )
func (EfiDppHwSubType) String ¶
func (e EfiDppHwSubType) String() string
type EfiDppMediaSubType ¶
type EfiDppMediaSubType EfiDevPathProtoSubType
const ( // DppTypeMedia, pg 319 + DppMTypeHdd EfiDppMediaSubType = iota + 1 // 0x01 DppMTypeCd // 0x02 DppMTypeVendor // 0x03 DppMTypeFilePath // 0x04 //p321 DppMTypeMedia // 0x05 //media protocol i.e. filesystem format?? DppMTypePIWGFF // 0x06 DppMTypePIWGFV // 0x07 DppMTypeRelOff // 0x08 DppMTypeRAM // 0x09 )
func (EfiDppMediaSubType) String ¶
func (e EfiDppMediaSubType) String() string
type EfiDppMsgSubType ¶
type EfiDppMsgSubType EfiDevPathProtoSubType
const ( DppMsgTypeATAPI EfiDppMsgSubType = iota + 1 DppMsgTypeSCSI // 2 DppMsgTypeFibreCh // 3 DppMsgTypeFirewire // 4 DppMsgTypeUSB // 5 DppMsgTypeIIO // 6 DppMsgTypeInfiniband // 9 DppMsgTypeVendor // 10 //uart flow control, sas are subtypes DppMsgTypeMAC // 11 DppMsgTypeIP4 // 12 DppMsgTypeIP6 // 13 DppMsgTypeUART // 14 DppMsgTypeUSBClass // 15 DppMsgTypeUSBWWID // 16 DppMsgTypeDevLU // 17 DppMsgTypeSATA // 18 DppMsgTypeISCSI // 19 DppMsgTypeVLAN // 20 DppMsgTypeSASEx // 22 DppMsgTypeNVME // 23 DppMsgTypeURI // 24 DppMsgTypeUFS // 25 DppMsgTypeSD // 26 DppMsgTypeBT // 27 DppMsgTypeWiFi // 28 DppMsgTypeeMMC // 29 DppMsgTypeBLE // 30 DppMsgTypeDNS // 31 DppMsgTypeNVDIMM // 32 DppMsgTypeRest // documented as 32, likely 33 )
func (EfiDppMsgSubType) String ¶
func (e EfiDppMsgSubType) String() string
type EfiLoadOption ¶
type EfiLoadOption struct {
Attributes uint32
FilePathListLength uint16
Description string
FilePathList EfiDevicePathProtocolList
OptionalData []byte
}
EfiLoadOption defines the data struct used for vars such as BootXXXX.
As defined in UEFI spec v2.8A:
typedef struct _EFI_LOAD_OPTION {
UINT32 Attributes;
UINT16 FilePathListLength;
// CHAR16 Description[];
// EFI_DEVICE_PATH_PROTOCOL FilePathList[];
// UINT8 OptionalData[];
} EFI_LOAD_OPTION;
type EfiPathSegmentResolver ¶
type EfiPathSegmentResolver interface {
// Returns description, does not require cleanup
String() string
// Mount fs, etc. You must call Cleanup() eventually.
Resolve(suggestedBasePath string) (string, error)
// For devices, returns BlockDev. Returns nil otherwise.
BlockInfo() *block.BlockDev
// For mounted devices, returns MountPoint. Returns nil otherwise.
MntPoint() *mount.MountPoint
// Unmount fs, free resources, etc
Cleanup() error
}
type HddResolver ¶
type HddResolver struct {
*block.BlockDev
*mount.MountPoint
}
HddResolver can identify and mount a partition.
func (*HddResolver) BlockInfo ¶
func (r *HddResolver) BlockInfo() *block.BlockDev
func (*HddResolver) Cleanup ¶
func (r *HddResolver) Cleanup() error
func (*HddResolver) MntPoint ¶
func (r *HddResolver) MntPoint() *mount.MountPoint
func (*HddResolver) String ¶
func (r *HddResolver) String() string
type PathResolver ¶
type PathResolver string
PathResolver outputs a file path.
func (*PathResolver) BlockInfo ¶
func (r *PathResolver) BlockInfo() *block.BlockDev
func (*PathResolver) Cleanup ¶
func (r *PathResolver) Cleanup() error
func (*PathResolver) MntPoint ¶
func (r *PathResolver) MntPoint() *mount.MountPoint
func (*PathResolver) String ¶
func (r *PathResolver) String() string