arm7tdmi

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: GPL-3.0, GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package arm7tdmi imlplements the ARM7TDMI instruction set as defined in the ARM7TDMI Instruction Set Reference:

http://www.ecs.csun.edu/~smirzaei/docs/ece425/arm7tdmi_instruction_set_reference.pdf

For this project we only need to emulte the Thumb architecture. The strategy for this was to implement the nineteen opcode formats in turn, until there was nothing left. As of writing only format 17, software interrupts, remain unimplemented. To this end, the following reference was preferred:

https://usermanual.wiki/Pdf/ARM7TDMImanualpt3.1481331792/view

The full version of that manual was found here. Cycle timings for the instructions were found in chapter 7.

https://www.dwedit.org/files/ARM7TDMI.pdf

More detailed explanations of Thumb instruction were found in chapter A7.1 of the ARM Architecture Reference Manual. In particular the side-effects of particular instructions were found in the supplied pseudo-code. Where appropriate, the pseudo-code has been included as a comment in the Go source.

https://www.cs.miami.edu/home/burt/learning/Csc521.141/Documents/arm_arm.pdf

Index

Constants

View Source
const (
	FlashOrigin       = uint32(0x00000000)
	Flash32kMemtop    = uint32(0x00007fff)
	SRAMOrigin        = uint32(0x40000000)
	SRAM8kMemtop      = uint32(0x40001fff)
	PeripheralsOrigin = uint32(0xe0000000)
	PeripheralsMemtop = uint32(0xffffffff)
)
View Source
const (
	TIMERcontrol = PeripheralsOrigin | 0x00008004
	TIMERvalue   = PeripheralsOrigin | 0x00008008
)
View Source
const (
	InternalClk = 70 // Mhz
)

Clock speeds inside the arm7 sub-system.

View Source
const (
	MAMCR = PeripheralsOrigin | 0x001fc000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ARM

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

ARM implements the ARM7TDMI-S LPC2103 processor.

func NewARM

func NewARM(mem SharedMemory, hook CartridgeHook) *ARM

NewARM is the preferred method of initialisation for the ARM type.

func (*ARM) CoProcID

func (arm *ARM) CoProcID() string

CoProcID implements the mapper.CartCoProcBus interface.

func (*ARM) Plumb added in v0.8.1

func (arm *ARM) Plumb() error

func (*ARM) PlumbSharedMemory

func (arm *ARM) PlumbSharedMemory(mem SharedMemory)

PlumbSharedMemory should be used to update the shared memory reference. Useful when used in conjunction with the rewind system.

func (*ARM) Run

func (arm *ARM) Run() (float32, error)

Run will continue until the ARM program encounters a switch from THUMB mode to ARM mode. Note that currently, this means the ARM program may run forever.

Returns the number of ARM cycles and any errors.

func (*ARM) SetDisassembler

func (arm *ARM) SetDisassembler(disasm mapper.CartCoProcDisassembler)

SetDisassembler implements the mapper.CartCoProcBus interface.

func (*ARM) Step

func (arm *ARM) Step(clock float32)

Step moves the ARM on one cycle. Currently, the timer will only step forward when Step() is called and not during the Run() process. This might cause problems in some instances with some ARM programs.

func (*ARM) String

func (arm *ARM) String() string

type ARMinterruptReturn

type ARMinterruptReturn struct {
	InterruptEvent    string
	SaveResult        bool
	SaveRegister      uint32
	SaveValue         uint32
	InterruptServiced bool
}

type CartridgeHook

type CartridgeHook interface {
	// Returns false if parent cartridge mapping does not understand the
	// address.
	ARMinterrupt(addr uint32, val1 uint32, val2 uint32) (ARMinterruptReturn, error)
}

CartridgeHook allows the parent cartridge mapping to emulate ARM code in a more direct way. This is primarily because we do not yet emulate full ARM bytecode only Thumb bytecode, and the value of doing so is unclear.

type SharedMemory

type SharedMemory interface {
	// Return memory block and array offset for the requested address. Memory
	// blocks mays be different for read and write operations.
	MapAddress(addr uint32, write bool) (*[]byte, uint32)

	// Return reset addreses for the Stack Pointer register; the Link Register;
	// and Program Counter
	ResetVectors() (uint32, uint32, uint32)
}

SharedMemory represents the memory passed between the parent cartridge-mapper implementation and the ARM.

Jump to

Keyboard shortcuts

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