updating code from Flying Laptop

This is the framework of Flying Laptop OBSW version A.13.0.
This commit is contained in:
2018-07-12 16:29:32 +02:00
parent 1d22a6c97e
commit 575f70ba03
395 changed files with 12807 additions and 8404 deletions

View File

@ -8,9 +8,9 @@
#ifndef ACCEPTSMEMORYMESSAGESIF_H_
#define ACCEPTSMEMORYMESSAGESIF_H_
#include <framework/ipc/MessageQueue.h>
#include <framework/memory/HasMemoryIF.h>
#include <framework/memory/MemoryMessage.h>
#include <framework/ipc/MessageQueueSenderIF.h>
class AcceptsMemoryMessagesIF : public HasMemoryIF {
public:

View File

@ -1,10 +1,3 @@
/*
* HasMemoryIF.h
*
* Created on: 12.07.2013
* Author: Bastian
*/
#ifndef HASMEMORYIF_H_
#define HASMEMORYIF_H_
@ -12,7 +5,7 @@
class HasMemoryIF {
public:
static const uint8_t INTERFACE_ID = HAS_MEMORY_IF;
static const uint8_t INTERFACE_ID = CLASS_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);
@ -21,6 +14,7 @@ public:
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 DUMP_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0);
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);

View File

@ -1,29 +1,31 @@
/*
* LocalMemory.cpp
*
* Created on: 05.11.2013
* Author: Bastian
*/
#ifdef LEON
#include <bsp_flp/hw_prom/HwProm.h>
#endif
#include <framework/memory/LocalMemory.h>
#include <framework/serialize/SerializeAdapter.h>
#include <framework/ipc/QueueFactory.h>
LocalMemory::LocalMemory(object_id_t setObjectId) :
SystemObject(setObjectId), commandQueue(), memoryHelper(this,
&commandQueue) {
SystemObject(setObjectId), commandQueue(NULL), memoryHelper(this,
commandQueue) {
commandQueue = QueueFactory::instance()->createMessageQueue();
}
ReturnValue_t LocalMemory::performOperation() {
LocalMemory::~LocalMemory() {
QueueFactory::instance()->deleteMessageQueue(commandQueue);
}
ReturnValue_t LocalMemory::performOperation(uint8_t opCode) {
ReturnValue_t handleResult;
CommandMessage message;
for (ReturnValue_t result = commandQueue.receiveMessage(&message);
for (ReturnValue_t result = commandQueue->receiveMessage(&message);
result == HasReturnvaluesIF::RETURN_OK;
result = commandQueue.receiveMessage(&message)) {
result = commandQueue->receiveMessage(&message)) {
handleResult = memoryHelper.handleMemoryCommand(&message);
if (handleResult != HasReturnvaluesIF::RETURN_OK) {
message.setToUnknownCommand(message.getCommand());
commandQueue.reply(&message);
message.setToUnknownCommand();
commandQueue->reply(&message);
}
}
return HasReturnvaluesIF::RETURN_OK;
@ -54,7 +56,7 @@ ReturnValue_t LocalMemory::initialize() {
}
MessageQueueId_t LocalMemory::getCommandQueue() const {
return commandQueue.getId();
return commandQueue->getId();
}
ReturnValue_t LocalMemory::checkWriteAccess(uint32_t address, uint32_t size) {
@ -66,14 +68,13 @@ ReturnValue_t LocalMemory::checkWriteAccess(uint32_t address, uint32_t size) {
if ((size % 4) != 0) {
return INVALID_SIZE;
}
#ifdef LEON
if (address < 0x40000000) {
HwProm prom(false);
if (prom.getPromWriteEnabled() != HwProm::WRITE_ENABLED) {
return WRITE_PROTECTED;
}
}
#endif
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -1,32 +1,29 @@
/*
* 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 <framework/ipc/MessageQueueIF.h>
#include <list>
class LocalMemory : public AcceptsMemoryMessagesIF, public ExecutableObjectIF, public SystemObject {
class LocalMemory: public AcceptsMemoryMessagesIF,
public ExecutableObjectIF,
public SystemObject {
private:
MessageQueue commandQueue;
MessageQueueIF* commandQueue;
MemoryHelper memoryHelper;
ReturnValue_t checkWriteAccess(uint32_t address, uint32_t size);
public:
LocalMemory( object_id_t setObjectId );
ReturnValue_t performOperation();
LocalMemory(object_id_t setObjectId);
~LocalMemory();
ReturnValue_t performOperation(uint8_t opCode);
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);
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_ */

View File

@ -1,25 +1,22 @@
/*
* 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>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis, MessageQueue* useThisQueue) :
MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue) :
workOnThis(workOnThis), queueToUse(useThisQueue), ipcStore(NULL), ipcAddress(), lastCommand(
CommandMessage::CMD_NONE), lastSender(0), reservedSpaceInIPC(
NULL) {
NULL), busy(false) {
}
ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) {
lastSender = message->getSender();
lastCommand = message->getCommand();
if (busy) {
debug << "MemHelper: Busy!" << std::endl;
}
switch (lastCommand) {
case MemoryMessage::CMD_MEMORY_DUMP:
handleMemoryCheckOrDump(message);
@ -47,8 +44,10 @@ ReturnValue_t MemoryHelper::initialize() {
void MemoryHelper::completeLoad(ReturnValue_t errorCode,
const uint8_t* dataToCopy, const uint32_t size, uint8_t* copyHere) {
busy = false;
switch (errorCode) {
case HasMemoryIF::DO_IT_MYSELF:
busy = true;
return;
case HasMemoryIF::POINTS_TO_MEMORY:
memcpy(copyHere, dataToCopy, size);
@ -75,10 +74,12 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode,
void MemoryHelper::completeDump(ReturnValue_t errorCode,
const uint8_t* dataToCopy, const uint32_t size) {
busy = false;
CommandMessage reply;
MemoryMessage::setMemoryReplyFailed(&reply, errorCode, lastCommand);
switch (errorCode) {
case HasMemoryIF::DO_IT_MYSELF:
busy = true;
return;
case HasReturnvaluesIF::RETURN_OK:
case HasMemoryIF::POINTS_TO_MEMORY:
@ -89,6 +90,7 @@ void MemoryHelper::completeDump(ReturnValue_t errorCode,
} else {
memcpy(reservedSpaceInIPC, dataToCopy, size);
}
/* NO BREAK falls through*/
case HasMemoryIF::ACTIVITY_COMPLETED:
switch (lastCommand) {
case MemoryMessage::CMD_MEMORY_DUMP: {
@ -110,6 +112,13 @@ void MemoryHelper::completeDump(ReturnValue_t errorCode,
break;
}
break;
case HasMemoryIF::DUMP_NOT_SUPPORTED:
if (lastCommand == MemoryMessage::CMD_MEMORY_CHECK){
MemoryMessage::setMemoryCheckReply(&reply, 0);
MemoryMessage::setCrcReturnValue(&reply,HasMemoryIF::DUMP_NOT_SUPPORTED);
}
ipcStore->deleteData(ipcAddress);
break;
default:
//Reply is already set to REJECTED.
ipcStore->deleteData(ipcAddress);

View File

@ -1,33 +1,27 @@
/*
* 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>
#include <framework/ipc/MessageQueueIF.h>
class MemoryHelper : public HasReturnvaluesIF {
public:
static const uint8_t INTERFACE_ID = MEMORY_HELPER;
static const uint8_t INTERFACE_ID = CLASS_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;
MessageQueueIF* queueToUse;
StorageManagerIF* ipcStore;
store_address_t ipcAddress;
Command_t lastCommand;
MessageQueueId_t lastSender;
uint8_t* reservedSpaceInIPC;
bool busy;
void handleMemoryLoad(CommandMessage* message);
void handleMemoryCheckOrDump(CommandMessage* message);
public:
@ -36,7 +30,7 @@ public:
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( HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue );
~MemoryHelper();
};
#endif /* MEMORYHELPER_H_ */

View File

@ -1,49 +0,0 @@
/*
* 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_ */

View File

@ -1,11 +1,3 @@
/*
* MemoryMessage.cpp
*
* Created on: 17.07.2013
* Author: Bastian
*/
#include <framework/memory/MemoryMessage.h>
#include <framework/objectmanager/ObjectManagerIF.h>
MemoryMessage::MemoryMessage() {
@ -61,10 +53,11 @@ void MemoryMessage::clear(CommandMessage* message) {
ipcStore->deleteData(getStoreID(message));
}
}
/* NO BREAK*/
/* NO BREAK falls through*/
case CMD_MEMORY_DUMP:
case CMD_MEMORY_CHECK:
case REPLY_MEMORY_CHECK:
case END_OF_MEMORY_COPY:
message->setCommand(CommandMessage::CMD_NONE);
message->setParameter(0);
message->setParameter2(0);
@ -87,10 +80,18 @@ ReturnValue_t MemoryMessage::setMemoryCheckReply(CommandMessage* message,
return HasReturnvaluesIF::RETURN_OK;
}
void MemoryMessage::setCrcReturnValue(CommandMessage* message, ReturnValue_t returnValue){
message->setParameter(returnValue<<16);
};
uint16_t MemoryMessage::getCrc(const CommandMessage* message) {
return (uint16_t)(message->getParameter());
}
ReturnValue_t MemoryMessage::getCrcReturnValue(const CommandMessage* message){
return (message->getParameter()>>16);
}
Command_t MemoryMessage::getInitialCommand(const CommandMessage* message) {
return message->getParameter2();
}
@ -102,3 +103,11 @@ ReturnValue_t MemoryMessage::setMemoryReplyFailed(CommandMessage* message,
message->setParameter2(initialCommand);
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t MemoryMessage::setMemoryCopyEnd(CommandMessage* message) {
message->setCommand(END_OF_MEMORY_COPY);
message->setParameter(0);
message->setParameter2(0);
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -1,10 +1,3 @@
/*
* MemoryMessage.h
*
* Created on: 17.07.2013
* Author: Bastian
*/
#ifndef MEMORYMESSAGE_H_
#define MEMORYMESSAGE_H_
@ -16,13 +9,14 @@ class MemoryMessage {
private:
MemoryMessage(); //A private ctor inhibits instantiation
public:
static const uint8_t MESSAGE_ID = MEMORY_MESSAGE_ID;
static const uint8_t MESSAGE_ID = MESSAGE_TYPE::MEMORY;
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 const Command_t END_OF_MEMORY_COPY = MAKE_COMMAND_ID(0xF0);
static uint32_t getAddress( const CommandMessage* message );
static store_address_t getStoreID( const CommandMessage* message );
@ -34,7 +28,10 @@ public:
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 ReturnValue_t setMemoryCopyEnd( CommandMessage* message);
static void setCrcReturnValue(CommandMessage*, ReturnValue_t returnValue);
static uint16_t getCrc( const CommandMessage* message );
static ReturnValue_t getCrcReturnValue(const CommandMessage* message);
static Command_t getInitialCommand( const CommandMessage* message );
static void clear(CommandMessage* message);
};

View File

@ -1,10 +1,3 @@
/*
* MemoryProxyIF.h
*
* Created on: 18.03.2015
* Author: baetz
*/
#ifndef FRAMEWORK_MEMORY_MEMORYPROXYIF_H_
#define FRAMEWORK_MEMORY_MEMORYPROXYIF_H_