bios

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package bios contains functions to support bios manipulation. Reviews for this package can be sent to tast-fw-library-reviewers@ (before tast-owners@ review).

Index

Constants

View Source
const (
	// HostProgrammer is the flashrom programmer type used to operate with AP firmware chip.
	HostProgrammer FlashromProgrammer = "host"

	// ECProgrammer is the flashrom programmer type used to operate with EC chip.
	ECProgrammer FlashromProgrammer = "ec"

	// BOOTSTUBImageSection is the named section for the Coreboot image (more recent devices use COREBOOT).
	BOOTSTUBImageSection ImageSection = "BOOT_STUB"

	// COREBOOTImageSection is the named section for the Coreboot image.
	COREBOOTImageSection ImageSection = "COREBOOT"

	// GBBImageSection is the named section for GBB as output from dump_fmap.
	GBBImageSection ImageSection = "GBB"

	// ECRWImageSection is the named section for EC writable data as output from dump_fmap.
	ECRWImageSection ImageSection = "EC_RW"

	// ECRWBImageSection is the named section for a secondary EC writable data for EFS.
	ECRWBImageSection ImageSection = "EC_RW_B"

	// EmptyImageSection is the empty string which will result in the whole AP/EC fw backup.
	EmptyImageSection ImageSection = ""
)

Variables

This section is empty.

Functions

func EnableAPSoftwareWriteProtect

func EnableAPSoftwareWriteProtect(ctx context.Context) error

EnableAPSoftwareWriteProtect enables and specifies the RO region for the AP.

func NewImageToFile

func NewImageToFile(ctx context.Context, section ImageSection, programmer FlashromProgrammer) (string, error)

NewImageToFile creates a file representing the desired section of currently loaded firmware image.

func ParseSections

func ParseSections(fmap string) (map[ImageSection]SectionInfo, error)

ParseSections extracts section names and locations from dump_fmap output.

func WriteImageFromFile

func WriteImageFromFile(ctx context.Context, path string, sec ImageSection, programmer FlashromProgrammer) error

WriteImageFromFile writes the provided path in the specified section of the firmware

Types

type FlashromProgrammer

type FlashromProgrammer string

FlashromProgrammer is the type of programmer being passed to flashrom command line.

type Image

type Image struct {
	Data     []byte
	Sections map[ImageSection]SectionInfo
}

Image represents the content and sections of a firmware image.

func NewImage

func NewImage(ctx context.Context, section ImageSection, programmer FlashromProgrammer) (*Image, error)

NewImage creates an Image object representing the currently loaded BIOS image. If you pass in a section, only that section will be read.

func NewImageFromData

func NewImageFromData(data []byte, sections map[ImageSection]SectionInfo) *Image

NewImageFromData creates an Image object from an in memory image.

func (*Image) ClearAndSetGBBFlags

func (i *Image) ClearAndSetGBBFlags(clearFlags, setFlags []pb.GBBFlag) error

ClearAndSetGBBFlags clears and sets the specified flags, leaving the rest unchanged, set has precedence over clear.

func (*Image) GetGBBFlags

func (i *Image) GetGBBFlags() ([]pb.GBBFlag, []pb.GBBFlag, error)

GetGBBFlags returns the list of cleared and list of set flags.

func (*Image) GetLayout

func (i *Image) GetLayout() []byte

GetLayout gets the section locations of all the ones we care about into a flashrom friendly format.

func (*Image) WriteFlashrom

func (i *Image) WriteFlashrom(ctx context.Context, sec ImageSection, programmer FlashromProgrammer) error

WriteFlashrom writes the current data in the specified section into flashrom.

type ImageSection

type ImageSection string

ImageSection is the name of sections supported by this package.

type SectionInfo

type SectionInfo struct {
	Start  uint
	Length uint
}

SectionInfo represents the location and size of a firmware image section.

Jump to

Keyboard shortcuts

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