cbfs

package
v0.0.0-...-61388f1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: BSD-3-Clause Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// FOV
	TypeDeleted2    FileType = 0xffffffff
	TypeDeleted              = 0
	TypeBootBlock            = 0x1
	TypeMaster               = 0x2
	TypeLegacyStage          = 0x10
	TypeStage                = 0x11
	TypeSELF                 = 0x20
	TypeFIT                  = 0x21
	TypeOptionRom            = 0x30
	TypeBootSplash           = 0x40
	TypeRaw                  = 0x50
	TypeVSA                  = 0x51 // very, very obsolete Geode thing
	TypeMBI                  = 0x52
	TypeMicroCode            = 0x53
	TypeFSP                  = 0x60
	TypeMRC                  = 0x61
	TypeMMA                  = 0x62
	TypeEFI                  = 0x63
	TypeStruct               = 0x70
	TypeCMOS                 = 0xaa
	TypeSPD                  = 0xab
	TypeMRCCache             = 0xac
	TypeCMOSLayout           = 0x1aa
)
View Source
const (
	HeaderMagic   = 0x4F524243
	HeaderV1      = 0x31313131
	HeaderV2      = 0x31313132
	HeaderVersion = HeaderV2
	Alignment     = 64
)
View Source
const (
	Unused     Tag = 0
	Unused2        = 0xffffffff
	Compressed     = 0x42435a4c
	Hash           = 0x68736148
	PSCB           = 0x42435350
	ALCB           = 0x42434c41
	SHCB           = 0x53746748
)
View Source
const (
	SegCode   SegmentType = 0x434F4445
	SegData               = 0x44415441
	SegBSS                = 0x42535320
	SegParams             = 0x50415241
	SegEntry              = 0x454E5452
)
View Source
const FileMagic = "LARCHIVE"
View Source
const FileSize = 24
View Source
const MasterHeaderLen = 32

this is the master cbfs header - it must be located somewhere available to bootblock (to load romstage). The last 4 bytes in the image contain its relative offset from the end of the image (as a 32-bit signed integer).

Variables

View Source
var (
	Master = []byte{}/* 696 elements not displayed */

	ListOutput = `` /* 784-byte string literal not displayed */

)
View Source
var Debug = func(format string, v ...interface{}) {}
View Source
var SegReaders = make(map[FileType]*SegReader)

Functions

func Read

func Read(r io.Reader, f interface{}) error

Read reads things in in BE format, which they are supposed to be in.

func ReadAttributes

func ReadAttributes(r io.Reader, f *File) error

func ReadData

func ReadData(r io.ReadSeeker, f *File) error

func ReadLE

func ReadLE(r io.Reader, f interface{}) error

ReadLE reads things in LE format, which the spec says it is not in.

func ReadName

func ReadName(r io.Reader, f *File, size uint32) error

ReadNameAndAttributes reads the variable CBFS file attribute after the fixed CBFS header That is the filename, CBFS Attribute, Hashes, ...

func RegisterFileReader

func RegisterFileReader(f *SegReader) error

func Write

func Write(w io.Writer, f interface{}) error

Write reads things in in BE format, which they are supposed to be in.

func WriteLE

func WriteLE(r io.Writer, f interface{}) error

WriteLE reads things in LE format, which the spec says it is not in.

Types

type Architecture

type Architecture uint32
const (
	X86 Architecture = 1
	ARM              = 0x10
)

type BootBlockRecord

type BootBlockRecord struct {
	File
}

func (*BootBlockRecord) GetFile

func (r *BootBlockRecord) GetFile() *File

func (*BootBlockRecord) Read

func (r *BootBlockRecord) Read(in io.ReadSeeker) error

func (*BootBlockRecord) String

func (r *BootBlockRecord) String() string

func (*BootBlockRecord) Write

func (r *BootBlockRecord) Write(w io.Writer) error

type CMOSLayoutRecord

type CMOSLayoutRecord struct {
	File
}

func (*CMOSLayoutRecord) GetFile

func (r *CMOSLayoutRecord) GetFile() *File

func (*CMOSLayoutRecord) Read

func (r *CMOSLayoutRecord) Read(in io.ReadSeeker) error

func (*CMOSLayoutRecord) String

func (r *CMOSLayoutRecord) String() string

func (*CMOSLayoutRecord) Write

func (r *CMOSLayoutRecord) Write(w io.Writer) error

type Compression

type Compression uint32
const (
	None Compression = iota
	LZMA
	LZ4
)

func (Compression) String

func (c Compression) String() string

type EmptyRecord

type EmptyRecord struct {
	File
}

func (*EmptyRecord) GetFile

func (r *EmptyRecord) GetFile() *File

func (*EmptyRecord) Read

