simulavr  1.1.0
HWStack Class Referenceabstract

Implements a stack register with stack logic. More...

#include <hwstack.h>

Inheritance diagram for HWStack:

Public Member Functions

 HWStack (AvrDevice *core)
 Creates a stack instance. More...
 
virtual ~HWStack ()
 
virtual void Push (unsigned char val)=0
 Pushs one byte to stack. More...
 
virtual unsigned char Pop ()=0
 Pops one byte from stack. More...
 
virtual void PushAddr (unsigned long addr)=0
 Pushs a address to stack. More...
 
virtual unsigned long PopAddr ()=0
 Pops a address from stack. More...
 
virtual void Reset ()
 Resets stack pointer and listener table. More...
 
unsigned long GetStackPointer () const
 Returns current stack pointer value. More...
 
void SetStackPointer (unsigned long val)
 Sets current stack pointer value (used by GDB interface) More...
 
void SetReturnPoint (unsigned long stackPointer, Funktor *listener)
 Subscribes a Listener for a return address. More...
 
void ResetLowestStackpointer (void)
 Sets lowest stack marker back to current stackpointer. More...
 
unsigned long GetLowestStackpointer (void)
 Gets back the lowest stack pointer (for measuring stack usage) More...
 

Public Attributes

ThreadList m_ThreadList
 

Protected Member Functions

void CheckReturnPoints ()
 Run functions registered for current stack address and delete them. More...
 

Protected Attributes

AvrDevicecore
 Link to device. More...
 
uint32_t stackPointer
 current value of stack pointer More...
 
uint32_t lowestStackPointer
 marker: lowest stackpointer used by program More...
 
std::multimap< unsigned long, Funktor * > returnPointList
 Maps adresses to listeners for return addresses. More...
 

Detailed Description

Implements a stack register with stack logic.

This is the base class for all 2 different stack types. It holds the interface for pushing and poping bytes and addresses from stack by core and for interrupt

Definition at line 91 of file hwstack.h.

Constructor & Destructor Documentation

◆ HWStack()

HWStack::HWStack ( AvrDevice core)

Creates a stack instance.

Definition at line 35 of file hwstack.cpp.

References Reset().

◆ ~HWStack()

HWStack::~HWStack ( )
virtual

Definition at line 42 of file hwstack.cpp.

References returnPointList.

Member Function Documentation

◆ CheckReturnPoints()

void HWStack::CheckReturnPoints ( )
protected

Run functions registered for current stack address and delete them.

Definition at line 55 of file hwstack.cpp.

References returnPointList, and stackPointer.

Referenced by HWStackSram::Pop(), HWStackSram::Push(), HWStackSram::SetSph(), and HWStackSram::SetSpl().

◆ GetLowestStackpointer()

unsigned long HWStack::GetLowestStackpointer ( void  )
inline

Gets back the lowest stack pointer (for measuring stack usage)

Definition at line 127 of file hwstack.h.

◆ GetStackPointer()

unsigned long HWStack::GetStackPointer ( ) const
inline

Returns current stack pointer value.

Definition at line 116 of file hwstack.h.

Referenced by ThreadList::OnCall(), and AvrDevice::Step().

◆ Pop()

virtual unsigned char HWStack::Pop ( )
pure virtual

Pops one byte from stack.

Implemented in ThreeLevelStack, and HWStackSram.

Referenced by avr_op_POP::operator()().

◆ PopAddr()

virtual unsigned long HWStack::PopAddr ( )
pure virtual

Pops a address from stack.

Implemented in ThreeLevelStack, and HWStackSram.

Referenced by avr_op_RET::operator()(), and avr_op_RETI::operator()().

◆ Push()

virtual void HWStack::Push ( unsigned char  val)
pure virtual

Pushs one byte to stack.

Implemented in ThreeLevelStack, and HWStackSram.

Referenced by avr_op_PUSH::operator()().

◆ PushAddr()

virtual void HWStack::PushAddr ( unsigned long  addr)
pure virtual

◆ Reset()

void HWStack::Reset ( void  )
virtual

Resets stack pointer and listener table.

Reimplemented in ThreeLevelStack, and HWStackSram.

Definition at line 49 of file hwstack.cpp.

References lowestStackPointer, returnPointList, and stackPointer.

Referenced by HWStack().

◆ ResetLowestStackpointer()

void HWStack::ResetLowestStackpointer ( void  )
inline

Sets lowest stack marker back to current stackpointer.

Definition at line 125 of file hwstack.h.

◆ SetReturnPoint()

void HWStack::SetReturnPoint ( unsigned long  stackPointer,
Funktor listener 
)

Subscribes a Listener for a return address.

Attention! SetReturnPoint must get a COPY of a Funktor because it self destroy this functor after usage!

Definition at line 66 of file hwstack.cpp.

References returnPointList.

Referenced by AvrDevice::Step().

◆ SetStackPointer()

void HWStack::SetStackPointer ( unsigned long  val)
inline

Sets current stack pointer value (used by GDB interface)

Definition at line 118 of file hwstack.h.

Member Data Documentation

◆ core

◆ lowestStackPointer

uint32_t HWStack::lowestStackPointer
protected

marker: lowest stackpointer used by program

Definition at line 96 of file hwstack.h.

Referenced by HWStackSram::Push(), ThreeLevelStack::PushAddr(), Reset(), HWStackSram::Reset(), and ThreeLevelStack::Reset().

◆ m_ThreadList

◆ returnPointList

std::multimap<unsigned long, Funktor*> HWStack::returnPointList
protected

Maps adresses to listeners for return addresses.

Definition at line 97 of file hwstack.h.

Referenced by CheckReturnPoints(), Reset(), HWStackSram::Reset(), ThreeLevelStack::Reset(), SetReturnPoint(), and ~HWStack().

◆ stackPointer


The documentation for this class was generated from the following files: