OpenASIP  2.0
Public Member Functions | Protected Member Functions | Static Private Attributes | List of all members
TPEF::ResourceSection Class Reference

#include <ResourceSection.hh>

Inheritance diagram for TPEF::ResourceSection:
Inheritance graph
Collaboration diagram for TPEF::ResourceSection:
Collaboration graph

Public Member Functions

virtual ~ResourceSection ()
 
virtual SectionType type () const
 
ResourceElementfindResource (ResourceElement::ResourceType aType, HalfWord anId) const
 
bool hasResource (ResourceElement::ResourceType aType, HalfWord anId) const
 
- Public Member Functions inherited from TPEF::Section
virtual ~Section ()
 
virtual bool isChunkable () const
 
virtual Chunkchunk (SectionOffset offset) const
 
bool isProgramSection () const
 
bool isAuxSection () const
 
virtual void addElement (SectionElement *element)
 
virtual void setElement (Word index, SectionElement *element)
 
SectionElementelement (Word index) const
 
Word elementCount () const
 
void setFlagNoBits ()
 
void unsetFlagNoBits ()
 
bool noBits () const
 
bool vLen () const
 
Byte flags () const
 
void setFlags (Byte flagByte)
 
void setStartingAddress (AddressImage address)
 
AddressImage startingAddress () const
 
void setLink (const ReferenceManager::SafePointer *aLink)
 
void setLink (Section *aLink)
 
Sectionlink () const
 
void setASpace (const ReferenceManager::SafePointer *addrSpace)
 
void setASpace (ASpaceElement *addrSpace)
 
ASpaceElementaSpace () const
 
void setName (const ReferenceManager::SafePointer *sectionName)
 
void setName (Chunk *sectionName)
 
Chunkname () const
 
virtual bool isDataSection () const
 
virtual bool isCodeSection () const
 
- Public Member Functions inherited from TPEF::SafePointable
virtual ~SafePointable ()
 

Protected Member Functions

 ResourceSection (bool init)
 
virtual Sectionclone () const
 
- Protected Member Functions inherited from TPEF::Section
 Section ()
 
void setFlagVLen ()
 
void unsetFlagVLen ()
 
- Protected Member Functions inherited from TPEF::SafePointable
 SafePointable ()
 

Static Private Attributes

static ResourceSection proto_
 Protorype instance of section. More...
 

Additional Inherited Members

- Public Types inherited from TPEF::Section
enum  SectionType {
  ST_NULL = 0x00, ST_STRTAB = 0x01, ST_SYMTAB = 0x02, ST_DEBUG = 0x03,
  ST_RELOC = 0x04, ST_LINENO = 0x05, ST_NOTE = 0x06, ST_ADDRSP = 0x07,
  ST_MR = 0x0A, ST_CODE = 0x81, ST_DATA = 0x82, ST_UDATA = 0x83,
  ST_LEDATA = 0x84, ST_DUMMY = 0xff
}
 
enum  SectionFlag { SF_VLEN = 0x40, SF_NOBITS = 0x80 }
 
- Static Public Member Functions inherited from TPEF::Section
static SectioncreateSection (SectionType type)
 
static bool isProgramSection (SectionType type)
 
- Static Protected Member Functions inherited from TPEF::Section
static void registerSection (const Section *section)
 

Detailed Description

Prosessor Resource Table section.

Definition at line 47 of file ResourceSection.hh.

Constructor & Destructor Documentation

◆ ~ResourceSection()

TPEF::ResourceSection::~ResourceSection ( )
virtual

Destructor.

Definition at line 58 of file ResourceSection.cc.

58  {
59 }

◆ ResourceSection()

TPEF::ResourceSection::ResourceSection ( bool  init)
protected

Constructor.

Parameters
initTrue if instance should register itself to base class.

Definition at line 45 of file ResourceSection.cc.

45  : Section() {
46  if (init) {
48  }
49 
51  unsetFlagVLen();
53 }

References TPEF::Section::registerSection(), TPEF::Section::setStartingAddress(), TPEF::Section::unsetFlagNoBits(), and TPEF::Section::unsetFlagVLen().

Referenced by clone().

Here is the call graph for this function:

Member Function Documentation

◆ clone()

Section * TPEF::ResourceSection::clone ( ) const
protectedvirtual

