efi

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Some simple EFI utilities. These are inspired and adapted from https://github.com/u-root/u-root/blob/master/pkg/uefivars https://github.com/Foxboron/go-uefi

Also useful references https://www.kernel.org/doc/html/latest/filesystems/efivarfs.html https://github.com/rhboot/efivar/ https://github.com/rhboot/efivar/blob/master/src/guids.txt https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-firmware-efi-vars

Index

Constants

View Source
const (
	EFI_VARIABLE_NON_VOLATILE                          Attributes = 0x00000001
	EFI_VARIABLE_BOOTSERVICE_ACCESS                               = 0x00000002
	EFI_VARIABLE_RUNTIME_ACCESS                                   = 0x00000004
	EFI_VARIABLE_HARDWARE_ERROR_RECORD                            = 0x00000008
	EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS                       = 0x00000010
	EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS            = 0x00000020
	EFI_VARIABLE_APPEND_WRITE                                     = 0x00000040
	EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS                    = 0x00000080
)

From the UEFI spec

View Source
const (
	BootUUID       = "8be4df61-93ca-11d2-aa0d-00e098032b8c"
	BootLoaderUUID = "4a67b082-0a4c-41cf-b6c7-440b29bb8c4f"
)

Variables

This section is empty.

Functions

func ReadLoaderEntrySelected

func ReadLoaderEntrySelected() (string, error)

func ReadSecureBoot

func ReadSecureBoot() (bool, error)

func ReadSetupMode

func ReadSetupMode() (bool, error)

func ReadVarAsBool

func ReadVarAsBool(uuid, name string) (bool, error)

func ReadVarAsUTF16

func ReadVarAsUTF16(uuid, name string) (string, error)

Types

type Attributes

type Attributes uint32

Per Linux docs, and uefi specs, there is a 4 byte attribute bitfield

type EfiVar

type EfiVar struct {
	Uuid       string // consider a uuid type?
	Name       string
	Attributes Attributes
	Raw        []byte
}

func ReadVar

func ReadVar(uuid string, name string) (*EfiVar, error)

ReadVar reads a given uuid, name pair from the efivars filesystem and returns an EfiVar struct.

func (*EfiVar) AsBool

func (ev *EfiVar) AsBool() (bool, error)

AsBool converts the raw data to a boolean value.

func (*EfiVar) AsUTF16

func (ev *EfiVar) AsUTF16() (string, error)

AsUTF16 converts the raw data to a utf16 encoded string.

func (*EfiVar) ReadRaw

func (ev *EfiVar) ReadRaw() error

ReadRaw loads the raw data from the efivar filesystem.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL