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 (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 |
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. | |
bool | flashLoaded |
Flag, true if there was a write to Flash after constructor call (program load). | |
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() () |
Holds AVR flash content and symbol informations.
Definition at line 38 of file flash.h.
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 | ( | unsigned int | addr, | |
int | secSize | |||
) |
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 | ( | ) |
Decode/create all instructions
Definition at line 38 of file flash.cpp.
References Memory::size.
Referenced by GdbServer::avr_core_flash_write(), GdbServer::avr_core_flash_write_hi8(), GdbServer::avr_core_flash_write_lo8(), AvrFlash(), Decode(), and WriteMem().
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 AvrDevice::Step().
bool AvrFlash::IsProgramLoaded | ( | void | ) | [inline] |
True if flash was written, i.e. a program was loaded
Definition at line 76 of file flash.h.
References flashLoaded.
Referenced by GdbServer::gdb_parse_packet().
bool AvrFlash::IsRWWLock | ( | unsigned int | addr | ) | [inline] |
True if simulated Flash write is in progress and the address is in locked area.
Definition at line 79 of file flash.h.
References rww_lock.
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: * prologue with frame pointer (sbiw, sbci, subi) * epilogue with frame pointer (adiw) * SP initialization after reset (ldi) * -mcall-prologues functions (sub, sbc, add, adc) * kernels like AvrX and DTRTK which switch stacks in two phases We analyze few preceding instructions in hope to rule out these cases. (GDB's weak prologue analysis is doctored elsewhere.)
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().
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_LPM_Z_incr::operator()(), avr_op_LPM::operator()(), avr_op_LPM_Z::operator()(), avr_op_ELPM::operator()(), avr_op_ELPM_Z_incr::operator()(), and avr_op_ELPM_Z::operator()().
unsigned char AvrFlash::ReadMemRaw | ( | unsigned int | addr | ) | [inline] |
Returns byte at flash address. Works even during flash writing.
Definition at line 89 of file flash.h.
References Memory::myMemory.
unsigned int AvrFlash::ReadMemRawWord | ( | unsigned int | addr | ) | [inline] |
Returns 16bits at flash address. Works even during flash writing.
Definition at line 95 of file flash.h.
References Memory::myMemory.
Referenced by GdbServer::avr_core_flash_read().
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_STS::operator()(), avr_op_LDS::operator()(), avr_op_JMP::operator()(), avr_op_CALL::operator()(), avr_op_STS::Trace(), avr_op_LDS::Trace(), avr_op_JMP::Trace(), and avr_op_CALL::Trace().
void AvrFlash::SetRWWLock | ( | unsigned int | addr | ) | [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 rww_lock.
Referenced by FlashProgramming::SetRWWLock(), and FlashProgramming::SPM_action().
void AvrFlash::WriteMem | ( | unsigned char * | src, | |
unsigned int | addr, | |||
unsigned int | secSize | |||
) | [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 AvrDevice::Load(), 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.
Referenced by GdbServer::avr_core_flash_write(), GdbServer::avr_core_flash_write_hi8(), and GdbServer::avr_core_flash_write_lo8().
int avr_op_CPSE::operator() | ( | ) | [friend] |
int avr_op_SBIC::operator() | ( | ) | [friend] |
int avr_op_SBIS::operator() | ( | ) | [friend] |
int avr_op_SBRC::operator() | ( | ) | [friend] |
int avr_op_SBRS::operator() | ( | ) | [friend] |
AvrDevice* AvrFlash::core [protected] |
std::vector<DecodedInstruction*> AvrFlash::DecodedMem [protected] |
Definition at line 42 of file flash.h.
Referenced by Decode(), GetInstruction(), LooksLikeContextSwitch(), avr_op_SBRS::operator()(), avr_op_SBRC::operator()(), avr_op_SBIS::operator()(), avr_op_SBIC::operator()(), avr_op_CPSE::operator()(), and ~AvrFlash().
bool AvrFlash::flashLoaded [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().
unsigned int AvrFlash::rww_lock [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(), IsRWWLock(), and SetRWWLock().