Skip to content

Commit

Permalink
Fix #281, cleanup memory range table
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
jphickey committed Mar 29, 2021
1 parent 73366d4 commit 94f104b
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 234 deletions.
18 changes: 3 additions & 15 deletions fsw/inc/cfe_psp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 3 additions & 11 deletions fsw/inc/cfe_psp_configdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_ */
5 changes: 2 additions & 3 deletions fsw/mcp750-vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,7 +21,7 @@ target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME}-impl PRIVATE
$<TARGET_PROPERTY:psp_module_api,INTERFACE_COMPILE_DEFINITIONS>
)

target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE
target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE
inc
$<TARGET_PROPERTY:psp_module_api,INTERFACE_INCLUDE_DIRECTORIES>
)
Expand Down
5 changes: 5 additions & 0 deletions fsw/mcp750-vxworks/src/cfe_psp_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/******************************************************************************
Expand Down
54 changes: 0 additions & 54 deletions fsw/mcp750-vxworks/src/cfe_psp_memtab.c

This file was deleted.

5 changes: 2 additions & 3 deletions fsw/pc-linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,7 +25,7 @@ target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME}-impl PRIVATE
$<TARGET_PROPERTY:psp_module_api,INTERFACE_COMPILE_DEFINITIONS>
)

target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE
target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE
inc
$<TARGET_PROPERTY:psp_module_api,INTERFACE_INCLUDE_DIRECTORIES>
)
Expand Down
8 changes: 8 additions & 0 deletions fsw/pc-linux/src/cfe_psp_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,14 @@ 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)
Expand Down
55 changes: 0 additions & 55 deletions fsw/pc-linux/src/cfe_psp_memtab.c

This file was deleted.

5 changes: 2 additions & 3 deletions fsw/pc-rtems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,7 +22,7 @@ target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME}-impl PRIVATE
$<TARGET_PROPERTY:psp_module_api,INTERFACE_COMPILE_DEFINITIONS>
)

target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE
target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE
inc
$<TARGET_PROPERTY:psp_module_api,INTERFACE_INCLUDE_DIRECTORIES>
)
Expand Down
7 changes: 7 additions & 0 deletions fsw/pc-rtems/src/cfe_psp_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/******************************************************************************
Expand Down
55 changes: 0 additions & 55 deletions fsw/pc-rtems/src/cfe_psp_memtab.c

This file was deleted.

22 changes: 22 additions & 0 deletions fsw/shared/inc/cfe_psp_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down
6 changes: 2 additions & 4 deletions fsw/shared/src/cfe_psp_configdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
Loading

0 comments on commit 94f104b

Please sign in to comment.