ata

package
v0.0.0-...-6bd98cc Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ATA commands
	ATA_SMART           = 0xb0
	ATA_IDENTIFY_DEVICE = 0xec

	// ATA feature register values for SMART
	SMART_READ_DATA     = 0xd0
	SMART_READ_LOG      = 0xd5
	SMART_RETURN_STATUS = 0xda
)

Variables

This section is empty.

Functions

func PrintSMARTPage

func PrintSMARTPage(smart SmartPage, drive drivedb.DriveModel, w io.Writer)

Types

type IdentifyDeviceData

type IdentifyDeviceData struct {
	GeneralConfig uint16 // Word 0, general configuration. If bit 15 is zero, device is ATA.

	SerialNumberRaw [20]byte // Word 10..19, device serial number, padded with spaces (20h).

	FirmwareRevisionRaw [8]byte  // Word 23..26, device firmware revision, padded with spaces (20h).
	ModelNumberRaw      [40]byte // Word 27..46, device model number, padded with spaces (20h).

	SATACap     uint16 // Word 76, SATA capabilities.
	SATACapAddl uint16 // Word 77, SATA additional capabilities.

	MajorVersion uint16 // Word 80, major version number.
	MinorVersion uint16 // Word 81, minor version number.

	Word85 uint16 // Word 85, supported commands and feature sets.

	Word87 uint16 // Word 87, supported commands and feature sets.

	WWNRaw [4]uint16 // Word 108..111, WWN (World Wide Name).

	RotationRate uint16 // Word 217, nominal media rotation rate.

	TransportMajor uint16 // Word 222, transport major version number.
	// contains filtered or unexported fields

} // 512 bytes

ATA IDENTIFY DEVICE struct. ATA8-ACS defines this as a page of 16-bit words. Some fields span multiple words (e.g., model number), but must (?) be byteswapped. Some fields use less than a single word, and are bitmasked together with other fields. Since many of the fields are now retired / obsolete, we only define the fields that are currently used by this package.

func (*IdentifyDeviceData) ATAMajorVersion

func (d *IdentifyDeviceData) ATAMajorVersion() (s string)

ATAMajorVersion returns the ATA major version from an ATA IDENTIFY command.

func (*IdentifyDeviceData) ATAMinorVersion

func (d *IdentifyDeviceData) ATAMinorVersion() string

ATAMinorVersion returns the ATA minor version from an ATA IDENTIFY command.

func (*IdentifyDeviceData) FirmwareRevision

func (d *IdentifyDeviceData) FirmwareRevision() []byte

FirmwareVersion returns the firmware version of a device from an ATA IDENTIFY command.

func (*IdentifyDeviceData) ModelNumber

func (d *IdentifyDeviceData) ModelNumber() []byte

ModelNumber returns the model number of a device from an ATA IDENTIFY command.

func (*IdentifyDeviceData) SerialNumber

func (d *IdentifyDeviceData) SerialNumber() []byte

ModelNumber returns the serial number of a device from an ATA IDENTIFY command.

func (*IdentifyDeviceData) Transport

func (d *IdentifyDeviceData) Transport() (s string)

func (*IdentifyDeviceData) WWN

func (d *IdentifyDeviceData) WWN() string

type SmartLogDirectory

type SmartLogDirectory struct {
	Version uint16
	Address [255]struct {
		NumPages byte
		// contains filtered or unexported fields
	}
}

SMART log address 00h

type SmartPage

type SmartPage struct {
	Version uint16
	Attrs   [30]smartAttr
}

Page of 30 SMART attributes as per ATA spec

type SmartSelfTestLog

type SmartSelfTestLog struct {
	Version uint16
	Entry   [21]struct {
		LBA_7          byte   // Content of the LBA field (7:0) when subcommand was issued
		Status         byte   // Self-test execution status
		LifeTimestamp  uint16 // Power-on lifetime of the device in hours when subcommand was completed
		Checkpoint     byte
		LBA            uint32 // LBA of first error (28-bit addressing)
		VendorSpecific [15]byte
	}
	VendorSpecific uint16
	Index          byte

	Checksum byte // Two's complement checksum of first 511 bytes
	// contains filtered or unexported fields
}

SMART log address 06h

type SmartSummaryErrorLog

type SmartSummaryErrorLog struct {
	Version    byte
	LogIndex   byte
	LogData    [5][90]byte // TODO: Expand out to error log structure
	ErrorCount uint16      // Device error count

	Checksum byte // Two's complement checksum of first 511 bytes
	// contains filtered or unexported fields
}

SMART log address 01h

Jump to

Keyboard shortcuts

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