diff --git a/fsw/5020-vxworks7/CMakeLists.txt b/fsw/5020-vxworks7/CMakeLists.txt new file mode 100644 index 00000000..2f48430a --- /dev/null +++ b/fsw/5020-vxworks7/CMakeLists.txt @@ -0,0 +1,13 @@ + +include_directories(inc) + +# Build the sp0-vxworks implementation as a library +add_library(psp-${CFE_SYSTEM_PSPNAME}-impl OBJECT + src/cfe_psp_exception.c + src/cfe_psp_memory.c + src/cfe_psp_memtab.c + src/cfe_psp_start.c + src/cfe_psp_support.c + src/cfe_psp_timer.c + src/cfe_psp_watchdog.c) + diff --git a/fsw/5020-vxworks7/inc/cfe_psp_config.h b/fsw/5020-vxworks7/inc/cfe_psp_config.h new file mode 100644 index 00000000..4418884f --- /dev/null +++ b/fsw/5020-vxworks7/inc/cfe_psp_config.h @@ -0,0 +1,108 @@ +/* +** cfe_psp_config.h +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +*/ + +#ifndef _cfe_psp_config_ +#define _cfe_psp_config_ + +#include "common_types.h" + +#include +#include +#include +#include +#include "speLib.h" +#include "excLib.h" +#include "taskLib.h" +#include "arch/ppc/esfPpc.h" +#include "fppLib.h" + +/* +** This define sets the number of memory ranges that are defined in the memory range defintion +** table. +*/ +#define CFE_PSP_MEM_TABLE_SIZE 10 + +/** + * This define sets the maximum number of exceptions + * that can be stored. + * + * It must always be a power of two. + */ +#define CFE_PSP_MAX_EXCEPTION_ENTRIES 4 + +/* +** Typedef for the layout of the vxWorks boot record structure +** +** This is statically placed at the beginning of system memory (sysMemTop) +** which should be reserved in the kernel. +*/ +typedef struct +{ + uint32 bsp_reset_type; + uint32 spare1; + uint32 spare2; + uint32 spare3; + +} CFE_PSP_ReservedMemoryBootRecord_t; + + +/** + * \brief The data type used by the underlying OS to represent a thread ID. + */ +typedef TASK_ID CFE_PSP_Exception_SysTaskId_t; + +/* +** Global variables +*/ +typedef struct +{ + UINT32 timebase_upper; /* Upper 32 bits of timebase as sampled by hook */ + UINT32 timebase_lower; /* Lower 32 bits of timebase as sampled by hook */ + int vector; /* vector number */ + ESFPPC esf; /* Exception stack frame */ + FP_CONTEXT fp; /* floating point registers */ + +} CFE_PSP_Exception_ContextDataEntry_t; + +/* +** Watchdog minimum and maximum values ( in milliseconds ) +*/ +#define CFE_PSP_WATCHDOG_MIN (0) +#define CFE_PSP_WATCHDOG_MAX (0xFFFFFFFF) + +/* +** Number of EEPROM banks on this platform +*/ +#define CFE_PSP_NUM_EEPROM_BANKS 1 + +/* + * The alignment to use for each reserved memory block. + * + * This is a mask to be applied to each block base address + * + * Chosen as the cache line size of the SP0 processor (32 bytes) + * such that the blocks will be cached more efficiently. + */ +#define CFE_PSP_MEMALIGN_MASK ((cpuaddr)0x1F) + +/* The task and task priority for existing VxWorks task. + */ +typedef struct +{ + const char * VxWorksTaskName; + int32 VxWorksTaskPriority; +} CFE_PSP_OS_Task_and_priority_t; + + +#endif /* _cfe_psp_config_ */ + + diff --git a/fsw/5020-vxworks7/inc/psp_version.h b/fsw/5020-vxworks7/inc/psp_version.h new file mode 100644 index 00000000..6414f5fe --- /dev/null +++ b/fsw/5020-vxworks7/inc/psp_version.h @@ -0,0 +1,33 @@ +/* +** $Id: psp_version.h 1.1.1.1 2009/08/10 17:11:07BST bmedina Exp $ +** +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** +** +** Purpose: +** Provide version identifiers for the cFE Platform Support Packages (PSP). +** +*/ + +#ifndef _psp_version_ +#define _psp_version_ + +#define CFE_PSP_IMPL_MAJOR_VERSION 0 +#define CFE_PSP_IMPL_MINOR_VERSION 1 +#define CFE_PSP_IMPL_REVISION 0 +#define CFE_PSP_IMPL_MISSION_REV 0 + +#define CFE_PSP_IMPL_VERSION "5020 testing" + +/* +** Macro Definitions +*/ +#endif /* _psp_version_ */ + diff --git a/fsw/5020-vxworks7/make/build_options.cmake b/fsw/5020-vxworks7/make/build_options.cmake new file mode 100644 index 00000000..2a2142fe --- /dev/null +++ b/fsw/5020-vxworks7/make/build_options.cmake @@ -0,0 +1,25 @@ +# This indicates where to install target binaries created during the build +set(INSTALL_SUBDIR "cf") + +message(STATUS "WIND_BASE IS $ENV{WIND_BASE}") + +## +## Target Defines for the OS, Hardware Arch, etc.. +## +#add_definitions("-DVOLTAB_PATH=\"/ram0/cf\"") +#add_definitions("-D_VXWORKS_OS_ -D_HAVE_STDINT_ -D_PPC_ -D__PPC__ -D_EMBED_ -DTOOL_FAMILY=gnu -DTOOL=e500v2gnu -D_WRS_KERNEL -DCPU=PPC85XX -DCPU_VARIANT=_ppc85xx_e500v2 \"-D_VSB_CONFIG_FILE=<../lib/h/config/vsbConfig.h>\"") + + +## +## Endian Defines +## +add_definitions(-D_EB -DENDIAN=_EB -DSOFTWARE_BIG_BIT_ORDER) + +## +## Compiler Architecture Switches +## +#add_definitions("-mcpu=8548 -te500v2 -mstrict-align -fno-builtin -fvolatile -mhard-float -fno-implicit-fp -mfloat-gprs=double -mspe=yes -mabi=spe -mlongcall") + +#include_directories($ENV{WIND_BASE}/target/h/wrn/coreip) +#include_directories($ENV{WIND_BASE}/target/3rdparty/aitech/sp0) +#include_directories($ENV{WIND_BASE}/target/config/sp0) diff --git a/fsw/5020-vxworks7/make/compiler-opts.mak b/fsw/5020-vxworks7/make/compiler-opts.mak new file mode 100644 index 00000000..94aa1282 --- /dev/null +++ b/fsw/5020-vxworks7/make/compiler-opts.mak @@ -0,0 +1,114 @@ +############################################################################### +## compiler-opts.mak - compiler definitions and options for building the cFE +## +## Target: PPC AiTech SP0 (Freescale 8548, e500 core) COTS board with vxWorks 6.x +############################################################################### + +## +## Warning Level Configuration +## +## WARNINGS =-Wall -ansi -pedantic -Wstrict-prototypes +WARNINGS = -Wall + +## +## A fix for Windows systems on vxWorks 6.4 +## When generating dependancies, the Windows GCC cannot seem to deal +## with the Windows style path separators in the WIND_BASE macro. +## +FIXED_WIND_BASE = $(subst \,/,$(WIND_BASE)) + +## +## vxWorks system includes +## +VXINCDIR = $(FIXED_WIND_BASE)/target/h \ +$(FIXED_WIND_BASE)/target/h/wrn/coreip \ +$(FIXED_WIND_BASE)/target/h/drv \ +$(FIXED_WIND_BASE)/target/src/config \ +$(FIXED_WIND_BASE)/target/src/drv \ +$(FIXED_WIND_BASE)/target/config/comps/src \ +$(FIXED_WIND_BASE)/target/config/comps/src/dosfs2 \ + +SYSINCS = $(VXINCDIR:%=-I%) + +## +## Target Defines for the OS, Hardware Arch, etc.. +## +TARGET_DEFS += -D_VXWORKS_OS_ -D_PPC_ -D__PPC__ $(CFE_SB_NET) -D$(OS) -D_EMBED_ \ + -DTOOL_FAMILY=gnu -DTOOL=e500v2gnu -D_WRS_KERNEL -DCPU=PPC85XX \ + -DCPU_VARIANT=_ppc85xx_e500v2 \ + "-D_VSB_CONFIG_FILE=<../lib/h/config/vsbConfig.h>" + +## +## Endian Defines +## +ENDIAN_DEFS = -D_EB -DENDIAN=_EB -DSOFTWARE_BIG_BIT_ORDER + +## +## Compiler Architecture Switches +## +ARCH_OPTS = -gstatement-frontiers -mcpu=e500mc -D_WRS_HARDWARE_FP -mabi=elfv2 -mcmodel=medium -fstrength-reduce \ + -mtls-size=16 -mhard-float -D__ppc -D__ppc__ -m64 -D__ppc64__ -mstrict-align -std=c11 -D__vxworks \ + -D__VXWORKS__ -D__ELF__ -D_HAVE_TOOL_XTORS -ftls-model=local-exec -fno-zero-initialized-in-bss \ + -fno-builtin -fno-strict-aliasing -D_USE_INIT_ARRAY -Wall -Wconversion -Wno-sign-conversion -MD -MP \ + -mlongcall -DCPU=_VX_PPCE500MC -DTOOL_FAMILY=gnu -DTOOL=gnu -D_WRS_KERNEL -D_WRS_VX_SMP -D_WRS_CONFIG_SMP \ + -D_VSB_CONFIG_FILE="/home/darkwing/work/nasa/582/cfs_5545/workspace/hello2/../vsb_5020/h/config/vsbConfig.h" + +## +## Application specific compiler switches +## +ifeq ($(BUILD_TYPE),CFE_APP) + APP_COPTS = -mlongcall + APP_ASOPTS = +else + APP_COPTS = + APP_ASOPTS = +endif + +## +## Extra Cflags for Assembly listings, etc. +## +LIST_OPTS = -Wa,-a=$*.lis + +## +## gcc options for dependancy generation +## +COPTS_D = $(APP_COPTS) $(ENDIAN_DEFS) $(TARGET_DEFS) $(ARCH_OPTS) $(SYSINCS) $(WARNINGS) + +## +## General gcc options that apply to compiling and dependency generation. +## +COPTS = $(LIST_OPTS) $(COPTS_D) + +## +## Extra defines and switches for assembly code +## +ASOPTS = $(APP_ASOPTS) -P -xassembler-with-cpp + +##--------------------------------------------------------- +## Application file extention type +## This is the defined application extention. +## Known extentions: Mac OS X: .bundle, Linux: .so, +## RTEMS: .s3r, vxWorks: .o etc.. +##--------------------------------------------------------- +APP_EXT = o + +#################################################### +## Host Development System and Toolchain definitions +## +## Host OS utils +## +RM = rm -f +CP = cp + +## +## Compiler tools +## +COMPILER = ccppc +ASSEMBLER = ccppc +LINKER = ldppc +AR = arppc +NM = nmppc +OBJCPY = objcopyppc +TABLE_BIN = elf2cfetbl + + diff --git a/fsw/5020-vxworks7/make/link-rules.mak b/fsw/5020-vxworks7/make/link-rules.mak new file mode 100644 index 00000000..e53b5cf0 --- /dev/null +++ b/fsw/5020-vxworks7/make/link-rules.mak @@ -0,0 +1,37 @@ +############################################################################### +# File: link-rules.mak +# +# Purpose: +# Makefile for linking code and producing the cFE Core executable image. +############################################################################### +## +## Executable target. This is target specific +## +EXE_TARGET=cfe-core.o + +CORE_INSTALL_FILES = $(EXE_TARGET) + + +## +## Linker flags that are needed +## +LDFLAGS = + +## +## Libraries to link in +## +LIBS = + +## +## cFE Core Link Rule +## +$(EXE_TARGET): $(CORE_OBJS) + $(COMPILER) $(DEBUG_FLAGS) -r -nostdlib -o $(EXE_TARGET) $(CORE_OBJS) + +## +## Application Link Rule +## +$(APPTARGET).$(APP_EXT): $(OBJS) + $(LINKER) -r $(OBJS) -o $@ + + diff --git a/fsw/5020-vxworks7/src/cfe_psp_exception.c b/fsw/5020-vxworks7/src/cfe_psp_exception.c new file mode 100644 index 00000000..e8953a8a --- /dev/null +++ b/fsw/5020-vxworks7/src/cfe_psp_exception.c @@ -0,0 +1,278 @@ +/****************************************************************************** +** +** File: cfe_psp_exception.c +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: +** cFE PSP Exception related functions. +** +** In original version of this code, the following loading error was noted: +** +** > ld < cfe-core.o +** Warning: module 0x22e1010 holds reference to undefined symbol fppRestore. +** Warning: module 0x22e1010 holds reference to undefined symbol fppSave. +** +** The following was found in the VxWorks 6.9 architecture supplement, pg 179, +** for PPC85xx: +** +** Do not confuse the hardware floating-point provided by the FPU with that +** provided by the SPE (see 6.3.10 Signal Processing Engine Support, p.190). +** If using the e500v2diab or e500v2gnu toolchains, you must use the speSave() +** speSave() and speRestore() routines to save and restore floating-point +** context. +** +** The e500 core's SPE is a hardware double precision unit capable of both +** scalar and vector(SIMD) computation. +** +******************************************************************************/ + +/* +** Include Files +*/ +#include +#include +#include +#include +#include +#include +#include "excLib.h" +#include "taskLib.h" +#include "speLib.h" +#include "arch/ppc/vxPpcLib.h" +#include "arch/ppc/esfPpc.h" +#include +#include "cfe_psp_exceptionstorage_api.h" + +/* +** cFE includes +*/ +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp.h" +#include "cfe_psp_config.h" +#include "cfe_psp_memory.h" +#include + + +/* +** cFE includes +*/ + +/* +** BSP Specific defines +*/ + +/* +** External Declarations +*/ +STATUS edrErrorPolicyHookRemove(void); + +/* +** Global variables +*/ +#include + +BOOL overRideDefaultedrPolicyHandlerHook = FALSE; + +/* The EDR_POLICY_HANDLER_HOOK is a function pointer defined + * in the header file edrLibP.h. + */ +LOCAL EDR_POLICY_HANDLER_HOOK currentedrPolicyHandlerHook = NULL; + + +/* +** Local Function Prototypes +*/ + + +/****************************************************************************** +** Function: CFE_PSP_edrPolicyHandlerHook +** +** Purpose: +** Makes the proper call to CFE_ES_ProcessCoreException +** +** Notes: When speSave() is called, it captures the last floating point +** context, which may not be valid. If a floating point exception +** occurs you can be almost 100% sure that this will reflect the +** proper context. But if another type of exception occurred then +** this has the possibility of not being valid. Specifically if a +** task that is not enabled for floating point causes a non-floating +** point exception, then the meaning of the floating point context +** will not be valid. If the task is enabled for floating point, +** then it will be valid. +** +** Arguments: +** Input - type - +** EDR_FACILITY_KERNEL - VxWorks kernel events + EDR_FACILITY_INTERRUPT - interrupt handler events + EDR_FACILITY_INIT - system startup events + EDR_FACILITY_BOOT - system boot events + EDR_FACILITY_REBOOT - system restart events + EDR_FACILITY_RTP - RTP system events + EDR_FACILITY_USER - user generated events +** Input - pInfo_param - +** A pointer to an architecture-specific EXC_INFO structure, +** in case of exceptions, with CPU exception information. The exception +** information is saved by the default VxWorks exception handler. +** The structure is defined for each architecture in one of these +** files: target/h/arch/arch/excArchLib.h For example: target/h/arch/ppc/excPpcLib.h +** Input - debug - +** This flag indicates whether the ED&R system is in debug (also known as lab) mode, +** or in field (or deployed) mode. +** +** +** Return: +** TRUE - Do not stop offending task +** FALSE - Stop offending task +** +******************************************************************************/ +BOOL CFE_PSP_edrPolicyHandlerHook(int type, void *pInfo_param, BOOL debug) +{ + CFE_PSP_Exception_LogData_t* Buffer; + BOOL returnStatus = FALSE; + EDR_TASK_INFO* pInfo = (EDR_TASK_INFO*)pInfo_param; + + Buffer = CFE_PSP_Exception_GetNextContextBuffer(); + if (Buffer != NULL) + { + /* + * Immediately get a snapshot of the timebase when exception occurred + * + * This is because the remainder of exception processing might be done + * in a cleanup job as a low priority background task, and might be + * considerably delayed from the time the actual exception occurred. + */ + vxTimeBaseGet(&Buffer->context_info.timebase_upper, &Buffer->context_info.timebase_lower); + + Buffer->sys_task_id = pInfo->taskId; + Buffer->context_info.vector = pInfo->vector; + + /* + * Save Exception Stack frame + */ + memcpy(&Buffer->context_info.esf, pInfo->pEsf, sizeof(Buffer->context_info.esf)); + /* + ** Save floating point registers + */ + fppSave(&Buffer->context_info.fp); + + CFE_PSP_Exception_WriteComplete(); + + if (overRideDefaultedrPolicyHandlerHook == FALSE) + { + if (currentedrPolicyHandlerHook != NULL) + { + returnStatus = currentedrPolicyHandlerHook(type, pInfo, debug); + } + } + } + if (GLOBAL_CFE_CONFIGDATA.SystemNotify != NULL) + { + /* notify the CFE of the event */ + GLOBAL_CFE_CONFIGDATA.SystemNotify(); + } + return returnStatus; +} + + +/****************************************************************************** +** Function: CFE_PSP_AttachExceptions +** +** Purpose: +** This function Initializes the VxWorks EDR Ploicy handling. The handler +** is called for every exception that other handlers do not handle. +** +** Notes: The floating point exceptions are handled by the default floating +** point exception handler, which does a graceful recovery from +** floating point exceptions in the file speExcLib.c. +** +** Arguments: +** None +** +** Return: +** None +******************************************************************************/ +void CFE_PSP_AttachExceptions(void) +{ + currentedrPolicyHandlerHook = edrPolicyHandlerHookGet(); + if (currentedrPolicyHandlerHook != NULL) + { + /* The call to edrErrorPolicyHookRemove will return ERROR if the handler + * is NULL otherwise it set the handler to NULL. No action was required but + * ignoring an error is a bad practice. + */ + if (edrErrorPolicyHookRemove() == ERROR) + { + OS_printf("CFE_PSP_AttachException() - edrErrorPolicyHookRemove() failed for address 0x%llx ", (uint64)currentedrPolicyHandlerHook); + currentedrPolicyHandlerHook = NULL; + } + + } + + if (edrPolicyHandlerHookAdd(CFE_PSP_edrPolicyHandlerHook) == ERROR) + { + OS_printf("CFE_PSP_AttachException() - edrPolicyHandlerHookAdd() failed " + "for CFE_PSP_edrPolicyHandlerHook()"); + } + else + { + OS_printf("CFE_PSP_AttacheException() - Attached cFE Exception Handler. "); + } +} + + + +/****************************************************************************** +** Function: CFE_PSP_SetDefaultExceptionEnvironment +** +** Purpose: +** This function sets a default exception environment that can be used +** +** Notes: The exception environment is local to each task. Therefore, this +** must be called for each task that wants to do floating point and +** catch exceptions. Currently, this is automatically called from +** OS_TaskRegister() for every task. +** +** Arguments: +** None +** +** Return: +** None +******************************************************************************/ +void CFE_PSP_SetDefaultExceptionEnvironment(void) +{ + /* TODO: Determine the proper exception environment for the SP0 */ +} + +/* + * Name: CFE_PSP_ExceptionGetSummary_Impl + * + * Purpose: Translate a stored exception log entry into a summary string + */ +int32 CFE_PSP_ExceptionGetSummary_Impl(const CFE_PSP_Exception_LogData_t* Buffer, char *ReasonBuf, uint32 ReasonSize) +{ + const char *TaskName; + + /* + ** Get the vxWorks task name + */ + TaskName = taskName(Buffer->sys_task_id); + + if ( TaskName == NULL ) + { + TaskName = "NULL"; + } + + snprintf(ReasonBuf, ReasonSize, "Vector=0x%06X, vxWorks Task Name=%s, Task ID=0x%08X", + Buffer->context_info.vector,TaskName,Buffer->sys_task_id); + + return CFE_PSP_SUCCESS; +} + diff --git a/fsw/5020-vxworks7/src/cfe_psp_memory.c b/fsw/5020-vxworks7/src/cfe_psp_memory.c new file mode 100644 index 00000000..2df73a99 --- /dev/null +++ b/fsw/5020-vxworks7/src/cfe_psp_memory.c @@ -0,0 +1,555 @@ +/****************************************************************************** +** File: cfe_psp_memory.c +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: +** cFE PSP Memory related functions +** +** This is the implementation of the cFE memory areas that have to be +** preserved, and the API that is designed to allow access to them. +** It also contains memory related routines to return the address of the +** kernel code used in the cFE checksum. +** +******************************************************************************/ + +/* +** Include Files +*/ +#include +#include +#include +#include +#include +#include +/* +** cFE includes +*/ +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp.h" +#include "cfe_psp_memory.h" + +#include +/* +** Macro Definitions +*/ + +/* Define cFE core loadable module name*/ +#define CFE_MODULE_NAME "cfe-core.o" + +/* +** External Declarations +*/ +extern unsigned long long GetWrsKernelTextStart(void); +extern unsigned long long GetWrsKernelTextEnd(void); + + +/* +** Global variables +*/ + +/* +** Pointer to the vxWorks USER_RESERVED_MEMORY area +** The sizes of each memory area is defined in os_processor.h for this architecture. +*/ +CFE_PSP_ReservedMemoryMap_t CFE_PSP_ReservedMemoryMap; + +CFE_PSP_MemoryBlock_t PSP_ReservedMemBlock; +/* +********************************************************************************* +** CDS related functions +********************************************************************************* +*/ + +/****************************************************************************** +** Function: CFE_PSP_GetCDSSize +** +** Purpose: +** This function fetches the size of the OS Critical Data Store area. +** +** Arguments: +** Output - pSizeOfCds - Pointer to variable that stores size of CDS +** +** Return: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR +******************************************************************************/ + +int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) +{ + int32 return_code; + + if ( SizeOfCDS == NULL ) + { + return_code = CFE_PSP_ERROR; + } + else + { + *SizeOfCDS = (uint32)CFE_PSP_ReservedMemoryMap.CDSMemory.BlockSize; + return_code = CFE_PSP_SUCCESS; + } + return(return_code); +} + +/****************************************************************************** +** Function: CFE_PSP_WriteToCDS +** +** Purpose: +** This function writes to the CDS Block. +** +** Arguments: +** Input - PtrToDataToWrite - Pointer to the input data buffer +** Input - CDSOffset - Memory offset of CDS +** Input - NumBytes - Number of bytes to write to CDS +** +** Return: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR +******************************************************************************/ +int32 CFE_PSP_WriteToCDS(const void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) +{ + uint8 *CopyPtr; + int32 return_code; + + if ( PtrToDataToWrite == NULL ) + { + return_code = CFE_PSP_ERROR; + } + else + { + if ( (CDSOffset < CFE_PSP_ReservedMemoryMap.CDSMemory.BlockSize ) && + ( (CDSOffset + NumBytes) <= CFE_PSP_ReservedMemoryMap.CDSMemory.BlockSize )) + { + CopyPtr = CFE_PSP_ReservedMemoryMap.CDSMemory.BlockPtr; + CopyPtr += CDSOffset; + memcpy(CopyPtr, (char *)PtrToDataToWrite,NumBytes); + + return_code = CFE_PSP_SUCCESS; + } + else + { + return_code = CFE_PSP_ERROR; + } + + } /* end if PtrToDataToWrite == NULL */ + + return(return_code); +} + + +/****************************************************************************** +** Function: CFE_PSP_ReadFromCDS +** +** Purpose: +** This function reads from the CDS Block. +** +** Arguments: +** Output - PtrToDataToRead - Pointer to output data buffer +** Input - CDSOffset - Memory offset of CDS +** Input - NumBytes - Number of bytes to read from CDS +** +** Return: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR +******************************************************************************/ + +int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes) +{ + uint8 *CopyPtr; + int32 return_code; + + if ( PtrToDataToRead == NULL ) + { + return_code = CFE_PSP_ERROR; + } + else + { + if ( (CDSOffset < CFE_PSP_ReservedMemoryMap.CDSMemory.BlockSize ) && + ( (CDSOffset + NumBytes) <= CFE_PSP_ReservedMemoryMap.CDSMemory.BlockSize )) + { + CopyPtr = CFE_PSP_ReservedMemoryMap.CDSMemory.BlockPtr; + CopyPtr += CDSOffset; + memcpy((char *)PtrToDataToRead,CopyPtr, NumBytes); + + return_code = CFE_PSP_SUCCESS; + } + else + { + return_code = CFE_PSP_ERROR; + } + + } /* end if PtrToDataToWrite == NULL */ + + return(return_code); + +} + +/* +********************************************************************************* +** ES Reset Area related functions +********************************************************************************* +*/ + +/****************************************************************************** +** Function: CFE_PSP_GetResetArea +** +** Purpose: +** This function returns the location and size of the ES Reset information area. +** This area is preserved during a processor reset and is used to store the +** ER Log, System Log and reset related variables +** +** Arguments: +** Output - PtrToResetArea - Pointer to the reset memory address +** Output - SizeOfResetArea - Pointer to variable that stores size of memory +** +** Return: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR +******************************************************************************/ +int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) +{ + int32 return_code; + + if ((PtrToResetArea == NULL) || (SizeOfResetArea == NULL)) + { + return_code = CFE_PSP_ERROR; + } + else + { + *PtrToResetArea = (cpuaddr)(CFE_PSP_ReservedMemoryMap.ResetMemory.BlockPtr); + *SizeOfResetArea = (uint32)CFE_PSP_ReservedMemoryMap.ResetMemory.BlockSize; + return_code = CFE_PSP_SUCCESS; + } + + return(return_code); +} + +/* +********************************************************************************* +** ES User Reserved Area related functions +********************************************************************************* +*/ + +/****************************************************************************** +** Function: CFE_PSP_GetUserReservedArea +** +** Purpose: +** This function returns the location and size of the memory used for the cFE +** user-reserved area. +** +** Arguments: +** Output - PtrToUserArea - Pointer to user-reserved memory address +** Output - SizeOfUserArea - Pointer to variable that stores size of memory +** +** Return: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR +******************************************************************************/ +int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea ) +{ + int32 return_code; + + if ((PtrToUserArea == NULL) || (SizeOfUserArea == NULL)) + { + return_code = CFE_PSP_ERROR; + } + else + { + *PtrToUserArea = (cpuaddr)(CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockPtr); + *SizeOfUserArea = (uint32)CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockSize; + return_code = CFE_PSP_SUCCESS; + } + + return(return_code); +} + +/* +********************************************************************************* +** ES Volatile disk memory related functions +********************************************************************************* +*/ + +/****************************************************************************** +** Function: CFE_PSP_GetVolatileDiskMem +** +** Purpose: +** This function returns the location and size of the memory used for the cFE +** volatile disk. +** +** Arguments: +** Output - PtrToVolDisk - Pointer to the volatile disk memory address +** Output - SizeOfVolDisk - Pointer to variable that stores size of memory +** +** Return: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR +******************************************************************************/ +int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ) +{ + int32 return_code; + + if ((PtrToVolDisk == NULL) || (SizeOfVolDisk == NULL)) + { + return_code = CFE_PSP_ERROR; + } + else + { + *PtrToVolDisk = (cpuaddr)(CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockPtr); + *SizeOfVolDisk = (uint32)CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockSize; + return_code = CFE_PSP_SUCCESS; + + } + + return(return_code); + +} + + +/* +********************************************************************************* +** ES BSP Top Level Reserved memory initialization +********************************************************************************* +*/ + +/****************************************************************************** +** Function: CFE_PSP_InitProcessorReservedMemory +** +** Purpose: +** This function performs the top level reserved memory initialization. +** +** Arguments: +** Input - RestartType - type of re-start +** +** Return: +** CFE_PSP_SUCCESS +******************************************************************************/ +int32 CFE_PSP_InitProcessorReservedMemory( uint32 RestartType ) +{ + cpuaddr start_addr; + size_t reserve_memory_size = 0; + int32 return_code = CFE_PSP_SUCCESS; + + userReservedGet((char**)&start_addr, &reserve_memory_size); + + if(PSP_ReservedMemBlock.BlockSize > reserve_memory_size) + { + OS_printf("CFE_PSP: VxWorks Reserved Memory Block Size not large enough, Total Size = 0x%lx, VxWorks Reserved Size=0x%lx\n", + (unsigned long)PSP_ReservedMemBlock.BlockSize, + (unsigned long)reserve_memory_size); + return_code = OS_ERROR; + + } + else if ( RestartType != CFE_PSP_RST_TYPE_PROCESSOR ) + { + OS_printf("CFE_PSP: Clearing Processor Reserved Memory.\n"); + memset(PSP_ReservedMemBlock.BlockPtr, 0, PSP_ReservedMemBlock.BlockSize); + + /* + ** Set the default reset type in case a watchdog reset occurs + */ + CFE_PSP_ReservedMemoryMap.BootPtr->bsp_reset_type = CFE_PSP_RST_TYPE_PROCESSOR; + + } + + return(return_code); + +} + +/****************************************************************************** +** Function: CFE_PSP_SetupReservedMemoryMap +** +** Purpose: +** Set up the CFE_PSP_ReservedMemoryMap global data structure +** This only sets the pointers, it does not initialize the data. +** +** Arguments: +** (none) +** +** Return: +** (none) +*/ +void CFE_PSP_SetupReservedMemoryMap(void) +{ + cpuaddr start_addr; + cpuaddr end_addr; + size_t reserve_memory_size = 0; + + /* + ** Setup the pointer to the reserved area in vxWorks. + ** This must be done before any of the reset variables are used. + */ + /* + ** Note: this uses a "cpuaddr" (integer address) as an intermediate + ** to avoid warnings about alignment. The output of userReservedGet() + ** should be aligned to hold any data type, being the very start + ** of the memory space. + */ + userReservedGet((char**)&start_addr, &reserve_memory_size); + + end_addr = start_addr; + + memset(&CFE_PSP_ReservedMemoryMap, 0, sizeof(CFE_PSP_ReservedMemoryMap)); + + CFE_PSP_ReservedMemoryMap.BootPtr = (CFE_PSP_ReservedMemoryBootRecord_t *)end_addr; + end_addr += sizeof(CFE_PSP_ReservedMemoryBootRecord_t); + end_addr = (end_addr + CFE_PSP_MEMALIGN_MASK) & ~CFE_PSP_MEMALIGN_MASK; + + CFE_PSP_ReservedMemoryMap.ExceptionStoragePtr = (CFE_PSP_ExceptionStorage_t *)end_addr; + end_addr += sizeof(CFE_PSP_ExceptionStorage_t); + end_addr = (end_addr + CFE_PSP_MEMALIGN_MASK) & ~CFE_PSP_MEMALIGN_MASK; + + CFE_PSP_ReservedMemoryMap.ResetMemory.BlockPtr = (void*)end_addr; + CFE_PSP_ReservedMemoryMap.ResetMemory.BlockSize = GLOBAL_CONFIGDATA.CfeConfig->ResetAreaSize; + end_addr += CFE_PSP_ReservedMemoryMap.ResetMemory.BlockSize; + end_addr = (end_addr + CFE_PSP_MEMALIGN_MASK) & ~CFE_PSP_MEMALIGN_MASK; + + CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockPtr = (void*)end_addr; + CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockSize = + GLOBAL_CONFIGDATA.CfeConfig->RamDiskSectorSize * GLOBAL_CONFIGDATA.CfeConfig->RamDiskTotalSectors; + end_addr += CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockSize; + end_addr = (end_addr + CFE_PSP_MEMALIGN_MASK) & ~CFE_PSP_MEMALIGN_MASK; + + CFE_PSP_ReservedMemoryMap.CDSMemory.BlockPtr = (void*)end_addr; + CFE_PSP_ReservedMemoryMap.CDSMemory.BlockSize = GLOBAL_CONFIGDATA.CfeConfig->CdsSize; + end_addr += CFE_PSP_ReservedMemoryMap.CDSMemory.BlockSize; + end_addr = (end_addr + CFE_PSP_MEMALIGN_MASK) & ~CFE_PSP_MEMALIGN_MASK; + + CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockPtr = (void*)end_addr; + CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockSize = GLOBAL_CONFIGDATA.CfeConfig->UserReservedSize; + end_addr += CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockSize; + end_addr = (end_addr + CFE_PSP_MEMALIGN_MASK) & ~CFE_PSP_MEMALIGN_MASK; + + /* The total size of the entire block is the difference in address */ + PSP_ReservedMemBlock.BlockPtr = (void*)start_addr; + PSP_ReservedMemBlock.BlockSize = end_addr - start_addr; + + OS_printf("CFE_PSP: Reserved Memory Block at 0x%p, Total Size = 0x%lx, VxWorks Reserved Size=0x%lx\n", + PSP_ReservedMemBlock.BlockPtr, + PSP_ReservedMemBlock.BlockSize, + reserve_memory_size); +} + +/****************************************************************************** + * Function: CFE_PSP_DeleteProcessorReservedMemory + * + * No action on SP0 - reserved block is statically allocated as user reserved + * memory. + * Implemented for API consistency with other PSPs. + */ +void CFE_PSP_DeleteProcessorReservedMemory(void) +{ +} + +/* +********************************************************************************* +** ES BSP kernel memory segment functions +********************************************************************************* +*/ + +/****************************************************************************** +** Function: CFE_PSP_GetKernelTextSegmentInfo +** +** Purpose: +** This function returns the start and end address of the kernel text segment. +** It may not be implemented on all architectures. +** +** Arguments: +** Output - PtrToKernelSegment - Pointer to kernel segment memory address +** Output - SizeOfKernelSegment - Pointer to variable that stores memory size +** +** Return: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR +******************************************************************************/ +int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment) +{ + int32 return_code; + cpuaddr StartAddress; + cpuaddr EndAddress; + + if ( SizeOfKernelSegment == NULL ) + { + return_code = CFE_PSP_ERROR; + } + else + { + /* + ** Get the kernel start and end + ** addresses from the BSP, because the + ** symbol table does not contain the symbls we need for this + */ + StartAddress = (cpuaddr) GetWrsKernelTextStart(); + EndAddress = (cpuaddr) GetWrsKernelTextEnd(); + + *PtrToKernelSegment = StartAddress; + *SizeOfKernelSegment = (uint32) (EndAddress - StartAddress); + + return_code = CFE_PSP_SUCCESS; + } + + return(return_code); +} + +/****************************************************************************** +** Function: CFE_PSP_GetCFETextSegmentInfo +** +** Purpose: +** This function returns the start and end address of the CFE text segment. +** It may not be implemented on all architectures. +** +** Arguments: +** Output - PtrToCFESegment - Pointer to CFE segment memory address +** Output - SizeOfCFESegment - Pointer to variable that stores memory size +** +** Return: +** CFE_PSP_SUCCESS +** CFE_PSP_ERROR +******************************************************************************/ +int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment) +{ + int32 return_code; + STATUS status; + MODULE_ID cFEModuleId; + MODULE_INFO cFEModuleInfo; + + if ( SizeOfCFESegment == NULL ) + { + return_code = CFE_PSP_ERROR; + } + else + { + char name[] = CFE_MODULE_NAME; + cFEModuleId = moduleFindByName(name); + + if ( cFEModuleId == NULL ) + { + return_code = CFE_PSP_ERROR; + } + else + { + status = moduleInfoGet(cFEModuleId, &cFEModuleInfo); + if ( status != ERROR ) + { + *PtrToCFESegment = (cpuaddr) (cFEModuleInfo.segInfo.textAddr); + *SizeOfCFESegment = (uint32) (cFEModuleInfo.segInfo.textSize); + return_code = CFE_PSP_SUCCESS; + } + else + { + return_code = CFE_PSP_SUCCESS; + } + } + } + + return(return_code); +} + + + diff --git a/fsw/5020-vxworks7/src/cfe_psp_memtab.c b/fsw/5020-vxworks7/src/cfe_psp_memtab.c new file mode 100644 index 00000000..e581fe77 --- /dev/null +++ b/fsw/5020-vxworks7/src/cfe_psp_memtab.c @@ -0,0 +1,43 @@ +/****************************************************************************** +** +** File : cfe_psp_memtab.c +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: +** TODO: Add description +** +******************************************************************************/ + +/* +** Includes +*/ +#include "common_types.h" +#include "cfe_psp.h" +#include "cfe_psp_config.h" + + +/* +** Valid memory map for this target. +** If you need to add more entries, increase CFE_PSP_MEM_TABLE_SIZE in the osconfig.h file. +*/ +CFE_PSP_MemTable_t CFE_PSP_MemoryTable[CFE_PSP_MEM_TABLE_SIZE] = +{ + { CFE_PSP_MEM_RAM, CFE_PSP_MEM_SIZE_DWORD, 0, 0x40000000, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, + { CFE_PSP_MEM_INVALID, 0, 0, 0, CFE_PSP_MEM_ATTR_READWRITE }, +}; + + diff --git a/fsw/5020-vxworks7/src/cfe_psp_start.c b/fsw/5020-vxworks7/src/cfe_psp_start.c new file mode 100644 index 00000000..1048545b --- /dev/null +++ b/fsw/5020-vxworks7/src/cfe_psp_start.c @@ -0,0 +1,490 @@ +/****************************************************************************** +** +** File: cfe_psp_start.c +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: +** cFE PSP main entry point +** +******************************************************************************/ + +/* +** Include Files +*/ +#include +#include +#include +#include +#include "osapi.h" +#include "cfe.h" +#include "cfe_psp.h" +#include "cfe_psp_memory.h" +#include "target_config.h" +#include + +#include + +extern VIRT_ADDR vxMmuEarlyRegMap(PHYS_ADDR p, size_t len); /* for pixis aux reg */ +/* +** Macro Definitions +*/ +#define CFE_PSP_TASK_PRIORITY (30) +#define CFE_PSP_TASK_STACK_SIZE (20 * 1024) + +/* CFE_PSP_TIMER_PRINT_DBG +** +** Debug flag +*/ +#define CFE_PSP_TIMER_PRINT_DBG FALSE + +#define PSP_1HZ_INTERVAL 1000000 + +/* +** External Function Prototypes +*/ + +/* + * The preferred way to obtain the CFE tunable values at runtime is via + * the dynamically generated configuration object. This allows a single build + * of the PSP to be completely CFE-independent. + */ + +#define CFE_PSP_MAIN_FUNCTION (*GLOBAL_CONFIGDATA.CfeConfig->SystemMain) +#define CFE_PSP_NONVOL_STARTUP_FILE (GLOBAL_CONFIGDATA.CfeConfig->NonvolStartupFile) +#define CFE_PSP_1HZ_FUNCTION (*GLOBAL_CONFIGDATA.CfeConfig->System1HzISR) + +/* +** Local Function Prototypes +*/ +static int32 SetSysTasksPrio(void); +static int32 SetTaskPrio(const char* tName, int32 tgtPrio); +void CFE_PSP_Start(void); + +/* +** Local Global Variables +*/ +static uint32 ResetType = 0; +static uint32 ResetSubtype = 0; +//static USER_SAFE_MODE_DATA_STRUCT safeModeUserData; +static uint32 PSP_1Hz_TimerId = 0; +static uint32 PSP_1Hz_ClockAccuracy = 0; + +/* + * The list of VxWorks task to change the task priority + * to before finishing initialization. + */ + +CFE_PSP_OS_Task_and_priority_t VxWorksTaskList[] = +{ + {"tLogTask", 0}, + {"tShell0", 201}, + {"tWdbTask", 203}, + {"tVxdbgTask", 200}, + {"tNet0", 25}, /* Should be set right below CI/TO */ + {"ipftps", 202}, + {"ipcom_syslogd", 205}, + {"ipcom_telnetd", 204} +}; + +/****************************************************************************** +** Function: CFE_PSP_Main() +** +** Purpose: +** vxWorks/PSP Application entry point +** +** Arguments: +** None +** Return: +** None +******************************************************************************/ +void CFE_PSP_Main(void) +{ + TASK_ID root_task_id = NULL; + char name[] = "PSP_START"; + + /* Need to add VX_FP_TASK (all tasks should just be created with it... + ** to deal with an "SPE unknown exception" error as soon as this task + ** would start on the SP0/PPC8548. + */ + + /* Note: When using e500vx_gnu tool chain, including VX_FP_TASK implicitly + ** includes VX_SPE_TASK, which is needed when starting tasks that might + ** use floating point on this processor. + */ + OS_printf_enable(); + root_task_id = taskSpawn(name, CFE_PSP_TASK_PRIORITY, + VX_FP_TASK, CFE_PSP_TASK_STACK_SIZE, + (FUNCPTR) CFE_PSP_Start, 0, + 0,0,0,0,0,0,0,0,0); + + if ((root_task_id == TASK_ID_NULL)||(root_task_id == TASK_ID_ERROR)) + { + OS_printf("CFE_PSP_Main() - ERROR - Unable to spawn PSP_START task!"); + } +} + +/****************************************************************************** +** Function: CFE_PSP_Start() +** +** Purpose: +** Application startup entry point from OSAL BSP. +** +** Arguments: +** (none) +** +** Return: +** (none) +*/ +void CFE_PSP_Start(void) +{ + int32 status = OS_SUCCESS; + int32 time_status; + int32 taskSetStatus = OS_SUCCESS; + uint32 sys_timebase_id; + uint32 fs_id; + + /* Initialize the OS API data structures */ + status = OS_API_Init(); + if (status != OS_SUCCESS) + { + OS_printf("CFE_PSP: CFE_PSP_Start() - OS_API_Init() failed (0x%X)\n", + status); + goto CFE_PSP_Start_Exit_Tag; + } + + CFE_PSP_SetupReservedMemoryMap(); + + /* Initialize the watchdog, it's left disabled */ + CFE_PSP_WatchdogInit(); + + /* PSP Determine the reset type */ + /* SDS: use the pixis PX_AUX reg (offset 6) which is 0 on POR to determine POR, + * as there is no reset cause register on this hardware */ + ResetType = CFE_PSP_RST_TYPE_POWERON; /* default value is safe */ + + /* SDS: board is DDR so memory clears upon restart. In order to prevent the system + * assuming the CDS (Critical data store) area of memory is not going to be clear, + * treat all restarts as poweron for now */ +#if 0 + { + PHYS_ADDR pixis_phys_addr=0; + VIRT_ADDR pixis_virt_addr=0; + size_t pixis_size = 0; + int offset = vxFdtNodeOffsetByCompatible(0, (char*)"fsl,fpga-ngpixis"); + if(offset>=0) { + if(vxFdtDefRegGet(offset, 0, &pixis_phys_addr, &pixis_size)==OK) { + pixis_virt_addr = vxMmuEarlyRegMap(pixis_phys_addr, pixis_size); + if(pixis_virt_addr) { + if((*(volatile uint8_t*)(pixis_virt_addr+6))) ResetType = CFE_PSP_RST_TYPE_PROCESSOR; + (*(volatile uint8_t*)(pixis_virt_addr+6)) = 1; /* the 1 will persist across warm reset */ + } + } + } + } +#endif + + /* Initialize the reserved memory */ + if (CFE_PSP_InitProcessorReservedMemory(ResetType) != OS_SUCCESS) + { + OS_printf("CFE_PSP: CFE_PSP_Start() - CFE_PSP_InitProcessorReservedMemory() failed (0x%x)\n", + status); + goto CFE_PSP_Start_Exit_Tag; + } + + time_status = OS_TimeBaseCreate(&sys_timebase_id, "cFS-Master", NULL); + if(time_status == OS_SUCCESS) { + time_status = OS_TimeBaseSet(sys_timebase_id, 10000, 10000); + /* example pc-linux psp doesn't check return value? */ + } + else { + sys_timebase_id = 0; + } + + status = OS_FileSysAddFixedMap(&fs_id, "host:/cf", "/cf"); + if(status != OS_SUCCESS) + { + /* startup can continue, but loads may fail later depending on config */ + OS_printf("CFE_PSP: OS_FileSysAddFixedMap() failure: %d\n", (int)status); + } + + status = OS_FileSysAddFixedMap(&fs_id, "/ram0", "/ram"); + if(status != OS_SUCCESS) + { + /* startup can continue, but loads may fail later depending on config */ + OS_printf("CFE_PSP: OS_FileSysAddFixedMap() failure: %d\n", (int)status); + } + + /* + ** Adjust system task priorities so that tasks such as the shell are + ** at a lower priority that the CFS apps + */ + taskSetStatus = SetSysTasksPrio(); + + /* Call cFE entry point. This will return when cFE startup is complete. */ + CFE_PSP_MAIN_FUNCTION(ResetType, ResetSubtype, 1, CFE_PSP_NONVOL_STARTUP_FILE); + + CFE_ES_WriteToSysLog("CFE_PSP: %s reset\n", (ResetType==CFE_PSP_RST_TYPE_POWERON)?"power on":"processor"); + + OS_Application_Run(); + + if (taskSetStatus != OS_SUCCESS) + { + CFE_ES_WriteToSysLog("CFE_PSP: CFE_PSP_Start() At least one vxWorks task priority set failed. System may have degraded performance.\n"); + } + + CFE_ES_WriteToSysLog("CFE_PSP: CFE_PSP_Start() done.\n"); + +CFE_PSP_Start_Exit_Tag: + return; +} + + +/****************************************************************************** +** Function: CFE_PSP_GetRestartType() +** +** Purpose: +** Provides the CFE PSP reset type and subtype +** +** Arguments: +** Output - resetSubType - Reset subtype +** +** Return: +** Reset type +******************************************************************************/ +uint32 CFE_PSP_GetRestartType(uint32 *resetSubType) +{ + if (resetSubType != NULL) + { + *resetSubType = ResetSubtype; + } + + return (ResetType); +} + + +/****************************************************************************** +** Function: SetTaskPrio() +** +** Purpose: +** Changes default task priority to a given priority +** +** Arguments: +** Input - tName - Task name +** Input - tgtPrio - New task priority +** +** Return: +** None +******************************************************************************/ +static int32 SetTaskPrio(const char* tName, int32 tgtPrio) +{ + TASK_ID tid = NULL; + int32 curPrio = 0; + int32 newPrio = 0; + int32 status = OS_SUCCESS; + + if ((tName != NULL) && (strlen(tName) > 0)) + { + newPrio = tgtPrio; + if (newPrio < 0) + { + newPrio = 0; + } + else if (newPrio > 255) + { + newPrio = 255; + } + + tid = taskNameToId((char*)tName); + if ((tid!=TASK_ID_NULL)&&(tid!=TASK_ID_ERROR)) + { + if (taskPriorityGet(tid, (int *)&curPrio) != ERROR) + { + OS_printf("PSP: SetTaskPrio() - Setting %s priority from %d to %d\n", + tName, curPrio, newPrio); + + if (taskPrioritySet(tid, newPrio) == ERROR) + { + OS_printf("PSP: taskPrioritySet() - Failed for %s priority from %d to %d\n", + tName, curPrio, newPrio); + status = OS_ERROR; + } + + } + } + } + + return status; +} + + +/****************************************************************************** +** Function: SetSysTasksPrio() +** +** Purpose: +** Changes system task priorities so that they are lower than CFS system +** task priorities +** +** Note: tNet0 priority should be adjusted to be right below what ever +** gets defined for CI/TO apps in your system if using the network +** interface CCSDS/UDP for CI/TO apps. +** +** Arguments: +** None +** +** Return: +** None +******************************************************************************/ +static int32 SetSysTasksPrio(void) +{ + int32 status = OS_SUCCESS; + int32 index = 0; + + int32 numberOfTask = sizeof(VxWorksTaskList)/sizeof(CFE_PSP_OS_Task_and_priority_t); + + OS_printf("\nSetting system tasks' priorities for %d tasks.\n", numberOfTask); + + for (index = 0; index < numberOfTask; index++) + { + if (SetTaskPrio(VxWorksTaskList[index].VxWorksTaskName, VxWorksTaskList[index].VxWorksTaskPriority) != OS_SUCCESS) + { + status = OS_ERROR; + } + } + + return status; +} + + +/****************************************************************************** +** Function: PSP_1HzLocalCallback() +** +** Purpose: +** The 1Hz call back handler calls the cfe 1Hz routine +** +** Arguments: +** Input TimerId - Id for 1Hz timer +** +** Return: +** (none) +*/ +void PSP_1HzLocalCallback(uint32 TimerId) +{ +#if CFE_PSP_TIMER_PRINT_DBG == TRUE + OS_time_t LocalTime; + CFE_PSP_GetTime(&LocalTime); +#endif + CFE_PSP_1HZ_FUNCTION(); +#if CFE_PSP_TIMER_PRINT_DBG == TRUE + + OS_printf("PSP_1HzLocalCallback: PSP Local Time: %d.%d\n", LocalTime.seconds,LocalTime.microsecs); +#endif +} +/****************************************************************************** +** Function: OS_Application_Run() +** +** Purpose: +** Initializes the 1Hz timer connects the cFE 1Hz ISR for providing the +** CFS 1Hz time sync, sync the scheduler's 1Hz major frame start to the +** 1Hz timer. +** +** Arguments: +** (none) +** +** Return: +** (none) +*/ +void OS_Application_Run(void) +{ + int32 Status = CFE_SUCCESS; + + /*Create the 1Hz timer for synchronizing the major frame*/ + Status = OS_TimerCreate(&PSP_1Hz_TimerId, + "PSP_1HZ_TIMER", + &PSP_1Hz_ClockAccuracy, + PSP_1HzLocalCallback); + if (Status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Failed to create OS_Timer for 1Hz local time.\n"); + } + else + { + /*Set the interval to one second in microseconds.*/ + Status = OS_TimerSet(PSP_1Hz_TimerId, PSP_1HZ_INTERVAL, PSP_1HZ_INTERVAL); + if (Status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Failed to set OS_Timer for 1Hz local time.\n"); + } + } + +} + +/*TODO have osal add conditional compile when SPE preset instead of FPU + * Once that has occurred we can remove vxFpscrGet and vxFpscrSet + * */ +/****************************************************************************** +** Function: vxFpscrGet() +** +** Purpose: +** Provides stub function for FPU exception handler, vxFpscrGet() +** +** Added this function here so that the code can compile & run without error. +** +** If there's code that calls these functions, we will get a message like so, +** > ld < cfe-core.o +** Warning: module 0x461d010 holds reference to undefined symbol vxFpscrGet. +** Warning: module 0x461d010 holds reference to undefined symbol vxFpscrSet. +** +** These do not seem to be included in 85xx build, but are defined as +** "defined(_PPC_) && CPU != PPC440" in vxWorks osapi.c, line 2707, v4.2.1a +** +** If this function is not used, stub it out like below. Otherwise, define it. +** +** Arguments: +** None +** +** Return: +** 0 +*******************************************************************************/ +unsigned int vxFpscrGet(void) +{ + CFE_ES_WriteToSysLog("%s->%s:%d:\n", __FILE__, __func__, __LINE__); + + return (0); +} + + +/****************************************************************************** +** Function: vxFpscrSet() +** +** Purpose: +** Provides stub function for FPU exception handler, vxFpscrSet() +** +** Added this function here so that the code can compile & run without error. +** +** If there's code that calls these functions, we will get a message like so, +** > ld < cfe-core.o +** Warning: module 0x461d010 holds reference to undefined symbol vxFpscrGet. +** Warning: module 0x461d010 holds reference to undefined symbol vxFpscrSet. +** +** These do not seem to be included in 85xx build, but are defined as +** "defined(_PPC_) && CPU != PPC440" in vxWorks osapi.c, line 2707, v4.2.1a +** +** If this function is not used, stub it out like below. Otherwise, define it. +** +** Arguments: +** Input - x - TODO: Describe x +** +** Return: +** None +*******************************************************************************/ +void vxFpscrSet(unsigned int x) +{ + CFE_ES_WriteToSysLog("%s->%s:%d:\n", __FILE__, __func__, __LINE__); +} + diff --git a/fsw/5020-vxworks7/src/cfe_psp_support.c b/fsw/5020-vxworks7/src/cfe_psp_support.c new file mode 100644 index 00000000..7a6298cf --- /dev/null +++ b/fsw/5020-vxworks7/src/cfe_psp_support.c @@ -0,0 +1,163 @@ +/****************************************************************************** +** +** File: cfe_psp_support.c +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: +** This file contains glue routines between the cFE and the OS Board Support +** Package (BSP). The functions here allow the cFE to interface functions +** that are board and OS specific and usually dont fit well in the OS +** abstraction layer. +** +******************************************************************************/ + +/* +** Include Files +*/ +#include +#include +#include +#include "vxWorks.h" +#include "cacheLib.h" +#include "rebootLib.h" + +#include "common_types.h" +#include "osapi.h" +#include "cfe_es.h" + +#include "cfe_psp.h" +#include "cfe_psp_memory.h" +#include "target_config.h" + +#define CFE_PSP_CPU_ID (GLOBAL_CONFIGDATA.Default_CpuId) +#define CFE_PSP_SPACECRAFT_ID (GLOBAL_CONFIGDATA.Default_SpacecraftId) + +/* + * Track the overall "reserved memory block" at the start of RAM. + * This single large block is then subdivided into separate areas for CFE use. + */ +extern CFE_PSP_MemoryBlock_t PSP_ReservedMemBlock; + +/****************************************************************************** +** Function: CFE_PSP_Restart() +** +** Purpose: +** Provides a common interface to the processor reset +** +** Arguments: +** Input - reset_type - Type of reset +** +** Return: +** None +******************************************************************************/ +void CFE_PSP_Restart(uint32 reset_type) +{ + if (reset_type == CFE_PSP_RST_TYPE_POWERON) + { + CFE_PSP_ReservedMemoryMap.BootPtr->bsp_reset_type = CFE_PSP_RST_TYPE_POWERON; + /*Normally the cache would be flushed but the reserved memory is not cached + * so the flush is not needed. + */ + reboot(BOOT_CLEAR); + } + else + { + CFE_PSP_ReservedMemoryMap.BootPtr->bsp_reset_type = CFE_PSP_RST_TYPE_PROCESSOR; + /*Normally the cache would be flushed but the reserved memory is not cached + * so the flush is not needed. + */ + reboot(BOOT_NORMAL); + } +} + + +/****************************************************************************** +** Function: CFE_PSP_Panic() +** +** Purpose: +** Provides a common interface to abort the cFE startup process and return +** back to the OS. +** +** Arguments: +** Input - errorCode - Error code that causes the exit +** +** Return: +** None +******************************************************************************/ +void CFE_PSP_Panic(int32 errorCode) +{ + char msg[] = "CFE_PSP_Panic Called with error code = 0x%08X. Exiting.\n"; + logMsg(msg, + (unsigned int)errorCode, 0,0,0,0,0); + + exit(-1); /* TODO: Need to improve this */ +} + + +/****************************************************************************** +** Function: CFE_PSP_FlushCaches() +** +** Purpose: +** Provides a common interface to flush the processor caches. This routine +** is in the BSP because it is sometimes implemented in hardware and +** sometimes taken care of by the RTOS. +** +** Arguments: +** Input - type - Cache memory type +** Input - address - Cache memory address +** Input - size - Cache memory size +** +** Return: +** None +******************************************************************************/ +void CFE_PSP_FlushCaches(uint32 type, void* address, uint32 size) +{ + /*The cache is managed by the SP0 BSP/VxWorks OS. + */ +} + + +/****************************************************************************** +** Function: CFE_PSP_GetProcessorId +** +** Purpose: +** return the processor ID. +** +** Arguments: +** None +** +** Return: +** cFE CPU ID +******************************************************************************/ +uint32 CFE_PSP_GetProcessorId(void) +{ + return CFE_PSP_CPU_ID; +} + + +/****************************************************************************** +** Function: CFE_PSP_GetSpacecraftId +** +** Purpose: +** Provides the pre-assigned cFE Spacecraft ID +** +** Arguments: +** None +** +** Return: +** cFE Spacecraft ID +******************************************************************************/ +uint32 CFE_PSP_GetSpacecraftId(void) +{ + return CFE_PSP_SPACECRAFT_ID; +} + + + + diff --git a/fsw/5020-vxworks7/src/cfe_psp_timer.c b/fsw/5020-vxworks7/src/cfe_psp_timer.c new file mode 100644 index 00000000..a55fdd09 --- /dev/null +++ b/fsw/5020-vxworks7/src/cfe_psp_timer.c @@ -0,0 +1,210 @@ +/************************************************************************************************ +** +** File: cfe_psp_timer.c +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: +** This file contains glue routines between the cFE and the OS Board Support Package (BSP). +** The functions here allow the cFE to interface functions that are board and OS specific +** and usually dont fit well in the OS abstraction layer. +** +*************************************************************************************************/ + +/* +** Include Files +*/ +#include +#include +#include +#include "osapi.h" +#include "cfe.h" +#include "cfe_psp.h" +#include "cfe_time.h" +#include "target_config.h" + +/* +** External Function Prototypes +*/ + +/* +** Function Prototypes +*/ + +/* +** Macro Definitions +*/ + + +/* CFE_PSP_TIMER_LOW32_ROLLOVER +** +** The number that the least significant 32 bits of the 64-bit timestamp returned +** by CFE_PSP_Get_Timebase() rolls over. +** +** If the lower 32 bits rolls at 1 second, then +** CFE_PSP_TIMER_LOW32_ROLLOVER will be 1000000. +** If the lower 32 bits rolls at its maximum value (2^32), then +** CFE_PSP_TIMER_LOW32_ROLLOVER will be 0. +*/ +#define CFE_PSP_TIMER_LOW32_ROLLOVER 0 + + +static uint32 tickPerSecond = 0; + + +/****************************************************************************** +** Function: CFE_PSP_GetTime() +** +** Purpose: +** Gets the value of the time from the hardware using the processor TBR +** +** Arguments: +** Output - pLocalTime - pointer to local time variable +** +** Return: +** None +******************************************************************************/ +void CFE_PSP_GetTime(OS_time_t *pLocalTime) +{ + uint32 tbu = 0; + uint32 tbl = 0; + unsigned long long tb = 0; + static uint32 errorCount = 0; + + if (pLocalTime != NULL) + { + + vxTimeBaseGet((UINT32 *)&tbu, (UINT32 *)&tbl); + + /* Re-assemble the 64-bit count */ + tb = ((unsigned long long)tbu << 32) | (unsigned long long)tbl; + /*if the ticks per second is zero initialize it. + * The SP0 value is 41666666 and the SP0-S value is 49999999 + */ + if (tickPerSecond == 0) + { + tickPerSecond = sysTimestampFreq(); + } + if (tickPerSecond != 0) + { + /* Convert to seconds and microseconds using only integer computations. + * The max seconds value is 442721864852 for the SP0 and 36893488221 for + * the SP0-S. The conversion below will cause a loss of data which is just + * a roll over of the clock for the local time defined in osal. + */ + pLocalTime->seconds = (tb / tickPerSecond); + pLocalTime->microsecs = ((tb % tickPerSecond) * 1000000 )/(tickPerSecond); + + } + else if (errorCount < 2) + { + OS_printf("CFE_PSP: CFE_PSP_GetTime() - tickPerSecond equals zero.\n"); + errorCount++; + } + } + +} + +/****************************************************************************** +** Function: CFE_PSP_Get_Timer_Tick() +** +** Purpose: +** Provides a common interface to system clock tick. This routine +** is in the BSP because it is sometimes implemented in hardware and +** sometimes taken care of by the RTOS. +** +** Arguments: +** None +** +** Return: +** OS system clock ticks per second +******************************************************************************/ +uint32 CFE_PSP_Get_Timer_Tick(void) +{ + return ((uint32)sysClkRateGet()); +} + + +/****************************************************************************** +** Function: CFE_PSP_GetTimerTicksPerSecond() +** +** Purpose: +** Provides number of timer ticks per second +** +** Arguments: +** None +** +** Return: +** Value of ticks per second returned by sysTimestampFreq +******************************************************************************/ +uint32 CFE_PSP_GetTimerTicksPerSecond(void) +{ + return (tickPerSecond); +} + + +/****************************************************************************** +** Function: CFE_PSP_GetTimerLow32Rollover() +** +** Purpose: +** Provides the value of the least significant 32 bits of the 64-bit timestamp +** +** Arguments: +** None +** +** Return: +** Value of CFE_PSP_TIMER_LOW32_ROLLOVER macro constant +******************************************************************************/ +uint32 CFE_PSP_GetTimerLow32Rollover(void) +{ + return ((uint32)CFE_PSP_TIMER_LOW32_ROLLOVER); +} + + +/****************************************************************************** +** Function: CFE_PSP_Get_Timebase() +** +** Purpose: +** Provides the Time-Base Register (TBR) values +** +** Arguments: +** Output - tbu - pointer to tbu variable +** Output - tbl - pointer to tbl variable +** +** Return: +** Time-Base Register (TBR) values +******************************************************************************/ +void CFE_PSP_Get_Timebase(uint32 *tbu, uint32* tbl) +{ + if ((tbu != NULL) && (tbl != NULL)) + { + vxTimeBaseGet((UINT32 *)tbu, (UINT32 *)tbl); + } +} + + +/****************************************************************************** +** Function: CFE_PSP_Get_Dec() +** +** Purpose: +** Provides a common interface to decrementer counter. This routine +** is in the BSP because it is sometimes implemented in hardware and +** sometimes taken care of by the RTOS. +** +** Arguments: +** None +** +** Return: +** ??? value +******************************************************************************/ +uint32 CFE_PSP_Get_Dec(void) +{ + return ((uint32)vxDecGet()); +} + + diff --git a/fsw/5020-vxworks7/src/cfe_psp_watchdog.c b/fsw/5020-vxworks7/src/cfe_psp_watchdog.c new file mode 100644 index 00000000..85cfb8e4 --- /dev/null +++ b/fsw/5020-vxworks7/src/cfe_psp_watchdog.c @@ -0,0 +1,162 @@ +/************************************************************************************************ +** +** File: cfe_psp_watchdog.c +** +** Copyright (c) 2004-2011, United States Government as represented by +** Administrator for The National Aeronautics and Space Administration. +** All Rights Reserved. +** +** This is governed by the NASA Open Source Agreement and may be used, +** distributed and modified only pursuant to the terms of that agreement. +** +** Purpose: +** This file contains glue routines between the cFE and the OS Board Support Package (BSP). +** The functions here allow the cFE to interface functions that are board and OS specific +** and usually dont fit well in the OS abstraction layer. +** +*************************************************************************************************/ + +/* +** Include Files +*/ +#include +#include +#include + +#include "common_types.h" +#include "osapi.h" +#include "cfe_psp.h" + + +/* +** Global Variables +*/ +uint32 CFE_PSP_WatchdogValue = 20000; /* Watchdog time in msecs */ + + +/****************************************************************************** +** Function: CFE_PSP_WatchdogInit() +** +** Purpose: +** To setup the timer resolution and/or other settings custom to this platform +** +** Arguments: +** None +** +** Return: +** None +******************************************************************************/ +void CFE_PSP_WatchdogInit(void) +{ + CFE_PSP_WatchdogSet(CFE_PSP_WatchdogValue); /* in msecs */ +} + + +/****************************************************************************** +** Function: CFE_PSP_WatchdogEnable() +** +** Purpose: +** Enable the watchdog timer +** +** If the processor BSP is set to define "ENABLE_STARTUP_WATCHDOG" in config.h or +** using the kernel config tool, this function will be called in sysHwInit2() +** in sysLib.c. The watchdog timer is disabled by default in startup firmware. +** The defalut value for the WATCH DOG timer is defined by "STARTUP_WATCHDOG_TIMEOUT". +** +** Arguments: +** None +** +** Return: +** None +******************************************************************************/ +void CFE_PSP_WatchdogEnable(void) +{ + //sysEnableFpgaWdt(1); +} + + +/****************************************************************************** +** Function: CFE_PSP_WatchdogDisable() +** +** Purpose: +** Disable the watchdog timer +** +** Arguments: +** None +** +** Return: +** None +******************************************************************************/ +void CFE_PSP_WatchdogDisable(void) +{ + //sysDisableFpgaWdt(); +} + + +/****************************************************************************** +** Function: CFE_PSP_WatchdogService() +** +** Purpose: +** Feed the watchdog timer +** +** Arguments: +** None +** +** Return: +** None +******************************************************************************/ +void CFE_PSP_WatchdogService(void) +{ + /* + * This function toggles the watchdog timer and it must be called at least + * once every watchdog timer period if the watchdog timer is enabled. + * Otherwise, the board will perform a reset once the timer expires. + */ + //sysPulseFpgaWdt(); +} + + +/****************************************************************************** +** Function: CFE_PSP_WatchdogGet +** +** Purpose: +** Get the current watchdog value +** +** Arguments: +** None +** +** Return: +** The current watchdog value in msecs +******************************************************************************/ +uint32 CFE_PSP_WatchdogGet(void) +{ + return((uint32)CFE_PSP_WatchdogValue); +} + + +/****************************************************************************** +** Function: CFE_PSP_WatchdogSet +** +** Purpose: +** Get the current watchdog value +** +** Arguments: +** input - watchDogValue - The new watchdog value in msecs +** +** Return: +** None +******************************************************************************/ +void CFE_PSP_WatchdogSet(uint32 watchDogValue) +{ +#if 0 + float rate = 0.0; + + CFE_PSP_WatchdogValue = watchDogValue/1000; /* in msecs */ + + /*Rate is in seconds*/ + rate = (((float)watchDogValue)*0.001); + sysSetFpgaWdt(rate); +#endif +} + + diff --git a/fsw/5020-vxworks7/src/psp.mak b/fsw/5020-vxworks7/src/psp.mak new file mode 100644 index 00000000..4a2eb9bb --- /dev/null +++ b/fsw/5020-vxworks7/src/psp.mak @@ -0,0 +1,49 @@ +############################################################################### +# +# File: psp.mak +# +# Purpose: +# Platform Support Package routines for the RAD750 PowerPC board +# running under vxWorks +# +############################################################################### + +# Subsystem produced by this makefile. +TARGET = psp.o + +#============================================================================== +# Object files required to build subsystem. +#============================================================================== +OBJS = cfe_psp_start.o \ + cfe_psp_support.o \ + cfe_psp_ssr.o \ + cfe_psp_voltab.o \ + cfe_psp_memtab.o \ + cfe_psp_timer.o \ + cfe_psp_watchdog.o \ + cfe_psp_memory.o \ + cfe_psp_exception.o \ + cfe_psp_ram.o \ + cfe_psp_eeprom.o \ + cfe_psp_port.o \ + cfe_psp_memrange.o \ + cfe_psp_memutils.o + +#============================================================================== +# Source files required to build subsystem; used to generate dependencies. +#============================================================================== +SOURCES = cfe_psp_start.c \ + cfe_psp_support.c \ + cfe_psp_ssr.c \ + cfe_psp_voltab.c \ + cfe_psp_memtab.c \ + cfe_psp_timer.c \ + cfe_psp_watchdog.c \ + cfe_psp_memory.c \ + cfe_psp_exception.c \ + cfe_psp_ram.c \ + cfe_psp_eeprom.c \ + cfe_psp_port.c \ + cfe_psp_memrange.c \ + cfe_psp_memutils.c + diff --git a/fsw/pc-linux/src/cfe_psp_exception.c b/fsw/pc-linux/src/cfe_psp_exception.c index fc57b0c9..9c3540d9 100644 --- a/fsw/pc-linux/src/cfe_psp_exception.c +++ b/fsw/pc-linux/src/cfe_psp_exception.c @@ -103,7 +103,7 @@ void CFE_PSP_ExceptionSigHandler (int signo, siginfo_t *si, void *ctxt) clock_gettime(CLOCK_MONOTONIC, &Buffer->context_info.event_time); memcpy(&Buffer->context_info.si, si, sizeof(Buffer->context_info.si)); NumAddrs = backtrace(Buffer->context_info.bt_addrs, CFE_PSP_MAX_EXCEPTION_BACKTRACE_SIZE); - Buffer->context_size = offsetof(CFE_PSP_Exception_ContextDataEntry_t, bt_addrs[NumAddrs]); + Buffer->context_size = (uint32)offsetof(CFE_PSP_Exception_ContextDataEntry_t, bt_addrs[NumAddrs]); /* pthread_self() is signal-safe per POSIX.1-2013 */ Buffer->sys_task_id = pthread_self(); CFE_PSP_Exception_WriteComplete(); diff --git a/fsw/pc-linux/src/cfe_psp_memory.c b/fsw/pc-linux/src/cfe_psp_memory.c index a1414ac7..384fb551 100644 --- a/fsw/pc-linux/src/cfe_psp_memory.c +++ b/fsw/pc-linux/src/cfe_psp_memory.c @@ -365,7 +365,7 @@ void CFE_PSP_InitResetArea(void) * reside in this shared memory segment so it will be preserved on a processor * reset. */ - align_mask = sysconf(_SC_PAGESIZE) - 1; /* align blocks to whole memory pages */ + align_mask = (size_t)(sysconf(_SC_PAGESIZE) - 1); /* align blocks to whole memory pages */ total_size = sizeof(CFE_PSP_LinuxReservedAreaFixedLayout_t); total_size = (total_size + align_mask) & ~align_mask; reset_offset = total_size; @@ -462,7 +462,7 @@ int32 CFE_PSP_GetResetArea (cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) else { *PtrToResetArea = (cpuaddr)CFE_PSP_ReservedMemoryMap.ResetMemory.BlockPtr; - *SizeOfResetArea = CFE_PSP_ReservedMemoryMap.ResetMemory.BlockSize; + *SizeOfResetArea = (uint32)CFE_PSP_ReservedMemoryMap.ResetMemory.BlockSize; return_code = CFE_PSP_SUCCESS; } @@ -578,7 +578,7 @@ int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea else { *PtrToUserArea = (cpuaddr)CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockPtr; - *SizeOfUserArea = CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockSize; + *SizeOfUserArea = (uint32)CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockSize; return_code = CFE_PSP_SUCCESS; } @@ -637,7 +637,7 @@ int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk ) else { *PtrToVolDisk = (cpuaddr)CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockPtr; - *SizeOfVolDisk = CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockSize; + *SizeOfVolDisk = (uint32)CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockSize; return_code = CFE_PSP_SUCCESS; } diff --git a/fsw/pc-linux/src/cfe_psp_start.c b/fsw/pc-linux/src/cfe_psp_start.c index c9202e4c..772a91dc 100644 --- a/fsw/pc-linux/src/cfe_psp_start.c +++ b/fsw/pc-linux/src/cfe_psp_start.c @@ -176,7 +176,7 @@ void OS_Application_Startup(void) ** Process the arguments with getopt_long(), then ** start the cFE */ - argc = OS_BSP_GetArgC(); + argc = (int)OS_BSP_GetArgC(); argv = OS_BSP_GetArgV(); opt = getopt_long( argc, argv, optString, longOpts, &longIndex ); while( opt != -1 ) @@ -200,7 +200,7 @@ void OS_Application_Startup(void) break; case 'S': - CommandData.SubType = strtol(optarg, NULL, 0 ); + CommandData.SubType = (uint32)strtol(optarg, NULL, 0 ); if ( CommandData.SubType < 1 || CommandData.SubType > 5 ) { printf("\nERROR: Invalid Reset SubType: %s\n\n",optarg); @@ -221,13 +221,13 @@ void OS_Application_Startup(void) break; case 'C': - CommandData.CpuId = strtol(optarg, NULL, 0 ); + CommandData.CpuId = (uint32)strtol(optarg, NULL, 0 ); printf("CFE_PSP: CPU ID: %d\n",(int)CommandData.CpuId); CommandData.GotCpuId = 1; break; case 'I': - CommandData.SpacecraftId = strtol(optarg, NULL, 0 ); + CommandData.SpacecraftId = (uint32)strtol(optarg, NULL, 0 ); printf("CFE_PSP: Spacecraft ID: %d\n",(int)CommandData.SpacecraftId); CommandData.GotSpacecraftId = 1; break; diff --git a/fsw/shared/src/cfe_psp_eeprom.c b/fsw/shared/src/cfe_psp_eeprom.c index ec68f7ba..7d5d7736 100644 --- a/fsw/shared/src/cfe_psp_eeprom.c +++ b/fsw/shared/src/cfe_psp_eeprom.c @@ -66,7 +66,7 @@ */ int32 CFE_PSP_EepromWrite32( cpuaddr MemoryAddress, uint32 uint32Value ) { - uint32 ret_value = CFE_PSP_SUCCESS; + int32 ret_value = CFE_PSP_SUCCESS; /* check 32 bit alignment */ if( MemoryAddress & 0x00000003) @@ -105,7 +105,7 @@ int32 CFE_PSP_EepromWrite16( cpuaddr MemoryAddress, uint16 uint16Value ) { uint32 write32; uint32 temp32; - uint32 aligned_address ; + cpuaddr aligned_address ; /* ** check 16 bit alignment , check the 1st lsb @@ -201,7 +201,7 @@ int32 CFE_PSP_EepromWrite16( cpuaddr MemoryAddress, uint16 uint16Value ) int32 CFE_PSP_EepromWrite8( cpuaddr MemoryAddress, uint8 ByteValue ) { - uint32 aligned_address ; + cpuaddr aligned_address ; uint16 write16 ,temp16; temp16 = ByteValue ; @@ -248,7 +248,7 @@ int32 CFE_PSP_EepromWrite8( cpuaddr MemoryAddress, uint8 ByteValue ) */ aligned_address = MemoryAddress - 1; CFE_PSP_MemRead16 ( aligned_address ,&write16) ; - write16 = (write16 & 0xFF00) | ( temp16) ; + write16 = (uint16)((write16 & 0xFF00) | ( temp16)) ; } else { @@ -257,7 +257,7 @@ int32 CFE_PSP_EepromWrite8( cpuaddr MemoryAddress, uint8 ByteValue ) */ aligned_address = MemoryAddress ; CFE_PSP_MemRead16 ( aligned_address, &write16 ) ; - write16 = (temp16 << 8 ) | (write16 & 0x00FF ) ; + write16 = (uint16)((temp16 << 8 ) | (write16 & 0x00FF )) ; } #endif diff --git a/fsw/shared/src/cfe_psp_module.c b/fsw/shared/src/cfe_psp_module.c index 0ef5e3b4..066ec6b9 100644 --- a/fsw/shared/src/cfe_psp_module.c +++ b/fsw/shared/src/cfe_psp_module.c @@ -89,7 +89,7 @@ int32 CFE_PSP_Module_GetAPIEntry(uint32 PspModuleId, CFE_PSP_ModuleApi_t **API) uint32 LocalId; Result = CFE_PSP_INVALID_MODULE_ID; - if ((PspModuleId & ~CFE_PSP_MODULE_INDEX_MASK) == CFE_PSP_MODULE_BASE) + if ((PspModuleId & (uint32)~CFE_PSP_MODULE_INDEX_MASK) == CFE_PSP_MODULE_BASE) { LocalId = PspModuleId & CFE_PSP_MODULE_INDEX_MASK; if (LocalId < CFE_PSP_ModuleCount)