Skip to content

Commit 3ab3600

Browse files
committed
Fix #263, basic proof of concept for selectable eeprom implementation
1 parent 0ccebed commit 3ab3600

File tree

13 files changed

+84
-9
lines changed

13 files changed

+84
-9
lines changed

CMakeLists.txt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,44 @@ target_compile_definitions(psp_module_api INTERFACE
2121
target_include_directories(psp_module_api INTERFACE
2222
fsw/inc # public API
2323
fsw/shared/inc # all PSP shared headers
24+
${CMAKE_CURRENT_LIST_DIR}/fsw/${CFE_PSP_TARGETNAME}/inc # platform-specific headers
2425
${CFE_SOURCE_DIR}/cmake/target/inc # for sysconfig
2526
$<TARGET_PROPERTY:osal,INTERFACE_INCLUDE_DIRECTORIES> # use headers from OSAL
2627
)
2728

29+
# Translate the CFE_PSP_TARGETNAME to a set of additional modules to build
30+
file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/fsw/${CFE_PSP_TARGETNAME}/psp_module_list.cmake" PSP_TARGET_MODULE_LIST REGEX "^[a-zA-Z]")
2831

29-
# The PSP is currently built in two parts, consisting of a fully platform-specific
30-
# module combined with a shared component which is built for multiple targets.
32+
# The PSP is currently built in modular parts, consisting of a platform-specific
33+
# module(s) combined with a shared component which is built for multiple targets.
3134
# The "shared" component is compiled using headers from the platform-specific module
3235
# so it is still ultimately a platform-specific binary, and it all gets wrapped into
3336
# a single PSP static library target.
3437
add_subdirectory(fsw/${CFE_PSP_TARGETNAME} ${CFE_PSP_TARGETNAME}-impl)
3538
add_subdirectory(fsw/shared ${CFE_PSP_TARGETNAME}-shared)
3639

40+
# Generate a list of PSP modules along with a pointer to its API structure/entry point
41+
set(GENERATED_EXTERNS)
42+
set(GENERATED_KEYVALS)
43+
foreach(PSPMOD ${PSP_TARGET_MODULE_LIST})
44+
add_subdirectory(fsw/modules/${PSPMOD} ${PSPMOD}-${CFE_PSP_TARGETNAME}-impl)
45+
list(APPEND GENERATED_EXTERNS "extern CFE_PSP_ModuleApi_t CFE_PSP_${PSPMOD}_API;\n")
46+
list(APPEND GENERATED_KEYVALS "{ .Name = \"${PSPMOD}\", .Api = &CFE_PSP_${PSPMOD}_API },\n")
47+
endforeach()
48+
49+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/module_list.c.in ${CMAKE_CURRENT_BINARY_DIR}/${CFE_PSP_TARGETNAME}_module_list.c @ONLY)
50+
3751
add_library(psp-${CFE_PSP_TARGETNAME} STATIC
52+
${CMAKE_CURRENT_BINARY_DIR}/${CFE_PSP_TARGETNAME}_module_list.c
3853
$<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME}-shared>
3954
$<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME}-impl>
4055
)
56+
target_link_libraries(psp-${CFE_PSP_TARGETNAME} PUBLIC
57+
${PSP_TARGET_MODULE_LIST}
58+
)
59+
target_link_libraries(psp-${CFE_PSP_TARGETNAME} PRIVATE
60+
psp_module_api
61+
)
4162

4263
target_include_directories(psp-${CFE_PSP_TARGETNAME} INTERFACE
4364
fsw/inc

cmake/module_list.c.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* This file is generated via CMake - do not edit in place */
2+
#include "cfe_psp_module.h"
3+
4+
@GENERATED_EXTERNS@
5+
6+
CFE_StaticModuleLoadEntry_t CFE_PSP_BASE_MODULE_LIST[] =
7+
{
8+
@GENERATED_KEYVALS@
9+
{ NULL }
10+
};
11+
12+
/* END OF FILE */
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This is a list of modules that is included as a fixed/base set
2+
# when this PSP is selected. They must exist under fsw/modules
3+
4+
eeprom_direct
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
# Create the module
3+
add_psp_module(eeprom_direct cfe_psp_eeprom_direct.c)

fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ void eeprom_mmap_file_Init(uint32 PspModuleId)
174174
cpuaddr eeprom_address;
175175
uint32 eeprom_size;
176176

177+
/* Inform the user that this module is in use */
178+
printf("CFE_PSP: Using MMAP simulated EEPROM implementation\n");
179+
177180
/*
178181
** Create the simulated EEPROM segment by mapping a memory segment to a file.
179182
** Since the file will be saved, the "EEPROM" contents will be preserved.
@@ -187,7 +190,8 @@ void eeprom_mmap_file_Init(uint32 PspModuleId)
187190
/*
188191
** Install the 2nd memory range as the mapped file ( EEPROM )
189192
*/
190-
Status = CFE_PSP_MemRangeSet(1, CFE_PSP_MEM_EEPROM, eeprom_address, eeprom_size, CFE_PSP_MEM_SIZE_DWORD, 0);
193+
Status = CFE_PSP_MemRangeSet(1, CFE_PSP_MEM_EEPROM, eeprom_address, eeprom_size, CFE_PSP_MEM_SIZE_DWORD,
194+
CFE_PSP_MEM_ATTR_READWRITE);
191195
OS_printf("CFE_PSP: EEPROM Range (2) created: Start Address = %08lX, Size = %08X Status = %d\n",
192196
(unsigned long)eeprom_address, (unsigned int)eeprom_size, Status);
193197
}

fsw/modules/eeprom_stub/cfe_psp_eeprom_stub.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ CFE_PSP_MODULE_DECLARE_SIMPLE(eeprom_stub);
3434

3535
void eeprom_stub_Init(uint32 PspModuleId)
3636
{
37-
/* Nothing to init */
37+
/* Inform the user that this module is in use */
38+
printf("CFE_PSP: Using STUB EEPROM implementation\n");
3839
}
3940

4041
int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value)

fsw/pc-linux/psp_module_list.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This is a list of modules that is included as a fixed/base set
2+
# when this PSP is selected. They must exist under fsw/modules
3+
4+
eeprom_mmap_file

fsw/pc-rtems/psp_module_list.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This is a list of modules that is included as a fixed/base set
2+
# when this PSP is selected. They must exist under fsw/modules
3+
4+
eeprom_stub

fsw/shared/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# Build the shared implementation as a library
1515
add_library(psp-${CFE_PSP_TARGETNAME}-shared OBJECT
1616
src/cfe_psp_configdata.c
17-
src/cfe_psp_eeprom.c
1817
src/cfe_psp_exceptionstorage.c
1918
src/cfe_psp_memrange.c
2019
src/cfe_psp_memutils.c

0 commit comments

Comments
 (0)