mshal

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorUnknownDevice   = errors.New("Unsupported device found")
	ErrorInvalidResponse = errors.New("Received invalid response")
	ErrorReadNotAllowed  = errors.New("Memory can't be read")
	ErrorWriteNotAllowed = errors.New("Memory can't be written")
	ErrorTimeout         = errors.New("The operation did not complete in time")
	ErrorPatchFailed     = errors.New("Could not patch code")
	ErrorMissingFunction = errors.New("This function is not supported in this mode")
	ErrorNoAck           = errors.New("No ACK received")
)

Functions

func ReadByte

func ReadByte(m MemoryRegion, addr int) (byte, error)

func WriteByte

func WriteByte(m MemoryRegion, addr int, value byte) error

Types

type CodeBlob

type CodeBlob struct {
	Data     []byte
	Relocate func(dataCopy []byte, addr int) (int, []byte)
}

type HAL

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

func New

func New(dev gohid.HIDDevice, config HALConfig) (*HAL, error)

func (*HAL) EEPROMIgnoreUser

func (h *HAL) EEPROMIgnoreUser() error

func (*HAL) EEPROMIsLoaded

func (h *HAL) EEPROMIsLoaded() (bool, int, error)

func (*HAL) EEPROMReloadUser

func (h *HAL) EEPROMReloadUser() error

func (*HAL) GPIOClear

func (h *HAL) GPIOClear(index int) error

func (*HAL) GPIORead

func (h *HAL) GPIORead(index int) (bool, error)

func (*HAL) GPIOSet

func (h *HAL) GPIOSet(index int) error

func (*HAL) GPIOUpdate

func (h *HAL) GPIOUpdate(stateSet byte, stateClear byte, outputSet byte, outputClear byte) (byte, byte, error)

func (*HAL) GPIOWrite

func (h *HAL) GPIOWrite(index int, value bool) error

func (*HAL) GetDeviceType

func (h *HAL) GetDeviceType() string

func (*HAL) I2CTransfer

func (h *HAL) I2CTransfer(addr uint8, wrBuf []byte, rdBuf []byte) (bool, error)

func (*HAL) MemoryRegionGet

func (h *HAL) MemoryRegionGet(name MemoryRegionNameType) MemoryRegion

func (*HAL) MemoryRegionList

func (h *HAL) MemoryRegionList() []MemoryRegionNameType

func (*HAL) PatchCodeBlobGetAddress

func (h *HAL) PatchCodeBlobGetAddress(index int) int

func (*HAL) PatchExecFunc

func (h *HAL) PatchExecFunc(inIRQ bool, addr int, req PatchExecFuncRequest) (PatchExecFuncResponse, error)

func (*HAL) ROMExchangeReport

func (h *HAL) ROMExchangeReport(out []byte) ([]byte, error)

func (*HAL) UARTTransmit

func (h *HAL) UARTTransmit(baud int, data []byte, invert bool) error

type HALConfig

type HALConfig struct {
	EEPromSize int

	PatchTryInstall         bool
	PatchIgnoreUserFirmware bool
	PatchProbeEEPROM        bool
	PatchBlobs              []CodeBlob

	LogFunc LogFunc
}

type HookNameType

type HookNameType string

type LogFunc

type LogFunc func(level int, format string, param ...interface{})

type MemoryRegion

type MemoryRegion interface {
	GetLength() int
	Access(write bool, addr int, buf []byte) (int, error)
	GetParent() (MemoryRegion, int)
	GetName() MemoryRegionNameType
	GetAlignment() int
}

func RecursiveGetParentAddress

func RecursiveGetParentAddress(region MemoryRegion, offset int) (MemoryRegion, int)

type MemoryRegionNameType

type MemoryRegionNameType string
const (
	MemoryRegionCODE             MemoryRegionNameType = "CODE"
	MemoryRegionRAM              MemoryRegionNameType = "RAM"
	MemoryRegionIRAM             MemoryRegionNameType = "IRAM"
	MemoryRegionSFR              MemoryRegionNameType = "SFR"
	MemoryRegionEEPROM           MemoryRegionNameType = "EEPROM"
	MemoryRegionUserConfig       MemoryRegionNameType = "USERCONFIG"
	MemoryRegionUserRAM          MemoryRegionNameType = "USERRAM"
	MemoryRegionRegisters2106TVD MemoryRegionNameType = "TVDREGS"
	MemoryRegionB7_0             MemoryRegionNameType = "B7_0"
	MemoryRegionB7_1             MemoryRegionNameType = "B7_1"
	MemoryRegionB9               MemoryRegionNameType = "B9"
	MemoryRegionFLASH            MemoryRegionNameType = "FLASH"
)

type PatchExecFuncRequest

type PatchExecFuncRequest struct {
	DPTR uint16
	R3   byte
	R4   byte
	R5   byte
	R6   byte
	R7_A byte
}

type PatchExecFuncResponse

type PatchExecFuncResponse struct {
	A  byte
	R2 byte
	R3 byte
	R4 byte
	R5 byte
	R6 byte
	R7 byte
	C  bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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