bits

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package bits does the low (bit-)level parsing and assembly of new-style Raspberry Pi revision codes.

Index

Constants

View Source
const CodeBitsize = 32

CodeBitsize is the number of bits in a Raspberry Pi revision code.

Variables

View Source
var ErrOverflow = errors.New("more Values than NumTotal")

ErrOverflow is returned when a function gets passed more Values than NumTotal.

Functions

This section is empty.

Types

type Code

type Code uint32

Code is a Raspberry Pi revision code.

func Assemble

func Assemble(s Values) (r Code, err error)

Assemble a slice of Values into a revision code.

type Field

type Field uint

A Field of revision code.

Keep in mind that, as an unsigned integer, Field cannot have negative values, and `f := Field(0) - 1` overflows to `f == Field(MaxUint)`. This means that you have to compare `f <= Last` if/when iterating down from Last.

const (
	NoOvervoltage   Field = iota // Overvoltage disallowed
	NoOTPPrograming              // OTP programming disallowed
	NoOTPReading                 // OTP reading disallowed
	Unused1                      //
	WarrantyVoid                 // Warranty has been voided by overclocking
	Unused2                      //
	NewStyleRev                  // New-style revision code
	Memory                       // Memory size in multiples of 256
	Manufacturer
	Processor
	Model
	Revision

	// NumTotal of known Fields.
	NumTotal // Taking advantage of iota continuing its effect here.
	// Last known field.
	Last = NumTotal - 1 // This automatically tracks the last field.
	// First of known Fields, short for "Field(0)" to iterate from.
	First Field = 0
)

Field constants.

func (Field) Bitmask

func (f Field) Bitmask() Value

Bitmask is an all-ones mask derived from the bitsize of the Field.

func (Field) Bitsize

func (f Field) Bitsize() uint8

Bitsize is the length of Field value in number of bits.

func (Field) String

func (i Field) String() string

func (Field) Validate

func (f Field) Validate(v Value) (err error)

Validate returns error if v is not a valid Value for the Field.

type Value

type Value uint8

The Value of a Field in a revision code.

type Values

type Values = []Value

Values is an alias for a Value slice.

func Parse

func Parse(r Code) Values

Parse a Raspberry Pi revision code into a slice of values.

Jump to

Keyboard shortcuts

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