Skip to content

Commit

Permalink
Merge pull request #172 from jphickey/fix-169-psp-target-reconfig
Browse files Browse the repository at this point in the history
Fix #169, make separate targets for PSP
  • Loading branch information
astrogeco authored Jul 1, 2020
2 parents 3408250 + e5f4bbc commit a21a1d8
Show file tree
Hide file tree
Showing 22 changed files with 178 additions and 57 deletions.
38 changes: 20 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<TARGET_OBJECTS:psp-${CFE_SYSTEM_PSPNAME}-impl>)
# 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
$<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME}-shared>
$<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME}-impl>
)

if (ENABLE_UNIT_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/fsw/ut-stubs)
endif (ENABLE_UNIT_TESTS)
Expand Down
12 changes: 11 additions & 1 deletion fsw/mcp750-vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions fsw/mcp750-vxworks/src/cfe_psp_exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <target_config.h>
Expand Down Expand Up @@ -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();
}

Expand Down
7 changes: 7 additions & 0 deletions fsw/mcp750-vxworks/src/cfe_psp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down
2 changes: 0 additions & 2 deletions fsw/mcp750-vxworks/src/cfe_psp_watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
#include "cfe_psp.h"
#include "cfe_psp_config.h"

IMPORT void sysPciRead32 (UINT32, UINT32 *);

/*
** Global data
*/
Expand Down
12 changes: 11 additions & 1 deletion fsw/pc-linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion fsw/pc-linux/src/cfe_psp_exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <execinfo.h>
#include <signal.h>
Expand Down
12 changes: 11 additions & 1 deletion fsw/pc-rtems/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion fsw/pc-rtems/src/cfe_psp_exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

/*
**
Expand Down
26 changes: 26 additions & 0 deletions fsw/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,40 @@
*/

/**
* \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 <cfe_psp.h>
#include <cfe_psp_config.h>

/*
* 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;



/* -------------------------------------------------------------
* 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
*
Expand All @@ -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
Expand Down Expand Up @@ -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_ */
61 changes: 61 additions & 0 deletions fsw/shared/inc/cfe_psp_exceptionstorage_types.h
Original file line number Diff line number Diff line change
@@ -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 <cfe_psp.h>
#include <cfe_psp_config.h>

/*
* 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_ */
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <target_config.h>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a21a1d8

Please sign in to comment.