m68kmem

package
v0.0.0-...-3598644 Latest Latest
Warning

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

Go to latest
Published: May 10, 2018 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	MinAddress uint32 = 0
	MaxAddress uint32 = 0xFFFFFF
)

Variables

This section is empty.

Functions

func AccessViolationError

func AccessViolationError(addr uint32) error

AccessViolationError returns an error indicating a memory address access violation for the given address.

Types

type Decoder

type Decoder struct {
	M Memory
	// contains filtered or unexported fields
}

A Decoder provides native type decoding for a Memory interface.

func NewDecoder

func NewDecoder(m Memory) *Decoder

NewDecoder returns a new Decoder for the given Memory interface.

func (*Decoder) Byte

func (m *Decoder) Byte(addr int) (b byte, err error)

Byte reads a single byte from the underlying Memory interface.

func (*Decoder) Long

func (m *Decoder) Long(addr int) (n uint32, err error)

Long reads a single 32-bit unsigned long from the underlying Memory interface.

func (*Decoder) Read

func (m *Decoder) Read(addr int, p []byte) (n int, err error)

Read reads from the underlying Memory interface.

func (*Decoder) Reset

func (m *Decoder) Reset() (err error)

Reset resets the underlying Memory interface.

func (*Decoder) Slong

func (m *Decoder) Slong(addr int) (n int32, err error)

Slong reads a single 32-bit signed long from the underlying Memory interface.

func (*Decoder) Sword

func (m *Decoder) Sword(addr int) (n int16, err error)

Sword reads a single 16-bit signed word from the underlying Memory interface.

func (*Decoder) Word

func (m *Decoder) Word(addr int) (n uint16, err error)

Word reads a single 16-bit unsigned word from the underlying Memory interface.

func (*Decoder) Write

func (m *Decoder) Write(addr int, p []byte) (n int, err error)

Write writes to the underlying Memory interface.

type Mapper

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

A Mapper allows a Motorola 68000 processor to communicate with external devices using a memory address, mapped into its addressable range.

Example
// create a memory mapper
m := NewMapper()

// map a ROM device to 0x00
dev1 := NewROM([]byte("This is device one.............\n"))
m.Map(dev1, 0, 0x1F)

// map a ROM device to 0x20
dev2 := NewROM([]byte("This is device two.............\n"))
m.Map(dev2, 0x20, 0x3F)

// map a ROM device to 0x40
dev3 := NewROM([]byte("This is device three...........\n"))
m.Map(dev3, 0x40, 0x5F)

// read 96 bytes from the memory mapper
b := make([]byte, 0x60)
m.Read(0, b)
fmt.Print(string(b))
Output:

This is device one.............
This is device two.............
This is device three...........

func NewMapper

func NewMapper() *Mapper

NewMapper returns a new MemoryMapper.

func (*Mapper) Map

func (mm *Mapper) Map(m Memory, start, end int) (err error)

Map maps the given Memory addressable device into the given address range.

func (*Mapper) Read

func (mm *Mapper) Read(addr int, p []byte) (n int, err error)

func (*Mapper) Reset

func (mm *Mapper) Reset() (err error)

Reset calls Reset on all mapped Memory devices. Mappings are preserved.

func (*Mapper) Write

func (mm *Mapper) Write(addr int, p []byte) (n int, err error)

type Memory

type Memory interface {
	Read(addr int, p []byte) (n int, err error)
	Write(addr int, p []byte) (n int, err error)
	Reset() (err error)
}

Memory is an interface for any IO device that is addressable via memory mapping. This interface will be satisfied by random access memory, a virtual memory manager, peripheral devices, etc.

func AttachBus

func AttachBus(m Memory) Memory

AttachBus protects all accesses to the given Memory device with a 68000 A23-A0 Address Bus emulator. The bus ensures all 32-bit addresses are reduced to a 24-bit address by masking the 8 most significant bits.

func Mirror

func Mirror(m Memory, n, r uint32) Memory

Mirror returns a new Mirror for the given Memory interface. If n is the size of the mirrored device, then r is the size of the range across which it is mirrored.

func NewNop

func NewNop() Memory

NewNop returns a No-Operation memory device that neither stores nor retrieves data. It serves only for debug or placeholder purposes.

func NewRAM

func NewRAM(size uint32) Memory

NewRAM returns Random Access Memory initialized to the given size. This memory can used to load programs and data for a 68000 processor. Memory access is protected by an AddressBus.

func NewROM

func NewROM(b []byte) Memory

NewROM returns Read-Only Memory initialized with the given byte data. This memory can be used to load programs and data for a 68000 processor. Memory access is protected by an AddressBus.

func NewTracer

func NewTracer(name string, w io.Writer, m Memory) Memory

NewTracer wraps a memory device to log all reads and write to the given io.Writer.

Example
m := NewTracer("ram", os.Stdout, NewRAM(64))
m.Write(0x10, []byte("Hello world!\n"))
m.Read(0x10, make([]byte, 13))
Output:

00000010 [ram] wrote 13 bytes: 48656c6c6f20776f726c64210a
00000010 [ram] read 13 bytes: 48656c6c6f20776f726c64210a

Jump to

Keyboard shortcuts

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