func (r *EmptyRecord) Read(in io.ReadSeeker) error

func (*EmptyRecord) String

func (r *EmptyRecord) String() string

func (*EmptyRecord) Write

func (r *EmptyRecord) Write(w io.Writer) error

type FSPRecord

type FSPRecord struct {
	File
}

func (*FSPRecord) GetFile

func (r *FSPRecord) GetFile() *File

File returns a pointer to the corresponding File

func (*FSPRecord) Read

func (r *FSPRecord) Read(in io.ReadSeeker) error

func (*FSPRecord) String

func (r *FSPRecord) String() string

func (*FSPRecord) Write

func (r *FSPRecord) Write(w io.Writer) error

type File

type File struct {
	FileHeader
	RecordStart uint32
	Name        string
	Attr        []byte
	FData       []byte
}

func (*File) MarshalJSON

func (f *File) MarshalJSON() ([]byte, error)

type FileAttr

type FileAttr struct {
	Tag  uint32
	Size uint32 // inclusize of Tag and Size
	Data []byte
}

The common fields of extended cbfs file attributes. Attributes are expected to start with tag/len, then append their specific fields.

type FileAttrAlign

type FileAttrAlign struct {
	Tag   Tag
	Size  uint32 // includes everything including data.
	Align uint32
}

type FileAttrCompression

type FileAttrCompression struct {
	Tag              Tag
	Size             uint32
	Compression      Compression
	DecompressedSize uint32
}

type FileAttrHash

type FileAttrHash struct {
	Tag      Tag
	Size     uint32 // includes everything including data.
	HashType uint32
	Data     []byte
}

type FileAttrPos

type FileAttrPos struct {
	Tag  Tag
	Size uint32 // includes everything including data.
	Pos  uint32
}

type FileAttrStageHeader

type FileAttrStageHeader struct {
	Tag         Tag
	Size        uint32
	LoadAddress uint64
	EntryOffset uint32
	MemSize     uint32
}

func (*FileAttrStageHeader) String

func (h *FileAttrStageHeader) String() string

type FileHeader

type FileHeader struct {
	Magic           [8]byte
	Size            uint32
	Type            FileType
	AttrOffset      uint32
	SubHeaderOffset uint32
}

func (*FileHeader) Deleted

func (h *FileHeader) Deleted() bool

type FileType

type FileType uint32

These are standard component types for well known

