Operation.h
/*
* File: Operation.h
*
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
* See included license file for license details.
*/
#if !defined(_Operation_h_)
#define _Operation_h_
#include "stdafx.h"
#include <vector>
#include "DataSource.h"
#include "DataTarget.h"
#include "smart_ptr.h"
#include "keyblob.h"
namespace elftosb
{
class Operation
{
public:
Operation() {}
virtual ~Operation() {}
};
class LoadOperation : public Operation
{
public:
LoadOperation()
: Operation()
, m_source()
, m_target()
, m_isDCDLoad(false)
{
}
void setSource(DataSource *source);
inline DataSource *getSource() { return m_source; }
void setTarget(DataTarget *target);
inline DataTarget *getTarget() { return m_target; }
inline void setDCDLoad(bool isDCD) { m_isDCDLoad = isDCD; }
inline bool isDCDLoad() const { return m_isDCDLoad; }
protected:
smart_ptr<DataSource> m_source;
smart_ptr<DataTarget> m_target;
bool m_isDCDLoad;
};
class ExecuteOperation : public Operation
{
public:
enum execute_type_t
{
kJump,
kCall
};
public:
ExecuteOperation()
: Operation()
, m_target()
, m_argument(0)
, m_type(kCall)
, m_isHAB(false)
, m_stackPointer(0)
, m_isStackPointerSet(false)
{
}
inline void setTarget(DataTarget *target) { m_target = target; }
inline DataTarget *getTarget() { return m_target; }
inline void setArgument(uint32_t arg) { m_argument = arg; }
inline uint32_t getArgument() { return m_argument; }
inline void setExecuteType(execute_type_t type) { m_type = type; }
inline execute_type_t getExecuteType() { return m_type; }
inline void setIsHAB(bool isHAB) { m_isHAB = isHAB; }
inline bool isHAB() const { return m_isHAB; }
inline void setStackPointer(uint32_t sp) { m_stackPointer = sp; }
inline uint32_t getStackPointer() { return m_stackPointer; }
inline void setIsStackPointerSet(bool isSet) { m_isStackPointerSet = isSet; }
inline bool isStackPonterSet() const { return m_isStackPointerSet; }
protected:
smart_ptr<DataTarget> m_target;
uint32_t m_argument;
uint32_t m_stackPointer;
execute_type_t m_type;
bool m_isHAB;
bool m_isStackPointerSet;
};
class HABExecuteOperation : public ExecuteOperation
{
public:
HABExecuteOperation()
: ExecuteOperation()
{
}
};
class BootModeOperation : public Operation
{
public:
BootModeOperation()
: Operation()
, m_bootMode(0)
{
}
inline void setBootMode(uint32_t mode) { m_bootMode = mode; }
inline uint32_t getBootMode() const { return m_bootMode; }
protected:
uint32_t m_bootMode;
};
class ResetOperation : public Operation
{
public:
ResetOperation()
: Operation()
{
}
};
class FlashEraseOperation : public Operation
{
public:
FlashEraseOperation()
: Operation()
, m_startAddress(0)
, m_byteCount(0)
{
}
void setRange(uint32_t start, uint32_t count)
{
m_startAddress = start;
m_byteCount = count;
}
void getRange(uint32_t *start, uint32_t *count) const;
protected:
uint32_t m_startAddress;
uint32_t m_byteCount;
};
class FlashEraseAllOperation : public FlashEraseOperation
{
public:
FlashEraseAllOperation()
: FlashEraseOperation()
{
}
};
class FlashEraseAllExternalOperation : public FlashEraseOperation
{
public:
FlashEraseAllExternalOperation()
: FlashEraseOperation()
, m_memoryId(0)
{
}
void setMemoryId(uint32_t memId) { m_memoryId = memId; }
uint32_t getMemoryId() const { return m_memoryId; }
protected:
uint32_t m_memoryId;
};
class FlashEraseAllUnsecureOperation : public FlashEraseOperation
{
public:
FlashEraseAllUnsecureOperation()
: FlashEraseOperation()
{
}
};
class MemEnableOperation : public Operation
{
public:
MemEnableOperation()
: Operation()
, m_startAddress(0)
, m_byteCount(0)
, m_memControllerId(0)
{
}
void setMemControllerId(uint32_t memControllerId) { m_memControllerId = memControllerId; }
uint32_t getMemControllerId() const { return m_memControllerId; }
void setRange(uint32_t start, uint32_t count)
{
m_startAddress = start;
m_byteCount = count;
}
void getRange(uint32_t *start, uint32_t *count) const;
protected:
uint32_t m_startAddress;
uint32_t m_byteCount;
uint32_t m_memControllerId;
};
class ProgramOperation : public LoadOperation
{
public:
ProgramOperation()
: LoadOperation()
, m_memSpace(0)
{
}
ProgramOperation(uint32_t memSpace)
: LoadOperation()
, m_memSpace(memSpace)
{
}
void setMemorySpace(uint32_t memSpace) { m_memSpace = memSpace; }
uint32_t getMemorySpace() const { return m_memSpace; }
protected:
uint32_t m_memSpace;
};
class KeywrapOperation : public LoadOperation
{
public:
KeywrapOperation()
: LoadOperation()
, m_keyblob()
{
}
KeywrapOperation(Keyblob *keyblob)
: LoadOperation()
, m_keyblob(keyblob)
{
}
void setKeyblob(Keyblob *keyblob) { m_keyblob = keyblob; }
Keyblob *getKeyblob() { return m_keyblob; }
protected:
smart_ptr<Keyblob> m_keyblob;
};
class EncryptOperation : public LoadOperation
{
public:
EncryptOperation()
: LoadOperation()
, m_keyblob()
{
}
EncryptOperation(Keyblob *keyblob)
: LoadOperation()
, m_keyblob(keyblob)
{
}
void setKeyblob(Keyblob *keyblob) { m_keyblob = keyblob; }
Keyblob *getKeyblob() { return m_keyblob; }
protected:
smart_ptr<Keyblob> m_keyblob;
};
class OperationSequence
{
public:
typedef std::vector<Operation *> operation_list_t;
typedef operation_list_t::iterator iterator_t;
typedef operation_list_t::const_iterator const_iterator_t;
public:
OperationSequence() {}
OperationSequence(Operation *soleElement) { m_operations.push_back(soleElement); }
virtual ~OperationSequence();
inline iterator_t begin() { return m_operations.begin(); }
inline const_iterator_t begin() const { return m_operations.begin(); }
inline iterator_t end() { return m_operations.end(); }
inline const_iterator_t end() const { return m_operations.end(); }
inline Operation *operator[](unsigned index) const { return m_operations[index]; }
inline unsigned getCount() const { return m_operations.size(); }
inline void append(Operation *op) { m_operations.push_back(op); }
void append(const OperationSequence *other);
OperationSequence &operator+=(const OperationSequence *other)
{
append(other);
return *this;
}
protected:
operation_list_t m_operations;
};
}; // namespace elftosb
#endif // _Operation_h_
elftosb::EncryptOperation::EncryptOperation
EncryptOperation()
Default constructor.
Definition: Operation.h:297
elftosb::EncryptOperation
Operation to encrypt data for OTFAD.
Definition: Operation.h:293
elftosb::FlashEraseAllExternalOperation
Operation to erase the entire external flash memory array.
Definition: Operation.h:182
elftosb::OperationSequence::m_operations
operation_list_t m_operations
The list of operations.
Definition: Operation.h:369
elftosb::DataSource
Abstract base class for data sources.
Definition: apps/elftosb/common/DataSource.h:33
elftosb::ProgramOperation
Operation to program persistent bits.
Definition: Operation.h:241
elftosb::OperationSequence
Ordered sequence of operations.
Definition: Operation.h:323
elftosb::BootModeOperation::m_bootMode
uint32_t m_bootMode
The new boot mode value.
Definition: Operation.h:127
elftosb::OperationSequence::iterator_t
operation_list_t::iterator iterator_t
Iterator over operations.
Definition: Operation.h:327
elftosb::OperationSequence::operation_list_t
std::vector< Operation * > operation_list_t
Type for a list of operation objects.
Definition: Operation.h:326
elftosb::KeywrapOperation::KeywrapOperation
KeywrapOperation()
Default constructor.
Definition: Operation.h:271
elftosb::ProgramOperation::ProgramOperation
ProgramOperation()
Default constructor.
Definition: Operation.h:245
elftosb::ResetOperation
Operation to reset the device.
Definition: Operation.h:133
elftosb::ExecuteOperation
Operation to execute code at a certain address.
Definition: Operation.h:58
elftosb::KeywrapOperation::m_keyblob
smart_ptr< Keyblob > m_keyblob
Active keyblob during this load.
Definition: Operation.h:287
elftosb::MemEnableOperation
Operation to enable external memory access.
Definition: Operation.h:212
elftosb::FlashEraseOperation
Operation to erase flash memory.
Definition: Operation.h:145
elftosb::KeywrapOperation
Operation to wrap and program keys.
Definition: Operation.h:267
smart_ptr
Simple, standard smart pointer class.
Definition: apps/elftosb/common/smart_ptr.h:18
elftosb::HABExecuteOperation
Authenticate with HAB and execute the entry point.
Definition: Operation.h:103
elftosb
Definition: BootImage.h:13
elftosb::DataTarget
Abstract base class for the target address or range of data.
Definition: apps/elftosb/common/DataTarget.h:34
elftosb::EncryptOperation::m_keyblob
smart_ptr< Keyblob > m_keyblob
Active keyblob during this load.
Definition: Operation.h:313
elftosb::OperationSequence::const_iterator_t
operation_list_t::const_iterator const_iterator_t
Const iterator over operations.
Definition: Operation.h:328
elftosb::FlashEraseAllOperation
Operation to erase the entire flash memory array.
Definition: Operation.h:170
elftosb::Keyblob
Keyblob specification.
Definition: Keyblob.h:27
elftosb::BootModeOperation
Operation to switch boot modes.
Definition: Operation.h:115
elftosb::ProgramOperation::ProgramOperation
ProgramOperation(uint32_t memSpace)
Constructor. Takes a memory space argument.
Definition: Operation.h:252
elftosb::FlashEraseAllUnsecureOperation
Operation to erase the entire flash memory array, unsecure version.
Definition: Operation.h:200
elftosb::Operation
Abstract base class for all boot operations.
Definition: Operation.h:22
elftosb::LoadOperation
Load data into memory operation.
Definition: Operation.h:32
elftosb::EncryptOperation::EncryptOperation
EncryptOperation(Keyblob *keyblob)
Constructor. Takes a keyblob argument.
Definition: Operation.h:304
elftosb::OperationSequence::OperationSequence
OperationSequence(Operation *soleElement)
Constructor. Makes a one-element sequence from soleElement.
Definition: Operation.h:334
elftosb::OperationSequence::operator+=
OperationSequence & operator+=(const OperationSequence *other)
Appends other onto this sequence.
Definition: Operation.h:361
elftosb::OperationSequence::OperationSequence
OperationSequence()
Default constructor.
Definition: Operation.h:332
elftosb::KeywrapOperation::KeywrapOperation
KeywrapOperation(Keyblob *keyblob)
Constructor. Takes a keyblob argument.
Definition: Operation.h:278