Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
Simulator.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 
31 #ifndef _Simulator_h_
32 #define _Simulator_h_
33 
34 #include "Bootloader.h"
35 #include "Command.h"
36 #include "SimulatorMemory.h"
37 #include "SimPacketizer.h"
38 #include "Peripheral.h"
39 #include "Logging.h"
40 
41 #include "bootloader/bl_command.h"
42 #include "bootloader/bl_context.h"
43 
44 namespace blfwk
45 {
52 class Simulator : public Bootloader
53 {
54 public:
56  typedef std::vector<blfwk::MemoryStore *> memory_vector_t;
57 
60  {
62  static Simulator theSimulator;
63  return theSimulator;
64  }
65 
67  virtual ~Simulator();
68 
70  void init();
71 
78  bool openStateFiles(const std::string &pathToDir, bool forceCreate);
79 
81 
82 
84  SimPacketizer *getHost() const { return dynamic_cast<SimPacketizer *>(m_hostPacketizer); }
90  MemoryStore *getMemoryStore(int index) const { return m_memoryStore[index]; }
92 
93 protected:
95  Simulator();
97  uchar_deque_t m_commandStream;
98  uchar_deque_t m_responseStream;
99  command_processor_data_t m_commandProcessor;
101  memory_vector_t m_memoryStore;
103  property_store_t m_propertyStore;
104  peripheral_descriptor_t m_activePeripheral;
106 };
107 
108 } // namespace blfwk
109 
110 #endif // _Simulator_h_
111 
113 // EOF
Represents the host bootloader.
Definition: src/blfwk/Bootloader.h:52
MemoryStore * getMemoryStore(int index) const
Get a device state memory store.
Definition: Simulator.h:90
FileLogger * m_logger
Singleton logger instance.
Definition: Simulator.h:105
Definition: BlfwkErrors.h:16
Represents the host bootloader.
Definition: Simulator.h:52
SimPacketizer * getDevice() const
Get the device packetizer.
Definition: Simulator.h:86
peripheral_descriptor_t m_activePeripheral
Descriptor for the active peripheral.
Definition: Simulator.h:104
std::vector< blfwk::MemoryStore * > memory_vector_t
A vector of memory stores.
Definition: Simulator.h:56
void init()
Initialize.
Definition: Simulator.cpp:216
OptionsStore m_optionsStore
Persistent options store.
Definition: Simulator.h:102
SimPacketizer * getHost() const
Get the host packetizer.
Definition: Simulator.h:84
Simulator()
Constructor.
Definition: Simulator.cpp:187
Holds persistent options.
Definition: SimulatorMemory.h:151
Represents target device memory as a disk file.
Definition: SimulatorMemory.h:41
Provides source and sink for packets in the simulator space.
Definition: SimPacketizer.h:46
bool openStateFiles(const std::string &pathToDir, bool forceCreate)
Configure and open state files.
Definition: Simulator.cpp:240
SimPacketizer * m_devicePacketizer
Packet interface to recieve commands on.
Definition: Simulator.h:96
static Simulator & getSimulator()
Get the singleton simulator object.
Definition: Simulator.h:59
memory_vector_t m_memoryStore
Vector of memory stores, one per map entry.
Definition: Simulator.h:101
virtual ~Simulator()
Destructor.
Definition: Simulator.cpp:206
bool m_areStateFilesOpen
True if state files are in use.
Definition: Simulator.h:100
Simple logger that writes to a file.
Definition: src/blfwk/Logging.h:266
Packetizer * m_hostPacketizer
Packet interface to send commands on.
Definition: src/blfwk/Bootloader.h:101