memio

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: BSD-3-Clause Imports: 7 Imported by: 48

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchIn

func ArchIn(addr uint16, data UintN) error

ArchIn is deprecated. Only here to keep compatibility

func ArchOut

func ArchOut(addr uint16, data UintN) error

ArchOut is deprecated. Only here to keep compatibility

func In

func In(addr uint16, data UintN) error

In is deprecated. Only here for compatibility. Use NewPort() and the interface functions instead.

func Out

func Out(addr uint16, data UintN) error

Out is deprecated. Only here for compatibility. Use NewPort() and the interface functions instead.

func Read

func Read(addr int64, data UintN) error

Read is deprecated. Still here for compatibility. Use NewMMap() and the interface function instead.

func Write

func Write(addr int64, data UintN) error

Write is deprecated. Still here for compatibility. Use NewMMap() and the interface function instead.

Types

type ArchPort added in v0.9.0

type ArchPort struct{}

ArchPort is used for architectural access to a port, instead of file system level access. On the x86, this means direct, in-line in[bwl]/out[bwl] instructions, requiring an iopl system call. On other architectures, it may require special mmap setup.

func (*ArchPort) Close added in v0.9.0

func (a *ArchPort) Close() error

Close implements close

func (*ArchPort) In added in v0.9.0

func (a *ArchPort) In(addr uint16, data UintN) error

In reads data from the x86 port at address addr. Data must be Uint8, Uint16, Uint32, but not Uint64.

func (*ArchPort) Out added in v0.9.0

func (a *ArchPort) Out(addr uint16, data UintN) error

Out writes data to the x86 port at address addr. data must be Uint8, Uint16 uint32, but not Uint64.

type ByteSlice

type ByteSlice []byte

ByteSlice is a wrapper around []byte.

func (*ByteSlice) Size

func (s *ByteSlice) Size() int64

Size of []byte.

func (*ByteSlice) String

func (s *ByteSlice) String() string

String formats a []byte in hex.

type LinuxPort added in v0.9.0

type LinuxPort struct {
	ReadWriteCloser
}

LinuxPort implements ReadWriteCloser for Linux devices.

func NewPort added in v0.9.0

func NewPort() (*LinuxPort, error)

NewPort returns a new instance of LinuxPort for read/write operations on /dev/port

func (*LinuxPort) Close added in v0.9.0

func (p *LinuxPort) Close() error

Close implements Close.

func (*LinuxPort) In added in v0.9.0

func (p *LinuxPort) In(addr uint16, data UintN) error

In reads data from the x86 port at address addr. Data must be Uint8, Uint16, Uint32, but not Uint64.

func (*LinuxPort) Out added in v0.9.0

func (p *LinuxPort) Out(addr uint16, data UintN) error

Out writes data to the x86 port at address addr. data must be Uint8, Uint16 uint32, but not Uint64.

type MMap added in v0.9.0

type MMap struct {
	*os.File
	// contains filtered or unexported fields
}

MMap is a struct containing an os.File and an interface to system calls to manage mapped files.

func NewMMap added in v0.9.0

func NewMMap(path string) (*MMap, error)

NewMMap returns an Mmap for a file (usually a device) passed as a string.

func (*MMap) Close added in v0.9.0

func (m *MMap) Close() error

Close implements Close.

func (*MMap) ReadAt added in v0.9.0

func (m *MMap) ReadAt(addr int64, data UintN) error

ReadAt reads data from physical memory at address addr. On x86 platforms, this uses the seek+read syscalls. On arm platforms, this uses mmap.

func (*MMap) WriteAt added in v0.9.0

func (m *MMap) WriteAt(addr int64, data UintN) error

WriteAt writes data to physical memory at address addr. On x86 platforms, this uses the seek+read syscalls. On arm platforms, this uses mmap.

type Port added in v0.9.0

type Port struct {
	*os.File
}

Port implements memory and IO port access via an os.File.

func NewMemIOPort added in v0.9.0

func NewMemIOPort(f *os.File) *Port

NewMemIOPort returns a Port, given an os.File.

func (*Port) Close added in v0.9.0

func (m *Port) Close() error

Close implements Close.

func (*Port) Read added in v0.9.0

func (m *Port) Read(out UintN, addr int64) error

Read implements Reader for a Port

func (*Port) Write added in v0.9.0

func (m *Port) Write(in UintN, addr int64) error

Write implements Writer for a Port

type PortReadWriter added in v0.9.0

type PortReadWriter interface {
	PortReader
	PortWriter
	io.Closer
}

PortReadWriter implements io.ReadWriter for IO ports.

type PortReader added in v0.9.0

type PortReader interface {
	In(uint16, UintN) error
}

PortReader is the interface for IO port read access.

type PortWriter added in v0.9.0

type PortWriter interface {
	Out(uint16, UintN) error
}

PortWriter is the interface for IO port write access.

type ReadWriteCloser added in v0.9.0

type ReadWriteCloser interface {
	Reader
	Writer
	io.Closer
}

ReadWriteCloser implements io.ReadWriteCloser

type Reader added in v0.9.0

type Reader interface {
	Read(UintN, int64) error
}

Reader is the interface for reading from memory and IO ports.

type Uint16

type Uint16 uint16

Uint16 is a wrapper around uint16.

func (*Uint16) Size

func (u *Uint16) Size() int64

Size of uint16 is 2.

func (*Uint16) String

func (u *Uint16) String() string

String formats a uint16 in hex.

type Uint32

type Uint32 uint32

Uint32 is a wrapper around uint32.

func (*Uint32) Size

func (u *Uint32) Size() int64

Size of uint32 is 4.

func (*Uint32) String

func (u *Uint32) String() string

String formats a uint32 in hex.

type Uint64

type Uint64 uint64

Uint64 is a wrapper around uint64.

func (*Uint64) Size

func (u *Uint64) Size() int64

Size of uint64 is 8.

func (*Uint64) String

func (u *Uint64) String() string

String formats a uint64 in hex.

type Uint8

type Uint8 uint8

Uint8 is a wrapper around uint8.

func (*Uint8) Size

func (u *Uint8) Size() int64

Size of uint8 is 1.

func (*Uint8) String

func (u *Uint8) String() string

String formats a uint8 in hex.

type UintN

type UintN interface {
	// Return size in bytes.
	Size() int64

	// Return string formatted in hex.
	String() string
	// contains filtered or unexported methods
}

UintN is a wrapper around uint types and provides a few io-related functions.

type Writer added in v0.9.0

type Writer interface {
	Write(UintN, int64) error
}

Writer is the interface for writing to memory and IO ports.

Jump to

Keyboard shortcuts

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