sfdp

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: BSD-3-Clause Imports: 5 Imported by: 2

Documentation

Overview

Package sfdp reads the SFDP (Serial Flash Discoverable Parameters) from a flash chip where supported. The SFDP is in a separate address space of the flash chip and usually read-only. It is used to discover the features implemented by the flash chip.

This supports v1.0 of SFDP. Support for v1.5 is incomplete.

Useful references: * Your flash chip's datasheet * https://chromium.googlesource.com/chromiumos/platform/ec/+/master/include/sfdp.h * https://www.macronix.com/Lists/ApplicationNote/Attachments/1870/AN114v1-SFDP%20Introduction.pdf * JEDEC specifications

Index

Constants

This section is empty.

Variables

View Source
var (
	ParamBlockSectorEraseSize           = Param{0, 0, 0x00, 0x02}
	ParamWriteGranularity               = Param{0, 0, 0x02, 0x01}
	ParamWriteEnableInstructionRequired = Param{0, 0, 0x03, 0x01}
	ParamWriteEnableOpcodeSelect        = Param{0, 0, 0x04, 0x01}
	Param4KBEraseOpcode                 = Param{0, 0, 0x08, 0x08}
	Param112FastRead                    = Param{0, 0, 0x10, 0x01}
	ParamAddressBytesNumberUsed         = Param{0, 0, 0x11, 0x02}
	ParamDoubleTransferRateClocking     = Param{0, 0, 0x13, 0x01}
	Param122FastReadSupported           = Param{0, 0, 0x14, 0x01}
	Param144FastReadSupported           = Param{0, 0, 0x15, 0x01}
	Param114FastReadSupported           = Param{0, 0, 0x16, 0x01}
	ParamFlashMemoryDensity             = Param{0, 1, 0x00, 0x20}
	Param144FastReadNumberOfWaitStates  = Param{0, 2, 0x00, 0x05}
	Param144FastReadNumberOfModeBits    = Param{0, 2, 0x05, 0x03}
	Param144FastReadOpcode              = Param{0, 2, 0x08, 0x08}
	Param114FastReadNumberOfWaitStates  = Param{0, 2, 0x10, 0x05}
	Param114FastReadNumberOfModeBits    = Param{0, 2, 0x15, 0x03}
	Param114FastReadOpcode              = Param{0, 2, 0x18, 0x08}
	Param112FastReadNumberOfWaitStates  = Param{0, 3, 0x00, 0x05}
	Param112FastReadNumberOfModeBits    = Param{0, 3, 0x05, 0x03}
	Param112FastReadOpcode              = Param{0, 3, 0x08, 0x08}
	Param122FastReadNumberOfWaitStates  = Param{0, 3, 0x10, 0x05}
	Param122FastReadNumberOfModeBits    = Param{0, 3, 0x15, 0x03}
	Param122FastReadOpcode              = Param{0, 3, 0x18, 0x08}
	Param222FastReadSupported           = Param{0, 4, 0x00, 0x01}
	Param444FastReadSupported           = Param{0, 4, 0x04, 0x01}
)

Parameters from the Basic Table (id=0).

