From 4db4fbe56cf8aabaf61d2f572896fd8d4a717970 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 29 Mar 2021 13:34:22 -0400 Subject: [PATCH 1/3] Fix #281, cleanup memory range table A number of cleanup items related to the PSP memory range API - Make the table itself an internal object - should only be accessed via the PSP API. - Update to use size_t instead of uint32 - Update the Linux/RTEMS implementation to use full range (SIZE_MAX). --- fsw/inc/cfe_psp.h | 18 ++----- fsw/inc/cfe_psp_configdata.h | 14 ++---- fsw/mcp750-vxworks/CMakeLists.txt | 5 +- fsw/mcp750-vxworks/src/cfe_psp_memory.c | 5 ++ fsw/mcp750-vxworks/src/cfe_psp_memtab.c | 54 -------------------- fsw/pc-linux/CMakeLists.txt | 5 +- fsw/pc-linux/src/cfe_psp_memory.c | 7 +++ fsw/pc-linux/src/cfe_psp_memtab.c | 55 --------------------- fsw/pc-rtems/CMakeLists.txt | 5 +- fsw/pc-rtems/src/cfe_psp_memory.c | 7 +++ fsw/pc-rtems/src/cfe_psp_memtab.c | 55 --------------------- fsw/shared/inc/cfe_psp_memory.h | 22 +++++++++ fsw/shared/src/cfe_psp_configdata.c | 6 +-- fsw/shared/src/cfe_psp_memrange.c | 65 +++++++++++++------------ ut-stubs/ut_psp_stubs.c | 2 +- 15 files changed, 91 insertions(+), 234 deletions(-) delete mode 100644 fsw/mcp750-vxworks/src/cfe_psp_memtab.c delete mode 100644 fsw/pc-linux/src/cfe_psp_memtab.c delete mode 100644 fsw/pc-rtems/src/cfe_psp_memtab.c diff --git a/fsw/inc/cfe_psp.h b/fsw/inc/cfe_psp.h index 47202913..025e0295 100644 --- a/fsw/inc/cfe_psp.h +++ b/fsw/inc/cfe_psp.h @@ -157,18 +157,6 @@ ** Type Definitions */ -/* -** Memory table type -*/ -typedef struct -{ - uint32 MemoryType; - uint32 WordSize; - cpuaddr StartAddr; - uint32 Size; - uint32 Attributes; -} CFE_PSP_MemTable_t; - /* ** Function prototypes */ @@ -394,11 +382,11 @@ int32 CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value); int32 CFE_PSP_MemCpy(void *dest, const void *src, uint32 n); int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n); -int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType); +int32 CFE_PSP_MemValidateRange(cpuaddr Address, size_t Size, uint32 MemoryType); uint32 CFE_PSP_MemRanges(void); -int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, uint32 Size, uint32 WordSize, +int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, size_t Size, size_t WordSize, uint32 Attributes); -int32 CFE_PSP_MemRangeGet(uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, uint32 *Size, uint32 *WordSize, +int32 CFE_PSP_MemRangeGet(uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, size_t *Size, size_t *WordSize, uint32 *Attributes); int32 CFE_PSP_EepromWrite8(cpuaddr MemoryAddress, uint8 ByteValue); diff --git a/fsw/inc/cfe_psp_configdata.h b/fsw/inc/cfe_psp_configdata.h index c8c446c0..b61f6291 100644 --- a/fsw/inc/cfe_psp_configdata.h +++ b/fsw/inc/cfe_psp_configdata.h @@ -56,11 +56,9 @@ typedef const struct */ typedef const struct { - uint32 PSP_WatchdogMin; /**< PSP Minimum watchdog in milliseconds */ - uint32 PSP_WatchdogMax; /**< PSP Maximum watchdog in milliseconds */ - uint32 PSP_MemTableSize; /**< Size of PSP memory table */ - uint32 PSP_ExceptionLogSize; /**< Size of PSP exception log */ - CFE_PSP_MemTable_t *PSP_MemoryTable; /**< Pointer to PSP memory table (forward reference) */ + uint32 PSP_WatchdogMin; /**< PSP Minimum watchdog in milliseconds */ + uint32 PSP_WatchdogMax; /**< PSP Maximum watchdog in milliseconds */ + uint32 PSP_ExceptionLogSize; /**< Size of PSP exception log */ /** * Number of EEPROM banks on this platform @@ -77,10 +75,4 @@ typedef const struct */ extern Target_PspConfigData GLOBAL_PSP_CONFIGDATA; -/** - * Extern reference to the psp memory table - * Allows the actual instantiation to be done outside this module - */ -extern CFE_PSP_MemTable_t CFE_PSP_MemoryTable[]; - #endif /* CFE_PSP_CONFIG_H_ */ diff --git a/fsw/mcp750-vxworks/CMakeLists.txt b/fsw/mcp750-vxworks/CMakeLists.txt index 1b6972fa..ecff8a65 100644 --- a/fsw/mcp750-vxworks/CMakeLists.txt +++ b/fsw/mcp750-vxworks/CMakeLists.txt @@ -4,14 +4,13 @@ # ###################################################################### -# This contains the fully platform-specific code to +# This contains the fully platform-specific code to # run CFE on this target. # Build the mcp750-vxworks implementation as a library add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT src/cfe_psp_exception.c src/cfe_psp_memory.c - src/cfe_psp_memtab.c src/cfe_psp_ssr.c src/cfe_psp_start.c src/cfe_psp_support.c @@ -22,7 +21,7 @@ target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME}-impl PRIVATE $ ) -target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE +target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE inc $ ) diff --git a/fsw/mcp750-vxworks/src/cfe_psp_memory.c b/fsw/mcp750-vxworks/src/cfe_psp_memory.c index 6af794c5..31795876 100644 --- a/fsw/mcp750-vxworks/src/cfe_psp_memory.c +++ b/fsw/mcp750-vxworks/src/cfe_psp_memory.c @@ -408,6 +408,11 @@ void CFE_PSP_SetupReservedMemoryMap(void) OS_printf("CFE_PSP: MCP750 Reserved Memory Block at 0x%08lx, Total Size = 0x%lx\n", (unsigned long)MCP750_ReservedMemBlock.BlockPtr, (unsigned long)MCP750_ReservedMemBlock.BlockSize); + + /* + * Set up the "RAM" entry in the memory table. + */ + CFE_PSP_MemRangeSet(0, CFE_PSP_MEM_RAM, 0, 0x8000000, CFE_PSP_MEM_SIZE_DWORD, CFE_PSP_MEM_ATTR_READWRITE); } /****************************************************************************** diff --git a/fsw/mcp750-vxworks/src/cfe_psp_memtab.c b/fsw/mcp750-vxworks/src/cfe_psp_memtab.c deleted file mode 100644 index ca04fab2..00000000 --- a/fsw/mcp750-vxworks/src/cfe_psp_memtab.c +++ /dev/null @@ -1,54 +0,0 @@ -/* -** 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_memtab.c -** -** Author : Alan Cudmore -** -** Purpose: -** -** -*/ - -/* -** 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, 0x8000000, 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/pc-linux/CMakeLists.txt b/fsw/pc-linux/CMakeLists.txt index 5918683d..88efd031 100644 --- a/fsw/pc-linux/CMakeLists.txt +++ b/fsw/pc-linux/CMakeLists.txt @@ -4,14 +4,13 @@ # ###################################################################### -# This contains the fully platform-specific code to +# This contains the fully platform-specific code to # run CFE on this target. # Build the pc-linux implementation as a library add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT src/cfe_psp_exception.c src/cfe_psp_memory.c - src/cfe_psp_memtab.c src/cfe_psp_ssr.c src/cfe_psp_start.c src/cfe_psp_support.c @@ -26,7 +25,7 @@ target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME}-impl PRIVATE $ ) -target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE +target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE inc $ ) diff --git a/fsw/pc-linux/src/cfe_psp_memory.c b/fsw/pc-linux/src/cfe_psp_memory.c index 5c9ddc2f..8a2325f6 100644 --- a/fsw/pc-linux/src/cfe_psp_memory.c +++ b/fsw/pc-linux/src/cfe_psp_memory.c @@ -674,6 +674,13 @@ void CFE_PSP_SetupReservedMemoryMap(void) CFE_PSP_InitResetArea(); CFE_PSP_InitVolatileDiskMem(); CFE_PSP_InitUserReservedArea(); + + /* + * Set up the "RAM" entry in the memory table. + * On Linux this is just encompasses the entire memory space, but an entry needs + * to exist so that CFE_PSP_ValidateMemRange() works as intended. + */ + CFE_PSP_MemRangeSet(0, CFE_PSP_MEM_RAM, 0, SIZE_MAX, CFE_PSP_MEM_SIZE_DWORD, CFE_PSP_MEM_ATTR_READWRITE); } int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType) diff --git a/fsw/pc-linux/src/cfe_psp_memtab.c b/fsw/pc-linux/src/cfe_psp_memtab.c deleted file mode 100644 index af22651b..00000000 --- a/fsw/pc-linux/src/cfe_psp_memtab.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -** 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_memtab.c -** -** Author : Alan Cudmore -** -** Purpose: Memory Range Table for cFE/PSP. -** -** -*/ - -/* -** Includes -*/ - -#include "common_types.h" -#include "osapi.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, 0xFFFFFFFF, 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/pc-rtems/CMakeLists.txt b/fsw/pc-rtems/CMakeLists.txt index 4d55fffc..98a963a9 100644 --- a/fsw/pc-rtems/CMakeLists.txt +++ b/fsw/pc-rtems/CMakeLists.txt @@ -4,14 +4,13 @@ # ###################################################################### -# This contains the fully platform-specific code to +# This contains the fully platform-specific code to # run CFE on this target. # Build the pc-rtems implementation as a library add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT src/cfe_psp_exception.c src/cfe_psp_memory.c - src/cfe_psp_memtab.c src/cfe_psp_ssr.c src/cfe_psp_start.c src/cfe_psp_support.c @@ -23,7 +22,7 @@ target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME}-impl PRIVATE $ ) -target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE +target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE inc $ ) diff --git a/fsw/pc-rtems/src/cfe_psp_memory.c b/fsw/pc-rtems/src/cfe_psp_memory.c index 559e1a2a..c8cc16fe 100644 --- a/fsw/pc-rtems/src/cfe_psp_memory.c +++ b/fsw/pc-rtems/src/cfe_psp_memory.c @@ -418,6 +418,13 @@ void CFE_PSP_SetupReservedMemoryMap(void) * (prefer this over removing the increment, as it is safer if another block is added) */ OS_printf("CFE_PSP: PSP reserved memory ends at: 0x%08lX\n", (unsigned long)ReservedMemoryAddr); + + /* + * Set up the "RAM" entry in the memory table. + * On RTEMS this is just encompasses the entire memory space, but an entry needs + * to exist so that CFE_PSP_ValidateMemRange() works as intended. + */ + CFE_PSP_MemRangeSet(0, CFE_PSP_MEM_RAM, 0, SIZE_MAX, CFE_PSP_MEM_SIZE_DWORD, CFE_PSP_MEM_ATTR_READWRITE); } /****************************************************************************** diff --git a/fsw/pc-rtems/src/cfe_psp_memtab.c b/fsw/pc-rtems/src/cfe_psp_memtab.c deleted file mode 100644 index af22651b..00000000 --- a/fsw/pc-rtems/src/cfe_psp_memtab.c +++ /dev/null @@ -1,55 +0,0 @@ -/* -** 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_memtab.c -** -** Author : Alan Cudmore -** -** Purpose: Memory Range Table for cFE/PSP. -** -** -*/ - -/* -** Includes -*/ - -#include "common_types.h" -#include "osapi.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, 0xFFFFFFFF, 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/shared/inc/cfe_psp_memory.h b/fsw/shared/inc/cfe_psp_memory.h index 602340ce..77559216 100644 --- a/fsw/shared/inc/cfe_psp_memory.h +++ b/fsw/shared/inc/cfe_psp_memory.h @@ -42,6 +42,18 @@ #include "cfe_psp_config.h" #include "cfe_psp_exceptionstorage_types.h" +/* +** Memory table type +*/ +typedef struct +{ + uint32 MemoryType; + size_t WordSize; + cpuaddr StartAddr; + size_t Size; + uint32 Attributes; +} CFE_PSP_MemTable_t; + typedef struct { void * BlockPtr; @@ -58,6 +70,16 @@ typedef struct CFE_PSP_MemoryBlock_t VolatileDiskMemory; CFE_PSP_MemoryBlock_t CDSMemory; CFE_PSP_MemoryBlock_t UserReservedMemory; + + /** + * \brief The system memory table + * + * This is the table used for CFE_PSP_MemRangeGet/Set and related ops + * that allow CFE applications to query the general system memory map. + */ + + CFE_PSP_MemTable_t SysMemoryTable[CFE_PSP_MEM_TABLE_SIZE]; + } CFE_PSP_ReservedMemoryMap_t; /** diff --git a/fsw/shared/src/cfe_psp_configdata.c b/fsw/shared/src/cfe_psp_configdata.c index 4153b588..82f5d322 100644 --- a/fsw/shared/src/cfe_psp_configdata.c +++ b/fsw/shared/src/cfe_psp_configdata.c @@ -38,10 +38,8 @@ * code such as CFE core or apps would not be able to \#include the * PSP cfe_psp_config.h or psp_version.h files */ -Target_PspConfigData GLOBAL_PSP_CONFIGDATA = {.PSP_WatchdogMin = CFE_PSP_WATCHDOG_MIN, - .PSP_WatchdogMax = CFE_PSP_WATCHDOG_MAX, - .PSP_MemTableSize = CFE_PSP_MEM_TABLE_SIZE, - .PSP_MemoryTable = CFE_PSP_MemoryTable, +Target_PspConfigData GLOBAL_PSP_CONFIGDATA = {.PSP_WatchdogMin = CFE_PSP_WATCHDOG_MIN, + .PSP_WatchdogMax = CFE_PSP_WATCHDOG_MAX, .HW_NumEepromBanks = CFE_PSP_NUM_EEPROM_BANKS, diff --git a/fsw/shared/src/cfe_psp_memrange.c b/fsw/shared/src/cfe_psp_memrange.c index 8ddd7800..ac8a2898 100644 --- a/fsw/shared/src/cfe_psp_memrange.c +++ b/fsw/shared/src/cfe_psp_memrange.c @@ -35,12 +35,7 @@ */ #include "cfe_psp.h" - -/* - * The "extern" declaration for the MemRange table is in the configdata header - */ -#include "cfe_psp_config.h" -#include "cfe_psp_configdata.h" +#include "cfe_psp_memory.h" /* ** Name: CFE_PSP_MemValidateRange @@ -68,15 +63,16 @@ ** CFE_PSP_INVALID_MEM_RANGE -- The Memory range associated with the address is not large enough to contain ** Address + Size. */ -int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) +int32 CFE_PSP_MemValidateRange(cpuaddr Address, size_t Size, uint32 MemoryType) { - cpuaddr StartAddressToTest = Address; - cpuaddr EndAddressToTest = Address + Size - 1; - cpuaddr StartAddressInTable; - cpuaddr EndAddressInTable; - uint32 TypeInTable; - int32 ReturnCode = CFE_PSP_INVALID_MEM_ADDR; - uint32 i; + cpuaddr StartAddressToTest = Address; + cpuaddr EndAddressToTest = Address + Size - 1; + cpuaddr StartAddressInTable; + cpuaddr EndAddressInTable; + uint32 TypeInTable; + int32 ReturnCode = CFE_PSP_INVALID_MEM_ADDR; + size_t i; + CFE_PSP_MemTable_t *SysMemPtr; /* ** Before searching table, do a preliminary parameter validation @@ -91,16 +87,17 @@ int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) return (CFE_PSP_INVALID_MEM_RANGE); } + SysMemPtr = CFE_PSP_ReservedMemoryMap.SysMemoryTable; for (i = 0; i < CFE_PSP_MEM_TABLE_SIZE; i++) { /* ** Only look at valid memory table entries */ - if (CFE_PSP_MemoryTable[i].MemoryType != CFE_PSP_MEM_INVALID) + if (SysMemPtr->MemoryType != CFE_PSP_MEM_INVALID) { - StartAddressInTable = CFE_PSP_MemoryTable[i].StartAddr; - EndAddressInTable = CFE_PSP_MemoryTable[i].StartAddr + CFE_PSP_MemoryTable[i].Size - 1; - TypeInTable = CFE_PSP_MemoryTable[i].MemoryType; + StartAddressInTable = SysMemPtr->StartAddr; + EndAddressInTable = SysMemPtr->StartAddr + SysMemPtr->Size - 1; + TypeInTable = SysMemPtr->MemoryType; /* ** Step 1: Get the Address to Fit within the range @@ -152,6 +149,8 @@ int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) } } /* End if MemoryType != CFE_PSP_MEM_INVALID */ + ++SysMemPtr; + } /* End for */ return (ReturnCode); } @@ -215,9 +214,10 @@ uint32 CFE_PSP_MemRanges(void) ** CFE_PSP_INVALID_MEM_WORDSIZE -- The WordSIze parameter is not one of the predefined types. ** CFE_PSP_INVALID_MEM_ATTR -- The Attributes parameter is not one of the predefined types. */ -int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, uint32 Size, uint32 WordSize, +int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, size_t Size, size_t WordSize, uint32 Attributes) { + CFE_PSP_MemTable_t *SysMemPtr; if (RangeNum >= CFE_PSP_MEM_TABLE_SIZE) { @@ -244,11 +244,13 @@ int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, /* ** Parameters check out, add the range */ - CFE_PSP_MemoryTable[RangeNum].MemoryType = MemoryType; - CFE_PSP_MemoryTable[RangeNum].StartAddr = StartAddr; - CFE_PSP_MemoryTable[RangeNum].Size = Size; - CFE_PSP_MemoryTable[RangeNum].WordSize = WordSize; - CFE_PSP_MemoryTable[RangeNum].Attributes = Attributes; + SysMemPtr = &CFE_PSP_ReservedMemoryMap.SysMemoryTable[RangeNum]; + + SysMemPtr->MemoryType = MemoryType; + SysMemPtr->StartAddr = StartAddr; + SysMemPtr->Size = Size; + SysMemPtr->WordSize = WordSize; + SysMemPtr->Attributes = Attributes; return (CFE_PSP_SUCCESS); } @@ -284,9 +286,10 @@ int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, ** CFE_PSP_INVALID_POINTER -- Parameter error ** CFE_PSP_INVALID_MEM_RANGE -- The index into the table is invalid */ -int32 CFE_PSP_MemRangeGet(uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, uint32 *Size, uint32 *WordSize, +int32 CFE_PSP_MemRangeGet(uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, size_t *Size, size_t *WordSize, uint32 *Attributes) { + CFE_PSP_MemTable_t *SysMemPtr; if (MemoryType == NULL || StartAddr == NULL || Size == NULL || WordSize == NULL || Attributes == NULL) { @@ -298,11 +301,13 @@ int32 CFE_PSP_MemRangeGet(uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAdd return (CFE_PSP_INVALID_MEM_RANGE); } - *MemoryType = CFE_PSP_MemoryTable[RangeNum].MemoryType; - *StartAddr = CFE_PSP_MemoryTable[RangeNum].StartAddr; - *Size = CFE_PSP_MemoryTable[RangeNum].Size; - *WordSize = CFE_PSP_MemoryTable[RangeNum].WordSize; - *Attributes = CFE_PSP_MemoryTable[RangeNum].Attributes; + SysMemPtr = &CFE_PSP_ReservedMemoryMap.SysMemoryTable[RangeNum]; + + *MemoryType = SysMemPtr->MemoryType; + *StartAddr = SysMemPtr->StartAddr; + *Size = SysMemPtr->Size; + *WordSize = SysMemPtr->WordSize; + *Attributes = SysMemPtr->Attributes; return (CFE_PSP_SUCCESS); } diff --git a/ut-stubs/ut_psp_stubs.c b/ut-stubs/ut_psp_stubs.c index b4369008..50b0888a 100644 --- a/ut-stubs/ut_psp_stubs.c +++ b/ut-stubs/ut_psp_stubs.c @@ -625,7 +625,7 @@ int32 CFE_PSP_MemRead8(cpuaddr Address, uint8 *Data) ** Returns either a user-defined status flag or OS_SUCCESS. ** ******************************************************************************/ -int32 CFE_PSP_MemValidateRange(cpuaddr Address, uint32 Size, uint32 MemoryType) +int32 CFE_PSP_MemValidateRange(cpuaddr Address, size_t Size, uint32 MemoryType) { int32 status; From a6c07e1a80beea0fd2ade17d5377e405d2e42185 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 29 Mar 2021 13:51:01 -0400 Subject: [PATCH 2/3] Fix #280, remove psp configdata global object This global config structure is not really necessary. The original intent was to allow dependents (e.g. CFE) to get vars at runtime but keep them stored within PSP. However for all those cases where CFE needs PSP info, an API function is defined to get the info. There should not be any need to read this variable directly. --- fsw/inc/cfe_psp.h | 7 -- fsw/inc/cfe_psp_configdata.h | 86 ------------------- fsw/mcp750-vxworks/inc/psp_version.h | 2 + fsw/pc-linux/inc/psp_version.h | 2 + fsw/pc-rtems/inc/psp_version.h | 2 + fsw/shared/CMakeLists.txt | 1 - fsw/shared/src/cfe_psp_configdata.c | 52 ----------- fsw/shared/src/cfe_psp_module.c | 1 - fsw/shared/src/cfe_psp_version.c | 16 ++-- .../ut-stubs/src/cfe-configdata-stubs.c | 3 +- ut-stubs/ut_psp_stubs.c | 4 +- 11 files changed, 16 insertions(+), 160 deletions(-) delete mode 100644 fsw/inc/cfe_psp_configdata.h delete mode 100644 fsw/shared/src/cfe_psp_configdata.c diff --git a/fsw/inc/cfe_psp.h b/fsw/inc/cfe_psp.h index 47202913..8826d259 100644 --- a/fsw/inc/cfe_psp.h +++ b/fsw/inc/cfe_psp.h @@ -146,13 +146,6 @@ #define CFE_PSP_RST_SUBTYPE_MAX 10 /** \} */ -/* Implement the "version" macros */ -#define CFE_PSP_MAJOR_VERSION (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MajorVersion) -#define CFE_PSP_MINOR_VERSION (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MinorVersion) -#define CFE_PSP_REVISION (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.Revision) -#define CFE_PSP_MISSION_REV (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MissionRev) -#define CFE_PSP_VERSION (GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.VersionString) - /* ** Type Definitions */ diff --git a/fsw/inc/cfe_psp_configdata.h b/fsw/inc/cfe_psp_configdata.h deleted file mode 100644 index c8c446c0..00000000 --- a/fsw/inc/cfe_psp_configdata.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -** 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_configdata.h - * - * Created on: Dec 31, 2014 - * Author: joseph.p.hickey@nasa.gov - */ - -#ifndef CFE_PSP_CONFIG_H_ -#define CFE_PSP_CONFIG_H_ - -/* osapi.h is required for the definition of OS_VolumeInto_t */ -#include "osapi.h" -/* cfe_psp.h is required for the definition of CFE_PSP_MemTable_t */ -#include "cfe_psp.h" - -/* -** PSP software version record -** (replaces PSP_*_VERSION macros) -*/ -typedef const struct -{ - uint8 MajorVersion; - uint8 MinorVersion; - uint8 Revision; - uint8 MissionRev; - const char *VersionString; /**< The simple semantic version identifier */ - const char *VersionCodeName; /**< Cross-module compatiblity indicator */ - uint32 BuildNumber; -} CFE_PSP_VersionInfo_t; - -/** - * PSP/Hardware configuration parameters - * This structure should be instantiated by the PSP according - * such that other modules do not need to directly include - * the PSP configuration at compile time. - */ -typedef const struct -{ - uint32 PSP_WatchdogMin; /**< PSP Minimum watchdog in milliseconds */ - uint32 PSP_WatchdogMax; /**< PSP Maximum watchdog in milliseconds */ - uint32 PSP_MemTableSize; /**< Size of PSP memory table */ - uint32 PSP_ExceptionLogSize; /**< Size of PSP exception log */ - CFE_PSP_MemTable_t *PSP_MemoryTable; /**< Pointer to PSP memory table (forward reference) */ - - /** - * Number of EEPROM banks on this platform - */ - uint32 HW_NumEepromBanks; - - CFE_PSP_VersionInfo_t PSP_VersionInfo; - -} Target_PspConfigData; - -/** - * Extern reference to psp config struct. - * Allows the actual instantiation to be done outside this module - */ -extern Target_PspConfigData GLOBAL_PSP_CONFIGDATA; - -/** - * Extern reference to the psp memory table - * Allows the actual instantiation to be done outside this module - */ -extern CFE_PSP_MemTable_t CFE_PSP_MemoryTable[]; - -#endif /* CFE_PSP_CONFIG_H_ */ diff --git a/fsw/mcp750-vxworks/inc/psp_version.h b/fsw/mcp750-vxworks/inc/psp_version.h index 1787761c..4ffb025c 100644 --- a/fsw/mcp750-vxworks/inc/psp_version.h +++ b/fsw/mcp750-vxworks/inc/psp_version.h @@ -42,6 +42,8 @@ 99 /*!< @brief ONLY APPLY for OFFICIAL releases. Revision version number. A value of "99" indicates an unreleased \ development version. */ +#define CFE_PSP_IMPL_CODENAME "Bootes" + /* * Tools to construct version string */ diff --git a/fsw/pc-linux/inc/psp_version.h b/fsw/pc-linux/inc/psp_version.h index c6838ee1..56373630 100644 --- a/fsw/pc-linux/inc/psp_version.h +++ b/fsw/pc-linux/inc/psp_version.h @@ -42,6 +42,8 @@ 99 /*!< @brief ONLY APPLY for OFFICIAL releases. Revision version number. A value of "99" indicates an unreleased \ development version. */ +#define CFE_PSP_IMPL_CODENAME "Bootes" + /* * Tools to construct version string */ diff --git a/fsw/pc-rtems/inc/psp_version.h b/fsw/pc-rtems/inc/psp_version.h index 45623afd..c1753330 100644 --- a/fsw/pc-rtems/inc/psp_version.h +++ b/fsw/pc-rtems/inc/psp_version.h @@ -42,6 +42,8 @@ 99 /*!< @brief ONLY APPLY for OFFICIAL releases. Revision version number. A value of "99" indicates an unreleased \ development version. */ +#define CFE_PSP_IMPL_CODENAME "Bootes" + /* * Tools to construct version string */ diff --git a/fsw/shared/CMakeLists.txt b/fsw/shared/CMakeLists.txt index b977467c..8cb560d9 100644 --- a/fsw/shared/CMakeLists.txt +++ b/fsw/shared/CMakeLists.txt @@ -13,7 +13,6 @@ # Build the shared implementation as a library add_library(psp-${CFE_PSP_TARGETNAME}-shared OBJECT - src/cfe_psp_configdata.c src/cfe_psp_exceptionstorage.c src/cfe_psp_memrange.c src/cfe_psp_memutils.c diff --git a/fsw/shared/src/cfe_psp_configdata.c b/fsw/shared/src/cfe_psp_configdata.c deleted file mode 100644 index 4153b588..00000000 --- a/fsw/shared/src/cfe_psp_configdata.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -** 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_configdata.c - * - * Created on: Dec 31, 2014 - * Author: joseph.p.hickey@nasa.gov - */ - -#include "cfe_psp.h" -#include "cfe_psp_config.h" -#include "psp_version.h" -#include "cfe_psp_configdata.h" - -/** - * Instantiation of the PSP/HW configuration data - * - * Because this is compiled within the context of the PSP code, - * this can access the internal PSP macros directly. External - * code such as CFE core or apps would not be able to \#include the - * PSP cfe_psp_config.h or psp_version.h files - */ -Target_PspConfigData GLOBAL_PSP_CONFIGDATA = {.PSP_WatchdogMin = CFE_PSP_WATCHDOG_MIN, - .PSP_WatchdogMax = CFE_PSP_WATCHDOG_MAX, - .PSP_MemTableSize = CFE_PSP_MEM_TABLE_SIZE, - .PSP_MemoryTable = CFE_PSP_MemoryTable, - - .HW_NumEepromBanks = CFE_PSP_NUM_EEPROM_BANKS, - - .PSP_VersionInfo = {.MajorVersion = CFE_PSP_IMPL_MAJOR_VERSION, - .MinorVersion = CFE_PSP_IMPL_MINOR_VERSION, - .Revision = CFE_PSP_IMPL_REVISION, - .MissionRev = CFE_PSP_IMPL_MISSION_REV, - .VersionString = CFE_PSP_IMPL_VERSION}}; diff --git a/fsw/shared/src/cfe_psp_module.c b/fsw/shared/src/cfe_psp_module.c index 1e4ede8d..adc18174 100644 --- a/fsw/shared/src/cfe_psp_module.c +++ b/fsw/shared/src/cfe_psp_module.c @@ -29,7 +29,6 @@ #include #include "osapi.h" -#include "cfe_psp_configdata.h" #include "cfe_psp_module.h" /* diff --git a/fsw/shared/src/cfe_psp_version.c b/fsw/shared/src/cfe_psp_version.c index 39c11b39..c8f3f72f 100644 --- a/fsw/shared/src/cfe_psp_version.c +++ b/fsw/shared/src/cfe_psp_version.c @@ -25,7 +25,7 @@ */ #include "cfe_psp.h" -#include "cfe_psp_configdata.h" +#include "psp_version.h" /*---------------------------------------------------------------- * @@ -37,7 +37,7 @@ *-----------------------------------------------------------------*/ const char *CFE_PSP_GetVersionString(void) { - return GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.VersionString; + return CFE_PSP_IMPL_VERSION; } /*---------------------------------------------------------------- @@ -50,7 +50,7 @@ const char *CFE_PSP_GetVersionString(void) *-----------------------------------------------------------------*/ const char *CFE_PSP_GetVersionCodeName(void) { - return GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.VersionCodeName; + return CFE_PSP_IMPL_CODENAME; } /*---------------------------------------------------------------- @@ -63,10 +63,10 @@ const char *CFE_PSP_GetVersionCodeName(void) *-----------------------------------------------------------------*/ void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4]) { - VersionNumbers[0] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MajorVersion; - VersionNumbers[1] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MinorVersion; - VersionNumbers[2] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.Revision; - VersionNumbers[3] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MissionRev; + VersionNumbers[0] = CFE_PSP_IMPL_MAJOR_VERSION; + VersionNumbers[1] = CFE_PSP_IMPL_MINOR_VERSION; + VersionNumbers[2] = CFE_PSP_IMPL_REVISION; + VersionNumbers[3] = CFE_PSP_IMPL_MISSION_REV; } /*---------------------------------------------------------------- @@ -79,5 +79,5 @@ void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4]) *-----------------------------------------------------------------*/ uint32 CFE_PSP_GetBuildNumber(void) { - return GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.BuildNumber; + return CFE_PSP_IMPL_BUILD_NUMBER; } diff --git a/unit-test-coverage/ut-stubs/src/cfe-configdata-stubs.c b/unit-test-coverage/ut-stubs/src/cfe-configdata-stubs.c index 315bc3c7..679baba6 100644 --- a/unit-test-coverage/ut-stubs/src/cfe-configdata-stubs.c +++ b/unit-test-coverage/ut-stubs/src/cfe-configdata-stubs.c @@ -47,8 +47,7 @@ Target_ConfigData GLOBAL_CONFIGDATA = {.MissionVersion = PCS_CONFIG_MISSIO .Default_CpuName = PCS_CONFIG_CPUNAME, .Default_CpuId = PCS_CONFIG_CPUNUMBER, .Default_SpacecraftId = PCS_CONFIG_SPACECRAFT, - .CfeConfig = &GLOBAL_CFE_CONFIGDATA, - .PspConfig = &GLOBAL_PSP_CONFIGDATA}; + .CfeConfig = &GLOBAL_CFE_CONFIGDATA}; /** * Stub for the main system entry function implemented in CFE ES diff --git a/ut-stubs/ut_psp_stubs.c b/ut-stubs/ut_psp_stubs.c index b4369008..8bdc3531 100644 --- a/ut-stubs/ut_psp_stubs.c +++ b/ut-stubs/ut_psp_stubs.c @@ -39,7 +39,6 @@ #include "target_config.h" -Target_PspConfigData GLOBAL_PSP_CONFIGDATA = {0}; Target_CfeConfigData GLOBAL_CFE_CONFIGDATA = {0}; /** @@ -57,8 +56,7 @@ Target_ConfigData GLOBAL_CONFIGDATA = {.MissionVersion = "MissionUnitTest" .Default_CpuName = "UnitTestCpu", .Default_CpuId = 1, .Default_SpacecraftId = 0x42, - .CfeConfig = &GLOBAL_CFE_CONFIGDATA, - .PspConfig = &GLOBAL_PSP_CONFIGDATA}; + .CfeConfig = &GLOBAL_CFE_CONFIGDATA}; /* ** Functions From 7acd39aa3c17fb2e118250f8e77910349318a229 Mon Sep 17 00:00:00 2001 From: "Gerardo E. Cruz-Ortiz" <59618057+astrogeco@users.noreply.github.com> Date: Fri, 2 Apr 2021 18:24:26 -0400 Subject: [PATCH 3/3] IC:2021-04-02, Bump to v1.5.0-rc1+dev101 --- README.md | 7 +++++++ fsw/mcp750-vxworks/inc/psp_version.h | 2 +- fsw/pc-linux/inc/psp_version.h | 2 +- fsw/pc-rtems/inc/psp_version.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 96181f47..69691f83 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,13 @@ This is a collection of APIs abstracting platform specific functionality to be l ## Version History +### Development Build: v1.5.0-rc1+dev101 + +- Removes unnecessary global config structure `Target_PspConfigData` and associated elements infavor of the new version API. +- The mem pool stats TLM command now works on 64-bit Linux and sends out the expected telemetry packet. +Converts `CFE_PSP_MemoryTable` to internal object (instead of external) that should only be accessed via the PSP API. Replace `uint32`s with `size_t`. Use full range (SIZE_MAX) in the Linux/RTEMS implementation. +- See and + ### Development Build: v1.5.0-rc1+dev95 - Includes `cfe_psp_version.c` in the cmake source list, which was mistakenly omitted previously. diff --git a/fsw/mcp750-vxworks/inc/psp_version.h b/fsw/mcp750-vxworks/inc/psp_version.h index b7699902..d6608424 100644 --- a/fsw/mcp750-vxworks/inc/psp_version.h +++ b/fsw/mcp750-vxworks/inc/psp_version.h @@ -29,7 +29,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 95 +#define CFE_PSP_IMPL_BUILD_NUMBER 101 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.5.0-rc1" /* diff --git a/fsw/pc-linux/inc/psp_version.h b/fsw/pc-linux/inc/psp_version.h index 2368c0e3..07441680 100644 --- a/fsw/pc-linux/inc/psp_version.h +++ b/fsw/pc-linux/inc/psp_version.h @@ -29,7 +29,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 95 +#define CFE_PSP_IMPL_BUILD_NUMBER 101 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.5.0-rc1" /* diff --git a/fsw/pc-rtems/inc/psp_version.h b/fsw/pc-rtems/inc/psp_version.h index 5efabd53..9ef4cf8f 100644 --- a/fsw/pc-rtems/inc/psp_version.h +++ b/fsw/pc-rtems/inc/psp_version.h @@ -29,7 +29,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 95 +#define CFE_PSP_IMPL_BUILD_NUMBER 101 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.5.0-rc1" /*