From 4db4fbe56cf8aabaf61d2f572896fd8d4a717970 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 29 Mar 2021 13:34:22 -0400 Subject: [PATCH] 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;