Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
src/blfwk/SRecordSourceFile.h
1 /*
2  * Copyright (c) 2013-14, 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(_SRecordSourceFile_h_)
31 #define _SRecordSourceFile_h_
32 
33 #include "SourceFile.h"
34 #include "StSRecordFile.h"
35 #include "StExecutableImage.h"
36 
37 namespace blfwk
38 {
51 {
52 public:
54  SRecordSourceFile(const std::string &path);
55 
57  virtual ~SRecordSourceFile() {}
59  static bool isSRecordFile(std::istream &stream);
60 
62 
63  virtual void open();
65 
67  virtual void close();
69 
71 
72  virtual bool supportsNamedSections() const { return false; }
73  virtual bool supportsNamedSymbols() const { return false; }
75 
77 
78  virtual DataSource *createDataSource();
81 
83 
84  virtual bool hasEntryPoint();
86 
88  virtual uint32_t getEntryPointAddress();
90 
91 protected:
96 
97 protected:
99  void buildMemoryImage();
100 };
101 
102 }; // namespace blfwk
103 
104 #endif // _SRecordSourceFile_h_
Definition: apps/elftosb/common/StSRecordFile.h:44
Definition: BlfwkErrors.h:16
StSRecordFile * m_file
S-record parser instance.
Definition: src/blfwk/SRecordSourceFile.h:92
virtual bool hasEntryPoint()
Returns true if an entry point was set in the file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:97
static bool isSRecordFile(std::istream &stream)
Test whether the stream contains a valid S-record file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:53
StExecutableImage * m_image
Memory image of the S-record file.
Definition: src/blfwk/SRecordSourceFile.h:93
void buildMemoryImage()
Build memory image of the S-record file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:130
S-record parser.
Definition: apps/elftosb/common/StSRecordFile.h:38
virtual ~SRecordSourceFile()
Destructor.
Definition: src/blfwk/SRecordSourceFile.h:57
Used to build a representation of memory regions.
Definition: apps/elftosb/common/StExecutableImage.h:27
Abstract base class for a source file containing executable code.
Definition: src/blfwk/SourceFile.h:56
virtual DataSource * createDataSource()
Returns data source for the entire file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:89
Executable file in the Motorola S-record format.
Definition: src/blfwk/SRecordSourceFile.h:50
virtual void open()
Opens the file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:59
bool m_hasEntryRecord
Whether an S7,8,9 record was found.
Definition: src/blfwk/SRecordSourceFile.h:94
virtual uint32_t getEntryPointAddress()
Returns the entry point address.
Definition: src/blfwk/src/SRecordSourceFile.cpp:108
virtual void close()
Closes the file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:76
SRecordSourceFile(const std::string &path)
Default constructor.
Definition: src/blfwk/src/SRecordSourceFile.cpp:46
Abstract base class for data sources.
Definition: src/blfwk/DataSource.h:56
StSRecordFile::SRecord m_entryRecord
Record for the entry point.
Definition: src/blfwk/SRecordSourceFile.h:95