4 * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5 * See included license file for license details.
7 #if !defined(_Operation_h_)
12 #include "DataSource.h"
13 #include "DataTarget.h"
14 #include "smart_ptr.h"
20 * \brief Abstract base class for all boot operations.
26 virtual ~Operation() {}
30 * \brief Load data into memory operation.
32 class LoadOperation : public Operation
35 LoadOperation() : Operation(), m_source(), m_target() {}
37 void setSource(DataSource * source);
38 inline DataSource * getSource() { return m_source; }
40 void setTarget(DataTarget * target);
41 inline DataTarget * getTarget() { return m_target; }
43 inline void setDCDLoad(bool isDCD) { m_isDCDLoad = isDCD; }
44 inline bool isDCDLoad() const { return m_isDCDLoad; }
47 smart_ptr<DataSource> m_source;
48 smart_ptr<DataTarget> m_target;
53 * \brief Operation to execute code at a certain address.
55 class ExecuteOperation : public Operation
65 ExecuteOperation() : Operation(), m_target(), m_argument(0), m_type(kCall), m_isHAB(false) {}
67 inline void setTarget(DataTarget * target) { m_target = target; }
68 inline DataTarget * getTarget() { return m_target; }
70 inline void setArgument(uint32_t arg) { m_argument = arg; }
71 inline uint32_t getArgument() { return m_argument; }
73 inline void setExecuteType(execute_type_t type) { m_type = type; }
74 inline execute_type_t getExecuteType() { return m_type; }
76 inline void setIsHAB(bool isHAB) { m_isHAB = isHAB; }
77 inline bool isHAB() const { return m_isHAB; }
80 smart_ptr<DataTarget> m_target;
82 execute_type_t m_type;
87 * \brief Authenticate with HAB and execute the entry point.
89 class HABExecuteOperation : public ExecuteOperation
92 HABExecuteOperation() : ExecuteOperation() {}
96 * \brief Operation to switch boot modes.
98 class BootModeOperation : public Operation
101 BootModeOperation() : Operation() {}
103 inline void setBootMode(uint32_t mode) { m_bootMode = mode; }
104 inline uint32_t getBootMode() const { return m_bootMode; }
107 uint32_t m_bootMode; //!< The new boot mode value.
111 * \brief Ordered sequence of operations.
113 * The operation objects owned by the sequence are \e not deleted when the
114 * sequence is destroyed. The owner of the sequence must manually delete
115 * the operation objects.
117 class OperationSequence
120 typedef std::vector<Operation*> operation_list_t; //!< Type for a list of operation objects.
121 typedef operation_list_t::iterator iterator_t; //!< Iterator over operations.
122 typedef operation_list_t::const_iterator const_iterator_t; //!< Const iterator over operations.
125 //! \brief Default constructor.
126 OperationSequence() {}
128 //! \brief Constructor. Makes a one-element sequence from \a soleElement.
129 OperationSequence(Operation * soleElement) { m_operations.push_back(soleElement); }
131 //! \brief Destructor.
132 virtual ~OperationSequence();
136 inline iterator_t begin() { return m_operations.begin(); }
137 inline const_iterator_t begin() const { return m_operations.begin(); }
138 inline iterator_t end() { return m_operations.end(); }
139 inline const_iterator_t end() const { return m_operations.end(); }
142 inline Operation * operator [] (unsigned index) const { return m_operations[index]; }
146 //! \brief Returns the number of operations in the sequence.
147 inline unsigned getCount() const { return m_operations.size(); }
152 //! \brief Append one operation object to the sequence.
153 inline void append(Operation * op) { m_operations.push_back(op); }
155 //! \brief Append the contents of \a other onto this sequence.
156 void append(const OperationSequence * other);
158 //! \brief Appends \a other onto this sequence.
159 OperationSequence & operator += (const OperationSequence * other) { append(other); return *this; }
163 operation_list_t m_operations; //!< The list of operations.
166 }; // namespace elftosb
168 #endif // _Operation_h_