Simulator.h
/*
* Copyright (c) 2013-14, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _Simulator_h_
#define _Simulator_h_
#include "Bootloader.h"
#include "Command.h"
#include "SimulatorMemory.h"
#include "SimPacketizer.h"
#include "Peripheral.h"
#include "Logging.h"
#include "bootloader/bl_command.h"
#include "bootloader/bl_context.h"
namespace blfwk
{
class Simulator : public Bootloader
{
public:
typedef std::vector<blfwk::MemoryStore *> memory_vector_t;
static Simulator &getSimulator()
{
static Simulator theSimulator;
return theSimulator;
}
virtual ~Simulator();
void init();
bool openStateFiles(const std::string &pathToDir, bool forceCreate);
SimPacketizer *getHost() const { return dynamic_cast< SimPacketizer *>(m_hostPacketizer); }
SimPacketizer *getDevice() const { return m_devicePacketizer; }
MemoryStore *getMemoryStore(int index) const { return m_memoryStore[index]; }
protected:
Simulator();
SimPacketizer *m_devicePacketizer;
uchar_deque_t m_commandStream;
uchar_deque_t m_responseStream;
command_processor_data_t m_commandProcessor;
bool m_areStateFilesOpen;
memory_vector_t m_memoryStore;
OptionsStore m_optionsStore;
property_store_t m_propertyStore;
peripheral_descriptor_t m_activePeripheral;
FileLogger *m_logger;
};
} // namespace blfwk
#endif // _Simulator_h_
// EOF
blfwk::Bootloader
Represents the host bootloader.
Definition: src/blfwk/Bootloader.h:52
blfwk::Simulator::getMemoryStore
MemoryStore * getMemoryStore(int index) const
Get a device state memory store.
Definition: Simulator.h:90
blfwk::Simulator::m_logger
FileLogger * m_logger
Singleton logger instance.
Definition: Simulator.h:105
blfwk
Definition: BlfwkErrors.h:16
blfwk::Simulator
Represents the host bootloader.
Definition: Simulator.h:52
blfwk::Simulator::getDevice
SimPacketizer * getDevice() const
Get the device packetizer.
Definition: Simulator.h:86
blfwk::Simulator::m_activePeripheral
peripheral_descriptor_t m_activePeripheral
Descriptor for the active peripheral.
Definition: Simulator.h:104
blfwk::Simulator::memory_vector_t
std::vector< blfwk::MemoryStore * > memory_vector_t
A vector of memory stores.
Definition: Simulator.h:56
blfwk::Simulator::init
void init()
Initialize.
Definition: Simulator.cpp:216
blfwk::Simulator::m_optionsStore
OptionsStore m_optionsStore
Persistent options store.
Definition: Simulator.h:102
blfwk::Simulator::getHost
SimPacketizer * getHost() const
Get the host packetizer.
Definition: Simulator.h:84
blfwk::Simulator::Simulator
Simulator()
Constructor.
Definition: Simulator.cpp:187
blfwk::OptionsStore
Holds persistent options.
Definition: SimulatorMemory.h:151
blfwk::MemoryStore
Represents target device memory as a disk file.
Definition: SimulatorMemory.h:41
blfwk::SimPacketizer
Provides source and sink for packets in the simulator space.
Definition: SimPacketizer.h:46
blfwk::Simulator::openStateFiles
bool openStateFiles(const std::string &pathToDir, bool forceCreate)
Configure and open state files.
Definition: Simulator.cpp:240
blfwk::Simulator::m_devicePacketizer
SimPacketizer * m_devicePacketizer
Packet interface to recieve commands on.
Definition: Simulator.h:96
blfwk::Simulator::getSimulator
static Simulator & getSimulator()
Get the singleton simulator object.
Definition: Simulator.h:59
blfwk::Simulator::m_memoryStore
memory_vector_t m_memoryStore
Vector of memory stores, one per map entry.
Definition: Simulator.h:101
blfwk::Simulator::~Simulator
virtual ~Simulator()
Destructor.
Definition: Simulator.cpp:206
blfwk::Simulator::m_areStateFilesOpen
bool m_areStateFilesOpen
True if state files are in use.
Definition: Simulator.h:100
FileLogger
Simple logger that writes to a file.
Definition: src/blfwk/Logging.h:266
blfwk::Bootloader::m_hostPacketizer
Packetizer * m_hostPacketizer
Packet interface to send commands on.
Definition: src/blfwk/Bootloader.h:101