View Source
var BasicTableLookup = []ParamLookupEntry{
	{"BlockSectorEraseSize", ParamBlockSectorEraseSize},
	{"WriteGranularity", ParamWriteGranularity},
	{"WriteEnableInstructionRequired", ParamWriteEnableInstructionRequired},
	{"WriteEnableOpcodeSelect", ParamWriteEnableOpcodeSelect},
	{"4KBEraseOpcode", Param4KBEraseOpcode},
	{"112FastRead", Param112FastRead},
	{"AddressBytesNumberUsed", ParamAddressBytesNumberUsed},
	{"DoubleTransferRateClocking", ParamDoubleTransferRateClocking},
	{"122FastReadSupported", Param122FastReadSupported},
	{"144FastReadSupported", Param144FastReadSupported},
	{"114FastReadSupported", Param114FastReadSupported},
	{"FlashMemoryDensity", ParamFlashMemoryDensity},
	{"144FastReadNumberOfWaitStates", Param144FastReadNumberOfWaitStates},
	{"144FastReadNumberOfModeBits", Param144FastReadNumberOfModeBits},
	{"144FastReadOpcode", Param144FastReadOpcode},
	{"114FastReadNumberOfWaitStates", Param114FastReadNumberOfWaitStates},
	{"114FastReadNumberOfModeBits", Param114FastReadNumberOfModeBits},
	{"114FastReadOpcode", Param114FastReadOpcode},
	{"112FastReadNumberOfWaitStates", Param112FastReadNumberOfWaitStates},
	{"112FastReadNumberOfModeBits", Param112FastReadNumberOfModeBits},
	{"112FastReadOpcode", Param112FastReadOpcode},
	{"122FastReadNumberOfWaitStates", Param122FastReadNumberOfWaitStates},
	{"122FastReadNumberOfModeBits", Param122FastReadNumberOfModeBits},
	{"122FastReadOpcode", Param122FastReadOpcode},
	{"222FastReadSupported", Param222FastReadSupported},
	{"444FastReadSupported", Param444FastReadSupported},
}

BasicTableLookup maps a textual param name to the Param for debug utilities. These are in a separate data structure to facilitate dead code elimination and reduce size for programs which do not require this information.

Functions

This section is empty.

Types

type DwordError

type DwordError struct {
	WantTableID uint16
	WantDword   int
}

DwordError is returned if the given dword index cannot be found in the given table.

func (*DwordError) Error

func (e *DwordError) Error() string

Error implements the error interface.

type Header struct {
	// Signature is 0x50444653 ("SFDP") if the chip supports SFDP.
	Signature                uint32
	MinorRev                 uint8
	MajorRev                 uint8
	NumberOfParameterHeaders uint8
	// contains filtered or unexported fields
}

Header is the header of the SFDP.

type Param

type Param struct {
	Table uint16
	Dword int
	Shift int
	Bits  int
}

Param contains information necessary to lookup a parameter in the SFDP tables.

type ParamLookupEntry

type ParamLookupEntry struct {
	Name  string
	Param Param
}

ParamLookupEntry is a single entry in the BasicTableLookup.

type Parameter

type Parameter struct {
	ParameterHeader
	Table []byte
}

Parameter holds a single table.

type ParameterHeader

type ParameterHeader struct {
	IDLSB    uint8
	MinorRev uint8
	MajorRev uint8
	// Length is the number of dwords.
	Length uint8
	// The top byte of Pointer is the MSB of the Id for revision 1.5.
	Pointer uint32
}

ParameterHeader is the header of Parameter.

func (ParameterHeader) ID

func (p ParameterHeader) ID(sfdpMajorRev, sfdpMinorRev uint8) uint16

ID returns the ID for the table. Ths size of the ID depends on the SFDP version.

type SFDP

type SFDP struct {
	Header
	Parameters []Parameter
}

SFDP (Serial Flash Discoverable Parameters) holds a copy of the tables of the SFDP.

The structure is:

SFDP
 |--> Header
 \--> []Parameter
         |--> ParameterHeader
         \--> Table: A copy of the table's contents.

func Read

func Read(r io.ReaderAt) (*SFDP, error)

Read reads the SFDP and all tables from the flash chip.

func (*SFDP) Dword

func (s *SFDP) Dword(table uint16, dword int) (uint32, error)

Dword reads a dword from the SFDP table with the given table id and dword index.

func (*SFDP) Param

func (s *SFDP) Param(p Param) (int64, error)

Param reads a Param from the SFDP table.

func (*SFDP) PrettyPrint

func (s *SFDP) PrettyPrint(w io.Writer, l []ParamLookupEntry) error

PrettyPrint prints each parameter from the lookup in a human-readable format.

type TableError

type TableError struct {
	WantTableID uint16
}

TableError is returned if the given table id cannot be found.

func (*TableError) Error

func (e *TableError) Error() string

Error implements the error interface.

type UnsupportedError

type UnsupportedError struct{}

UnsupportedError is returned if no SFDP can be found.

func (*UnsupportedError) Error

func (*UnsupportedError) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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