Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
IntelHexSourceFile.h
1 /*
2  * Copyright (c) 2013-15, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #if !defined(_IntelHexSourceFile_h_)
31 #define _IntelHexSourceFile_h_
32 
33 #include "SourceFile.h"
34 #include "StIntelHexFile.h"
35 #include "StExecutableImage.h"
36 
37 namespace blfwk
38 {
48 {
49 public:
51  IntelHexSourceFile(const std::string &path);
52 
54  virtual ~IntelHexSourceFile() {}
56  static bool isIntelHexFile(std::istream &stream);
57 
59 
60  virtual void open();
62 
64  virtual void close();
66 
68 
69  virtual bool supportsNamedSections() const { return false; }
70  virtual bool supportsNamedSymbols() const { return false; }
72 
74 
75  virtual DataSource *createDataSource();
78 
80 
81  virtual bool hasEntryPoint();
83 
85  virtual uint32_t getEntryPointAddress();
87 
88 protected:
93 
94 protected:
96  void buildMemoryImage();
97 };
98 
99 }; // namespace blfwk
100 
101 #endif // _IntelHexSourceFile_h_
Definition: BlfwkErrors.h:16
StExecutableImage * m_image
Memory image of the Intel Hex file..
Definition: IntelHexSourceFile.h:90
StIntelHexFile::IntelHex m_entryRecord
Record for the entry point.
Definition: IntelHexSourceFile.h:92
virtual void open()
Opens the file.
Definition: IntelHexSourceFile.cpp:60
Used to build a representation of memory regions.
Definition: apps/elftosb/common/StExecutableImage.h:27
void buildMemoryImage()
Build memory image of the Intel Hex file.
Definition: IntelHexSourceFile.cpp:137
Abstract base class for a source file containing executable code.
Definition: src/blfwk/SourceFile.h:56
Definition: StIntelHexFile.h:96
virtual uint32_t getEntryPointAddress()
Returns the entry point address.
Definition: IntelHexSourceFile.cpp:107
static bool isIntelHexFile(std::istream &stream)
Test whether the stream contains a valid Intel Hex file.
Definition: IntelHexSourceFile.cpp:54
bool m_hasEntryRecord
Whether a type 03 or 05 record was found.
Definition: IntelHexSourceFile.h:91
Abstract base class for data sources.
Definition: src/blfwk/DataSource.h:56
virtual ~IntelHexSourceFile()
Destructor.
Definition: IntelHexSourceFile.h:54
IntelHexSourceFile(const std::string &path)
Default constructor.
Definition: IntelHexSourceFile.cpp:47
StIntelHexFile * m_file
Intel Hex parser instance.
Definition: IntelHexSourceFile.h:89
virtual DataSource * createDataSource()
Returns data source for the entire file.
Definition: IntelHexSourceFile.cpp:90
virtual void close()
Closes the file.
Definition: IntelHexSourceFile.cpp:77
Intel Hex parser.
Definition: StIntelHexFile.h:90
Executable file in the Intel Hex format.
Definition: IntelHexSourceFile.h:47
virtual bool hasEntryPoint()
Returns true if an entry point was set in the file.
Definition: IntelHexSourceFile.cpp:98