simulavr
1.1.0
|
Holds AVR flash content and symbol informations. More...
#include <flash.h>
Public Member Functions | |
AvrFlash (AvrDevice *c, int size) | |
~AvrFlash () | |
void | Decode () |
void | Decode (unsigned int addr) |
void | Decode (unsigned int addr, int secSize) |
void | WriteMem (const unsigned char *src, unsigned int addr, unsigned int secSize) |
void | WriteMemByte (unsigned char val, unsigned int address) |
bool | IsProgramLoaded (void) |
bool | IsRWWLock (unsigned int addr) |
void | SetRWWLock (unsigned int addr) |
DecodedInstruction * | GetInstruction (unsigned int pc) |
unsigned char | ReadMemRaw (unsigned int addr) |
unsigned char | ReadMem (unsigned int addr) |
unsigned int | ReadMemRawWord (unsigned int addr) |
unsigned int | ReadMemWord (unsigned int addr) |
bool | LooksLikeContextSwitch (unsigned int addr) const |
![]() | |
Memory (int size) | |
virtual | ~Memory () |
std::string | GetSymbolAtAddress (unsigned int add) |
unsigned int | GetAddressAtSymbol (const std::string &s) |
void | AddSymbol (std::pair< unsigned int, std::string > p) |
unsigned int | GetSize () |
Protected Attributes | |
AvrDevice * | core |
std::vector< DecodedInstruction * > | DecodedMem |
unsigned int | rww_lock |
When Flash write is in progress then addresses below this are inaccesible, otherwise 0. More... | |
bool | flashLoaded |
Flag, true if there was a write to Flash after constructor call (program load) More... | |
![]() | |
unsigned int | size |
Friends | |
int | avr_op_CPSE::operator() () |
int | avr_op_SBIC::operator() () |
int | avr_op_SBIS::operator() () |
int | avr_op_SBRC::operator() () |
int | avr_op_SBRS::operator() () |
Additional Inherited Members | |
![]() | |
unsigned char * | myMemory |
std::multimap< unsigned int, std::string > | sym |
AvrFlash::AvrFlash | ( | AvrDevice * | c, |
int | size | ||
) |
Definition at line 43 of file flash.cpp.
References Decode(), Memory::myMemory, rww_lock, and Memory::size.
AvrFlash::~AvrFlash | ( | ) |
Definition at line 55 of file flash.cpp.
References DecodedMem, and Memory::size.
void AvrFlash::Decode | ( | ) |
Decode/create all instructions
Definition at line 38 of file flash.cpp.
References Memory::size.
Referenced by AvrFlash(), Decode(), and WriteMem().
void AvrFlash::Decode | ( | unsigned int | addr | ) |
Decode/create instruction at address 'addr'.
Definition at line 109 of file flash.cpp.
References core, DecodedMem, lookup_opcode(), Memory::myMemory, and Memory::size.
void AvrFlash::Decode | ( | unsigned int | addr, |
int | secSize | ||
) |
DecodedInstruction * AvrFlash::GetInstruction | ( | unsigned int | pc | ) |
Returns instruction at pointer PC. Aborts if Flash write is in progress.
Definition at line 80 of file flash.cpp.
References avr_error, DecodedMem, and IsRWWLock().
Referenced by SetRWWLock(), and AvrDevice::Step().
|
inline |
True if flash was written, i.e. a program was loaded
Definition at line 76 of file flash.h.
References flashLoaded.
|
inline |
True if simulated Flash write is in progress and the address is in locked area.
Definition at line 79 of file flash.h.
Referenced by GetInstruction(), ReadMem(), and ReadMemWord().
bool AvrFlash::LooksLikeContextSwitch | ( | unsigned int | addr | ) | const |
Returns true if insn at address index*2 looks like switching thread stacks (heuristics).
Any switch contains "out SP?,r??" insn. We return false for any other. Problematic uses of "out SP?,r??" that are not a switch:
Definition at line 131 of file flash.cpp.
References DecodedMem, DecodedInstruction::GetModifiedR(), DecodedInstruction::GetModifiedRHi(), avr_op_OUT::ioreg, avr_op_OUT::R1, and Memory::size.
Referenced by ThreadList::OnSPWrite(), and ReadMemRawWord().
unsigned char AvrFlash::ReadMem | ( | unsigned int | addr | ) |
Returns byte at flash address. Aborts if Flash write is in progress.
Definition at line 86 of file flash.cpp.
References avr_warning, IsRWWLock(), and Memory::myMemory.
Referenced by avr_op_ELPM_Z::operator()(), avr_op_ELPM_Z_incr::operator()(), avr_op_ELPM::operator()(), avr_op_LPM_Z::operator()(), avr_op_LPM::operator()(), avr_op_LPM_Z_incr::operator()(), and ReadMemRaw().
|
inline |
Returns byte at flash address. Works even during flash writing.
Definition at line 89 of file flash.h.
References Memory::myMemory, and ReadMem().
|
inline |
Returns 16bits at flash address. Works even during flash writing.
Definition at line 95 of file flash.h.
References LooksLikeContextSwitch(), Memory::myMemory, and ReadMemWord().
unsigned int AvrFlash::ReadMemWord | ( | unsigned int | addr | ) |
Returns 16bits at flash address. Aborts if Flash write is in progress.
Definition at line 94 of file flash.cpp.
References avr_warning, IsRWWLock(), Memory::myMemory, and Memory::size.
Referenced by avr_op_CALL::operator()(), avr_op_JMP::operator()(), avr_op_LDS::operator()(), avr_op_STS::operator()(), and ReadMemRawWord().
|
inline |
Sets/Resets RWW lock address
addr | address, below flash is locked, 0 to disable lock |
Definition at line 83 of file flash.h.
References GetInstruction().
Referenced by FlashProgramming::SetRWWLock(), and FlashProgramming::SPM_action().
|
virtual |
Write `secSize' bytes from `src' data to byte address `addr'.
src | binary c-string with data to write in |
secSize | count of available data (bytes) in src |
Implements Memory.
Definition at line 62 of file flash.cpp.
References Decode(), flashLoaded, Memory::myMemory, and Memory::size.
Referenced by ELFLoad(), and FlashProgramming::SPM_action().
void AvrFlash::WriteMemByte | ( | unsigned char | val, |
unsigned int | address | ||
) |
Write byte `val' at `address' (in bytes). Caller must call Decode() later.
Definition at line 74 of file flash.cpp.
References flashLoaded, Memory::myMemory, and Memory::size.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
Definition at line 42 of file flash.h.
Referenced by Decode(), GetInstruction(), LooksLikeContextSwitch(), avr_op_CPSE::operator()(), avr_op_SBIC::operator()(), avr_op_SBIS::operator()(), avr_op_SBRC::operator()(), avr_op_SBRS::operator()(), and ~AvrFlash().
|
protected |
Flag, true if there was a write to Flash after constructor call (program load)
Definition at line 44 of file flash.h.
Referenced by IsProgramLoaded(), WriteMem(), and WriteMemByte().
|
protected |
When Flash write is in progress then addresses below this are inaccesible, otherwise 0.
Definition at line 43 of file flash.h.
Referenced by AvrFlash().