Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #608 - Add RTEMS 5.x support #661

Merged
merged 1 commit into from Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/bsp/pc-rtems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ add_library(osal_pc-rtems_impl OBJECT
src/bsp_console.c
)

# This definition is needed for the gethostname call
# By defining this, it avoids the need to use the -std=gnu99
# instead of the preferred -std=c99 GCC switch
target_compile_definitions(osal_pc-rtems_impl PUBLIC
_BSD_SOURCE
)

# This BSP only works with "rtems" OS layer.
# Confirming this reduces risk of accidental misconfiguration
set(OSAL_EXPECTED_OSTYPE "rtems" PARENT_SCOPE)
14 changes: 9 additions & 5 deletions src/bsp/pc-rtems/src/bsp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ void OS_BSP_Setup(void)
cmdlinestr = bsp_cmdline();

printf("\n\n*** RTEMS Info ***\n");
printf("%s", _Copyright_Notice);
printf("%s\n\n", _RTEMS_version);
printf(" Stack size=%d\n", (int)Configuration.stack_space_size);
printf(" Workspace size=%d\n", (int)Configuration.work_space_size);
printf("%s", OSAL_BSP_COPYRIGHT_NOTICE);
printf("%s\n\n", rtems_get_version_string());
printf(" Stack size=%d\n", (int)rtems_configuration_get_stack_space_size());
printf(" Workspace size=%d\n", (int)rtems_configuration_get_work_space_size());
if (cmdlinestr != NULL)
{
printf(" Bootloader Command Line: %s\n", cmdlinestr);
Expand Down Expand Up @@ -374,9 +374,13 @@ rtems_task Init(rtems_task_argument ignored)
#define CONFIGURE_MAXIMUM_TIMERS (OS_MAX_TIMERS + 2)
#define CONFIGURE_MAXIMUM_SEMAPHORES (OS_MAX_BIN_SEMAPHORES + OS_MAX_COUNT_SEMAPHORES + OS_MAX_MUTEXES + 16)
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES (OS_MAX_QUEUES + 4)
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8)
#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
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8)
#endif

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
Expand Down
9 changes: 9 additions & 0 deletions src/bsp/pc-rtems/src/pcrtems_bsp_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@
#define RTEMS_MAX_USER_OPTIONS 4
#define RTEMS_MAX_CMDLINE 256

/*
* Handle the differences between RTEMS 5 and 4.11 copyright notice
*/
#ifdef _RTEMS_5_
#define OSAL_BSP_COPYRIGHT_NOTICE rtems_get_copyright_notice()
#else
#define OSAL_BSP_COPYRIGHT_NOTICE _Copyright_Notice
#endif

/*
* The location which the general purpose file system will be mounted
*/
Expand Down
14 changes: 14 additions & 0 deletions src/os/rtems/inc/os-rtems.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@
/****************************************************************************************
DEFINES
***************************************************************************************/
/*
* 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
#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
#endif

/****************************************************************************************
TYPEDEFS
Expand Down
4 changes: 2 additions & 2 deletions src/os/rtems/src/os-impl-heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
*-----------------------------------------------------------------*/
int32 OS_HeapGetInfo_Impl(OS_heap_prop_t *heap_prop)
{
region_information_block info;
int status;
OSAL_HEAP_INFO_BLOCK info;
int status;

status = malloc_info(&info);

Expand Down
8 changes: 4 additions & 4 deletions src/os/rtems/src/os-impl-loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ int32 OS_Rtems_ModuleAPI_Impl_Init(void)
* This could be fine-tuned later.
*
*-----------------------------------------------------------------*/
static bool OS_rtems_rtl_check_unresolved(rtems_rtl_unresolv_rec_t *rec, void *data)
static bool OS_rtems_rtl_check_unresolved(OSAL_UNRESOLV_REC_TYPE *rec, void *data)
{
int32 *status = data;

switch (rec->type)
{
case rtems_rtl_unresolved_name:
OS_DEBUG("unresolved name: %s\n", rec->rec.name.name);
case OSAL_UNRESOLVED_SYMBOL:
OS_DEBUG("unresolved symbol: %s\n", rec->rec.name.name);
*status = OS_ERROR;
break;
case rtems_rtl_unresolved_reloc:
Expand Down Expand Up @@ -142,7 +142,7 @@ int32 OS_ModuleLoad_Impl(uint32 module_id, const char *translated_path)

OS_DEBUG("module has has unresolved externals\n");
status = OS_SUCCESS; /* note - not final, probably overridden */
rtems_rtl_unresolved_interate(OS_rtems_rtl_check_unresolved, &status);
OSAL_UNRESOLVED_ITERATE(OS_rtems_rtl_check_unresolved, &status);
}
else
{
Expand Down