OpenASIP  2.0
TPEFHeaders.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 TPEFHeaders.hh
26  *
27  * TPEF file and section header related offsets and
28  * some other TPEF binary file related values.
29  *
30  * @author Mikael Lepistö 2004 (tmlepist-no.spam-cs.tut.fi)
31  *
32  * @note rating: yellow
33  */
34 
35 #ifndef TTA_TPEF_HEADERS
36 #define TTA_TPEF_HEADERS
37 
38 #include "TPEFBaseType.hh"
39 
40 namespace TPEF {
41 namespace TPEFHeaders {
42 
43  /// File format identification mark (TPEF version 1).
44  /// See TPEF documentation for more info.
45  const Byte FH_ID_BYTES[] = {
46  0x7f, 0x54, 0x54, 0x41, 0x2d, 0x50, 0x46, 0x00, 0x01, 0x0a
47  };
48 
49  /// Size of file identification code.
50  const Byte FH_ID_SIZE = 10;
51  /// Size of file header.
52  const HalfWord FH_HEADER_SIZE = 26;
53  /// Suze of section header.
54  const HalfWord SH_HEADER_SIZE = 32;
55 
56  enum TPEFVersion {
57  TPEF_V1 = 0x01, ///< Initial TPEF version.
58  TPEF_V2 = 0x02 ///< Support for over 255 Buses, FUs, RFs.
59  };
60 
61  /**
62  * Offsets of file header.
63  */
65  FH_ID = 0, ///< File identification code.
66  FH_ARCH = 10, ///< Architecture template.
67  FH_TYPE = 11, ///< Type of TTA program.
68  FH_SHOFF = 12, ///< Offset to first section header.
69  FH_SIZE = 16, ///< File header size.
70  FH_SHSIZE = 18, ///< Size of section header entry.
71  FH_SHNUM = 20, ///< Number of section headers.
72  FH_SHSTRTAB = 22 ///< Offset to header of string table.
73  };
74 
75  /**
76  * Offsets of section header.
77  */
79  SH_NAME = 0, ///< Section offset to name.
80  SH_TYPE = 4, ///< Type of section.
81  SH_FLAGS = 5, ///< Flags of section.
82  SH_ADDR = 6, ///< Starting memory address of program section.
83  SH_OFFSET = 10, ///< Offset to section data.
84  SH_SIZE = 14, ///< Size of section data.
85  SH_ID = 18, ///< Section identification code.
86  SH_ASPACE = 20, ///< Section address space identifier.
87  SH_PADDING = 21, ///< Padding, must be zero.
88  SH_LINK = 22, ///< Section identifier link.
89  SH_INFO = 24, ///< Section specific information, usually zero.
90  SH_ENTSIZE = 28 ///< Size of section elements (if fixed size).
91  };
92 
93  /**
94  * Values for SymbolElement other field.
95  */
97  STO_ABS = 0x80 ///< Section is absolute, not relocating.
98  };
99 
100  /**
101  * Values for RelocationElement type field
102  */
104  STF_RELOCATION_TYPE_MASK = 0x0F, ///< Mask for getting reloc type.
105  STF_CHUNK = 0x80 ///< Relocation applied to chunk(1)
106  ///< or complete address(0).
107  };
108 
109  /**
110  * InstructionAnnotation flags and masks.
111  */
113  IANNOTE_CONTINUATION = 0x80, ///< If there is more annotations.
114  IANNOTE_SIZE = 0x7f ///< Size of payload of annotation.
115  };
116 
117  /**
118  * Instruction attribute flags and masks.
119  */
121  IA_TYPE = 0x01, ///< Instruction type: move (0), immediate (1).
122  IA_END = 0x02, ///< Is end of instruction.
123  IA_ANNOTE = 0x04, ///< Contains annotation.
124  IA_EMPTY = 0x08, ///< Empty instruction.
125  IA_IMMSIZE = 0xf0, ///< Immediade size mask.
126  IA_MGUARD = 0x10 ///< Is conditional move or unconditional move.
127  };
128 
129  /**
130  * Masks for getting source and destination fields from instruction.
131  */
133  IE_SRC_TYPE_MASK = 0x0c, ///< Instruction source type mask.
134  IE_DST_TYPE_MASK = 0x30, ///< Instruction destination type mask.
135  IE_GUARD_TYPE_MASK = 0x80,///< If (1) guard points to GPR,(0) to FU.
136  MVS_NULL = 0x00, ///< Illegal source.
137  MVS_RF = 0x04, ///< Source is RF.
138  MVS_IMM = 0x08, ///< Source is immediate.
139  MVS_UNIT = 0x0c, ///< Source is FU.
140  MVD_NULL = 0x00, ///< Illegal destination.
141  MVD_RF = 0x10, ///< Destination is RF.
142  MVD_ILLEGAL = 0x20, ///< Illegal destination.
143  MVD_UNIT = 0x30, ///< Destination is FU.
144  MVG_UNIT = 0x00, ///< Guard is FU.
145  MVG_RF = 0x80, ///< Guard is RF.
146  IE_GUARD_INV_MASK = 0x40 ///< Guard inverted (1) means inverted.
147  };
148 
149 } // namespace TPEFHeaders;
150 } // namespace TPEF;
151 
152 #endif
TPEF::TPEFHeaders::MVD_NULL
@ MVD_NULL
Illegal destination.
Definition: TPEFHeaders.hh:140
TPEF::TPEFHeaders::IA_ANNOTE
@ IA_ANNOTE
Contains annotation.
Definition: TPEFHeaders.hh:123
TPEF::TPEFHeaders::SH_LINK
@ SH_LINK
Section identifier link.
Definition: TPEFHeaders.hh:88
TPEF::TPEFHeaders::InstructionFieldType
InstructionFieldType
Definition: TPEFHeaders.hh:132
TPEF::TPEFHeaders::IA_MGUARD
@ IA_MGUARD
Is conditional move or unconditional move.
Definition: TPEFHeaders.hh:126
TPEF::TPEFHeaders::FH_TYPE
@ FH_TYPE
Type of TTA program.
Definition: TPEFHeaders.hh:67
TPEF::TPEFHeaders::IA_END
@ IA_END
Is end of instruction.
Definition: TPEFHeaders.hh:122
TPEF::TPEFHeaders::TPEF_V2
@ TPEF_V2
Support for over 255 Buses, FUs, RFs.
Definition: TPEFHeaders.hh:58
TPEF::TPEFHeaders::MVD_RF
@ MVD_RF
Destination is RF.
Definition: TPEFHeaders.hh:141
TPEF::TPEFHeaders::SH_TYPE
@ SH_TYPE
Type of section.
Definition: TPEFHeaders.hh:80
TPEF::TPEFHeaders::MVS_RF
@ MVS_RF
Source is RF.
Definition: TPEFHeaders.hh:137
TPEF::TPEFHeaders::SH_OFFSET
@ SH_OFFSET
Offset to section data.
Definition: TPEFHeaders.hh:83
TPEF::TPEFHeaders::IANNOTE_CONTINUATION
@ IANNOTE_CONTINUATION
If there is more annotations.
Definition: TPEFHeaders.hh:113
TPEF::TPEFHeaders::IA_TYPE
@ IA_TYPE
Instruction type: move (0), immediate (1).
Definition: TPEFHeaders.hh:121
TPEF::TPEFHeaders::FH_ID_SIZE
const Byte FH_ID_SIZE
Size of file identification code.
Definition: TPEFHeaders.hh:50
TPEF::TPEFHeaders::STF_RELOCATION_TYPE_MASK
@ STF_RELOCATION_TYPE_MASK
Mask for getting reloc type.
Definition: TPEFHeaders.hh:104
TPEF::TPEFHeaders::SH_ASPACE
@ SH_ASPACE
Section address space identifier.
Definition: TPEFHeaders.hh:86
TPEF::TPEFHeaders::SH_INFO
@ SH_INFO
Section specific information, usually zero.
Definition: TPEFHeaders.hh:89
Byte
unsigned char Byte
Definition: BaseType.hh:116
TPEF::TPEFHeaders::FH_SHSIZE
@ FH_SHSIZE
Size of section header entry.
Definition: TPEFHeaders.hh:70
TPEF::TPEFHeaders::FH_SHSTRTAB
@ FH_SHSTRTAB
Offset to header of string table.
Definition: TPEFHeaders.hh:72
TPEF::TPEFHeaders::SH_PADDING
@ SH_PADDING
Padding, must be zero.
Definition: TPEFHeaders.hh:87
TPEF::TPEFHeaders::FH_ID_BYTES
const Byte FH_ID_BYTES[]
File format identification mark (TPEF version 1). See TPEF documentation for more info.
Definition: TPEFHeaders.hh:45
TPEF::TPEFHeaders::FH_HEADER_SIZE
const HalfWord FH_HEADER_SIZE
Size of file header.
Definition: TPEFHeaders.hh:52
TPEF::TPEFHeaders::MVS_UNIT
@ MVS_UNIT
Source is FU.
Definition: TPEFHeaders.hh:139
TPEF::TPEFHeaders::InstructionAnnotationMasks
InstructionAnnotationMasks
Definition: TPEFHeaders.hh:112
TPEF::TPEFHeaders::TPEFVersion
TPEFVersion
Definition: TPEFHeaders.hh:56
TPEF::TPEFHeaders::SH_ENTSIZE
@ SH_ENTSIZE
Size of section elements (if fixed size).
Definition: TPEFHeaders.hh:90
TPEF::TPEFHeaders::MVG_RF
@ MVG_RF
Guard is RF.
Definition: TPEFHeaders.hh:145
TPEF::TPEFHeaders::MVD_ILLEGAL
@ MVD_ILLEGAL
Illegal destination.
Definition: TPEFHeaders.hh:142
TPEF::TPEFHeaders::IANNOTE_SIZE
@ IANNOTE_SIZE
Size of payload of annotation.
Definition: TPEFHeaders.hh:114
TPEF::TPEFHeaders::FH_SHOFF
@ FH_SHOFF
Offset to first section header.
Definition: TPEFHeaders.hh:68
TPEF::TPEFHeaders::MVS_NULL
@ MVS_NULL
Illegal source.
Definition: TPEFHeaders.hh:136
TPEF::TPEFHeaders::SH_ID
@ SH_ID
Section identification code.
Definition: TPEFHeaders.hh:85
TPEF::TPEFHeaders::InstructionAttributeField
InstructionAttributeField
Definition: TPEFHeaders.hh:120
TPEF::TPEFHeaders::SH_HEADER_SIZE
const HalfWord SH_HEADER_SIZE
Suze of section header.
Definition: TPEFHeaders.hh:54
TPEF::TPEFHeaders::IA_EMPTY
@ IA_EMPTY
Empty instruction.
Definition: TPEFHeaders.hh:124
TPEF::TPEFHeaders::FH_SHNUM
@ FH_SHNUM
Number of section headers.
Definition: TPEFHeaders.hh:71
TPEF::TPEFHeaders::MVS_IMM
@ MVS_IMM
Source is immediate.
Definition: TPEFHeaders.hh:138
TPEF::TPEFHeaders::SymbolOtherValues
SymbolOtherValues
Definition: TPEFHeaders.hh:96
TPEF::TPEFHeaders::TPEF_V1
@ TPEF_V1
Initial TPEF version.
Definition: TPEFHeaders.hh:57
TPEF::TPEFHeaders::IE_GUARD_INV_MASK
@ IE_GUARD_INV_MASK
Guard inverted (1) means inverted.
Definition: TPEFHeaders.hh:146
TPEF::TPEFHeaders::STF_CHUNK
@ STF_CHUNK
Relocation applied to chunk(1) or complete address(0).
Definition: TPEFHeaders.hh:105
TPEF::TPEFHeaders::IE_GUARD_TYPE_MASK
@ IE_GUARD_TYPE_MASK
If (1) guard points to GPR,(0) to FU.
Definition: TPEFHeaders.hh:135
TPEF::TPEFHeaders::MVG_UNIT
@ MVG_UNIT
Guard is FU.
Definition: TPEFHeaders.hh:144
TPEF::TPEFHeaders::SectionHeaderOffset
SectionHeaderOffset
Definition: TPEFHeaders.hh:78
TPEF::TPEFHeaders::SH_SIZE
@ SH_SIZE
Size of section data.
Definition: TPEFHeaders.hh:84
TPEF::TPEFHeaders::RelocTypeValues
RelocTypeValues
Definition: TPEFHeaders.hh:103
TPEF::TPEFHeaders::IE_DST_TYPE_MASK
@ IE_DST_TYPE_MASK
Instruction destination type mask.
Definition: TPEFHeaders.hh:134
TPEF::TPEFHeaders::MVD_UNIT
@ MVD_UNIT
Destination is FU.
Definition: TPEFHeaders.hh:143
TPEF::TPEFHeaders::SH_ADDR
@ SH_ADDR
Starting memory address of program section.
Definition: TPEFHeaders.hh:82
TPEF::TPEFHeaders::SH_FLAGS
@ SH_FLAGS
Flags of section.
Definition: TPEFHeaders.hh:81
TPEF::TPEFHeaders::SH_NAME
@ SH_NAME
Section offset to name.
Definition: TPEFHeaders.hh:79
TPEFBaseType.hh
TPEF::TPEFHeaders::FileHeaderOffset
FileHeaderOffset
Definition: TPEFHeaders.hh:64
TPEF::TPEFHeaders::FH_SIZE
@ FH_SIZE
File header size.
Definition: TPEFHeaders.hh:69
TPEF::TPEFHeaders::FH_ID
@ FH_ID
File identification code.
Definition: TPEFHeaders.hh:65
TPEF::TPEFHeaders::FH_ARCH
@ FH_ARCH
Architecture template.
Definition: TPEFHeaders.hh:66
TPEF::TPEFHeaders::IA_IMMSIZE
@ IA_IMMSIZE
Immediade size mask.
Definition: TPEFHeaders.hh:125
TPEF::TPEFHeaders::IE_SRC_TYPE_MASK
@ IE_SRC_TYPE_MASK
Instruction source type mask.
Definition: TPEFHeaders.hh:133
TPEF::TPEFHeaders::STO_ABS
@ STO_ABS
Section is absolute, not relocating.
Definition: TPEFHeaders.hh:97
TPEF
Definition: Assembler.hh:43