Documentation
¶
Index ¶
- Constants
- type AddressBus
- type AddressError
- type AddressRange
- type AddressRangeDevice
- type Breakpoint
- type BreakpointEvent
- type BreakpointHit
- type BreakpointType
- type Bus
- func (b *Bus) AddDevice(device Device)
- func (b *Bus) Peek(s Size, address uint32) (uint32, error)
- func (b *Bus) Read(s Size, address uint32) (uint32, error)
- func (b *Bus) Reset()
- func (b *Bus) SetWaitHook(hook WaitHook)
- func (b *Bus) SetWaitStates(states uint32)
- func (b *Bus) Write(s Size, address uint32, value uint32) error
- type BusAccessCallback
- type BusAccessInfo
- type BusError
- type CPU
- type CycleListener
- type CycleScheduler
- func (s *CycleScheduler) AddListener(listener CycleListener)
- func (s *CycleScheduler) Advance(delta uint64)
- func (s *CycleScheduler) Now() uint64
- func (s *CycleScheduler) Reset(now uint64)
- func (s *CycleScheduler) Schedule(at uint64, fn func(now uint64))
- func (s *CycleScheduler) ScheduleAfter(delta uint64, fn func(now uint64))
- type DebugFaultInfo
- type DebugState
- type Device
- type DisassemblyLine
- type ExceptionCallback
- type ExceptionInfo
- type ExceptionStackFrame
- type ExceptionStackFrameFormat
- type HistoryEntry
- type HistoryKind
- type InterruptCallback
- type InterruptController
- type InterruptInfo
- type MappedDevice
- func (d *MappedDevice) AddressRange() (uint32, uint32)
- func (d *MappedDevice) Contains(address uint32) bool
- func (d *MappedDevice) Peek(size Size, address uint32) (uint32, error)
- func (d *MappedDevice) Read(size Size, address uint32) (uint32, error)
- func (d *MappedDevice) Reset()
- func (d *MappedDevice) Write(size Size, address uint32, value uint32) error
- type MemoryRange
- type PeekDevice
- type PreTraceCallback
- type PreTraceInfo
- type RAM
- func (ram *RAM) AddressRange() (uint32, uint32)
- func (ram *RAM) Contains(address uint32) bool
- func (ram *RAM) Peek(s Size, address uint32) (uint32, error)
- func (ram *RAM) Read(s Size, address uint32) (uint32, error)
- func (ram *RAM) Reset()
- func (ram *RAM) Write(s Size, address uint32, value uint32) error
- type Registers
- type RunPredicateInfo
- type RunResult
- type RunStopReason
- type RunUntilOptions
- type ScheduledEvent
- type Size
- type TraceCallback
- type TraceInfo
- type VerboseLogger
- type VerboseLoggerOptions
- type WaitHook
- type WaitStateDevice
Constants ¶
const ( Version = "1.4.0" XBusError = 2 XAddressError = 3 XIllegal = 4 XDivByZero = 5 XPrivViolation = 8 XLineA = 10 XLineF = 11 XUninitializedInt = 15 XTrap = 32 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressBus ¶
type AddressBus interface {
Read(s Size, address uint32) (uint32, error)
Write(s Size, address uint32, value uint32) error
Reset()
}
AddressBus for accessing address areas
type AddressError ¶
type AddressError uint32
func (AddressError) Error ¶
func (ae AddressError) Error() string
type AddressRange ¶ added in v1.2.0
func (AddressRange) Contains ¶ added in v1.2.0
func (r AddressRange) Contains(address uint32) bool
type AddressRangeDevice ¶ added in v1.1.0
AddressRangeDevice exposes a fixed address range that can be indexed by the bus.
type Breakpoint ¶
type BreakpointEvent ¶
type BreakpointEvent struct {
Type BreakpointType
Address uint32
Registers Registers
}
type BreakpointHit ¶
type BreakpointHit struct {
Address uint32
Type BreakpointType
}
func (BreakpointHit) Error ¶
func (bh BreakpointHit) Error() string
type BreakpointType ¶
type BreakpointType int
const ( BreakpointExecute BreakpointType = iota BreakpointRead BreakpointWrite )
func (BreakpointType) String ¶
func (bt BreakpointType) String() string
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus multiplexes memory access between attached devices and performs common checks such as alignment and bus error handling.
func (*Bus) Peek ¶ added in v1.1.0
Peek reads from the mapped device without charging wait states. Devices may use this for debugger-friendly, side-effect-free inspection.
func (*Bus) Read ¶
Read forwards a read to the mapped device after performing alignment and mapping checks.
func (*Bus) SetWaitHook ¶
SetWaitHook installs a callback that receives the configured wait states for every transaction. Callers can use this to count cycles or block for a desired duration.
func (*Bus) SetWaitStates ¶
SetWaitStates defines how many states the bus should report for each transaction when a WaitHook is configured.
type BusAccessCallback ¶ added in v1.2.0
type BusAccessCallback func(BusAccessInfo)
type BusAccessInfo ¶ added in v1.2.0
type BusAccessInfo struct {
Address uint32
Size Size
Value uint32
Write bool
InstructionFetch bool
PC uint32
}
BusAccessInfo describes one memory transaction observed by the CPU core.
type CPU ¶
type CPU interface {
Registers() Registers
DebugState() DebugState
Step() error
RunCycles(budget uint64) error
RunInstructions(count uint64) error
RunUntil(options RunUntilOptions) (RunResult, error)
Reset() error
SetTracer(TraceCallback)
SetPreTracer(PreTraceCallback)
SetExceptionTracer(ExceptionCallback)
SetBusTracer(BusAccessCallback)
SetInterruptTracer(InterruptCallback)
SetScheduler(*CycleScheduler)
Scheduler() *CycleScheduler
AddBreakpoint(Breakpoint)
RequestInterrupt(level uint8, vector *uint8) error
Cycles() uint64
SetHistoryLimit(limit int)
History() []HistoryEntry
CurrentExceptionFrame() (ExceptionStackFrame, bool, error)
}
CPU exposes the minimal interface for interacting with the emulator core.
func NewCPU ¶
func NewCPU(bus AddressBus) (CPU, error)
type CycleListener ¶ added in v1.1.0
type CycleScheduler ¶ added in v1.1.0
type CycleScheduler struct {
// contains filtered or unexported fields
}
func NewCycleScheduler ¶ added in v1.2.0
func NewCycleScheduler() *CycleScheduler
func (*CycleScheduler) AddListener ¶ added in v1.2.0
func (s *CycleScheduler) AddListener(listener CycleListener)
func (*CycleScheduler) Advance ¶ added in v1.2.0
func (s *CycleScheduler) Advance(delta uint64)
func (*CycleScheduler) Now ¶ added in v1.2.0
func (s *CycleScheduler) Now() uint64
func (*CycleScheduler) Reset ¶ added in v1.2.0
func (s *CycleScheduler) Reset(now uint64)
func (*CycleScheduler) Schedule ¶ added in v1.2.0
func (s *CycleScheduler) Schedule(at uint64, fn func(now uint64))
func (*CycleScheduler) ScheduleAfter ¶ added in v1.2.0
func (s *CycleScheduler) ScheduleAfter(delta uint64, fn func(now uint64))
type DebugFaultInfo ¶ added in v1.2.0
type DebugState ¶ added in v1.2.0
type DebugState struct {
Registers Registers
InException bool
InterruptMask uint8
LastFault DebugFaultInfo
LastException ExceptionInfo
HasException bool
LastInterrupt InterruptInfo
HasInterrupt bool
}
type Device ¶
type Device interface {
Contains(address uint32) bool
Read(Size, uint32) (uint32, error)
Write(Size, uint32, uint32) error
Reset()
}
Device represents a memory-mapped peripheral on the address bus. Implementations are expected to be safe for repeated Reset calls and must internally validate the address ranges they cover.
type DisassemblyLine ¶ added in v1.2.0
DisassemblyLine captures one decoded instruction plus the backing bytes.
func DisassembleInstruction ¶ added in v1.2.0
func DisassembleInstruction(bus AddressBus, address uint32) (DisassemblyLine, error)
DisassembleInstruction decodes one instruction at the given bus address.
func DisassembleMemoryRange ¶ added in v1.2.0
func DisassembleMemoryRange(bus AddressBus, start uint32, length uint32) ([]DisassemblyLine, error)
DisassembleMemoryRange decodes instructions sequentially until the range is covered.
func (DisassemblyLine) String ¶ added in v1.2.0
func (line DisassemblyLine) String() string
String renders a disassembly line with its bytes for human-readable logs.
type ExceptionCallback ¶ added in v1.2.0
type ExceptionCallback func(ExceptionInfo)
type ExceptionInfo ¶ added in v1.2.0
type ExceptionInfo struct {
Vector uint32
PC uint32
NewPC uint32
Opcode uint16
OpcodeAddress uint32
FaultAddress uint32
FaultValid bool
SR uint16
NewSR uint16
StackPointer uint32
Frame ExceptionStackFrame
FrameValid bool
InterruptMask uint8
Group0 bool
}
ExceptionInfo describes one taken exception after vectoring has completed.
type ExceptionStackFrame ¶ added in v1.2.3
type ExceptionStackFrame struct {
Format ExceptionStackFrameFormat
StackPointer uint32
StatusWord uint16
FaultAddress uint32
InstructionRegister uint16
SR uint16
PC uint32
}
ExceptionStackFrame mirrors the exception frame currently stored on the supervisor stack.
func ReadExceptionStackFrame ¶ added in v1.2.3
func ReadExceptionStackFrame(bus AddressBus, sp uint32, format ExceptionStackFrameFormat) (ExceptionStackFrame, error)
ReadExceptionStackFrame decodes a 68000 exception frame directly from memory without requiring the caller to know the byte layout.
type ExceptionStackFrameFormat ¶ added in v1.2.3
type ExceptionStackFrameFormat int
ExceptionStackFrameFormat identifies the 68000 frame layout captured for an exception.
const ( ExceptionStackFrameGroup12 ExceptionStackFrameFormat = iota ExceptionStackFrameGroup0 )
type HistoryEntry ¶ added in v1.2.3
type HistoryEntry struct {
Kind HistoryKind
Trace TraceInfo
Exception ExceptionInfo
Interrupt InterruptInfo
BusAccess BusAccessInfo
}
HistoryEntry stores one recent debug event in the optional rolling history buffer.
type HistoryKind ¶ added in v1.2.3
type HistoryKind int
const ( HistoryInstruction HistoryKind = iota HistoryException HistoryInterrupt HistoryBusAccess )
type InterruptCallback ¶ added in v1.2.3
type InterruptCallback func(InterruptInfo)
type InterruptController ¶
type InterruptController struct {
// contains filtered or unexported fields
}
func NewInterruptController ¶
func NewInterruptController() *InterruptController
func (*InterruptController) Request ¶
func (ic *InterruptController) Request(level uint8, vector *uint8) error
func (*InterruptController) Reset ¶ added in v1.2.0
func (ic *InterruptController) Reset()
type InterruptInfo ¶ added in v1.2.3
type InterruptInfo struct {
Level uint8
Vector uint32
AutoVector bool
PC uint32
NewPC uint32
SR uint16
NewSR uint16
}
InterruptInfo describes an interrupt that was accepted by the CPU.
type MappedDevice ¶ added in v1.1.0
type MappedDevice struct {
// contains filtered or unexported fields
}
MappedDevice wraps another device with an explicit 24-bit address range.
func (*MappedDevice) AddressRange ¶ added in v1.1.0
func (d *MappedDevice) AddressRange() (uint32, uint32)
func (*MappedDevice) Contains ¶ added in v1.1.0
func (d *MappedDevice) Contains(address uint32) bool
func (*MappedDevice) Peek ¶ added in v1.1.0
func (d *MappedDevice) Peek(size Size, address uint32) (uint32, error)
func (*MappedDevice) Read ¶ added in v1.1.0
func (d *MappedDevice) Read(size Size, address uint32) (uint32, error)
func (*MappedDevice) Reset ¶ added in v1.1.0
func (d *MappedDevice) Reset()
type MemoryRange ¶ added in v1.2.0
MemoryRange describes a region of memory to disassemble for debug output.
type PeekDevice ¶ added in v1.1.0
PeekDevice exposes a side-effect-free read path for debugging and disassembly.
type PreTraceCallback ¶ added in v1.2.3
type PreTraceCallback func(PreTraceInfo)
type PreTraceInfo ¶ added in v1.2.3
type PreTraceInfo struct {
PC uint32
SR uint16
Registers Registers
Opcode uint16
Bytes []byte
Mnemonic string
Cycles uint64
}
PreTraceInfo reports an instruction just before execution.
type RAM ¶
type RAM struct {
// contains filtered or unexported fields
}
simple flat memory structure
func (*RAM) AddressRange ¶ added in v1.2.0
type Registers ¶
type Registers struct {
D [8]int32
A [8]uint32
PC uint32
SR uint16
SSP uint32
USP uint32
IR uint16 // instruction register
}
Registers represents the programmer visible registers of the 68000 CPU.
type RunPredicateInfo ¶ added in v1.2.3
type RunPredicateInfo struct {
Registers Registers
Instructions uint64
Cycles uint64
LastException ExceptionInfo
HasException bool
LastBusAccess BusAccessInfo
HasBusAccess bool
LastInterrupt InterruptInfo
HasInterrupt bool
}
RunPredicateInfo is passed to StopPredicate after each completed instruction.
type RunResult ¶ added in v1.2.0
type RunResult struct {
Reason RunStopReason
Instructions uint64
Cycles uint64
PC uint32
Exception ExceptionInfo
HasException bool
BusAccess BusAccessInfo
HasBusAccess bool
Interrupt InterruptInfo
HasInterrupt bool
}
RunResult reports why RunUntil stopped and what the CPU observed while stopping.
type RunStopReason ¶ added in v1.2.0
type RunStopReason int
const ( RunStopNone RunStopReason = iota RunStopInstructionLimit RunStopPC RunStopPCInRange RunStopPCOutsideRange RunStopBusAccess RunStopPredicate RunStopException RunStopIllegalOpcode )
func (RunStopReason) String ¶ added in v1.2.0
func (reason RunStopReason) String() string
type RunUntilOptions ¶ added in v1.2.0
type RunUntilOptions struct {
MaxInstructions uint64
StopOnException bool
StopOnIllegal bool
StopAtPC []uint32
StopOnPCRange *AddressRange
StopWhenPCOutside *AddressRange
StopOnBusAccess func(BusAccessInfo) bool
StopPredicate func(RunPredicateInfo) bool
}
RunUntilOptions controls which conditions stop the instruction runner.
type ScheduledEvent ¶ added in v1.1.0
type TraceCallback ¶
type TraceCallback func(TraceInfo)
type TraceInfo ¶
type TraceInfo struct {
PC uint32
SR uint16
Registers Registers
BeforeRegisters Registers
Opcode uint16
Bytes []byte
Mnemonic string
CycleDelta uint32
Cycles uint64
}
TraceInfo reports the outcome of a single executed instruction.
type VerboseLogger ¶ added in v1.2.0
type VerboseLogger struct {
// contains filtered or unexported fields
}
VerboseLogger formats trace callbacks with disassembly and optional state dumps.
func NewVerboseLogger ¶ added in v1.2.0
func NewVerboseLogger(cpu CPU, bus AddressBus, writer io.Writer, options VerboseLoggerOptions) *VerboseLogger
NewVerboseLogger builds a trace callback helper that writes detailed execution logs.
func (*VerboseLogger) Trace ¶ added in v1.2.0
func (logger *VerboseLogger) Trace(info TraceInfo)
Trace implements TraceCallback for use with CPU.SetTracer.
type VerboseLoggerOptions ¶ added in v1.2.0
type VerboseLoggerOptions struct {
IncludeRegisters bool
IncludeCycles bool
MemoryRanges []MemoryRange
}
VerboseLoggerOptions controls how much detail a VerboseLogger emits.
type WaitHook ¶
type WaitHook func(states uint32)
WaitHook can be used to simulate wait states or count cycles for bus access.
type WaitStateDevice ¶
WaitStateDevice optionally advertises additional wait states a device imposes per transaction. Implementations may vary their contribution based on access size and address.