Documentation ¶
Index ¶
- Constants
- func CalculateBiosDirectoryCheckSum(biosDirRaw []byte) uint32
- func CalculatePSPDirectoryCheckSum(pspDirRaw []byte) uint32
- type AMDFirmware
- type BIOSDirectoryTable
- type BIOSDirectoryTableEntry
- type BIOSDirectoryTableEntryType
- type BIOSDirectoryTableHeader
- type EmbeddedFirmwareStructure
- type Firmware
- type FirmwareImage
- type FirmwareVersion
- type PSPDirectoryTable
- type PSPDirectoryTableEntry
- type PSPDirectoryTableEntryType
- type PSPDirectoryTableHeader
- type PSPFirmware
- type PSPHeader
- func (h *PSPHeader) CookieLength() uint64
- func (h *PSPHeader) CookieOffset() uint64
- func (h *PSPHeader) Reserved1Length() uint64
- func (h *PSPHeader) Reserved1Offset() uint64
- func (h *PSPHeader) Reserved2Length() uint64
- func (h *PSPHeader) Reserved2Offset() uint64
- func (h *PSPHeader) VersionLength() uint64
- func (h *PSPHeader) VersionOffset() uint64
Constants ¶
const BIOSDirectoryTableCookie = 0x44484224 // $BHD
BIOSDirectoryTableCookie is a special identifier of BIOS Directory table level 1
const BIOSDirectoryTableEntrySize = 16
const BIOSDirectoryTableLevel2Cookie = 0x324C4224 // $BL2
BIOSDirectoryTableLevel2Cookie is a special identifier of BIOS Directory table level 2
const EmbeddedFirmwareStructureSignature = 0x55aa55aa
EmbeddedFirmwareStructureSignature is a special identifier of Firmware Embedded Structure
const PSPBootloaderCookie = 0x31535024 // "$PS1"
PSPBootloaderCookie is a special identifier of a PSP binary
const PSPDirectoryTableCookie = 0x50535024 // "$PSP"
PSPDirectoryTableCookie is a special identifier of PSP Directory table level 1
const PSPDirectoryTableEntrySize = 16
const PSPDirectoryTableLevel2Cookie = 0x324C5024 // "$PL2"
PSPDirectoryTableLevel2Cookie is a special identifier of PSP Directory table level 2
Variables ¶
This section is empty.
Functions ¶
func CalculateBiosDirectoryCheckSum ¶
CalculateBiosDirectoryCheckSum calculates expected checksum of BIOS Directory represented in serialised form
func CalculatePSPDirectoryCheckSum ¶
CalculatePSPDirectoryCheckSum calculates expected checksum of PSP Directory represented in serialised form
Types ¶
type AMDFirmware ¶
type AMDFirmware struct {
// contains filtered or unexported fields
}
AMDFirmware represents an instance of firmware that exposes AMD specific meatadata and structure.
func NewAMDFirmware ¶
func NewAMDFirmware(firmware Firmware) (*AMDFirmware, error)
NewAMDFirmware returns an AMDFirmware structure or an error if internal firmware structures cannot be parsed
func (*AMDFirmware) Firmware ¶
func (a *AMDFirmware) Firmware() Firmware
Firmware returns the internal reference to Firmawre interface
func (*AMDFirmware) PSPFirmware ¶
func (a *AMDFirmware) PSPFirmware() *PSPFirmware
PSPFirmware returns the PSPFirmware reference held by the AMDFirmware object
type BIOSDirectoryTable ¶
type BIOSDirectoryTable struct { BIOSDirectoryTableHeader Entries []BIOSDirectoryTableEntry }
BIOSDirectoryTable represents a BIOS Directory Table Header with all entries Table 11 & Table 12 from (1)
func FindBIOSDirectoryTable ¶
func FindBIOSDirectoryTable(image []byte) (*BIOSDirectoryTable, bytes2.Range, error)
FindBIOSDirectoryTable scans firmware for BIOSDirectoryTableCookie and treats remaining bytes as BIOSDirectoryTable
func ParseBIOSDirectoryTable ¶
func ParseBIOSDirectoryTable(data []byte) (*BIOSDirectoryTable, uint64, error)
ParseBIOSDirectoryTable converts input bytes into BIOSDirectoryTable
func (BIOSDirectoryTable) String ¶
func (b BIOSDirectoryTable) String() string
type BIOSDirectoryTableEntry ¶
type BIOSDirectoryTableEntry struct { Type BIOSDirectoryTableEntryType RegionType uint8 ResetImage bool CopyImage bool ReadOnly bool Compressed bool Instance uint8 Subprogram uint8 RomID uint8 Size uint32 SourceAddress uint64 DestinationAddress uint64 }
BIOSDirectoryTableEntry represents a single entry in BIOS Directory Table Table 12 from (1)
func ParseBIOSDirectoryTableEntry ¶
func ParseBIOSDirectoryTableEntry(r io.Reader) (*BIOSDirectoryTableEntry, uint64, error)
ParseBIOSDirectoryTableEntry converts input bytes into BIOSDirectoryTableEntry
type BIOSDirectoryTableEntryType ¶
type BIOSDirectoryTableEntryType uint8
BIOSDirectoryTableEntryType is an entry type of BIOS Directory table
const ( // APCBDataEntry represents APCB data entry in BIOS Directory table APCBDataEntry BIOSDirectoryTableEntryType = 0x60 // APOBBinaryEntry denotes APOB binary in BIOS Directory table APOBBinaryEntry BIOSDirectoryTableEntryType = 0x61 // BIOSRTMVolumeEntry represents BIOS RTM Volume entry in BIOS Directory table BIOSRTMVolumeEntry BIOSDirectoryTableEntryType = 0x62 // PMUFirmwareInstructionsEntry represents the instruction portion of PMU firmware PMUFirmwareInstructionsEntry BIOSDirectoryTableEntryType = 0x64 // PMUFirmwareDataEntry represents the data portion of PMU firmware PMUFirmwareDataEntry BIOSDirectoryTableEntryType = 0x65 // MicrocodePatchEntry represents the microcode patch file location MicrocodePatchEntry BIOSDirectoryTableEntryType = 0x66 // APCBDataBackupEntry contains a backup copy of APCB data APCBDataBackupEntry BIOSDirectoryTableEntryType = 0x68 // VideoInterpreterEntry interpreter binary that displays the video image VideoInterpreterEntry BIOSDirectoryTableEntryType = 0x69 // BIOSDirectoryTableLevel2Entry denotes an entry that points to BIOS Directory table level 2 BIOSDirectoryTableLevel2Entry BIOSDirectoryTableEntryType = 0x70 )
type BIOSDirectoryTableHeader ¶
type BIOSDirectoryTableHeader struct { BIOSCookie uint32 Checksum uint32 TotalEntries uint32 Reserved uint32 }
BIOSDirectoryTableHeader represents a BIOS Directory Table Header Table 11 from (1)
type EmbeddedFirmwareStructure ¶
type EmbeddedFirmwareStructure struct { Signature uint32 Reserved1 [16]byte PSPDirectoryTablePointer uint32 BIOSDirectoryTableFamily17hModels00h0FhPointer uint32 BIOSDirectoryTableFamily17hModels10h1FhPointer uint32 BIOSDirectoryTableFamily17hModels30h3FhPointer uint32 Reserved2 uint32 BIOSDirectoryTableFamily17hModels60h3FhPointer uint32 Reserved3 [30]byte }
EmbeddedFirmwareStructure represents Embedded Firmware Structure defined in Table 2 in (1)
func FindEmbeddedFirmwareStructure ¶
func FindEmbeddedFirmwareStructure(firmware Firmware) (*EmbeddedFirmwareStructure, bytes2.Range, error)
FindEmbeddedFirmwareStructure locates and parses Embedded Firmware Structure
func ParseEmbeddedFirmwareStructure ¶
func ParseEmbeddedFirmwareStructure(r io.Reader) (*EmbeddedFirmwareStructure, uint64, error)
ParseEmbeddedFirmwareStructure converts input bytes into EmbeddedFirmwareStructure
type Firmware ¶
type Firmware interface { ImageBytes() []byte PhysAddrToOffset(physAddr uint64) uint64 OffsetToPhysAddr(offset uint64) uint64 }
Firmware is an abstraction of a firmware image, obtained for example via flashrom
type FirmwareImage ¶ added in v1.2.0
type FirmwareImage []byte
FirmwareImage implements Firmware given image content.
func (FirmwareImage) ImageBytes ¶ added in v1.2.0
func (img FirmwareImage) ImageBytes() []byte
ImageBytes returns image content.
func (FirmwareImage) OffsetToPhysAddr ¶ added in v1.2.0
func (img FirmwareImage) OffsetToPhysAddr(offset uint64) uint64
OffsetToPhysAddr maps an offset in the image to the physical address.
func (FirmwareImage) PhysAddrToOffset ¶ added in v1.2.0
func (img FirmwareImage) PhysAddrToOffset(physAddr uint64) uint64
PhysAddrToOffset maps a physical address to the offset in the image.
type FirmwareVersion ¶
type FirmwareVersion [4]byte
FirmwareVersion represents PSP firmware version
func (FirmwareVersion) String ¶
func (v FirmwareVersion) String() string
String converts FirmwareVersion into a string
type PSPDirectoryTable ¶
type PSPDirectoryTable struct { PSPDirectoryTableHeader Entries []PSPDirectoryTableEntry }
PSPDirectoryTable represents PSP Directory Table Header with all entries Table 5 in (1)
func FindPSPDirectoryTable ¶
func FindPSPDirectoryTable(image []byte) (*PSPDirectoryTable, bytes2.Range, error)
FindPSPDirectoryTable scans firmware for PSPDirectoryTableCookie and treats remaining bytes as PSPDirectoryTable
func ParsePSPDirectoryTable ¶
func ParsePSPDirectoryTable(data []byte) (*PSPDirectoryTable, uint64, error)
ParsePSPDirectoryTable converts input bytes into PSPDirectoryTable
func (PSPDirectoryTable) String ¶
func (p PSPDirectoryTable) String() string
type PSPDirectoryTableEntry ¶
type PSPDirectoryTableEntry struct { Type PSPDirectoryTableEntryType Subprogram uint8 ROMId uint8 Size uint32 LocationOrValue uint64 }
PSPDirectoryTableEntry represents a single entry in PSP Directory Table Table 5 in (1)
func ParsePSPDirectoryTableEntry ¶
func ParsePSPDirectoryTableEntry(r io.Reader) (*PSPDirectoryTableEntry, uint64, error)
ParsePSPDirectoryTableEntry converts input bytes into PSPDirectoryTableEntry
type PSPDirectoryTableEntryType ¶
type PSPDirectoryTableEntryType uint8
PSPDirectoryTableEntryType is an entry type of PSP Directory table
const ( // AMDPublicKeyEntry denotes AMD public key entry in PSP Directory table AMDPublicKeyEntry PSPDirectoryTableEntryType = 0x00 // PSPBootloaderFirmwareEntry denotes a PSP bootloader firmware entry in PSP Directory table PSPBootloaderFirmwareEntry PSPDirectoryTableEntryType = 0x01 // PSPDirectoryTableLevel2Entry denotes an entry that points to PSP Directory table level 2 PSPDirectoryTableLevel2Entry PSPDirectoryTableEntryType = 0x40 )
type PSPDirectoryTableHeader ¶
type PSPDirectoryTableHeader struct { PSPCookie uint32 Checksum uint32 TotalEntries uint32 AdditionalInfo uint32 }
PSPDirectoryTableHeader represents a BIOS Directory Table Header Tables 3&4 from (1)
type PSPFirmware ¶
type PSPFirmware struct { EmbeddedFirmware EmbeddedFirmwareStructure EmbeddedFirmwareRange bytes2.Range PSPDirectoryLevel1 *PSPDirectoryTable PSPDirectoryLevel1Range bytes2.Range PSPDirectoryLevel2 *PSPDirectoryTable PSPDirectoryLevel2Range bytes2.Range BIOSDirectoryLevel1 *BIOSDirectoryTable BIOSDirectoryLevel1Range bytes2.Range BIOSDirectoryLevel2 *BIOSDirectoryTable BIOSDirectoryLevel2Range bytes2.Range }
PSPFirmware contains essential parts of the AMD's PSP firmware internals
type PSPHeader ¶
type PSPHeader struct { Reserved1 [16]byte Cookie uint32 Reserved2 [76]byte Version FirmwareVersion Reserved3 [156]byte }
PSPHeader represents a header of each firmware binary See: https://doc.coreboot.org/soc/amd/psp_integration.html
func ParsePSPHeader ¶
ParsePSPHeader parses the PSP header that is supposed to be the beginning of each PSP binary
func (*PSPHeader) CookieLength ¶
CookieLength returns the size in bytes of field Cookie
func (*PSPHeader) CookieOffset ¶
CookieOffset returns the offset in bytes of field Cookie
func (*PSPHeader) Reserved1Length ¶
func (*PSPHeader) Reserved1Offset ¶
Reserved1Offset returns the offset in bytes of field Reserved1
func (*PSPHeader) Reserved2Length ¶
Reserved2Length returns the size in bytes of field Reserved2
func (*PSPHeader) Reserved2Offset ¶
Reserved2Offset returns the offset in bytes of field Reserved2
func (*PSPHeader) VersionLength ¶
VersionLength returns the size in bytes of field Version
func (*PSPHeader) VersionOffset ¶
VersionOffset returns the offset in bytes of field Version