AvrFlash Class Reference

Holds AVR flash content and symbol informations. More...

#include <flash.h>

Inheritance diagram for AvrFlash:
Inheritance graph
[legend]
Collaboration diagram for AvrFlash:
Collaboration graph
[legend]

List of all members.

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)
DecodedInstructionGetInstruction (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

AvrDevicecore
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() ()

Detailed Description

Holds AVR flash content and symbol informations.

Definition at line 38 of file flash.h.


Constructor & Destructor Documentation

AvrFlash::AvrFlash ( AvrDevice c,
int  size 
)

Definition at line 43 of file flash.cpp.

References Decode(), Memory::myMemory, rww_lock, and Memory::size.

Here is the call graph for this function:

AvrFlash::~AvrFlash (  ) 

Definition at line 55 of file flash.cpp.

References DecodedMem, and Memory::size.


Member Function Documentation

void AvrFlash::Decode ( unsigned int  addr,
int  secSize 
)

Decode memory block with offset and size

Parameters:
offset data offset in memory block, beginning from start of THIS memory block!
secSize count of available data (bytes) in src

Definition at line 104 of file flash.cpp.

References Decode().

Here is the call graph for this function:

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.

Here is the call graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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()().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void AvrFlash::SetRWWLock ( unsigned int  addr  )  [inline]

Sets/Resets RWW lock address

Parameters:
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().

Here is the caller graph for this function:

void AvrFlash::WriteMem ( unsigned char *  src,
unsigned int  addr,
unsigned int  secSize 
) [virtual]

Write `secSize' bytes from `src' data to byte address `addr'.

Parameters:
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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:


Friends And Related Function Documentation

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]

Member Data Documentation

AvrDevice* AvrFlash::core [protected]

Definition at line 41 of file flash.h.

Referenced by Decode().

std::vector<DecodedInstruction*> AvrFlash::DecodedMem [protected]
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().


The documentation for this class was generated from the following files:
Generated on Sun Feb 12 16:50:38 2012 for Simulavr by  doxygen 1.6.3