xme_status_t doMarshalingForTopic2 ( xme_core_dataManager_dataPacketId_t inputPort, void* buffer ) { xme_wp_deMarshalerTest_topic_topic2_t topicData; unsigned int topicDataSize; unsigned int bytesRead; uint8_t* bufferPtr; xme_status_t status; topicDataSize = sizeof(xme_wp_deMarshalerTest_topic_topic2_t); // Read topic data status = xme_core_dataHandler_readData ( inputPort, &topicData, topicDataSize, &bytesRead ); XME_CHECK(status == XME_STATUS_SUCCESS, XME_STATUS_INTERNAL_ERROR); XME_CHECK(bytesRead == topicDataSize, XME_STATUS_INTERNAL_ERROR); // Marshal topic data bufferPtr = (uint8_t*)buffer; // uint32_t topicData.test { uint32_t netValue; netValue = xme_hal_net_htonl((uint32_t)topicData.test); (void) xme_hal_mem_copy(bufferPtr, &netValue, sizeof(uint32_t)); bufferPtr += sizeof(uint32_t); } return XME_STATUS_SUCCESS; }
xme_status_t xme_core_directory_nodeRegistryController_finiNodeInterfaceIterator ( xme_core_directory_nodeRegistryController_nodeInterfaceIterator_t *iterator ) { XME_CHECK(NULL != iterator, XME_STATUS_INVALID_PARAMETER); xme_hal_mem_free(iterator); return XME_STATUS_SUCCESS; }
xme_status_t xme_core_login_loginClient_init(void) { xme_com_interface_address_t intf; XME_CHECK( XME_CORE_NODE_INVALID_NODE_ID == loginInformation.nodeId, XME_STATUS_INVALID_CONFIGURATION); // Generate random GUID loginInformation.guid = ((uint64_t)xme_hal_random_randRange(0x0000, 0xFFFF)) << 48 | ((uint64_t)xme_hal_random_randRange(0x0000, 0xFFFF)) << 32 | ((uint64_t)xme_hal_random_randRange(0x0000, 0xFFFF)) << 16 | ((uint64_t)xme_hal_random_randRange(0x0000, 0xFFFF)); loginInformation.nodeId = xme_core_node_getCurrentNodeId(); XME_CHECK(XME_STATUS_SUCCESS == xme_core_node_getInterface(&intf), XME_STATUS_INTERNAL_ERROR); XME_CHECK(XME_STATUS_SUCCESS == xme_com_interface_genericAddressToIPv4(&intf, &loginInformation.ipAddress, &loginInformation.portAddress), XME_STATUS_INTERNAL_ERROR); return XME_STATUS_SUCCESS; }
xme_status_t xme_core_directory_nodeRegistryController_finiNodeIDIterator ( xme_core_directory_nodeRegistryController_nodeIDIterator_t* iterator ) { XME_CHECK(NULL != iterator, XME_STATUS_INVALID_PARAMETER); // Nothing to do return XME_STATUS_SUCCESS; }
extern xme_status_t xme_core_loop_init( void ) { XME_HAL_SINGLYLINKEDLIST_INIT(xme_core_loop_SchedulerData.initQueue); XME_HAL_SINGLYLINKEDLIST_INIT(xme_core_loop_SchedulerData.chunks); /* Registration of the RTE modules */ XME_CHECK_MSG( XME_STATUS_SUCCESS == xme_core_loop_RegisterModulesCallback(), XME_STATUS_INVALID_CONFIGURATION, XME_LOG_FATAL, MODULE_ACRONYM "Could not register RTE modules!\n"); /* A configuration routine to define RTE "chunks" - the basic blocks of RTE module execution on OS level */ XME_CHECK_MSG( XME_STATUS_SUCCESS == xme_core_loop_CreateChunksCallback(), XME_STATUS_INVALID_CONFIGURATION, XME_LOG_FATAL, MODULE_ACRONYM "Could not create RTE chunks!\n"); /* Check the chunks for plausibility and register in EM */ XME_CHECK_MSG( XME_STATUS_SUCCESS == xme_core_loop_completeInitialization(), XME_STATUS_INVALID_CONFIGURATION, XME_LOG_FATAL, MODULE_ACRONYM "Could not complete RTE initialization!\n"); XME_HAL_SINGLYLINKEDLIST_ITERATE_BEGIN(xme_core_loop_SchedulerData.initQueue, xme_core_exec_componentDescriptor_t, compToInit); if(compToInit->autoInit) { XME_LOG(XME_LOG_NOTE, MODULE_ACRONYM "RTE scheduler: initialize component %3d with priority %5d\n", compToInit->componentId, compToInit->initPriority); XME_CHECK_MSG(XME_STATUS_SUCCESS == compToInit->init(compToInit->initParam), XME_STATUS_INVALID_CONFIGURATION, XME_LOG_FATAL, MODULE_ACRONYM "Failure during initialization of the component %d\n", compToInit->componentId); } XME_HAL_SINGLYLINKEDLIST_ITERATE_END(); XME_CHECK( XME_STATUS_SUCCESS == xme_core_loop_ActivateScheduleCallback(), XME_STATUS_INTERNAL_ERROR); return XME_STATUS_SUCCESS; }
xme_com_interface_address_t* xme_core_directory_nodeRegistryController_nextInterface ( xme_core_directory_nodeRegistryController_nodeInterfaceIterator_t *iterator ) { xme_com_interface_address_t* interfaceItem = NULL; XME_CHECK(NULL != iterator, NULL); // Store the pointer to current interfaceItem in the iterator // This will be returned in this call interfaceItem = iterator->interfaceItem; // This check is added for wrap around of the iterator. // After the last item in the list the XME_HAL_TABLE_GET_NEXT sets the // row handle as INVALID_ROW_HANDLE and the pointer as NULL. // Then accordingly hasNextInterface returns false. // But if this function is called even when hasNextInterface has returned false // the iterator begins from the start and wraps around. // This happens because the XME_HAL_TABLE_GET_NEXT assumes INVALID_ROW_HANDLE as a parameter // for the table to start the iteration. // This is a safe check because the corresponding init function initializes the pointer to first value if it exists // Then this check will pass and return the correct value for nextInterface after the init. // And if it does not exist then this will fail and return NULL from here. XME_CHECK((XME_HAL_TABLE_INVALID_ROW_HANDLE != iterator->currentHandle && NULL != iterator->interfaceItem), NULL); iterator->interfaceItem = NULL; // Move the iterator to next item XME_HAL_TABLE_GET_NEXT ( iterator->nodeItem->interfaces, xme_hal_table_rowHandle_t, iterator->currentHandle, xme_com_interface_address_t, iterator->interfaceItem, iterator->interfaceItem->addressType == iterator->addressType || XME_COM_INTERFACE_ADDRESS_TYPE_INVALID == iterator->addressType ); return interfaceItem; }
xme_status_t xme_core_exec_dispatcher_executionCompleted ( xme_core_component_t componentId, xme_core_component_functionId_t functionId ) { xme_core_exec_taskDescriptor_t* thisTask = NULL; /* We only deal with an initialized component */ if (!xme_core_exec_isInitialized()) return XME_STATUS_UNEXPECTED; XME_LOG(XME_LOG_DEBUG, MODULE_ACRONYM "(t): > [%d|%d] dispatcher_executionCompleted()\n", componentId, functionId); /* Look up for a task descriptor */ XME_CHECK(XME_STATUS_SUCCESS == xme_core_exec_descriptorTable_getTaskDescriptor(componentId, functionId, &thisTask), XME_STATUS_NOT_FOUND); /* Stop monitoring the task */ thisTask->running = false; XME_LOG(XME_LOG_DEBUG, MODULE_ACRONYM "(t): [%d|%d] execution time total = %" PRIu64 "\n", componentId, functionId, xme_hal_time_getTimeInterval(&(thisTask->startTime), (bool)false)); XME_CHECK(XME_STATUS_SUCCESS == xme_core_exec_dispatcher_returnExecutionToken(thisTask), XME_STATUS_INTERNAL_ERROR); XME_LOG(XME_LOG_DEBUG, MODULE_ACRONYM "***************** /executionCompleted [%d|%d] *********************\n", componentId, functionId); return XME_STATUS_SUCCESS; }
xme_status_t xme_core_directory_nodeRegistryController_getGUIDFromNodeId ( xme_core_node_nodeId_t nodeId, xme_core_node_guid_t* outGuid ) { xme_hal_table_rowHandle_t handle; xme_core_node_nodeData_t* nodeItem; XME_CHECK(XME_CORE_NODE_INVALID_NODE_ID != nodeId, XME_STATUS_INVALID_PARAMETER); XME_CHECK(NULL != outGuid, XME_STATUS_INVALID_PARAMETER); // Search for an existing item for this node handle = XME_HAL_TABLE_INVALID_ROW_HANDLE; nodeItem = NULL; XME_HAL_TABLE_GET_NEXT ( xme_core_directory_nodeRegistryController_nodeTable, xme_hal_table_rowHandle_t, handle, xme_core_node_nodeData_t, nodeItem, nodeItem->nodeId == nodeId ); // The node is not yet registered if (XME_HAL_TABLE_INVALID_ROW_HANDLE == handle || NULL == nodeItem) { *outGuid = 0; return XME_STATUS_NOT_FOUND; } // The guid is registered *outGuid = nodeItem->guid; return XME_STATUS_SUCCESS; }
xme_status_t xme_core_dataHandler_databaseTestProbe_applyManipulations ( xme_core_dataHandler_database_dataStore_t* const dataStore ) { xme_status_t status; // Copy again the data packet. status = copyBetweenMemoryRegionCopies ( dataStore->dataStoreID, XME_CORE_DATAHANDLER_DATABASE_INDEX_MASTER, XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW ); XME_CHECK(XME_STATUS_SUCCESS == status, status); status = reapplyManipulations(dataStore->dataStoreID); XME_CHECK(XME_STATUS_SUCCESS == status, status); return XME_STATUS_SUCCESS; }
extern xme_status_t xme_core_loop_addChunkToGlobalSchedule ( xme_core_exec_schedule_handle_t scheduleId, xme_core_loop_Chunk_handle_t chunkId ) { xme_hal_sched_taskHandle_t taskHandle; xme_core_exec_schedule_table_t* schedule = NULL; xme_core_loop_ChunkDescriptor_t* chunkDesc = xme_core_loop_getChunkDescriptor(chunkId); XME_CHECK( NULL != chunkDesc, XME_STATUS_NOT_FOUND); // If a chunk has already been registered, do not do it if(XME_STATUS_NOT_FOUND == xme_core_exec_dispatcher_getRunnable(chunkDesc->executionUnit->componentId, chunkDesc->executionUnit->functionId,&taskHandle)) { XME_LOG(XME_LOG_DEBUG, MODULE_ACRONYM "addToGlobalSchedule(%d, %d)\n", scheduleId, chunkDesc->id); // fixme: hello Lint, ist it ok? XME_CHECK_MSG(XME_STATUS_SUCCESS == xme_core_exec_dispatcher_createFunctionExecutionUnit( chunkDesc->executionUnit, (bool) false), XME_STATUS_INTERNAL_ERROR, XME_LOG_ERROR, MODULE_ACRONYM "execution unit could not be started\n"); } XME_CHECK(XME_STATUS_SUCCESS == xme_core_exec_scheduler_getSchedule(scheduleId, &schedule), XME_STATUS_NOT_FOUND); return xme_core_exec_scheduler_addElementToScheduleTable( schedule, RTE_BASE_COMPONENT_ID, chunkDesc->id, (xme_core_component_functionVariantId_t)(chunkDesc->id), chunkDesc->startTime_ns, chunkDesc->endTime_ns-chunkDesc->startTime_ns, 0, 0, (bool) true ); }
xme_status_t xme_core_dataHandler_databaseTestProbe_startTopicManipulation ( xme_core_dataManager_dataStoreID_t dataStoreID, uint32_t offset ) { xme_core_dataHandler_database_dataStore_t* dataStore; xme_status_t status; XME_ASSERT(NULL != xme_core_dataHandler_database); // Get the data packet information. XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_NOT_FOUND); if (offset > dataStore->dataStoreSize) { return XME_STATUS_INVALID_CONFIGURATION; } if (!dataStore->manipulated) { status = copyBetweenMemoryRegionCopies ( dataStoreID, XME_CORE_DATAHANDLER_DATABASE_INDEX_MASTER, XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW ); XME_CHECK(XME_STATUS_SUCCESS == status, status); status = reapplyManipulations(dataStore->dataStoreID); XME_CHECK(XME_STATUS_SUCCESS == status, status); dataStore->manipulated = true; } return XME_STATUS_SUCCESS; }
/** TODO: refactor: implement */ static xme_status_t xme_core_exec_dispatcher_checkWCETConformance( xme_core_component_t componentId, xme_core_component_functionId_t functionId) { xme_core_exec_taskDescriptor_t* thisTask = NULL; XME_CHECK(XME_STATUS_SUCCESS == xme_core_exec_descriptorTable_getTaskDescriptor(componentId, functionId, &thisTask), XME_STATUS_NOT_FOUND); // TODO: Monitor time to completion return XME_STATUS_SUCCESS; }
xme_status_t chromosomeGui_wp_marshaler_run ( xme_wp_waypoint_instanceId_t instanceId ) { xme_status_t status; configurationItem_t* configurationItem; configurationItem = XME_HAL_TABLE_ITEM_FROM_HANDLE ( configurationTable, (xme_hal_table_rowHandle_t)instanceId ); XME_CHECK ( NULL != configurationItem, XME_STATUS_INVALID_HANDLE ); // Do the marshaling for this configuration status = doMarshaling ( configurationItem->topic, configurationItem->inputPort, configurationItem->outputPort ); XME_CHECK ( XME_STATUS_SUCCESS == status, XME_STATUS_INTERNAL_ERROR ); return XME_STATUS_SUCCESS; }
xme_status_t doMarshalingForButtonSignal ( xme_core_dataManager_dataPacketId_t inputPort, void* buffer ) { chromosomeGui_topic_ButtonSignal_t topicData; unsigned int topicDataSize; unsigned int bytesRead; uint8_t* bufferPtr; xme_status_t status; topicDataSize = sizeof(chromosomeGui_topic_ButtonSignal_t); // Read topic data status = xme_core_dataHandler_readData ( inputPort, &topicData, topicDataSize, &bytesRead ); XME_CHECK(status == XME_STATUS_SUCCESS, XME_STATUS_INTERNAL_ERROR); XME_CHECK(bytesRead == topicDataSize, XME_STATUS_INTERNAL_ERROR); // Marshal topic data bufferPtr = (uint8_t*)buffer; // char topicData.buttonPushed xme_hal_mem_copy(bufferPtr, &topicData.buttonPushed, sizeof(char)); bufferPtr += sizeof(char); return XME_STATUS_SUCCESS; }
/*--------------------------------------------------------------------------*/ xme_status_t xme_core_exec_descriptorTable_init( void ) { /* Initialize a critical section to control the access to the task list */ taskDescriptorsMutex = xme_hal_sync_createCriticalSection(); XME_CHECK( XME_HAL_SYNC_INVALID_CRITICAL_SECTION_HANDLE != taskDescriptorsMutex, XME_STATUS_INTERNAL_ERROR); xme_hal_sync_enterCriticalSection(taskDescriptorsMutex); XME_HAL_TABLE_INIT(taskDescriptorsTable); xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex); return XME_STATUS_SUCCESS; }
xme_status_t xme_core_dataHandler_databaseTestProbe_endAttributeManipulation ( xme_core_dataManager_dataStoreID_t dataStoreID, uint32_t offset, uint32_t attributeKey ) { xme_core_dataHandler_database_dataStore_t* dataStore; xme_core_dataHandler_database_attribute_t* attribute; void* databaseAddress; uintptr_t dataAddress; xme_status_t status; XME_ASSERT(NULL != xme_core_dataHandler_database); // Get the data packet information. XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_NOT_FOUND); XME_CHECK(XME_STATUS_SUCCESS == getAttribute(dataStore, attributeKey, &attribute), XME_STATUS_INVALID_PARAMETER); if (offset > attribute->attributeValueSize) { return XME_STATUS_INVALID_CONFIGURATION; } databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW - 1U); XME_CHECK(0U != databaseAddress, XME_STATUS_NOT_FOUND); dataAddress = (((uintptr_t) databaseAddress) + attribute->attributeOffset + offset); status = removeManipulation(dataStoreID, dataAddress); XME_CHECK(XME_STATUS_SUCCESS == status, status); if (0U == getNumberOfManipulationsForDataStore(dataStoreID)) { dataStore->manipulated = false; // Activate master database. dataStore->activeDatabaseIndex = XME_CORE_DATAHANDLER_DATABASE_INDEX_MASTER; } else { status = copyBetweenMemoryRegionCopies ( dataStoreID, XME_CORE_DATAHANDLER_DATABASE_INDEX_MASTER, XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW ); XME_CHECK(XME_STATUS_SUCCESS == status, status); status = reapplyManipulations(dataStore->dataStoreID); XME_CHECK(XME_STATUS_SUCCESS == status, status); } return XME_STATUS_SUCCESS; }
xme_status_t autopnp_adv_cleaningGui_cleaningGuiComponentWrapper_receivePort ( xme_core_dataManager_dataPacketId_t portId, autopnp_adv_cleaningGui_cleaningGuiComponentWrapper_interalPortId_t componentInternalPortId ) { XME_CHECK ( (autopnp_adv_cleaningGui_cleaningGuiComponentWrapper_interalPortId_t) PORT_COUNT > componentInternalPortId, XME_STATUS_INVALID_PARAMETER ); ports[componentInternalPortId] = portId; return XME_STATUS_SUCCESS; }
static xme_status_t xme_core_loop_completeChunkInit ( xme_core_loop_ChunkDescriptor_t* const chunk ) { xme_core_exec_functionDescriptor_t* newFunctionDesc; /* Verify if the schedule does not contain intersections and compute wcet*/ XME_CHECK(XME_STATUS_SUCCESS == xme_core_loop_checkRteChunkSchedule(chunk), XME_STATUS_INVALID_CONFIGURATION); /* Create a function descriptor for an RTE chunk. * This will be the descriptor of our executable unit. */ newFunctionDesc = (xme_core_exec_functionDescriptor_t*) xme_hal_mem_alloc( sizeof(xme_core_exec_functionDescriptor_t) ); /* Ugly reassignments, thanks MS for C99 support */ newFunctionDesc->componentId = RTE_BASE_COMPONENT_ID; newFunctionDesc->functionId = chunk->id; newFunctionDesc->task = &xme_core_loop_execChunk; newFunctionDesc->taskArgs = (void*)newFunctionDesc; newFunctionDesc->wcet_ns = chunk->wcet_ns; newFunctionDesc->state = XME_CORE_EXEC_FUNCTION_STATE_INVALID_STATE; chunk->executionUnit = newFunctionDesc; /* Add the respective RTE components to the init queue */ XME_HAL_SINGLYLINKEDLIST_ITERATE_BEGIN( chunk->slots, // list to iterate over xme_core_loop_SlotDescriptor_t, slot ); // iterator variable // fixme: dear Lint, is it ok? if(XME_STATUS_SUCCESS != xme_core_loop_addToInitQueue(slot->componentDesc)) { XME_LOG(XME_LOG_NOTE, MODULE_ACRONYM "slot [%d|%d] has not been added to startup queue\n", slot->functionDesc->componentId, slot->functionDesc->functionId); } XME_HAL_SINGLYLINKEDLIST_ITERATE_END(); return XME_STATUS_SUCCESS; }
xme_status_t xme_core_exec_dispatcher_waitForStart ( xme_core_component_t componentId, xme_core_component_functionId_t functionId, void** functionArguments ) { xme_core_exec_taskDescriptor_t* thisTask = NULL; /* We only deal with an initialized component */ if (!xme_core_exec_isInitialized()) return XME_STATUS_UNEXPECTED; XME_LOG(XME_LOG_DEBUG, MODULE_ACRONYM "(t): > dispatcher_waitForStart()\n"); XME_CHECK_MSG(XME_STATUS_SUCCESS == xme_core_exec_descriptorTable_getTaskDescriptor(componentId, functionId, &thisTask), XME_STATUS_NOT_FOUND, XME_LOG_FATAL, MODULE_ACRONYM "task [%d|%d] not present in the task table!\n", componentId, functionId); XME_LOG(XME_LOG_DEBUG, MODULE_ACRONYM "(t): [%d|%d] waitForStart()\n", componentId, functionId); XME_CHECK(XME_STATUS_SUCCESS == xme_core_exec_dispatcher_requestExecutionToken(thisTask), XME_STATUS_INTERNAL_ERROR); XME_LOG(XME_LOG_DEBUG, MODULE_ACRONYM "passing %" PRIu32 " to function [%d|%d]\n", (uint32_t)(uintptr_t)startData, componentId, functionId); if (NULL != functionArguments) *functionArguments = startData; /* XXX temporary workaround to allow smooth transition to xme_core_exec_getTaskState() */ thisTask->wrapper->state = thisTask->state; XME_LOG(XME_LOG_DEBUG, MODULE_ACRONYM "(t): < [%d|%d] dispatcher_waitForStart()\n", componentId, functionId); return XME_STATUS_SUCCESS; }
/*--------------------------------------------------------------------------*/ xme_status_t xme_core_exec_dispatcher_getRunnable ( xme_core_component_t componentId, xme_core_component_functionId_t functionId, xme_hal_sched_taskHandle_t* taskHandle ) { xme_core_exec_taskDescriptor_t* taskRecord = NULL; xme_status_t status; XME_CHECK(XME_STATUS_SUCCESS == (status = xme_core_exec_descriptorTable_getTaskDescriptor(componentId, functionId, &taskRecord)), status); *taskHandle = taskRecord->handle; return XME_STATUS_SUCCESS; }
xme_status_t addManipulation ( xme_core_dataManager_dataStoreID_t dataStoreID, uintptr_t address, uint32_t value ) { xme_core_dataHandler_database_manipulationItem_t* manipulationItem = NULL; xme_hal_table_rowHandle_t internalHandle = XME_HAL_TABLE_INVALID_ROW_HANDLE; // Obtain the next element. XME_HAL_TABLE_GET_NEXT ( manipulationsTable, xme_hal_table_rowHandle_t, internalHandle, xme_core_dataHandler_database_manipulationItem_t, manipulationItem, (manipulationItem->dataStoreID == dataStoreID && manipulationItem->address == (uintptr_t) address) ); if (XME_HAL_TABLE_INVALID_ROW_HANDLE == internalHandle) { // Create a new element. internalHandle = XME_HAL_TABLE_ADD_ITEM(manipulationsTable); XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != internalHandle, XME_STATUS_OUT_OF_RESOURCES); manipulationItem = XME_HAL_TABLE_ITEM_FROM_HANDLE(manipulationsTable, internalHandle); XME_ASSERT(NULL != manipulationItem); manipulationItem->dataStoreID = dataStoreID; manipulationItem->address = address; manipulationItem->value = value; } else { // Use existing element. manipulationItem->value = value; } return XME_STATUS_SUCCESS; }
xme_status_t sensorMonitor_adv_monitorB_monitorBComponentWrapper_receivePort ( xme_core_dataManager_dataPacketId_t dataPacketId, sensorMonitor_adv_monitorB_monitorBComponentWrapper_internalPortId_t componentInternalPortId ) { XME_CHECK ( inputPortCount > componentInternalPortId, XME_STATUS_INVALID_PARAMETER ); { inputPorts[componentInternalPortId].dataPacketId = dataPacketId; inputPorts[componentInternalPortId].state.dataValid = 0; inputPorts[componentInternalPortId].state.attributesValid = 0; inputPorts[componentInternalPortId].state.locked = 0; inputPorts[componentInternalPortId].state.error = 0; } return XME_STATUS_SUCCESS; }
bool xme_core_directory_nodeRegistryController_isNodeGuidRegistered ( xme_core_node_guid_t guid, xme_core_node_nodeId_t* const outNodeID ) { xme_hal_table_rowHandle_t handle; xme_core_node_nodeData_t* nodeItem; XME_CHECK(0 != guid, false); // Search for an existing item for this node handle = XME_HAL_TABLE_INVALID_ROW_HANDLE; nodeItem = NULL; XME_HAL_TABLE_GET_NEXT ( xme_core_directory_nodeRegistryController_nodeTable, xme_hal_table_rowHandle_t, handle, xme_core_node_nodeData_t, nodeItem, nodeItem->guid == guid ); if (XME_HAL_TABLE_INVALID_ROW_HANDLE != handle) { if (NULL != outNodeID) { *outNodeID = nodeItem->nodeId; } return true; } return false; }
static xme_status_t xme_core_exec_dispatcher_recaptureExecutionToken ( xme_core_exec_taskDescriptor_t* task ) { xme_core_exec_functionDescriptor_t* function = NULL; XME_CHECK(NULL != task, XME_STATUS_INVALID_HANDLE); function = task->wrapper; XME_LOG(XME_LOG_DEBUG, MODULE_ACRONYM "[%d|%d] dispatcher_recaptureExecutionToken()\n", function->componentId, function->functionId); xme_core_exec_lockMutex("T/m", task->execLock, function->componentId, function->functionId); xme_core_exec_lockMutex("R/m", cpuToken, function->componentId, function->functionId); xme_core_exec_unlockMutex("S/m", task->waitLock, function->componentId, function->functionId); XME_LOG(XME_LOG_DEBUG, MODULE_ACRONYM "[%d|%d] /dispatcher_recaptureExecutionToken()\n", function->componentId, function->functionId); return XME_STATUS_SUCCESS; }
/*--------------------------------------------------------------------------*/ xme_status_t xme_core_exec_setTaskState ( xme_core_component_t componentId, xme_core_component_functionId_t functionId, xme_core_exec_functionState_t newTaskState ) { xme_core_exec_taskDescriptor_t* task = NULL; XME_CHECK_MSG(XME_STATUS_SUCCESS == xme_core_exec_descriptorTable_getTaskDescriptor(componentId, functionId, &task), XME_STATUS_INTERNAL_ERROR, XME_LOG_WARNING, MODULE_ACRONYM "error getting task descriptor for [%d|%d]\n", componentId, functionId); XME_CHECK(NULL != task, XME_STATUS_INTERNAL_ERROR); xme_hal_sync_enterCriticalSection(taskDescriptorsMutex); task->state = newTaskState; xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex); return XME_STATUS_SUCCESS; }
xme_status_t copyBetweenMemoryRegionCopies ( xme_core_dataManager_dataStoreID_t dataStoreID, uint16_t sourceDatabaseIndex, uint16_t targetDatabaseIndex ) { uintptr_t sourceDataAddress; uintptr_t sinkDataAddress; xme_core_dataHandler_database_dataStore_t* dataStore; uint32_t transferSizeInBytes; uint32_t totalOffset; void* returnAddress; void* sourceDatabaseAddress; void* sinkDatabaseAddress; XME_ASSERT(NULL != xme_core_dataHandler_database); // Get the data packet information. XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE); // Calculate the total offsets to add. totalOffset = dataStore->topicOffset; // Calculate the position in the queue for the source and sink address. if (dataStore->queueSize > 1) { totalOffset += dataStore->dataStoreSize * dataStore->currentCBWritePosition; } // Get the number of bytes to use in the transfer operation. transferSizeInBytes = getBytesToCopy(dataStore->topicSize, dataStore->topicSize, 0U); // Get source database address from the source database copy. sourceDatabaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, sourceDatabaseIndex - 1U); // Get source database address from the source database copy. sinkDatabaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, targetDatabaseIndex - 1U); // Check that the database addresses contain correct values. XME_CHECK(0U != sourceDatabaseAddress, XME_STATUS_NOT_FOUND); XME_CHECK(0U != sinkDatabaseAddress, XME_STATUS_NOT_FOUND); if (dataStore->dataAvailable) { // Add the offset corresponding to the source and sink addresses. sourceDataAddress = ((uintptr_t) sourceDatabaseAddress + totalOffset); sinkDataAddress = ((uintptr_t) sinkDatabaseAddress + totalOffset); // Do the transfer for the current copy of the database-> returnAddress = xme_hal_mem_copy((void*) sinkDataAddress, (void*) sourceDataAddress, transferSizeInBytes); XME_CHECK(returnAddress == (void*) sinkDataAddress, XME_STATUS_INTERNAL_ERROR); } // Try the transfer for all attributes as well. XME_HAL_SINGLYLINKEDLIST_ITERATE_BEGIN(dataStore->attributes, xme_core_dataHandler_database_attribute_t, attribute); { if (attribute->dataAvailable == true) { // If the attribute exists in the target data packet. uint32_t totalAttributeOffset; uintptr_t sourceAttributeAddress; uintptr_t sinkAttributeAddress; uint32_t totalAttributeSizeInBytes; // Calculate the total offsets to add. totalAttributeOffset = attribute->attributeOffset; // Calculate the position in the queue for the source and sink address. if (dataStore->queueSize > 1) { totalAttributeOffset += dataStore->dataStoreSize * dataStore->currentCBWritePosition; } // Get trasnfer bytes to copy. totalAttributeSizeInBytes = getBytesToCopy(attribute->attributeValueSize, attribute->attributeValueSize, 0U); // Add the offset corresponding to the source and sink addresses. sourceAttributeAddress = ((uintptr_t) sourceDatabaseAddress + totalAttributeOffset); sinkAttributeAddress = ((uintptr_t) sinkDatabaseAddress + totalAttributeOffset); // Do the transfer for the current copy of the database-> returnAddress = xme_hal_mem_copy((void*) sinkAttributeAddress, (void*) sourceAttributeAddress, totalAttributeSizeInBytes); XME_CHECK(returnAddress == (void*) sinkAttributeAddress, XME_STATUS_INTERNAL_ERROR); } } XME_HAL_SINGLYLINKEDLIST_ITERATE_END(); return XME_STATUS_SUCCESS; }
xme_status_t xme_core_dataHandler_databaseTestProbe_readAttribute ( xme_core_dataHandler_database_index_t databaseIndex, xme_core_dataManager_dataPacketId_t dataStoreID, uint32_t attributeKey, uint32_t offsetInBytes, void* const targetBuffer, size_t targetBufferSizeInBytes, uint32_t* const readBytes ) { uintptr_t attributeAddress; size_t attributeSizeInBytes; xme_core_dataHandler_database_dataStore_t* dataStore; xme_core_dataHandler_database_attribute_t* attribute; uint32_t totalOffset; void* returnAddress; void* databaseAddress; XME_ASSERT(NULL != xme_core_dataHandler_database); XME_ASSERT(NULL != readBytes); *readBytes = 0U; // Obtain first the data packet and then the attribute. XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE); XME_CHECK(XME_STATUS_SUCCESS == getAttribute(dataStore, attributeKey, &attribute), XME_STATUS_INVALID_PARAMETER); XME_CHECK(databaseIndex <= dataStore->memoryRegion->numOfCopies, XME_STATUS_INVALID_CONFIGURATION); XME_CHECK(attribute->dataAvailable, XME_STATUS_NO_SUCH_VALUE); // Return an error if an attempt is made to read outside the bounds of the data packet XME_CHECK(offsetInBytes < attribute->attributeValueSize, XME_STATUS_INVALID_PARAMETER); // Calculate the total offset to add. totalOffset = attribute->attributeOffset + offsetInBytes; // Add queue write position. if (dataStore->queueSize > 1) { totalOffset += (dataStore->dataStoreSize * dataStore->currentCBReadPosition); } // Get the number of bytes to use in the read operation. attributeSizeInBytes = getBytesToCopy(attribute->attributeValueSize, targetBufferSizeInBytes, offsetInBytes); if (((xme_core_dataHandler_database_index_t)XME_CORE_DATAHANDLER_DATABASE_INDEX_DEFAULT) == databaseIndex) { // Get database address from the active database in the data packet. databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, dataStore->activeDatabaseIndex - 1U); } else { // Get database address from the provided database index. databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, databaseIndex - 1U); } // Check that the database address and size contains correct values. XME_CHECK(0U != databaseAddress, XME_STATUS_NOT_FOUND); // Add the offset. attributeAddress = ((uintptr_t) databaseAddress + totalOffset); if (targetBufferSizeInBytes > attributeSizeInBytes) { uintptr_t bufferToCopy; bufferToCopy = ((uintptr_t) targetBuffer + (targetBufferSizeInBytes - attributeSizeInBytes)); returnAddress = xme_hal_mem_copy(targetBuffer, (void*) bufferToCopy, attributeSizeInBytes); XME_CHECK(returnAddress == (void*) targetBuffer, XME_STATUS_INTERNAL_ERROR); } else { // Do the read operation returnAddress = xme_hal_mem_copy(targetBuffer, (void*) attributeAddress, attributeSizeInBytes); XME_CHECK(returnAddress == (void*) targetBuffer, XME_STATUS_INTERNAL_ERROR); } // Set the effectively read bytes. *readBytes = attributeSizeInBytes; // Check that the target buffer is not null-valued. XME_CHECK(NULL != targetBuffer, XME_STATUS_INVALID_CONFIGURATION); return XME_STATUS_SUCCESS; }
xme_status_t xme_core_dataHandler_databaseTestProbe_readData ( xme_core_dataHandler_database_index_t databaseIndex, xme_core_dataManager_dataPacketId_t dataStoreID, uint32_t offsetInBytes, void* const targetBuffer, size_t targetBufferSizeInBytes, uint32_t* const readBytes ) { uintptr_t dataAddress; size_t dataSizeInBytes; xme_core_dataHandler_database_dataStore_t* dataStore; uint32_t totalOffset; void* returnAddress; void* databaseAddress; XME_ASSERT(NULL != xme_core_dataHandler_database); XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE); XME_CHECK(databaseIndex <= dataStore->memoryRegion->numOfCopies, XME_STATUS_INVALID_CONFIGURATION); if (!dataStore->dataAvailable) { *readBytes = 0U; return XME_STATUS_NO_SUCH_VALUE; } if (offsetInBytes >= dataStore->topicSize) { // We can not read outside the limit of the data packet. An error is returned. *readBytes = 0U; return XME_STATUS_INVALID_PARAMETER; } // Calculate the total offset to add. totalOffset = dataStore->topicOffset + offsetInBytes; // Add queue write position. if (dataStore->queueSize > 1) { totalOffset += (dataStore->dataStoreSize * dataStore->currentCBReadPosition); } // Get the number of bytes to use in the read operation. dataSizeInBytes = getBytesToCopy(dataStore->topicSize, targetBufferSizeInBytes, offsetInBytes); if (((xme_core_dataHandler_database_index_t)XME_CORE_DATAHANDLER_DATABASE_INDEX_DEFAULT) == databaseIndex) { // Get database address from the active database in the data packet. databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, dataStore->activeDatabaseIndex - 1U); } else { // Get database address from the provided database index. databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, databaseIndex - 1U); } // Check that the database address and size contains correct values. XME_CHECK(0U != databaseAddress, XME_STATUS_NOT_FOUND); // Add the offset. dataAddress = ((uintptr_t) databaseAddress + totalOffset); if (targetBufferSizeInBytes > dataSizeInBytes) { uintptr_t bufferToCopy; bufferToCopy = ((uintptr_t) targetBuffer + (targetBufferSizeInBytes - dataSizeInBytes)); returnAddress = xme_hal_mem_copy((void*) bufferToCopy, (void*) dataAddress, dataSizeInBytes); XME_CHECK(returnAddress == (void*) bufferToCopy, XME_STATUS_INTERNAL_ERROR); } else { // Do the read operation returnAddress = xme_hal_mem_copy(targetBuffer, (void*) dataAddress, dataSizeInBytes); XME_CHECK(returnAddress == (void*) targetBuffer, XME_STATUS_INTERNAL_ERROR); } // Set the effectively read bytes. *readBytes = dataSizeInBytes; return XME_STATUS_SUCCESS; }
xme_status_t xme_core_dataHandler_databaseTestProbe_writeAttribute ( uint16_t databaseIndex, xme_core_dataManager_dataPacketId_t dataStoreID, uint32_t attributeKey, uint32_t offsetInBytes, const void* const sourceBuffer, size_t sourceBufferSizeInBytes, uint32_t* const writtenBytes ) { uintptr_t attributeAddress; size_t attributeSizeInBytes; xme_core_dataHandler_database_dataStore_t* dataStore; xme_core_dataHandler_database_attribute_t* attribute; uint32_t totalOffset; void* returnAddress; void* databaseAddress; XME_ASSERT(NULL != xme_core_dataHandler_database); // Obtain first the data packet and then the attribute. XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE); XME_CHECK(XME_STATUS_SUCCESS == getAttribute(dataStore, attributeKey, &attribute), XME_STATUS_INVALID_PARAMETER); XME_CHECK(databaseIndex <= dataStore->memoryRegion->numOfCopies, XME_STATUS_INVALID_CONFIGURATION); if (offsetInBytes >= attribute->attributeValueSize) { // We can not write outside the limit of the data packet. An error is returned. *writtenBytes = 0U; return XME_STATUS_INVALID_PARAMETER; } // Calculate the total offset to add. totalOffset = attribute->attributeOffset + offsetInBytes; // Add queue write position. if (dataStore->queueSize > 1) { totalOffset += (dataStore->dataStoreSize * dataStore->currentCBWritePosition); } // Get the number of bytes to use in the write operation. attributeSizeInBytes = getBytesToCopy(attribute->attributeValueSize, sourceBufferSizeInBytes, offsetInBytes); XME_CHECK(XME_CORE_DATAHANDLER_DATABASE_INDEX_DEFAULT != databaseIndex, XME_STATUS_INVALID_PARAMETER); // Get database address. databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, databaseIndex - 1U); // Check that the data address and size contains correct values. XME_CHECK(0U != databaseAddress, XME_STATUS_NOT_FOUND); // Add the offset. attributeAddress = ((uintptr_t) databaseAddress + totalOffset); // Do the copy operation returnAddress = xme_hal_mem_copy((void*) attributeAddress, sourceBuffer, attributeSizeInBytes); XME_CHECK(returnAddress == (void*) attributeAddress, XME_STATUS_INTERNAL_ERROR); // Set the effectively written bytes. *writtenBytes = attributeSizeInBytes; // Check that the target buffer is not null-valued. XME_CHECK(NULL != sourceBuffer, XME_STATUS_INVALID_CONFIGURATION); // Set attribute availability to true. XME_CHECK(XME_STATUS_SUCCESS == setAttributeAvailability(attribute, true), XME_STATUS_INVALID_CONFIGURATION); if (XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW == databaseIndex) { // Add the manipulation. uint32_t* value = (uint32_t*) sourceBuffer; xme_status_t status = addManipulation(dataStoreID, attributeAddress, *value); XME_CHECK(XME_STATUS_SUCCESS == status, XME_STATUS_INVALID_CONFIGURATION); // Activate the shadow database. dataStore->activeDatabaseIndex = XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW; } return XME_STATUS_SUCCESS; }
xme_status_t configuratorExtension_adv_publisherHighQuality_manifest_createComponentTypeManifest ( xme_core_componentManifest_t* componentManifest ) { XME_CHECK ( NULL != componentManifest, XME_STATUS_INVALID_PARAMETER ); (void)xme_hal_mem_set(componentManifest, 0U, sizeof(xme_core_componentManifest_t)); componentManifest->componentType = (xme_core_componentType_t)4100; componentManifest->componentWrapperInit = configuratorExtension_adv_publisherHighQuality_publisherHighQualityComponentWrapper_init; componentManifest->componentWrapperReceivePort = configuratorExtension_adv_publisherHighQuality_publisherHighQualityComponentWrapper_receivePort; componentManifest->componentWrapperFini = configuratorExtension_adv_publisherHighQuality_publisherHighQualityComponentWrapper_fini; componentManifest->componentInit = (xme_core_componentManifest_componentInit_t)configuratorExtension_adv_publisherHighQuality_publisherHighQualityComponent_init; (void)xme_hal_safeString_strncpy(componentManifest->name, "publisherHighQuality", sizeof(componentManifest->name)); componentManifest->configStructSize = sizeof(configuratorExtension_adv_publisherHighQuality_publisherHighQualityComponent_config_t); { uint32_t functionArrayLength = sizeof(componentManifest->functionManifests) / sizeof(componentManifest->functionManifests[0]); // Function 'send' { if (0U >= functionArrayLength) // Check generated by tool (which does not know about the array size) { if (0U == functionArrayLength) // Only trigger warning once { XME_LOG ( XME_LOG_WARNING, "%s:%d Component type 'publisherHighQuality' defines more functions (%d) than can be stored in the manifest data structure (%d).\n", __FILE__, __LINE__, 1, functionArrayLength ); } } else { xme_core_functionManifest_t* functionManifest; functionManifest = &componentManifest->functionManifests[0]; functionManifest->functionId = (xme_core_component_functionId_t)1; functionManifest->wcet = xme_hal_time_timeIntervalFromMilliseconds(10ull); functionManifest->alphaCurve.alphaCurve = 0; functionManifest->completion = true; functionManifest->requiredPortIndicesLength = 1; functionManifest->requiredPortIndices[0] = (configuratorExtension_adv_publisherHighQuality_publisherHighQualityComponentWrapper_internalPortId_t)CONFIGURATOREXTENSION_ADV_PUBLISHERHIGHQUALITY_PUBLISHERHIGHQUALITYCOMPONENTWRAPPER_PORT_OUT; functionManifest->optionalPortIndicesLength = 0; functionManifest->functionInit = (xme_core_exec_initCallback_t)configuratorExtension_adv_publisherHighQuality_sendFunction_init; functionManifest->functionFini = (xme_core_exec_finiCallback_t)configuratorExtension_adv_publisherHighQuality_sendFunction_fini; functionManifest->functionWrapperExecute = configuratorExtension_adv_publisherHighQuality_sendFunctionWrapper_execute; } } } { uint32_t portArrayLength; portArrayLength = sizeof(componentManifest->portManifests) / sizeof(componentManifest->portManifests[0]); // Publication 'out' { if (0 >= portArrayLength) // Check generated by tool (which does not know about the array size) { if (0 == portArrayLength) // Only trigger warning once { XME_LOG ( XME_LOG_WARNING, "%s:%d Component type 'publisherHighQuality' defines more ports (%d) than can be stored in the manifest data structure (%d).\n", __FILE__, __LINE__, 1, portArrayLength ); } } else { xme_core_componentPortManifest_t* portManifest; xme_status_t status; portManifest = &componentManifest->portManifests[0]; portManifest->portType = XME_CORE_COMPONENT_PORTTYPE_DCC_PUBLICATION; portManifest->topic = CONFIGURATOREXTENSION_TOPIC_DATA; portManifest->lowerConnectionBound = XME_CORE_COMPONENT_CONNECTIONBOUND_INVALID; portManifest->upperConnectionBound = XME_CORE_COMPONENT_CONNECTIONBOUND_INVALID; portManifest->queueSize = 1; portManifest->persistent = false; portManifest->attrSet = xme_core_directory_attribute_createAttributeSet(); // Add attribute definition: quality = 42 { uint32_t value = 42; status = xme_core_directory_attribute_addPredefinedAttributeDefinition ( portManifest->attrSet, (xme_core_attribute_key_t)CONFIGURATOREXTENSION_ATTRIBUTE_QUALITY, &value, 1U, sizeof(value), XME_CORE_DIRECTORY_ATTRIBUTE_DATATYPE_UNSIGNED, false ); XME_CHECK(XME_STATUS_SUCCESS == status, XME_STATUS_INTERNAL_ERROR); } } } } return XME_STATUS_SUCCESS; }