-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix nasa#928, Added software bus routing module
- Implementation for direct map and unsorted routing table - Includes full coverage tests - Removed msg key and route stack concepts from direct map
- Loading branch information
Showing
8 changed files
with
791 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
################################################################## | ||
# | ||
# cFE software bus routing module CMake build recipe | ||
# | ||
# This CMakeLists.txt adds source files for the | ||
# SBR module included in the cFE distribution. Selected | ||
# files are built into a static library that in turn | ||
# is linked into the final executable. | ||
# | ||
# Note this is different than applications which are dynamically | ||
# linked to support runtime loading. The core applications all | ||
# use static linkage. | ||
# | ||
################################################################## | ||
|
||
if (NOT MISSION_MSGMAP_IMPLEMENTATION) | ||
set(MISSION_MSGMAP_IMPLEMENTATION "DIRECT") | ||
endif (NOT MISSION_MSGMAP_IMPLEMENTATION) | ||
|
||
if (MISSION_MSGMAP_IMPLEMENTATION STREQUAL "DIRECT") | ||
message(STATUS "Using direct map software bus routing implementation") | ||
set(${DEP}_SRC | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_sbr_map_direct.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_sbr_route_unsorted.c) | ||
elseif (MISSION_MSGMAP_IMPLEMENTATION STREQUAL "HASH") | ||
message(STATUS "Using hashed map software bus routing implementation") | ||
set(${DEP}_SRC | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_sbr_map_hash.c | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_sbr_route_unsorted.c) | ||
else() | ||
message(ERROR "Invalid software bush routing implementation selected:" MISSION_MSGMAP_IMPLEMENTATION) | ||
endif() | ||
|
||
# Module library | ||
add_library(${DEP} STATIC ${${DEP}_SRC}) | ||
|
||
# Add private include | ||
target_include_directories(${DEP} PRIVATE private_inc) | ||
|
||
# Add unit test coverage subdirectory | ||
if(ENABLE_UNIT_TESTS) | ||
add_subdirectory(unit-test-coverage) | ||
endif(ENABLE_UNIT_TESTS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
** GSC-18128-1, "Core Flight Executive Version 6.7" | ||
** | ||
** Copyright (c) 2006-2019 United States Government as represented by | ||
** the Administrator of the National Aeronautics and Space Administration. | ||
** All Rights Reserved. | ||
** | ||
** Licensed under the Apache License, Version 2.0 (the "License"); | ||
** you may not use this file except in compliance with the License. | ||
** You may obtain a copy of the License at | ||
** | ||
** http://www.apache.org/licenses/LICENSE-2.0 | ||
** | ||
** Unless required by applicable law or agreed to in writing, software | ||
** distributed under the License is distributed on an "AS IS" BASIS, | ||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
** See the License for the specific language governing permissions and | ||
** limitations under the License. | ||
*/ | ||
|
||
/****************************************************************************** | ||
* Prototypes for private functions and type definitions for SB | ||
* routing internal use. | ||
*****************************************************************************/ | ||
|
||
#ifndef CFE_SBR_PRIV_H_ | ||
#define CFE_SBR_PRIV_H_ | ||
|
||
/* | ||
* Includes | ||
*/ | ||
#include "private/cfe_sbr.h" | ||
|
||
/* | ||
* Macro Definitions | ||
*/ | ||
|
||
/** \brief Invalid route id */ | ||
#define CFE_SBR_INVALID_ROUTE_ID ((CFE_SBR_RouteId_t) {.RouteId = 0}) | ||
|
||
/****************************************************************************** | ||
* Function prototypes | ||
*/ | ||
|
||
/** | ||
* \brief Routing map initialization | ||
*/ | ||
void CFE_SBR_Init_Map(void); | ||
|
||
/** | ||
* \brief Associates the given route ID with the given message ID | ||
* | ||
* Used for implementations that use a mapping table (typically hash or direct) | ||
* and need this information to later get the route id from the message id. | ||
* | ||
* \note Typically not needed for a search implementation. Assumes | ||
* message ID is valid | ||
* | ||
* \param[in] MsgId Message id to associate with route id | ||
* \param[in] RouteId Route id to associate with message id | ||
* | ||
* \returns Number of collisions | ||
*/ | ||
uint32 CFE_SBR_SetRouteId(CFE_SB_MsgId_t MsgId, CFE_SBR_RouteId_t RouteId); | ||
|
||
#endif /* CFE_SBR_PRIV_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
** GSC-18128-1, "Core Flight Executive Version 6.7" | ||
** | ||
** Copyright (c) 2006-2019 United States Government as represented by | ||
** the Administrator of the National Aeronautics and Space Administration. | ||
** All Rights Reserved. | ||
** | ||
** Licensed under the Apache License, Version 2.0 (the "License"); | ||
** you may not use this file except in compliance with the License. | ||
** You may obtain a copy of the License at | ||
** | ||
** http://www.apache.org/licenses/LICENSE-2.0 | ||
** | ||
** Unless required by applicable law or agreed to in writing, software | ||
** distributed under the License is distributed on an "AS IS" BASIS, | ||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
** See the License for the specific language governing permissions and | ||
** limitations under the License. | ||
*/ | ||
|
||
/****************************************************************************** | ||
* Direct routing map implementation | ||
* | ||
* Notes: | ||
* These functions manipulate/access global variables and need | ||
* to be protected by the SB Shared data lock. | ||
* | ||
*/ | ||
|
||
/* | ||
* Include Files | ||
*/ | ||
|
||
#include "common_types.h" | ||
#include "private/cfe_sbr.h" | ||
#include "cfe_sbr_priv.h" | ||
#include <string.h> | ||
|
||
/* | ||
* Macro Definitions | ||
*/ | ||
|
||
/** | ||
* \brief Message map size | ||
* | ||
* For direct mapping, map size is maximum valid MsgId value + 1 (since MsgId 0 is valid) | ||
*/ | ||
#define CFE_SBR_MSG_MAP_SIZE (CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1) | ||
|
||
/****************************************************************************** | ||
* Shared data | ||
*/ | ||
|
||
/** \brief Message map shared data */ | ||
CFE_SBR_RouteId_t CFE_SBR_MSGMAP[CFE_SBR_MSG_MAP_SIZE]; | ||
|
||
/****************************************************************************** | ||
* Interface function - see header for description | ||
*/ | ||
void CFE_SBR_Init_Map(void) | ||
{ | ||
/* Clear the shared data */ | ||
memset(&CFE_SBR_MSGMAP, 0, sizeof(CFE_SBR_MSGMAP)); | ||
} | ||
|
||
/****************************************************************************** | ||
* Interface function - see header for description | ||
*/ | ||
uint32 CFE_SBR_SetRouteId(CFE_SB_MsgId_t MsgId, CFE_SBR_RouteId_t RouteId) | ||
{ | ||
if (CFE_SB_IsValidMsgId(MsgId)) | ||
{ | ||
CFE_SBR_MSGMAP[CFE_SB_MsgIdToValue(MsgId)] = RouteId; | ||
} | ||
|
||
/* Direct lookup never collides, always return 0 */ | ||
return 0; | ||
} | ||
|
||
/****************************************************************************** | ||
* Interface function - see API for description | ||
*/ | ||
CFE_SBR_RouteId_t CFE_SBR_GetRouteId(CFE_SB_MsgId_t MsgId) | ||
{ | ||
CFE_SBR_RouteId_t routeid = CFE_SBR_INVALID_ROUTE_ID; | ||
|
||
if (CFE_SB_IsValidMsgId(MsgId)) | ||
{ | ||
routeid = CFE_SBR_MSGMAP[CFE_SB_MsgIdToValue(MsgId)]; | ||
} | ||
|
||
return routeid; | ||
} |
Oops, something went wrong.