diff --git a/CMakeLists.txt b/CMakeLists.txt index e59dcd36..24ec09f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,30 +1,32 @@ +###################################################################### +# +# CMAKE build recipe for CFE Platform Support Package (PSP) +# +###################################################################### + project(CFEPSP C) if (NOT CFE_SYSTEM_PSPNAME) message(FATAL_ERROR "CFE_SYSTEM_PSPNAME is not defined - do not know which to build") endif() +set(CFE_PSP_TARGETNAME "${CFE_SYSTEM_PSPNAME}") add_definitions(-D_CFE_PSP_) -include_directories(fsw/shared) - -# Build the PSP implementation which lies in a system-specific subdirectory -include_directories(fsw/shared) -include_directories(fsw/${CFE_SYSTEM_PSPNAME}/inc) -add_subdirectory(fsw/${CFE_SYSTEM_PSPNAME} ${CFE_SYSTEM_PSPNAME}) - -# Build the "common" parts as a library -add_library(psp-${CFE_SYSTEM_PSPNAME} STATIC - fsw/shared/cfe_psp_configdata.c - fsw/shared/cfe_psp_eeprom.c - fsw/shared/cfe_psp_exceptionstorage.c - fsw/shared/cfe_psp_memrange.c - fsw/shared/cfe_psp_memutils.c - fsw/shared/cfe_psp_module.c - fsw/shared/cfe_psp_port.c - fsw/shared/cfe_psp_ram.c - $) +# The PSP is currently built in two parts, consisting of a fully platform-specific +# module combined with a shared component which is built for multiple targets. +# The "shared" component is compiled using headers from the platform-specific module +# so it is still ultimately a platform-specific binary, and it all gets wrapped into +# a single PSP static library target. +include_directories(fsw/shared/inc) +add_subdirectory(fsw/${CFE_PSP_TARGETNAME} ${CFE_PSP_TARGETNAME}-impl) +add_subdirectory(fsw/shared ${CFE_PSP_TARGETNAME}-shared) +add_library(psp-${CFE_PSP_TARGETNAME} STATIC + $ + $ +) + if (ENABLE_UNIT_TESTS) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/fsw/ut-stubs) endif (ENABLE_UNIT_TESTS) diff --git a/fsw/mcp750-vxworks/CMakeLists.txt b/fsw/mcp750-vxworks/CMakeLists.txt index 91bf5d78..e57cdb0e 100644 --- a/fsw/mcp750-vxworks/CMakeLists.txt +++ b/fsw/mcp750-vxworks/CMakeLists.txt @@ -1,6 +1,16 @@ +###################################################################### +# +# CMAKE build recipe for mcp750-vxworks PSP component +# +###################################################################### + +# This contains the fully platform-specific code to +# run CFE on this target. + +include_directories(inc) # Build the mcp750-vxworks implementation as a library -add_library(psp-${CFE_SYSTEM_PSPNAME}-impl OBJECT +add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT src/cfe_psp_exception.c src/cfe_psp_memory.c src/cfe_psp_memtab.c diff --git a/fsw/mcp750-vxworks/src/cfe_psp_exception.c b/fsw/mcp750-vxworks/src/cfe_psp_exception.c index 7fbee892..aaf94800 100644 --- a/fsw/mcp750-vxworks/src/cfe_psp_exception.c +++ b/fsw/mcp750-vxworks/src/cfe_psp_exception.c @@ -54,7 +54,8 @@ #include "cfe_psp.h" #include "cfe_psp_config.h" -#include "cfe_psp_exceptionstorage.h" +#include "cfe_psp_exceptionstorage_types.h" +#include "cfe_psp_exceptionstorage_api.h" #include "cfe_psp_memory.h" #include @@ -88,7 +89,7 @@ void CFE_PSP_ExceptionHook ( TASK_ID task_id, int vector, void* vpEsf ); void CFE_PSP_AttachExceptions(void) { excHookAdd( CFE_PSP_ExceptionHook ); - OS_printf("CFE_PSP: Attached cFE Exception Handler. Context Size = %u bytes.\n",sizeof(CFE_PSP_Exception_ContextDataEntry_t)); + OS_printf("CFE_PSP: Attached cFE Exception Handler. Context Size = %lu bytes.\n",(unsigned long)sizeof(CFE_PSP_Exception_ContextDataEntry_t)); CFE_PSP_Exception_Reset(); } diff --git a/fsw/mcp750-vxworks/src/cfe_psp_start.c b/fsw/mcp750-vxworks/src/cfe_psp_start.c index 720c46c7..e1f337b3 100644 --- a/fsw/mcp750-vxworks/src/cfe_psp_start.c +++ b/fsw/mcp750-vxworks/src/cfe_psp_start.c @@ -111,6 +111,13 @@ void OS_Application_Startup(void) /* note: use printf here, as OS_printf may not work */ printf("CFE_PSP: OS_API_Init() failure\n"); CFE_PSP_Panic(Status); + + /* + * normally CFE_PSP_Panic() does not return, except + * during unit testing. This return avoids executing + * the rest of this function in that case. + */ + return; } /* diff --git a/fsw/mcp750-vxworks/src/cfe_psp_watchdog.c b/fsw/mcp750-vxworks/src/cfe_psp_watchdog.c index fabd576c..5081bea3 100644 --- a/fsw/mcp750-vxworks/src/cfe_psp_watchdog.c +++ b/fsw/mcp750-vxworks/src/cfe_psp_watchdog.c @@ -66,8 +66,6 @@ #include "cfe_psp.h" #include "cfe_psp_config.h" -IMPORT void sysPciRead32 (UINT32, UINT32 *); - /* ** Global data */ diff --git a/fsw/pc-linux/CMakeLists.txt b/fsw/pc-linux/CMakeLists.txt index bb10d4f0..c89361a7 100644 --- a/fsw/pc-linux/CMakeLists.txt +++ b/fsw/pc-linux/CMakeLists.txt @@ -1,6 +1,16 @@ +###################################################################### +# +# CMAKE build recipe for pc-linux PSP component +# +###################################################################### + +# This contains the fully platform-specific code to +# run CFE on this target. + +include_directories(inc) # Build the pc-linux implementation as a library -add_library(psp-${CFE_SYSTEM_PSPNAME}-impl OBJECT +add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT src/cfe_psp_exception.c src/cfe_psp_memory.c src/cfe_psp_memtab.c diff --git a/fsw/pc-linux/src/cfe_psp_exception.c b/fsw/pc-linux/src/cfe_psp_exception.c index bf16fb5e..fc57b0c9 100644 --- a/fsw/pc-linux/src/cfe_psp_exception.c +++ b/fsw/pc-linux/src/cfe_psp_exception.c @@ -46,7 +46,8 @@ S #include "osapi.h" #include "cfe_psp.h" #include "cfe_psp_config.h" -#include "cfe_psp_exceptionstorage.h" +#include "cfe_psp_exceptionstorage_types.h" +#include "cfe_psp_exceptionstorage_api.h" #include #include diff --git a/fsw/pc-rtems/CMakeLists.txt b/fsw/pc-rtems/CMakeLists.txt index 5abbc21a..1014f67b 100644 --- a/fsw/pc-rtems/CMakeLists.txt +++ b/fsw/pc-rtems/CMakeLists.txt @@ -1,6 +1,16 @@ +###################################################################### +# +# CMAKE build recipe for pc-rtems PSP component +# +###################################################################### + +# This contains the fully platform-specific code to +# run CFE on this target. + +include_directories(inc) # Build the pc-rtems implementation as a library -add_library(psp-${CFE_SYSTEM_PSPNAME}-impl OBJECT +add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT src/cfe_psp_exception.c src/cfe_psp_memory.c src/cfe_psp_memtab.c diff --git a/fsw/pc-rtems/src/cfe_psp_exception.c b/fsw/pc-rtems/src/cfe_psp_exception.c index 0178555f..04f58fc1 100644 --- a/fsw/pc-rtems/src/cfe_psp_exception.c +++ b/fsw/pc-rtems/src/cfe_psp_exception.c @@ -47,7 +47,8 @@ #include "cfe_psp.h" #include "cfe_psp_config.h" #include "cfe_psp_memory.h" -#include "cfe_psp_exceptionstorage.h" +#include "cfe_psp_exceptionstorage_types.h" +#include "cfe_psp_exceptionstorage_api.h" /* ** diff --git a/fsw/shared/CMakeLists.txt b/fsw/shared/CMakeLists.txt new file mode 100644 index 00000000..08b28bcc --- /dev/null +++ b/fsw/shared/CMakeLists.txt @@ -0,0 +1,26 @@ +###################################################################### +# +# CMAKE build recipe for shared PSP component +# +###################################################################### + +# This contains supplemental code to support running CFE +# on a variety of targets. +# +# Note this shared PSP code is currently built against headers provided by the +# target implementation. This makes it implementation-specific even though +# the same source code is used with multiple targets. +include_directories("${CFEPSP_SOURCE_DIR}/fsw/${CFE_PSP_TARGETNAME}/inc") +include_directories(inc) + +# Build the shared implementation as a library +add_library(psp-${CFE_PSP_TARGETNAME}-shared OBJECT + src/cfe_psp_configdata.c + src/cfe_psp_eeprom.c + src/cfe_psp_exceptionstorage.c + src/cfe_psp_memrange.c + src/cfe_psp_memutils.c + src/cfe_psp_module.c + src/cfe_psp_port.c + src/cfe_psp_ram.c +) diff --git a/fsw/shared/cfe_psp_exceptionstorage.h b/fsw/shared/inc/cfe_psp_exceptionstorage_api.h similarity index 67% rename from fsw/shared/cfe_psp_exceptionstorage.h rename to fsw/shared/inc/cfe_psp_exceptionstorage_api.h index 4b837fb7..45bf5137 100644 --- a/fsw/shared/cfe_psp_exceptionstorage.h +++ b/fsw/shared/inc/cfe_psp_exceptionstorage_api.h @@ -19,40 +19,21 @@ */ /** - * \file cfe_psp_exceptionstorage.h + * \file cfe_psp_exceptionstorage_api.h * * Provides a generic storage buffer ring for exceptions */ -#ifndef CFE_PSP_EXCEPTIONSTORAGE_H_ -#define CFE_PSP_EXCEPTIONSTORAGE_H_ +#ifndef CFE_PSP_EXCEPTIONSTORAGE_API_H_ +#define CFE_PSP_EXCEPTIONSTORAGE_API_H_ #include -#include /* - * The "MetaData" stores ephemeral exception information - * which only has meaning within the currently-running process. - * - * This data is important for diagnosing the exception, but it - * is NOT saved to any persistent log because it will not be - * relevant once the process ends. + * Abstract types for exception storage. + * These are made concrete depending on PSP-specific config information. */ -typedef struct -{ - uint32 context_id; /**< a unique ID assigned to this exception entry */ - uint32 context_size; /**< actual size of the "context_info" data */ - CFE_PSP_Exception_SysTaskId_t sys_task_id; /**< the BSP-specific task info (not osal abstracted id) */ - CFE_PSP_Exception_ContextDataEntry_t context_info; -} CFE_PSP_Exception_LogData_t; - - -typedef struct -{ - volatile uint32 NumWritten; - volatile uint32 NumRead; - CFE_PSP_Exception_LogData_t Entries[CFE_PSP_MAX_EXCEPTION_ENTRIES]; -} CFE_PSP_ExceptionStorage_t; +struct CFE_PSP_Exception_LogData; @@ -60,6 +41,18 @@ typedef struct * Functions implemented in shared layer, invoked by impl layer. * ------------------------------------------------------------- */ +/** + * \brief Get the next buffer for exception buffer corresponding to sequence + * + * This function obtains a storage buffer corresponding to the given sequence number. + * The pointer to storage memory is directly returned. It is not cleared or modified, + * and no checks are performed to determine if the sequence number is valid. + * + * \param seq Sequence number + * \returns pointer to buffer. + */ +extern struct CFE_PSP_Exception_LogData* CFE_PSP_Exception_GetBuffer(uint32 seq); + /** * \brief Get the next buffer for exception context storage * @@ -69,7 +62,7 @@ typedef struct * * \returns pointer to buffer, or NULL if storage is full. */ -extern CFE_PSP_Exception_LogData_t* CFE_PSP_Exception_GetNextContextBuffer(void); +extern struct CFE_PSP_Exception_LogData* CFE_PSP_Exception_GetNextContextBuffer(void); /** * \brief Finish storage of exception data @@ -102,6 +95,6 @@ extern void CFE_PSP_Exception_Reset(void); * * \returns CFE_PSP_SUCCESS on success */ -extern int32 CFE_PSP_ExceptionGetSummary_Impl(const CFE_PSP_Exception_LogData_t* Buffer, char *ReasonBuf, uint32 ReasonSize); +extern int32 CFE_PSP_ExceptionGetSummary_Impl(const struct CFE_PSP_Exception_LogData* Buffer, char *ReasonBuf, uint32 ReasonSize); -#endif /* CFE_PSP_EXCEPTIONSTORAGE_H_ */ +#endif /* CFE_PSP_EXCEPTIONSTORAGE_API_H_ */ diff --git a/fsw/shared/inc/cfe_psp_exceptionstorage_types.h b/fsw/shared/inc/cfe_psp_exceptionstorage_types.h new file mode 100644 index 00000000..dad4c788 --- /dev/null +++ b/fsw/shared/inc/cfe_psp_exceptionstorage_types.h @@ -0,0 +1,61 @@ +/* +** 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. +*/ + +/** + * \file cfe_psp_exceptionstorage_types.h + * + * Provides a generic storage buffer ring for exceptions + */ + +#ifndef CFE_PSP_EXCEPTIONSTORAGE_TYPES_H_ +#define CFE_PSP_EXCEPTIONSTORAGE_TYPES_H_ + +#include +#include + +/* + * The "MetaData" stores ephemeral exception information + * which only has meaning within the currently-running process. + * + * This data is important for diagnosing the exception, but it + * is NOT saved to any persistent log because it will not be + * relevant once the process ends. + */ +struct CFE_PSP_Exception_LogData +{ + uint32 context_id; /**< a unique ID assigned to this exception entry */ + uint32 context_size; /**< actual size of the "context_info" data */ + CFE_PSP_Exception_SysTaskId_t sys_task_id; /**< the BSP-specific task info (not osal abstracted id) */ + CFE_PSP_Exception_ContextDataEntry_t context_info; +}; + + +struct CFE_PSP_ExceptionStorage +{ + volatile uint32 NumWritten; + volatile uint32 NumRead; + struct CFE_PSP_Exception_LogData Entries[CFE_PSP_MAX_EXCEPTION_ENTRIES]; +}; + +typedef struct CFE_PSP_Exception_LogData CFE_PSP_Exception_LogData_t; +typedef struct CFE_PSP_ExceptionStorage CFE_PSP_ExceptionStorage_t; + + +#endif /* CFE_PSP_EXCEPTIONSTORAGE_TYPES_H_ */ diff --git a/fsw/shared/cfe_psp_memory.h b/fsw/shared/inc/cfe_psp_memory.h similarity index 98% rename from fsw/shared/cfe_psp_memory.h rename to fsw/shared/inc/cfe_psp_memory.h index 2a0ae905..6c42eb35 100644 --- a/fsw/shared/cfe_psp_memory.h +++ b/fsw/shared/inc/cfe_psp_memory.h @@ -40,7 +40,7 @@ #include "common_types.h" #include "cfe_psp_config.h" -#include "cfe_psp_exceptionstorage.h" +#include "cfe_psp_exceptionstorage_types.h" typedef struct { diff --git a/fsw/shared/cfe_psp_module.h b/fsw/shared/inc/cfe_psp_module.h similarity index 100% rename from fsw/shared/cfe_psp_module.h rename to fsw/shared/inc/cfe_psp_module.h diff --git a/fsw/shared/cfe_psp_configdata.c b/fsw/shared/src/cfe_psp_configdata.c similarity index 100% rename from fsw/shared/cfe_psp_configdata.c rename to fsw/shared/src/cfe_psp_configdata.c diff --git a/fsw/shared/cfe_psp_eeprom.c b/fsw/shared/src/cfe_psp_eeprom.c similarity index 100% rename from fsw/shared/cfe_psp_eeprom.c rename to fsw/shared/src/cfe_psp_eeprom.c diff --git a/fsw/shared/cfe_psp_exceptionstorage.c b/fsw/shared/src/cfe_psp_exceptionstorage.c similarity index 99% rename from fsw/shared/cfe_psp_exceptionstorage.c rename to fsw/shared/src/cfe_psp_exceptionstorage.c index a3843b57..749de91e 100644 --- a/fsw/shared/cfe_psp_exceptionstorage.c +++ b/fsw/shared/src/cfe_psp_exceptionstorage.c @@ -47,7 +47,8 @@ #include "cfe_psp.h" #include "cfe_psp_config.h" -#include "cfe_psp_exceptionstorage.h" +#include "cfe_psp_exceptionstorage_types.h" +#include "cfe_psp_exceptionstorage_api.h" #include "cfe_psp_memory.h" #include diff --git a/fsw/shared/cfe_psp_memrange.c b/fsw/shared/src/cfe_psp_memrange.c similarity index 100% rename from fsw/shared/cfe_psp_memrange.c rename to fsw/shared/src/cfe_psp_memrange.c diff --git a/fsw/shared/cfe_psp_memutils.c b/fsw/shared/src/cfe_psp_memutils.c similarity index 100% rename from fsw/shared/cfe_psp_memutils.c rename to fsw/shared/src/cfe_psp_memutils.c diff --git a/fsw/shared/cfe_psp_module.c b/fsw/shared/src/cfe_psp_module.c similarity index 100% rename from fsw/shared/cfe_psp_module.c rename to fsw/shared/src/cfe_psp_module.c diff --git a/fsw/shared/cfe_psp_port.c b/fsw/shared/src/cfe_psp_port.c similarity index 100% rename from fsw/shared/cfe_psp_port.c rename to fsw/shared/src/cfe_psp_port.c diff --git a/fsw/shared/cfe_psp_ram.c b/fsw/shared/src/cfe_psp_ram.c similarity index 100% rename from fsw/shared/cfe_psp_ram.c rename to fsw/shared/src/cfe_psp_ram.c