OpenASIP  2.0
TPEFReader.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file TPEFReader.hh
26  *
27  * Declaration of TPEFReader.
28  *
29  * @author Mikael Lepistö 2003 (tmlepist-no.spam-cs.tut.fi)
30  *
31  * @note rating: yellow
32  */
33 
34 #ifndef TTA_TPEF_READER_HH
35 #define TTA_TPEF_READER_HH
36 
37 #include <map>
38 
39 #include "BinaryReader.hh"
40 #include "Exception.hh"
41 #include "TPEFBaseType.hh"
42 
43 namespace TPEF {
44  class BinaryStream;
45  class Binary;
46  class ASpaceElement;
47  class ASpaceSection;
48  class Section;
49 /**
50  * Reads binary file that is in TPEF binary format.
51  */
52 class TPEFReader : public BinaryReader {
53 public:
55  const ASpaceElement* aSpaceId,
56  AddressImage address) const;
57 
58  static BinaryReader* instance();
59 
62 
63  void addSectionSize(const Section* sect, Word length);
64 
66 
67 protected:
68  TPEFReader(const TPEFReader&);
70 
71  TPEFReader();
72  virtual ~TPEFReader();
73 
74  virtual Binary* readData(BinaryStream& stream) const;
75 
76  virtual bool isMyStreamType(BinaryStream& stream) const;
77 
78 private:
80  BinaryStream& stream,
81  FileOffset headerOffset,
82  Byte stringTableId,
83  Byte aSpaceSectionId) const;
84 
85 
86  /// Prototype instance registered into BinaryReader.
87  static TPEFReader* proto_;
88 
89  /// Last or currently read binary.
90  mutable Binary *binary_;
91  /// Identification code of address space section (there is only
92  /// one at maximum).
94  /// Identification code of string table containing section name strings.
96  /// Cache of sizes in addresses of read sections.
97  mutable std::map<const Section*, Word> sectionSizes_;
98 };
99 }
100 
101 #endif
TPEF::SectionId
HalfWord SectionId
Type for storing binary file section ids.
Definition: TPEFBaseType.hh:43
TPEF::TPEFReader::instance
static BinaryReader * instance()
Definition: TPEFReader.cc:262
BinaryReader.hh
TPEF::TPEFReader::addSectionSize
void addSectionSize(const Section *sect, Word length)
Definition: TPEFReader.cc:320
Exception.hh
TPEF::TPEFReader::aSpaceSection
ASpaceSection * aSpaceSection() const
Definition: TPEFReader.cc:351
TPEF::TPEFReader::sectionSizes_
std::map< const Section *, Word > sectionSizes_
Cache of sizes in addresses of read sections.
Definition: TPEFReader.hh:97
TPEF::Binary
Definition: Binary.hh:49
TPEF::TPEFReader::proto_
static TPEFReader * proto_
Prototype instance registered into BinaryReader.
Definition: TPEFReader.hh:87
TPEF::BinaryStream
Definition: BinaryStream.hh:59
Byte
unsigned char Byte
Definition: BaseType.hh:116
TPEF::TPEFReader::TPEFReader
TPEFReader()
Definition: TPEFReader.cc:66
TPEF::BinaryReader
Definition: BinaryReader.hh:51
TPEF::TPEFReader::operator=
TPEFReader & operator=(const TPEFReader &)
TPEF::Section
Definition: Section.hh:64
TPEF::TPEFReader::isMyStreamType
virtual bool isMyStreamType(BinaryStream &stream) const
Definition: TPEFReader.cc:231
TPEF::TPEFReader::sectionOfAddress
Section * sectionOfAddress(const ASpaceElement *aSpaceId, AddressImage address) const
Definition: TPEFReader.cc:277
TPEF::TPEFReader::strTableId_
SectionId strTableId_
Identification code of string table containing section name strings.
Definition: TPEFReader.hh:95
TPEF::ASpaceElement
Definition: ASpaceElement.hh:48
TPEF::FileOffset
Word FileOffset
Type for storing absolute file offsets.
Definition: TPEFBaseType.hh:52
TPEF::TPEFReader::binary_
Binary * binary_
Last or currently read binary.
Definition: TPEFReader.hh:90
TPEF::TPEFReader::readData
virtual Binary * readData(BinaryStream &stream) const
Definition: TPEFReader.cc:94
TPEF::TPEFReader::aSpaceId
SectionId aSpaceId()
Definition: TPEFReader.cc:330
TPEF::TPEFReader::strTableId
SectionId strTableId()
Definition: TPEFReader.cc:341
AddressImage
UInt32 AddressImage
Type for storing addresses to memory image.
Definition: BaseType.hh:179
TPEF::TPEFReader
Definition: TPEFReader.hh:52
TPEF::TPEFReader::readSection
Section * readSection(BinaryStream &stream, FileOffset headerOffset, Byte stringTableId, Byte aSpaceSectionId) const
TPEFBaseType.hh
TPEF::TPEFReader::aSpaceId_
SectionId aSpaceId_
Identification code of address space section (there is only one at maximum).
Definition: TPEFReader.hh:93
TPEF::ASpaceSection
Definition: ASpaceSection.hh:44
TPEF::TPEFReader::~TPEFReader
virtual ~TPEFReader()
Definition: TPEFReader.cc:73
TPEF
Definition: Assembler.hh:43