src/blfwk/Bootloader.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 _Bootloader_h_
#define _Bootloader_h_
#include "Command.h"
#include "Packetizer.h"
#include "Peripheral.h"
#include "Logging.h"
#include <time.h>
namespace blfwk
{
class Bootloader
{
public:
Bootloader();
Bootloader(const Peripheral::PeripheralConfigData &config);
virtual ~Bootloader();
void inject(Command &cmd)
{
clock_t start = clock();
cmd.sendTo(*m_hostPacketizer);
clock_t finish = clock();
Log::debug(" - took %2.3f seconds\n", (double)(finish - start) / CLOCKS_PER_SEC);
}
void flush();
void execute(uint32_t entry_point, uint32_t param = 0, uint32_t stack_pointer = 0);
void reset();
standard_version_t getVersion();
uint32_t getSecurityState();
void ping(int retries, unsigned int delay, int comSpeed);
Packetizer *getPacketizer() const { return m_hostPacketizer; }
protected:
Packetizer *m_hostPacketizer;
FileLogger *m_logger;
};
} // namespace blfwk
#endif // _Bootloader_h_
// EOF
blfwk::Packetizer
Interface class for packetization of commands and data.
Definition: Packetizer.h:59
blfwk::Bootloader
Represents the host bootloader.
Definition: src/blfwk/Bootloader.h:52
blfwk
Definition: BlfwkErrors.h:16
blfwk::Command
Represents a bootloader command.
Definition: Command.h:301
blfwk::Bootloader::execute
void execute(uint32_t entry_point, uint32_t param=0, uint32_t stack_pointer=0)
Execute the execute command.
Definition: src/blfwk/src/Bootloader.cpp:169
blfwk::Command::sendTo
virtual void sendTo(Packetizer &packetizer)
Send command to packetizer and on to peripheral.
Definition: Command.h:370
blfwk::Bootloader::ping
void ping(int retries, unsigned int delay, int comSpeed)
Send a ping if applicable.
Definition: src/blfwk/src/Bootloader.cpp:245
standard_version_t
Definition: qspi_config_block_generator.c:101
blfwk::Bootloader::reset
void reset()
Execute the reset command.
Definition: src/blfwk/src/Bootloader.cpp:187
blfwk::Bootloader::Bootloader
Bootloader()
Default Constructor for Simulator.
Definition: src/blfwk/src/Bootloader.cpp:57
Log::debug
static void debug(const char *fmt,...)
Log a message with Logger::kDebug level.
Definition: src/blfwk/src/Logging.cpp:192
blfwk::Bootloader::m_logger
FileLogger * m_logger
Singleton logger instance.
Definition: src/blfwk/Bootloader.h:102
blfwk::Bootloader::flush
void flush()
Flush state.
Definition: src/blfwk/src/Bootloader.cpp:159
blfwk::Bootloader::inject
void inject(Command &cmd)
Inject a command into the bootloader.
Definition: src/blfwk/Bootloader.h:67
blfwk::Bootloader::getVersion
standard_version_t getVersion()
Execute the get-property(current-version) command.
Definition: src/blfwk/src/Bootloader.cpp:205
blfwk::Bootloader::~Bootloader
virtual ~Bootloader()
Destructor.
Definition: src/blfwk/src/Bootloader.cpp:149
blfwk::Bootloader::getPacketizer
Packetizer * getPacketizer() const
Get the host packetizer.
Definition: src/blfwk/Bootloader.h:97
blfwk::Bootloader::getSecurityState
uint32_t getSecurityState()
Execute the get-property(flash-security-state) command.
Definition: src/blfwk/src/Bootloader.cpp:225
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
blfwk::Peripheral::PeripheralConfigData
Definition: Peripheral.h:60