Today's the day. Renamed platform to framework.
This commit is contained in:
21
memory/AcceptsMemoryMessagesIF.h
Normal file
21
memory/AcceptsMemoryMessagesIF.h
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @file AcceptsMemoryMessagesIF.h
|
||||
* @brief This file defines the AcceptsMemoryMessagesIF class.
|
||||
* @date 11.07.2013
|
||||
* @author baetz
|
||||
*/
|
||||
|
||||
#ifndef ACCEPTSMEMORYMESSAGESIF_H_
|
||||
#define ACCEPTSMEMORYMESSAGESIF_H_
|
||||
|
||||
#include <framework/ipc/MessageQueue.h>
|
||||
#include <framework/memory/HasMemoryIF.h>
|
||||
#include <framework/memory/MemoryMessage.h>
|
||||
|
||||
class AcceptsMemoryMessagesIF : public HasMemoryIF {
|
||||
public:
|
||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* ACCEPTSMEMORYMESSAGESIF_H_ */
|
53
memory/HasMemoryIF.h
Normal file
53
memory/HasMemoryIF.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* HasMemoryIF.h
|
||||
*
|
||||
* Created on: 12.07.2013
|
||||
* Author: Bastian
|
||||
*/
|
||||
|
||||
#ifndef HASMEMORYIF_H_
|
||||
#define HASMEMORYIF_H_
|
||||
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
class HasMemoryIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = HAS_MEMORY_IF;
|
||||
static const ReturnValue_t DO_IT_MYSELF = MAKE_RETURN_CODE(1);
|
||||
static const ReturnValue_t POINTS_TO_VARIABLE = MAKE_RETURN_CODE(2);
|
||||
static const ReturnValue_t POINTS_TO_MEMORY = MAKE_RETURN_CODE(3);
|
||||
static const ReturnValue_t ACTIVITY_COMPLETED = MAKE_RETURN_CODE(4);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_UINT8 = MAKE_RETURN_CODE(5);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_UINT16 = MAKE_RETURN_CODE(6);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_UINT32 = MAKE_RETURN_CODE(7);
|
||||
static const ReturnValue_t POINTS_TO_VECTOR_FLOAT = MAKE_RETURN_CODE(8);
|
||||
static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE0);
|
||||
static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0xE1);
|
||||
static const ReturnValue_t INVALID_CONTENT = MAKE_RETURN_CODE(0xE2);
|
||||
static const ReturnValue_t UNALIGNED_ACCESS = MAKE_RETURN_CODE(0xE3);
|
||||
static const ReturnValue_t WRITE_PROTECTED = MAKE_RETURN_CODE(0xE4);
|
||||
// static const ReturnValue_t TARGET_BUSY = MAKE_RETURN_CODE(0xE5);
|
||||
virtual ~HasMemoryIF() {}
|
||||
virtual ReturnValue_t handleMemoryLoad(uint32_t address, const uint8_t* data, uint32_t size, uint8_t** dataPointer) = 0;
|
||||
virtual ReturnValue_t handleMemoryDump(uint32_t address, uint32_t size, uint8_t** dataPointer, uint8_t* dumpTarget ) = 0;
|
||||
/**
|
||||
* Sets the address of the memory, if possible.
|
||||
* startAddress is a proposal for an address, or the base address if multiple addresses are set.
|
||||
*/
|
||||
virtual ReturnValue_t setAddress( uint32_t* startAddress ) { return HasReturnvaluesIF::RETURN_FAILED; }
|
||||
static bool memAccessWasSuccessful(ReturnValue_t result) {
|
||||
switch (result) {
|
||||
case DO_IT_MYSELF:
|
||||
case POINTS_TO_MEMORY:
|
||||
case POINTS_TO_VARIABLE:
|
||||
case HasReturnvaluesIF::RETURN_OK:
|
||||
case ACTIVITY_COMPLETED:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* HASMEMORYIF_H_ */
|
79
memory/LocalMemory.cpp
Normal file
79
memory/LocalMemory.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* LocalMemory.cpp
|
||||
*
|
||||
* Created on: 05.11.2013
|
||||
* Author: Bastian
|
||||
*/
|
||||
|
||||
#include <bsp_flp/hw_prom/HwProm.h>
|
||||
#include <framework/memory/LocalMemory.h>
|
||||
#include <framework/serialize/SerializeAdapter.h>
|
||||
|
||||
LocalMemory::LocalMemory(object_id_t setObjectId) :
|
||||
SystemObject(setObjectId), commandQueue(), memoryHelper(this,
|
||||
&commandQueue) {
|
||||
}
|
||||
|
||||
ReturnValue_t LocalMemory::performOperation() {
|
||||
ReturnValue_t handleResult;
|
||||
CommandMessage message;
|
||||
for (ReturnValue_t result = commandQueue.receiveMessage(&message);
|
||||
result == HasReturnvaluesIF::RETURN_OK;
|
||||
result = commandQueue.receiveMessage(&message)) {
|
||||
handleResult = memoryHelper.handleMemoryCommand(&message);
|
||||
if (handleResult != HasReturnvaluesIF::RETURN_OK) {
|
||||
message.setToUnknownCommand(message.getCommand());
|
||||
commandQueue.reply(&message);
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalMemory::handleMemoryLoad(uint32_t address,
|
||||
const uint8_t* data, uint32_t size, uint8_t** dataPointer) {
|
||||
ReturnValue_t result = checkWriteAccess(address, size);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
uint32_t value = 0;
|
||||
for (uint32_t temp_address = address; temp_address < (address + size);
|
||||
temp_address += 4, data += 4) {
|
||||
value = (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3];
|
||||
*((uint32_t*) temp_address) = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalMemory::handleMemoryDump(uint32_t address, uint32_t size,
|
||||
uint8_t** dataPointer, uint8_t* dumpTarget) {
|
||||
*dataPointer = (uint8_t*) address;
|
||||
return POINTS_TO_MEMORY;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalMemory::initialize() {
|
||||
return memoryHelper.initialize();
|
||||
}
|
||||
|
||||
MessageQueueId_t LocalMemory::getCommandQueue() const {
|
||||
return commandQueue.getId();
|
||||
}
|
||||
|
||||
ReturnValue_t LocalMemory::checkWriteAccess(uint32_t address, uint32_t size) {
|
||||
|
||||
if ((address % 4) != 0) {
|
||||
return UNALIGNED_ACCESS;
|
||||
}
|
||||
|
||||
if ((size % 4) != 0) {
|
||||
return INVALID_SIZE;
|
||||
}
|
||||
|
||||
if (address < 0x40000000) {
|
||||
HwProm prom(false);
|
||||
if (prom.getPromWriteEnabled() != HwProm::WRITE_ENABLED) {
|
||||
return WRITE_PROTECTED;
|
||||
}
|
||||
}
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
32
memory/LocalMemory.h
Normal file
32
memory/LocalMemory.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* LocalMemory.h
|
||||
*
|
||||
* Created on: 05.11.2013
|
||||
* Author: Bastian
|
||||
*/
|
||||
|
||||
#ifndef LOCALMEMORY_H_
|
||||
#define LOCALMEMORY_H_
|
||||
|
||||
#include <framework/ipc/MessageQueue.h>
|
||||
#include <framework/memory/HasMemoryIF.h>
|
||||
#include <framework/memory/MemoryHelper.h>
|
||||
#include <framework/objectmanager/SystemObject.h>
|
||||
#include <framework/tasks/ExecutableObjectIF.h>
|
||||
#include <list>
|
||||
class LocalMemory : public AcceptsMemoryMessagesIF, public ExecutableObjectIF, public SystemObject {
|
||||
private:
|
||||
MessageQueue commandQueue;
|
||||
MemoryHelper memoryHelper;
|
||||
ReturnValue_t checkWriteAccess(uint32_t address, uint32_t size);
|
||||
public:
|
||||
LocalMemory( object_id_t setObjectId );
|
||||
ReturnValue_t performOperation();
|
||||
ReturnValue_t initialize();
|
||||
MessageQueueId_t getCommandQueue() const;
|
||||
ReturnValue_t handleMemoryLoad(uint32_t address, const uint8_t* data, uint32_t size, uint8_t** dataPointer);
|
||||
ReturnValue_t handleMemoryDump(uint32_t address, uint32_t size, uint8_t** dataPointer, uint8_t* dumpTarget);
|
||||
};
|
||||
|
||||
|
||||
#endif /* LOCALMEMORY_H_ */
|
176
memory/MemoryHelper.cpp
Normal file
176
memory/MemoryHelper.cpp
Normal file
@ -0,0 +1,176 @@
|
||||
/*
|
||||
* MemoryHelper.cpp
|
||||
*
|
||||
* Created on: 29.10.2013
|
||||
* Author: Bastian
|
||||
*/
|
||||
|
||||
#include <framework/globalfunctions/crc_ccitt.h>
|
||||
#include <framework/memory/MemoryHelper.h>
|
||||
#include <framework/memory/MemoryMessage.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include <framework/serialize/EndianSwapper.h>
|
||||
|
||||
MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis, MessageQueue* useThisQueue) :
|
||||
workOnThis(workOnThis), queueToUse(useThisQueue), ipcStore(NULL), ipcAddress(), lastCommand(
|
||||
CommandMessage::CMD_NONE), lastSender(0), reservedSpaceInIPC(
|
||||
NULL) {
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) {
|
||||
lastSender = message->getSender();
|
||||
lastCommand = message->getCommand();
|
||||
switch (lastCommand) {
|
||||
case MemoryMessage::CMD_MEMORY_DUMP:
|
||||
handleMemoryCheckOrDump(message);
|
||||
return RETURN_OK;
|
||||
case MemoryMessage::CMD_MEMORY_LOAD:
|
||||
handleMemoryLoad(message);
|
||||
return RETURN_OK;
|
||||
case MemoryMessage::CMD_MEMORY_CHECK:
|
||||
handleMemoryCheckOrDump(message);
|
||||
return RETURN_OK;
|
||||
default:
|
||||
lastCommand = CommandMessage::CMD_NONE;
|
||||
return UNKNOWN_CMD;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryHelper::initialize() {
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore != NULL) {
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryHelper::completeLoad(ReturnValue_t errorCode,
|
||||
const uint8_t* dataToCopy, const uint32_t size, uint8_t* copyHere) {
|
||||
switch (errorCode) {
|
||||
case HasMemoryIF::DO_IT_MYSELF:
|
||||
return;
|
||||
case HasMemoryIF::POINTS_TO_MEMORY:
|
||||
memcpy(copyHere, dataToCopy, size);
|
||||
break;
|
||||
case HasMemoryIF::POINTS_TO_VARIABLE:
|
||||
EndianSwapper::swap(copyHere, dataToCopy, size);
|
||||
break;
|
||||
case HasMemoryIF::ACTIVITY_COMPLETED:
|
||||
case RETURN_OK:
|
||||
break;
|
||||
default:
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, errorCode,
|
||||
MemoryMessage::CMD_MEMORY_LOAD);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
return;
|
||||
}
|
||||
//Only reached on success
|
||||
CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, 0);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
}
|
||||
|
||||
void MemoryHelper::completeDump(ReturnValue_t errorCode,
|
||||
const uint8_t* dataToCopy, const uint32_t size) {
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, errorCode, lastCommand);
|
||||
switch (errorCode) {
|
||||
case HasMemoryIF::DO_IT_MYSELF:
|
||||
return;
|
||||
case HasReturnvaluesIF::RETURN_OK:
|
||||
case HasMemoryIF::POINTS_TO_MEMORY:
|
||||
case HasMemoryIF::POINTS_TO_VARIABLE:
|
||||
//"data" must be valid pointer!
|
||||
if (errorCode == HasMemoryIF::POINTS_TO_VARIABLE) {
|
||||
EndianSwapper::swap(reservedSpaceInIPC, dataToCopy, size);
|
||||
} else {
|
||||
memcpy(reservedSpaceInIPC, dataToCopy, size);
|
||||
}
|
||||
case HasMemoryIF::ACTIVITY_COMPLETED:
|
||||
switch (lastCommand) {
|
||||
case MemoryMessage::CMD_MEMORY_DUMP: {
|
||||
MemoryMessage::setMemoryDumpReply(&reply, ipcAddress);
|
||||
break;
|
||||
}
|
||||
case MemoryMessage::CMD_MEMORY_CHECK: {
|
||||
uint16_t crc = ::Calculate_CRC(reservedSpaceInIPC, size);
|
||||
//Delete data immediately, was temporary.
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
MemoryMessage::setMemoryCheckReply(&reply, crc);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
//This should never happen!
|
||||
//Is it ok to send message? Otherwise: return;
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
reply.setParameter(STATE_MISMATCH);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//Reply is already set to REJECTED.
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
break;
|
||||
}
|
||||
if (queueToUse->sendMessage(lastSender, &reply) != RETURN_OK) {
|
||||
reply.clearCommandMessage();
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryHelper::swapMatrixCopy(uint8_t* out, const uint8_t *in,
|
||||
uint32_t totalSize, uint8_t datatypeSize) {
|
||||
if (totalSize % datatypeSize != 0){
|
||||
return;
|
||||
}
|
||||
|
||||
while (totalSize > 0){
|
||||
EndianSwapper::swap(out,in,datatypeSize);
|
||||
out += datatypeSize;
|
||||
in += datatypeSize;
|
||||
totalSize -= datatypeSize;
|
||||
}
|
||||
}
|
||||
|
||||
MemoryHelper::~MemoryHelper() {
|
||||
//Nothing to destroy
|
||||
}
|
||||
|
||||
void MemoryHelper::handleMemoryLoad(CommandMessage* message) {
|
||||
uint32_t address = MemoryMessage::getAddress(message);
|
||||
ipcAddress = MemoryMessage::getStoreID(message);
|
||||
const uint8_t* p_data = NULL;
|
||||
uint8_t* dataPointer = NULL;
|
||||
uint32_t size = 0;
|
||||
ReturnValue_t returnCode = ipcStore->getData(ipcAddress, &p_data, &size);
|
||||
if (returnCode == RETURN_OK) {
|
||||
returnCode = workOnThis->handleMemoryLoad(address, p_data, size,
|
||||
&dataPointer);
|
||||
completeLoad(returnCode, p_data, size, dataPointer);
|
||||
} else {
|
||||
//At least inform sender.
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, returnCode,
|
||||
MemoryMessage::CMD_MEMORY_LOAD);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryHelper::handleMemoryCheckOrDump(CommandMessage* message) {
|
||||
uint32_t address = MemoryMessage::getAddress(message);
|
||||
uint32_t size = MemoryMessage::getLength(message);
|
||||
uint8_t* dataPointer = NULL;
|
||||
ReturnValue_t returnCode = ipcStore->getFreeElement(&ipcAddress, size,
|
||||
&reservedSpaceInIPC);
|
||||
if (returnCode == RETURN_OK) {
|
||||
returnCode = workOnThis->handleMemoryDump(address, size, &dataPointer,
|
||||
reservedSpaceInIPC);
|
||||
completeDump(returnCode, dataPointer, size);
|
||||
} else {
|
||||
CommandMessage reply;
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, returnCode, lastCommand);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
}
|
||||
}
|
42
memory/MemoryHelper.h
Normal file
42
memory/MemoryHelper.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* MemoryHelper.h
|
||||
*
|
||||
* Created on: 29.10.2013
|
||||
* Author: Bastian
|
||||
*/
|
||||
|
||||
#ifndef MEMORYHELPER_H_
|
||||
#define MEMORYHELPER_H_
|
||||
#include <framework/ipc/CommandMessage.h>
|
||||
#include <framework/ipc/MessageQueue.h>
|
||||
#include <framework/memory/AcceptsMemoryMessagesIF.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
|
||||
class MemoryHelper : public HasReturnvaluesIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = MEMORY_HELPER;
|
||||
static const ReturnValue_t UNKNOWN_CMD = MAKE_RETURN_CODE(0xE0);
|
||||
static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0xE1);
|
||||
static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE2);
|
||||
static const ReturnValue_t STATE_MISMATCH = MAKE_RETURN_CODE(0xE3);
|
||||
private:
|
||||
HasMemoryIF* workOnThis;
|
||||
MessageQueue* queueToUse;
|
||||
StorageManagerIF* ipcStore;
|
||||
store_address_t ipcAddress;
|
||||
Command_t lastCommand;
|
||||
MessageQueueId_t lastSender;
|
||||
uint8_t* reservedSpaceInIPC;
|
||||
void handleMemoryLoad(CommandMessage* message);
|
||||
void handleMemoryCheckOrDump(CommandMessage* message);
|
||||
public:
|
||||
ReturnValue_t handleMemoryCommand(CommandMessage* message);
|
||||
void completeLoad( ReturnValue_t errorCode, const uint8_t* dataToCopy = NULL, const uint32_t size = 0, uint8_t* copyHere = NULL );
|
||||
void completeDump( ReturnValue_t errorCode, const uint8_t* dataToCopy = NULL, const uint32_t size = 0);
|
||||
void swapMatrixCopy( uint8_t *out, const uint8_t *in, uint32_t totalSize, uint8_t datatypeSize);
|
||||
ReturnValue_t initialize();
|
||||
MemoryHelper( HasMemoryIF* workOnThis, MessageQueue* useThisQueue );
|
||||
~MemoryHelper();
|
||||
};
|
||||
#endif /* MEMORYHELPER_H_ */
|
49
memory/MemoryListAdapter.h
Normal file
49
memory/MemoryListAdapter.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* MemoryListAdapter.h
|
||||
*
|
||||
* Created on: 21.03.2014
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#ifndef MEMORYLISTADAPTER_H_
|
||||
#define MEMORYLISTADAPTER_H_
|
||||
|
||||
#include <framework/container/SinglyLinkedList.h>
|
||||
#include <framework/memory/HasMemoryIF.h>
|
||||
|
||||
template<typename T>
|
||||
class MemoryListAdapter : public SinglyLinkedList<T>, public HasMemoryIF {
|
||||
public:
|
||||
MemoryListAdapter(typename LinkedElement<T>::Iterator start) : SinglyLinkedList<T>(start) {
|
||||
}
|
||||
MemoryListAdapter() : SinglyLinkedList<T>() {
|
||||
}
|
||||
|
||||
ReturnValue_t handleMemoryLoad(uint32_t address, const uint8_t* data, uint32_t size, uint8_t** dataPointer) {
|
||||
return handleMemoryLoad(SinglyLinkedList<T>::start, address, data, size, dataPointer);
|
||||
}
|
||||
|
||||
static ReturnValue_t handleMemoryLoad(LinkedElement<T>* element, uint32_t address, const uint8_t* data, uint32_t size, uint8_t** dataPointer) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
while (!HasMemoryIF::memAccessWasSuccessful(result) && (element != NULL)) {
|
||||
result = element->value->handleMemoryLoad(address, data, size, dataPointer);
|
||||
element = element->getNext();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t handleMemoryDump(uint32_t address, uint32_t size, uint8_t** dataPointer, uint8_t* dumpTarget ) {
|
||||
return handleMemoryDump(SinglyLinkedList<T>::start, address, size, dataPointer, dumpTarget);
|
||||
}
|
||||
static ReturnValue_t handleMemoryDump(LinkedElement<T>* element, uint32_t address, uint32_t size, uint8_t** dataPointer, uint8_t* dumpTarget ) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
while (!HasMemoryIF::memAccessWasSuccessful(result) && (element != NULL)) {
|
||||
result = element->value->handleMemoryDump(address, size, dataPointer, dumpTarget);
|
||||
element = element->getNext();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* MEMORYLISTADAPTER_H_ */
|
104
memory/MemoryMessage.cpp
Normal file
104
memory/MemoryMessage.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* MemoryMessage.cpp
|
||||
*
|
||||
* Created on: 17.07.2013
|
||||
* Author: Bastian
|
||||
*/
|
||||
|
||||
|
||||
#include <framework/memory/MemoryMessage.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
MemoryMessage::MemoryMessage() {
|
||||
}
|
||||
|
||||
uint32_t MemoryMessage::getAddress(const CommandMessage* message) {
|
||||
return message->getParameter();
|
||||
}
|
||||
|
||||
store_address_t MemoryMessage::getStoreID(const CommandMessage* message) {
|
||||
store_address_t temp;
|
||||
temp.raw = message->getParameter2();
|
||||
return temp;
|
||||
}
|
||||
|
||||
uint32_t MemoryMessage::getLength(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryDumpCommand(CommandMessage* message,
|
||||
uint32_t address, uint32_t length) {
|
||||
message->setCommand(CMD_MEMORY_DUMP);
|
||||
message->setParameter( address );
|
||||
message->setParameter2( length );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryDumpReply(CommandMessage* message, store_address_t storageID) {
|
||||
message->setCommand(REPLY_MEMORY_DUMP);
|
||||
message->setParameter2( storageID.raw );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryLoadCommand(CommandMessage* message,
|
||||
uint32_t address, store_address_t storageID) {
|
||||
message->setCommand(CMD_MEMORY_LOAD);
|
||||
message->setParameter( address );
|
||||
message->setParameter2( storageID.raw );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::getErrorCode(const CommandMessage* message) {
|
||||
return message->getParameter();
|
||||
}
|
||||
|
||||
void MemoryMessage::clear(CommandMessage* message) {
|
||||
switch (message->getCommand()) {
|
||||
case CMD_MEMORY_LOAD:
|
||||
case REPLY_MEMORY_DUMP: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != NULL) {
|
||||
ipcStore->deleteData(getStoreID(message));
|
||||
}
|
||||
}
|
||||
/* NO BREAK*/
|
||||
case CMD_MEMORY_DUMP:
|
||||
case CMD_MEMORY_CHECK:
|
||||
case REPLY_MEMORY_CHECK:
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
message->setParameter(0);
|
||||
message->setParameter2(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryCheckCommand(CommandMessage* message,
|
||||
uint32_t address, uint32_t length) {
|
||||
message->setCommand(CMD_MEMORY_CHECK);
|
||||
message->setParameter( address );
|
||||
message->setParameter2( length );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryCheckReply(CommandMessage* message,
|
||||
uint16_t crc) {
|
||||
message->setCommand(REPLY_MEMORY_CHECK);
|
||||
message->setParameter( crc );
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
uint16_t MemoryMessage::getCrc(const CommandMessage* message) {
|
||||
return (uint16_t)(message->getParameter());
|
||||
}
|
||||
|
||||
Command_t MemoryMessage::getInitialCommand(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryMessage::setMemoryReplyFailed(CommandMessage* message,
|
||||
ReturnValue_t errorCode, Command_t initialCommand) {
|
||||
message->setCommand(REPLY_MEMORY_FAILED);
|
||||
message->setParameter(errorCode);
|
||||
message->setParameter2(initialCommand);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
42
memory/MemoryMessage.h
Normal file
42
memory/MemoryMessage.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* MemoryMessage.h
|
||||
*
|
||||
* Created on: 17.07.2013
|
||||
* Author: Bastian
|
||||
*/
|
||||
|
||||
#ifndef MEMORYMESSAGE_H_
|
||||
#define MEMORYMESSAGE_H_
|
||||
|
||||
#include <framework/ipc/CommandMessage.h>
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
|
||||
|
||||
class MemoryMessage {
|
||||
private:
|
||||
MemoryMessage(); //A private ctor inhibits instantiation
|
||||
public:
|
||||
static const uint8_t MESSAGE_ID = MEMORY_MESSAGE_ID;
|
||||
static const Command_t CMD_MEMORY_LOAD = MAKE_COMMAND_ID( 0x01 );
|
||||
static const Command_t CMD_MEMORY_DUMP = MAKE_COMMAND_ID( 0x02 );
|
||||
static const Command_t CMD_MEMORY_CHECK = MAKE_COMMAND_ID( 0x03 );
|
||||
static const Command_t REPLY_MEMORY_DUMP = MAKE_COMMAND_ID( 0x10 );
|
||||
static const Command_t REPLY_MEMORY_CHECK = MAKE_COMMAND_ID( 0x30 );
|
||||
static const Command_t REPLY_MEMORY_FAILED = MAKE_COMMAND_ID( 0xE0 );
|
||||
|
||||
static uint32_t getAddress( const CommandMessage* message );
|
||||
static store_address_t getStoreID( const CommandMessage* message );
|
||||
static uint32_t getLength( const CommandMessage* message );
|
||||
static ReturnValue_t getErrorCode( const CommandMessage* message );
|
||||
static ReturnValue_t setMemoryDumpCommand( CommandMessage* message, uint32_t address, uint32_t length );
|
||||
static ReturnValue_t setMemoryDumpReply( CommandMessage* message, store_address_t storageID );
|
||||
static ReturnValue_t setMemoryLoadCommand( CommandMessage* message, uint32_t address, store_address_t storageID );
|
||||
static ReturnValue_t setMemoryCheckCommand( CommandMessage* message, uint32_t address, uint32_t length );
|
||||
static ReturnValue_t setMemoryCheckReply( CommandMessage* message, uint16_t crc );
|
||||
static ReturnValue_t setMemoryReplyFailed( CommandMessage* message, ReturnValue_t errorCode, Command_t initialCommand );
|
||||
static uint16_t getCrc( const CommandMessage* message );
|
||||
static Command_t getInitialCommand( const CommandMessage* message );
|
||||
static void clear(CommandMessage* message);
|
||||
};
|
||||
|
||||
#endif /* MEMORYMESSAGE_H_ */
|
29
memory/MemoryProxyIF.h
Normal file
29
memory/MemoryProxyIF.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* MemoryProxyIF.h
|
||||
*
|
||||
* Created on: 18.03.2015
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORK_MEMORY_MEMORYPROXYIF_H_
|
||||
#define FRAMEWORK_MEMORY_MEMORYPROXYIF_H_
|
||||
|
||||
#include <framework/memory/AcceptsMemoryMessagesIF.h>
|
||||
|
||||
/**
|
||||
* This was a nice idea to transparently forward incoming messages to another object.
|
||||
* But it doesn't work like that.
|
||||
*/
|
||||
class MemoryProxyIF : public AcceptsMemoryMessagesIF {
|
||||
public:
|
||||
virtual MessageQueueId_t getProxyQueue() const = 0;
|
||||
MessageQueueId_t getCommandQueue() const {
|
||||
return getProxyQueue();
|
||||
}
|
||||
virtual ~MemoryProxyIF() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_MEMORY_MEMORYPROXYIF_H_ */
|
Reference in New Issue
Block a user