Skip to content

Commit

Permalink
Merge pull request #283 from jphickey/fix-281-memrange-cleanup
Browse files Browse the repository at this point in the history
Fix #281, cleanup memory range table
  • Loading branch information
jphickey committed Apr 2, 2021
2 parents 511392c + 4db4fbe commit 54083e1
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 219 deletions.
18 changes: 3 additions & 15 deletions fsw/inc/cfe_psp.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,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 @@ -387,11 +375,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
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
7 changes: 7 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,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)
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
Loading

0 comments on commit 54083e1

Please sign in to comment.