Skip to content

Commit

Permalink
Fix nasa#1447, Add TARFS functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Feb 23, 2024
1 parent 5e1e6ca commit 3e63c13
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 85 deletions.
21 changes: 21 additions & 0 deletions src/bsp/pc-rtems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,24 @@ target_compile_definitions(osal_public_api INTERFACE
)

set_property(TARGET osal_pc-rtems_impl PROPERTY OSAL_EXPECTED_OSTYPE "rtems")

# The list of header files that control configuration
set(BSP_RTEMS_CONFIG_FILE_LIST
bsp_rtems_cfg.h
)

# Create wrappers around the all the config header files
# This makes them individually overridable by the missions, without modifying
# the distribution default copies
foreach(BSP_RTEMS_CFGFILE ${BSP_RTEMS_CONFIG_FILE_LIST})
get_filename_component(CFGKEY "${BSP_RTEMS_CFGFILE}" NAME_WE)
if (DEFINED BSP_RTEMS_CFGFILE_SRC_${CFGKEY})
set(DEFAULT_SOURCE GENERATED_FILE "${BSP_RTEMS_CFGFILE_SRC_${CFGKEY}}")
else()
set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${BSP_RTEMS_CFGFILE}")
endif()
generate_config_includefile(
FILE_NAME "${BSP_RTEMS_CFGFILE}"
${DEFAULT_SOURCE}
)
endforeach()
82 changes: 82 additions & 0 deletions src/bsp/pc-rtems/config/default_bsp_rtems_cfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as �~@~\core Flight System: Bootes�~@~]
*
* Copyright (c) 2020 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
************************************************************************/

/**
* @file
* Default RTEMS OS Configuration definitions
*
* @note
* This file may be overridden/superseded by mission-provided definitions
* by overriding this header.
*/
#ifndef BSP_RTEMS_CFG_H
#define BSP_RTEMS_CFG_H

#include "osconfig.h"

#define TASK_INTLEVEL 0
#define CONFIGURE_INIT
#define CONFIGURE_INIT_TASK_ATTRIBUTES \
(RTEMS_FLOATING_POINT | RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR | RTEMS_INTERRUPT_LEVEL(TASK_INTLEVEL))
#define CONFIGURE_INIT_TASK_STACK_SIZE (20 * 1024)
#define CONFIGURE_INIT_TASK_PRIORITY 10

/*
* Note that these resources are shared with RTEMS itself (e.g. the init task, the shell)
* so they should be allocated slightly higher than the user limits in osconfig.h
*
* Many RTEMS services use tasks internally, including the idle task, BSWP, ATA driver,
* low level console I/O, the shell, TCP/IP network stack, and DHCP (if enabled).
* Many of these also use semaphores for synchronization.
*
* Budgeting for additional:
* 8 internal tasks
* 2 internal timers
* 4 internal queues
* 16 internal semaphores
*
*/
#define CONFIGURE_MAXIMUM_TASKS (OS_MAX_TASKS + 8)
#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_MAXIMUM_DRIVERS 10
#define CONFIGURE_MAXIMUM_POSIX_KEYS 4
#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
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
#define CONFIGURE_FILESYSTEM_RFS
#define CONFIGURE_FILESYSTEM_IMFS
#define CONFIGURE_FILESYSTEM_DOSFS
#define CONFIGURE_FILESYSTEM_DEVFS
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
#define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER

#define CONFIGURE_EXECUTIVE_RAM_SIZE (8 * 1024 * 1024)
#define CONFIGURE_MICROSECONDS_PER_TICK 10000
#define CONFIGURE_ATA_DRIVER_TASK_PRIORITY 9

#endif
88 changes: 4 additions & 84 deletions src/bsp/pc-rtems/src/bsp_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include "bsp-impl.h"
#include <rtems.h>

/* BSP RTEMS configuration, these two includes must be in this order */
#include "bsp_rtems_cfg.h"
#include <rtems/confdefs.h>

#ifdef RTEMS_INCLUDE_TARFS

#include <rtems/untar.h>
Expand Down Expand Up @@ -66,87 +70,3 @@ rtems_task Init(rtems_task_argument ignored)

OS_BSPMain();
}

/* configuration information */

/*
** RTEMS OS Configuration definitions
*/
#define TASK_INTLEVEL 0
#define CONFIGURE_INIT
#define CONFIGURE_INIT_TASK_ATTRIBUTES \
(RTEMS_FLOATING_POINT | RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR | RTEMS_INTERRUPT_LEVEL(TASK_INTLEVEL))
#define CONFIGURE_INIT_TASK_STACK_SIZE (20 * 1024)
#define CONFIGURE_INIT_TASK_PRIORITY 10

/*
* Note that these resources are shared with RTEMS itself (e.g. the init task, the shell)
* so they should be allocated slightly higher than the user limits in osconfig.h
*
* Many RTEMS services use tasks internally, including the idle task, BSWP, ATA driver,
* low level console I/O, the shell, TCP/IP network stack, and DHCP (if enabled).
* Many of these also use semaphores for synchronization.
*
* Budgeting for additional:
* 8 internal tasks
* 2 internal timers
* 4 internal queues
* 16 internal semaphores
*
*/
#define CONFIGURE_MAXIMUM_TASKS (OS_MAX_TASKS + 8)
#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_MAXIMUM_DRIVERS 10
#define CONFIGURE_MAXIMUM_POSIX_KEYS 4
#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
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
#define CONFIGURE_FILESYSTEM_RFS
#define CONFIGURE_FILESYSTEM_IMFS
#define CONFIGURE_FILESYSTEM_DOSFS
#define CONFIGURE_FILESYSTEM_DEVFS
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK

/* TODO figure out how to switch these if needed
#define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER */

#define CONFIGURE_EXECUTIVE_RAM_SIZE (8 * 1024 * 1024)
#define CONFIGURE_MICROSECONDS_PER_TICK 10000
#define CONFIGURE_ATA_DRIVER_TASK_PRIORITY 9

/*
** This include file must be AFTER the
** configuration data.
*/
#include <rtems/confdefs.h>

/* TODO Enablibg the GRETH driver is a platform specific setting. This is supposed to be a "generic" rtems psp. */
#ifdef RTEMS_INCLUDE_TARFS /* TODO Is there a better networking-related define? */

#include <drvmgr/drvmgr.h>

/* Configure Driver manager */
#if defined(RTEMS_DRVMGR_STARTUP) && defined(LEON3) /* if --drvmgr was given to configure */
/* Add Timer and UART Driver for this example */
#ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
#endif
#ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
#endif
#endif
#define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRETH

#include <drvmgr/drvmgr_confdefs.h>

#endif
2 changes: 1 addition & 1 deletion src/bsp/pc-rtems/src/bsp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void OS_BSP_Setup(void)
int status;

printf("\n\n*** RTEMS Info ***\n");
printf("%s", OSAL_BSP_COPYRIGHT_NOTICE);
printf("%s\n", 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());
Expand Down

0 comments on commit 3e63c13

Please sign in to comment.