From 07ff93c93ffbde9b55b7fdd7b437723a28fee2f8 Mon Sep 17 00:00:00 2001 From: Alan Cudmore Date: Thu, 19 May 2022 09:40:58 -0700 Subject: [PATCH 1/2] Fix #1256, Add RTEMS 6 Support --- src/bsp/pc-rtems/build_options.cmake | 13 ++++++++++--- src/bsp/pc-rtems/src/bsp_start.c | 13 +++++++++---- src/bsp/pc-rtems/src/pcrtems_bsp_internal.h | 6 +++--- src/os/rtems/inc/os-rtems.h | 17 +++++++++-------- src/os/rtems/src/os-impl-filesys.c | 4 +++- src/os/rtems/src/os-impl-loader.c | 2 +- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/bsp/pc-rtems/build_options.cmake b/src/bsp/pc-rtems/build_options.cmake index d32e9245a..136857ac1 100644 --- a/src/bsp/pc-rtems/build_options.cmake +++ b/src/bsp/pc-rtems/build_options.cmake @@ -5,6 +5,13 @@ ########################################################################## # Link the RTEMS BSP with the "rtemscpu" system library -target_link_libraries(osal_bsp - rtemscpu -) +if(CMAKE_SYSTEM_VERSION GREATER 5) + target_link_libraries(osal_bsp + rtemscpu + networking + ) +else() + target_link_libraries(osal_bsp + rtemscpu + ) +endif(CMAKE_SYSTEM_VERSION GREATER 5) diff --git a/src/bsp/pc-rtems/src/bsp_start.c b/src/bsp/pc-rtems/src/bsp_start.c index a95e861d2..172748692 100644 --- a/src/bsp/pc-rtems/src/bsp_start.c +++ b/src/bsp/pc-rtems/src/bsp_start.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -47,6 +46,10 @@ #include #include +#if defined(OS_RTEMS_4_DEPRECATED) || defined(OS_RTEMS_5) +#include +#endif + #include "pcrtems_bsp_internal.h" /* @@ -178,6 +181,7 @@ void OS_BSP_Setup(void) BSP_DEBUG("rtems_semaphore_create: %s\n", rtems_status_text(status)); } +#if defined(OS_RTEMS_4_DEPRECATED) || defined(OS_RTEMS_5) /* ** Create the RTEMS Root file system */ @@ -186,6 +190,7 @@ void OS_BSP_Setup(void) { printf("Creating Root file system failed: %s\n", rtems_status_text(status)); } +#endif /* * Create the mountpoint for the general purpose file system @@ -413,10 +418,10 @@ rtems_task Init(rtems_task_argument ignored) #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES (OS_MAX_QUEUES + 4) #define CONFIGURE_MAXIMUM_DRIVERS 10 #define CONFIGURE_MAXIMUM_POSIX_KEYS 4 -#ifdef _RTEMS_5_ -#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8) -#else +#ifdef OS_RTEMS_4_DEPRECATED #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8) +#else +#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8) #endif #define CONFIGURE_RTEMS_INIT_TASKS_TABLE diff --git a/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h b/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h index e752abd84..dc909d239 100644 --- a/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h +++ b/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h @@ -42,10 +42,10 @@ /* * Handle the differences between RTEMS 5 and 4.11 copyright notice */ -#ifdef _RTEMS_5_ -#define OSAL_BSP_COPYRIGHT_NOTICE rtems_get_copyright_notice() -#else +#ifdef OS_RTEMS_4_DEPRECATED #define OSAL_BSP_COPYRIGHT_NOTICE _Copyright_Notice +#else +#define OSAL_BSP_COPYRIGHT_NOTICE rtems_get_copyright_notice() #endif /* diff --git a/src/os/rtems/inc/os-rtems.h b/src/os/rtems/inc/os-rtems.h index ca250a19c..e18ed3b15 100644 --- a/src/os/rtems/inc/os-rtems.h +++ b/src/os/rtems/inc/os-rtems.h @@ -51,21 +51,22 @@ DEFINES ***************************************************************************************/ /* - * Handle the data structure and API name changes between RTEMS 4.11 and RTEMS 5.1 + * Handle the data structure and API name changes between RTEMS 4.11 and RTEMS 5.1+ */ -#ifdef _RTEMS_5_ -#define OSAL_HEAP_INFO_BLOCK Heap_Information_block -#define OSAL_UNRESOLV_REC_TYPE rtems_rtl_unresolv_rec -#define OSAL_UNRESOLVED_SYMBOL rtems_rtl_unresolved_symbol -#define OSAL_UNRESOLVED_ITERATE rtems_rtl_unresolved_iterate - -#else +#ifdef OS_RTEMS_4_DEPRECATED #define OSAL_HEAP_INFO_BLOCK region_information_block #define OSAL_UNRESOLV_REC_TYPE rtems_rtl_unresolv_rec_t #define OSAL_UNRESOLVED_SYMBOL rtems_rtl_unresolved_name #define OSAL_UNRESOLVED_ITERATE rtems_rtl_unresolved_interate +#else + +#define OSAL_HEAP_INFO_BLOCK Heap_Information_block +#define OSAL_UNRESOLV_REC_TYPE rtems_rtl_unresolv_rec +#define OSAL_UNRESOLVED_SYMBOL rtems_rtl_unresolved_symbol +#define OSAL_UNRESOLVED_ITERATE rtems_rtl_unresolved_iterate + #endif /**************************************************************************************** diff --git a/src/os/rtems/src/os-impl-filesys.c b/src/os/rtems/src/os-impl-filesys.c index f211d8d62..efa175fe9 100644 --- a/src/os/rtems/src/os-impl-filesys.c +++ b/src/os/rtems/src/os-impl-filesys.c @@ -190,7 +190,9 @@ int32 OS_FileSysStartVolume_Impl(const OS_object_token_t *token) */ if (return_code == OS_SUCCESS && local->system_mountpt[0] == 0) { - snprintf(local->system_mountpt, sizeof(local->system_mountpt), "/%s", local->volume_name); + local->system_mountpt[0] = '/'; + local->system_mountpt[sizeof(local->system_mountpt) - 1] = 0; + strncpy(&local->system_mountpt[1], local->volume_name, sizeof(local->system_mountpt) - 2); OS_DEBUG("OSAL: using mount point %s for %s\n", local->system_mountpt, local->volume_name); } diff --git a/src/os/rtems/src/os-impl-loader.c b/src/os/rtems/src/os-impl-loader.c index 4974aaa48..c044d12b9 100644 --- a/src/os/rtems/src/os-impl-loader.c +++ b/src/os/rtems/src/os-impl-loader.c @@ -39,7 +39,7 @@ TYPEDEFS ***************************************************************************************/ -#ifndef _RTEMS_5_ +#ifdef OS_RTEMS_4_DEPRECATED typedef rtems_rtl_obj_t rtems_rtl_obj; /* Alias for RTEMS 4.11 */ From cae3e492952ff5a4fafb5a3da5a988b09b7c3f45 Mon Sep 17 00:00:00 2001 From: Alan Cudmore Date: Thu, 26 May 2022 15:16:13 -0700 Subject: [PATCH 2/2] Fix #1256, Simplify build_options.cmake --- src/bsp/pc-rtems/build_options.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bsp/pc-rtems/build_options.cmake b/src/bsp/pc-rtems/build_options.cmake index 136857ac1..909fe8b7e 100644 --- a/src/bsp/pc-rtems/build_options.cmake +++ b/src/bsp/pc-rtems/build_options.cmake @@ -5,13 +5,13 @@ ########################################################################## # Link the RTEMS BSP with the "rtemscpu" system library +target_link_libraries(osal_bsp + rtemscpu +) + +# Add the networking library for RTEMS 6+ if(CMAKE_SYSTEM_VERSION GREATER 5) target_link_libraries(osal_bsp - rtemscpu networking ) -else() - target_link_libraries(osal_bsp - rtemscpu - ) endif(CMAKE_SYSTEM_VERSION GREATER 5)