Creates an instance of section.

Returns
Newly created section.

Implements TPEF::Section.

Definition at line 77 of file ResourceSection.cc.

77  {
78  return new ResourceSection(false);
79 }

References ResourceSection().

Here is the call graph for this function:

◆ findResource()

ResourceElement & TPEF::ResourceSection::findResource ( ResourceElement::ResourceType  aType,
HalfWord  anId 
) const

Returns machine resource by id and type.

Todo:
Instance not found exception. After all exceptions are implemented.
Parameters
aTypeType of requested resource.
anIdId of resource to find.
Returns
Matching resource.

Definition at line 91 of file ResourceSection.cc.

92  {
93 
94  for (Word i = 0; i < elementCount(); i++) {
95  ResourceElement *elem = static_cast<ResourceElement*>(element(i));
96 
97  if (elem->type() == aType && elem->id() == anId) {
98  return *elem;
99  }
100  }
101 
102  // just to remind about exception to throw.
103  std::cerr << "Can't find resource type: " << aType
104  << "\tid: " << anId << std::endl;
105 
106  assert(false);
107 
108  // added throw clause to stop compiler from complaining --Pekka
109  throw new int;
110 }

References assert, TPEF::Section::element(), TPEF::Section::elementCount(), TPEF::ResourceElement::id(), and TPEF::ResourceElement::type().

Referenced by TPEFDisassembler::createDisassemblyElement(), TTAProgram::TPEFProgramFactory::createTerminal(), TTAProgram::TPEFProgramFactory::findBus(), TTAProgram::TPEFProgramFactory::findFunctionUnit(), TTAProgram::TPEFProgramFactory::findGuard(), TTAProgram::TPEFProgramFactory::findImmediateUnit(), TTAProgram::TPEFProgramFactory::findRegisterFile(), and TPEF::TPEFTools::resourceName().

Here is the call graph for this function:

◆ hasResource()

bool TPEF::ResourceSection::hasResource ( ResourceElement::ResourceType  aType,
HalfWord  anId 
) const

Checks if queried resource if found from section.

Parameters
aTypeType of requested resource.
anIdId of resource to find.
Returns
True if resource was found.

Definition at line 120 of file ResourceSection.cc.

121  {
122 
123  for (Word i = 0; i < elementCount(); i++) {
124  ResourceElement *elem = static_cast<ResourceElement*>(element(i));
125 
126  if (elem->type() == aType && elem->id() == anId) {
127  return true;
128  }
129  }
130 
131  return false;
132 }

References TPEF::Section::element(), TPEF::Section::elementCount(), TPEF::ResourceElement::id(), and TPEF::ResourceElement::type().

Referenced by TPEFDisassembler::createDisassemblyElement(), TTAProgram::TPEFProgramFactory::createTerminal(), TTAProgram::TPEFProgramFactory::findBus(), TTAProgram::TPEFProgramFactory::findGuard(), and TPEF::TPEFTools::resourceName().

Here is the call graph for this function:

◆ type()

Section::SectionType TPEF::ResourceSection::type ( ) const
virtual

Returns section's type.

Returns
Type of section.

Implements TPEF::Section.

Definition at line 67 of file ResourceSection.cc.

67  {
68  return ST_MR;
69 }

References TPEF::Section::ST_MR.

Member Data Documentation

◆ proto_

ResourceSection TPEF::ResourceSection::proto_
staticprivate

Protorype instance of section.

Definition at line 65 of file ResourceSection.hh.


The documentation for this class was generated from the following files:
TPEF::Section::unsetFlagVLen
void unsetFlagVLen()
assert
#define assert(condition)
Definition: Application.hh:86
TPEF::Section::element
SectionElement * element(Word index) const
TPEF::Section::Section
Section()
Definition: Section.cc:64
TPEF::ResourceSection::ResourceSection
ResourceSection(bool init)
Definition: ResourceSection.cc:45
TPEF::Section::unsetFlagNoBits
void unsetFlagNoBits()
TPEF::Section::setStartingAddress
void setStartingAddress(AddressImage address)
TPEF::Section::registerSection
static void registerSection(const Section *section)
Definition: Section.cc:114
TPEF::Section::ST_MR
@ ST_MR
Machine resources section.
Definition: Section.hh:78
TPEF::Section::elementCount
Word elementCount() const