components (i.e - those that coreboot needs to consume.
Users are welcome to use any other value for their
components.

func (FileType) String

func (f FileType) String() string

type Image

type Image struct {
	Segs []ReadWriter
	// Scarf away the fmap info.
	FMAP         *fmap.FMap
	FMAPMetadata *fmap.Metadata
	Area         *fmap.Area
	// And all the data.
	Data []byte
}

func NewImage

func NewImage(rs io.ReadSeeker) (*Image, error)

func Open

func Open(n string) (*Image, error)

func (*Image) MarshalJSON

func (i *Image) MarshalJSON() ([]byte, error)

func (*Image) Remove

func (i *Image) Remove(n string) error

func (*Image) String

func (i *Image) String() string

func (*Image) Update

func (i *Image) Update() error

Update creates a new []byte for the cbfs. It is complicated a lot by the fact that endianness is not consistent in cbfs images.

func (*Image) WriteFile

func (i *Image) WriteFile(name string, perm os.FileMode) error

type LegacyStageRecord

type LegacyStageRecord struct {
	File
	StageHeader
	Data []byte
}

func (*LegacyStageRecord) GetFile

func (r *LegacyStageRecord) GetFile() *File

func (*LegacyStageRecord) MarshalJSON

func (h *LegacyStageRecord) MarshalJSON() ([]byte, error)

func (*LegacyStageRecord) Read

func (r *LegacyStageRecord) Read(in io.ReadSeeker) error

func (*LegacyStageRecord) String

func (h *LegacyStageRecord) String() string

func (*LegacyStageRecord) Write

func (r *LegacyStageRecord) Write(w io.Writer) error

type MasterHeader

type MasterHeader struct {
	Magic         uint32
	Version       uint32
	RomSize       uint32
	BootBlockSize uint32
	Align         uint32 // always 64 bytes -- FOV
	Offset        uint32
	Architecture  Architecture // integer, not name -- FOV
	// contains filtered or unexported fields
}

type MasterRecord

type MasterRecord struct {
	File
	MasterHeader
}

func (*MasterRecord) GetFile

func (r *MasterRecord) GetFile() *File

func (*MasterRecord) Read

func (r *MasterRecord) Read(in io.ReadSeeker) error

func (*MasterRecord) String

func (r *MasterRecord) String() string

func (*MasterRecord) Write

func (r *MasterRecord) Write(w io.Writer) error

type MicrocodeRecord

type MicrocodeRecord struct {
	File
}

func (*MicrocodeRecord) GetFile

func (r *MicrocodeRecord) GetFile() *File

Header returns a pointer to the corresponding File

func (*MicrocodeRecord) Read

func (r *MicrocodeRecord) Read(in io.ReadSeeker) error

func (*MicrocodeRecord) String

func (r *MicrocodeRecord) String() string

func (*MicrocodeRecord) Write

func (r *MicrocodeRecord) Write(w io.Writer) error

type OptionRom

type OptionRom struct {
	File
	Compression Compression
	Size        uint32
}

type PayloadHeader

type PayloadHeader struct {
	Type        SegmentType
	Compression Compression
	Offset      uint32
	LoadAddress uint64
	Size        uint32
	MemSize     uint32
}

func (*PayloadHeader) String

func (r *PayloadHeader) String() string

type PayloadRecord

type PayloadRecord struct {
	File
	Segs []PayloadHeader
	Data []byte
}

func (*PayloadRecord) GetFile

func (r *PayloadRecord) GetFile() *File

func (*PayloadRecord) Read

func (p *PayloadRecord) Read(in io.ReadSeeker) error

func (*PayloadRecord) String

func (h *PayloadRecord) String() string

func (*PayloadRecord) Write

func (r *PayloadRecord) Write(w io.Writer) error

type Props

type Props struct {
	Offset uint32
	Size   uint32
}

type RawRecord

type RawRecord struct {
	File
}

func (*RawRecord) GetFile

func (r *RawRecord) GetFile() *File

func (*RawRecord) Read

func (r *RawRecord) Read(in io.ReadSeeker) error

func (*RawRecord) String

func (r *RawRecord) String() string

func (*RawRecord) Write

func (r *RawRecord) Write(w io.Writer) error

type ReadWriter

type ReadWriter interface {
	GetFile() *File
	String() string
	Read(r io.ReadSeeker) error
	Write(f io.Writer) error
}

Each CBFS file type must implement at least this interface.

func NewBootBlock

func NewBootBlock(f *File) (ReadWriter, error)

func NewCMOSLayout

func NewCMOSLayout(f *File) (ReadWriter, error)

func NewEmptyRecord

func NewEmptyRecord(f *File) (ReadWriter, error)

func NewFSP

func NewFSP(f *File) (ReadWriter, error)

NewFSP returns a ReadWriter interface for the CBFS type TypeFSP

func NewLegacyStageRecord

func NewLegacyStageRecord(f *File) (ReadWriter, error)

func NewMaster

func NewMaster(f *File) (ReadWriter, error)

func NewMicrocode

func NewMicrocode(f *File) (ReadWriter, error)

NewMicrocode returns a ReadWriter interface for the CBFS type TypeMicroCode

func NewPayloadRecord

func NewPayloadRecord(f *File) (ReadWriter, error)

func NewRaw

func NewRaw(f *File) (ReadWriter, error)

func NewSPD

func NewSPD(f *File) (ReadWriter, error)

NewSPD returns a ReadWriter for the CBFS type TypeSPD

func NewStageRecord

func NewStageRecord(f *File) (ReadWriter, error)

type SPDRecord

type SPDRecord struct {
	File
}

func (*SPDRecord) GetFile

func (r *SPDRecord) GetFile() *File

Header returns a pointer to the corresponding File

func (*SPDRecord) Read

func (r *SPDRecord) Read(in io.ReadSeeker) error

func (*SPDRecord) String

func (r *SPDRecord) String() string

func (*SPDRecord) Write

func (r *SPDRecord) Write(w io.Writer) error

type SegReader

type SegReader struct {
	Type FileType
	New  func(f *File) (ReadWriter, error)
	Name string
}

type SegmentType

type SegmentType uint32

fix this mess later to use characters, not constants. I had done this once and it never made it into coreboot and I still don't know why.

func (SegmentType) String

func (s SegmentType) String() string

type StageHeader

type StageHeader struct {
	Compression Compression
	Entry       uint64
	LoadAddress uint64
	Size        uint32
	MemSize     uint32
}

func (*StageHeader) String

func (h *StageHeader) String() string

type StageRecord

type StageRecord struct {
	File
	FileAttrStageHeader
	Data []byte
}

func (*StageRecord) GetFile

func (r *StageRecord) GetFile() *File

func (*StageRecord) Read

func (r *StageRecord) Read(in io.ReadSeeker) error

func (*StageRecord) String

func (h *StageRecord) String() string

func (*StageRecord) Write

func (r *StageRecord) Write(w io.Writer) error

type Tag

type Tag uint32

Jump to

Keyboard shortcuts

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