acpi

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package acpi reads, modifies, and writes ACPI tables.

acpi is designed to support copying individual tables or a blob containing many tables from one spot to another, supporting filtering. For example, one might read tables from /dev/mem, using the RSDP, so as to create an ACPI table blob for use in coreboot. In this case, we only care about checking the signature.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultMethod is the name of the default method used to get tables.
	DefaultMethod = "files"
	// Methods is the map of all methods implemented for Linux.
	Methods = map[string]TableMethod{
		"files": RawTablesFromSys,
		"ebda":  RawTablesFromMem,
	}
)
View Source
var Debug = func(string, ...interface{}) {}

Debug enables various debug prints. External code can set it to, e.g., log.Printf

Functions

func MethodNames

func MethodNames() []string

MethodNames returns the list of supported MethodNames.

func NewRSDP

func NewRSDP(addr uintptr, len uint) []byte

NewRSDP returns a new and partially initialized RSDP, setting only the defaultRSDP values, address, length, and signature.

func String

func String(t Table) string

String pretty-prints a Table

func WriteTables

func WriteTables(w io.Writer, tab Table, tabs ...Table) error

WriteTables writes one or more tables to an io.Writer.

Types

type BiosTable

type BiosTable struct {
	RSDP   *RSDP
	Tables []Table
}

BiosTable contains the information needed to create table images for firmware such as coreboot or oreboot. It hence includes the RSDP, [XR]SDT, and the raw table data. The *SDT is always Tables[0] as in the real tables.

func ReadBiosTables

func ReadBiosTables() (*BiosTable, error)

ReadBiosTables reads tables that are not interpreted by the OS, i.e. it goes straight to memory and gets them there. We optimistically hope the bios has not stomped around in low memory messing around.

type RSDP

type RSDP struct {
	// contains filtered or unexported fields
}

RSDP is the v2 version of the ACPI RSDP struct.

func GetRSDP

func GetRSDP() (*RSDP, error)

GetRSDP finds the RSDP pointer and struct. The rsdpgetters must be defined in rsdp_$(GOOS).go, since, e.g.,OSX, BSD, and Linux have some intersections but some unique aspects too, and Plan 9 has nothing in common with any of them.

It is able to use several methods, because there is no consistency about how it is done.

func GetRSDPEBDA

func GetRSDPEBDA() (*RSDP, error)

GetRSDPEBDA finds the RSDP in the EBDA.

func GetRSDPEFI

func GetRSDPEFI() (*RSDP, error)

GetRSDPEFI finds the RSDP in the EFI System Table.

func GetRSDPMem

func GetRSDPMem() (*RSDP, error)

GetRSDPMem is the option of last choice, it just grovels through the e0000-ffff0 area, 16 bytes at a time, trying to find an RSDP. These are well-known addresses for 20+ years.

func (*RSDP) AllData

func (r *RSDP) AllData() []byte

AllData returns the RSDP as a []byte

func (*RSDP) Len

func (r *RSDP) Len() uint32

Len returns the RSDP length

func (*RSDP) OEMID

func (r *RSDP) OEMID() string

OEMID returns the RSDP OEMID

func (*RSDP) RSDPAddr

func (r *RSDP) RSDPAddr() int64

RSDPAddr returns the physical base address of the RSDP.

func (*RSDP) SDTAddr

func (r *RSDP) SDTAddr() int64

SDTAddr returns a base address or the [RX]SDT.

It will preferentially return the XSDT, but if that is 0 it will return the RSDT address.

func (*RSDP) Sig

func (r *RSDP) Sig() string

Sig returns the RSDP signature

func (*RSDP) TableData

func (r *RSDP) TableData() []byte

TableData returns the RSDP table data as a []byte

type Raw

type Raw struct {
	// contains filtered or unexported fields
}

Raw is just a table embedded in a []byte. Operations on Raw are for figuring out how to skip a table you don't care about or, possibly, truncating a table and regenerating a checksum.

func (*Raw) Address

func (r *Raw) Address() int64

Address returns the table's base address

func (*Raw) CheckSum

func (r *Raw) CheckSum() uint8

CheckSum returns the table CheckSum.

func (*Raw) CreatorID

func (r *Raw) CreatorID() uint32

CreatorID returns the table CreatorID.

func (*Raw) CreatorRevision

func (r *Raw) CreatorRevision() uint32

CreatorRevision returns the table CreatorRevision.

func (*Raw) Data

func (r *Raw) Data() []byte

Data returns all the data in a Raw table.

func (*Raw) Len

func (r *Raw) Len() uint32

Len returns the total table length.

func (*Raw) OEMID

func (r *Raw) OEMID() string

OEMID returns the table OEMID.

func (*Raw) OEMRevision

func (r *Raw) OEMRevision() uint32

OEMRevision returns the table OEMRevision.

func (*Raw) OEMTableID

func (r *Raw) OEMTableID() string

OEMTableID returns the table OEMTableID.

func (*Raw) Revision

func (r *Raw) Revision() uint8

Revision returns the table Revision.

func (*Raw) Sig

func (r *Raw) Sig() string

Sig returns the table signature.

func (*Raw) TableData

func (r *Raw) TableData() []byte

TableData returns the Raw table, minus the standard ACPI header.

type SDT

type SDT struct {
	// Table is the SDT itself.
	Table

	// Addrs is the array of physical addresses in the SDT.
	Addrs []int64

	// Base is the SDT base, used to generate a new SDT for, e.g, coreboot.
	Base int64
}

SDT contains information about tables. It does not differentiate 32- vs 64-bit tables.

func NewSDT

func NewSDT(t Table, addr int64) (*SDT, error)

NewSDT returns an SDT, given a Table

func NewSDTAddr

func NewSDTAddr(addr int64) (*SDT, error)

NewSDTAddr returns an SDT, given an address.

func (*SDT) String

func (sdt *SDT) String() string

String implements string for an SDT.

type Table

type Table interface {
	Sig() string
	Len() uint32
	Revision() uint8
	CheckSum() uint8
	OEMID() string
	OEMTableID() string
	OEMRevision() uint32
	CreatorID() uint32
	CreatorRevision() uint32
	Data() []byte
	TableData() []byte
	Address() int64
}

Table is an individual ACPI table.

func GetTable

func GetTable() (string, []Table, error)

GetTable uses all the Methods until one works.

func NewRaw

func NewRaw(b []byte) ([]Table, error)

NewRaw returns a new Raw []Table fron a given byte slice.

func RawFromFile

func RawFromFile(r io.Reader) ([]Table, error)

RawFromFile reads from an io.Reader and returns a []Table and error if any.

func RawFromName

func RawFromName(n string) ([]Table, error)

RawFromName reads a raw []Table in from a named file.

func RawTablesFromMem

func RawTablesFromMem() ([]Table, error)

RawTablesFromMem reads all the tables from Mem, using the SDT.

func RawTablesFromSys

func RawTablesFromSys() ([]Table, error)

RawTablesFromSys returns an array of Raw tables, for all ACPI tables available in /sys.

func ReadRawTable

func ReadRawTable(physAddr int64) (Table, error)

ReadRawTable reads a full table in, given an address.

ReadRawTable uses the io package. This may not always work if the kernel has restrictions on reading memory above the 1M boundary, and the tables are above boundary.

func ReadTables

func ReadTables(n string) ([]Table, error)

ReadTables reads tables, given a method name.

type TableMethod

type TableMethod func() ([]Table, error)

TableMethod defines the type of functions used to read a table.

func Method

func Method(n string) (TableMethod, error)

Method accepts a method name and returns a TableMethod if one exists, or error othewise.

Jump to

Keyboard shortcuts

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