From bf7953e08c93d347249e0bf64c53228f38b0b40e Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Fri, 23 Feb 2024 19:45:30 +0000 Subject: [PATCH] Fix #1447 #1349, Add TARFS functionality and finish generic RTEMS support --- src/bsp/pc-rtems/CMakeLists.txt | 55 +++++--- .../pc-rtems/config/default_bsp_rtems_cfg.h | 82 ++++++++++++ src/bsp/pc-rtems/src/bsp_cmdline.c | 19 ++- src/bsp/pc-rtems/src/bsp_cmdline.h | 31 +++++ src/bsp/pc-rtems/src/bsp_init.c | 123 +----------------- .../{bsp_setupfs.c => bsp_mount_setupfs.c} | 12 +- src/bsp/pc-rtems/src/bsp_no_cmdline.c | 32 +++++ src/bsp/pc-rtems/src/bsp_no_shell.c | 5 +- src/bsp/pc-rtems/src/bsp_setupfs.h | 31 +++++ src/bsp/pc-rtems/src/bsp_shell.c | 18 +-- src/bsp/pc-rtems/src/bsp_shell.h | 31 +++++ src/bsp/pc-rtems/src/bsp_start.c | 31 ++--- src/bsp/pc-rtems/src/bsp_start.h | 6 +- src/bsp/pc-rtems/src/bsp_tarfs_setupfs.c | 43 ++++++ src/bsp/pc-rtems/src/pcrtems_bsp_internal.h | 35 +---- 15 files changed, 337 insertions(+), 217 deletions(-) create mode 100644 src/bsp/pc-rtems/config/default_bsp_rtems_cfg.h create mode 100644 src/bsp/pc-rtems/src/bsp_cmdline.h rename src/bsp/pc-rtems/src/{bsp_setupfs.c => bsp_mount_setupfs.c} (94%) create mode 100644 src/bsp/pc-rtems/src/bsp_no_cmdline.c create mode 100644 src/bsp/pc-rtems/src/bsp_setupfs.h create mode 100644 src/bsp/pc-rtems/src/bsp_shell.h create mode 100644 src/bsp/pc-rtems/src/bsp_tarfs_setupfs.c diff --git a/src/bsp/pc-rtems/CMakeLists.txt b/src/bsp/pc-rtems/CMakeLists.txt index a75b3d2f9..5f918f457 100644 --- a/src/bsp/pc-rtems/CMakeLists.txt +++ b/src/bsp/pc-rtems/CMakeLists.txt @@ -7,28 +7,24 @@ # Basic set of files set(OS_BSP_SRCLIST src/bsp_console.c + src/bsp_init.c src/bsp_start.c ) -# If dynamic loading but also using TARFS, we use our Init to untar and -# set up file system based on tarfile contents -if (RTEMS_DYNAMIC_LOAD AND RTEMS_INCLUDE_TARFS) +# Source select file system setup implementation +if (RTEMS_INCLUDE_TARFS) list(APPEND OS_BSP_SRCLIST - src/bsp_init.c - src/bsp_setupfs.c # TODO move to only if enabled + src/bsp_tarfs_setupfs.c ) -endif () - -# If not dynamic loading, include Init and config -if (NOT RTEMS_DYNAMIC_LOAD) +else () + # NOTE: rtems config needs to define supporting configuration (FILESYSTEM and DRIVERs) list(APPEND OS_BSP_SRCLIST - src/bsp_init.c - src/bsp_setupfs.c # TODO move to only if enabled + src/bsp_mount_setupfs.c ) +endif () - # TODO could add the two flags for FS support vs adding from include - - # Link the RTEMS BSP with the "rtemscpu" system library +# Link rtemscpu to osal public api if not dynamic loading +if (NOT RTEMS_DYNAMIC_LOAD) target_link_libraries(osal_public_api INTERFACE rtemscpu ) @@ -44,7 +40,15 @@ else () ) endif () -# TODO add the cmdline if not RTEMS_NO_CMDLINE +if (RTEMS_NO_CMDLINE) + list(APPEND OS_BSP_SRCLIST + src/bsp_no_cmdline.c + ) +else () + list(APPEND OS_BSP_SRCLIST + src/bsp_cmdline.c + ) +endif () add_library(osal_pc-rtems_impl OBJECT ${OS_BSP_SRCLIST} @@ -58,3 +62,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 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() diff --git a/src/bsp/pc-rtems/config/default_bsp_rtems_cfg.h b/src/bsp/pc-rtems/config/default_bsp_rtems_cfg.h new file mode 100644 index 000000000..176e1abc7 --- /dev/null +++ b/src/bsp/pc-rtems/config/default_bsp_rtems_cfg.h @@ -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 diff --git a/src/bsp/pc-rtems/src/bsp_cmdline.c b/src/bsp/pc-rtems/src/bsp_cmdline.c index a11b33b3c..2c99f2c39 100644 --- a/src/bsp/pc-rtems/src/bsp_cmdline.c +++ b/src/bsp/pc-rtems/src/bsp_cmdline.c @@ -25,7 +25,6 @@ /* ** Include Files */ -/* TODO clean these */ #include #include #include @@ -33,20 +32,18 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -/* TODO remove or refactor? Still needs global */ #include "pcrtems_bsp_internal.h" +/* + * BSP compile-time tuning + */ +#define RTEMS_MAX_USER_OPTIONS 4 +#define RTEMS_MAX_CMDLINE 256 + void OS_BSP_CmdLine(void) { + char userargbuffer[RTEMS_MAX_CMDLINE]; const char *cmdlinestr; const char *cmdp; char * cmdi, *cmdo; @@ -91,7 +88,7 @@ void OS_BSP_CmdLine(void) { if (cmdo == NULL) { - cmdo = OS_BSP_PcRtemsGlobal.UserArgBuffer; + cmdo = userargbuffer; } else { diff --git a/src/bsp/pc-rtems/src/bsp_cmdline.h b/src/bsp/pc-rtems/src/bsp_cmdline.h new file mode 100644 index 000000000..d4d0f7887 --- /dev/null +++ b/src/bsp/pc-rtems/src/bsp_cmdline.h @@ -0,0 +1,31 @@ +/************************************************************************ + * 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 + * + * Purpose: + * Header file for bsp cmdline + */ + +#ifndef BSP_CMDLINE_H +#define BSP_CMDLINE_H + +void OS_BSP_CmdLine(void); + +#endif diff --git a/src/bsp/pc-rtems/src/bsp_init.c b/src/bsp/pc-rtems/src/bsp_init.c index f1844c71e..994fccc8e 100644 --- a/src/bsp/pc-rtems/src/bsp_init.c +++ b/src/bsp/pc-rtems/src/bsp_init.c @@ -22,131 +22,18 @@ * RTEMS main entry point * Configures RTEMS and wraps OS_BSPMain for use in a stand alone executable */ - -/* -** Include Files -*/ #include "bsp_start.h" #include "bsp-impl.h" -#include - -#ifdef RTEMS_INCLUDE_TARFS -#include -/* -** Tar file symbols -*/ -extern int _binary_tarfile_start; -extern int _binary_tarfile_size; -#define TARFILE_START _binary_tarfile_start -#define TARFILE_SIZE _binary_tarfile_size - -#endif +/* BSP RTEMS configuration, must be in this order */ +#include +#include "bsp_rtems_cfg.h" +#include /* - ** A simple entry point to start from the loader + * A simple entry point to start from the loader */ rtems_task Init(rtems_task_argument ignored) { - -#ifdef RTEMS_INCLUDE_TARFS - /* - ** Initialize the file system - */ - printf("Populating Root file system from TAR file.\n"); - int status = Untar_FromMemory( - (unsigned char *)(&TARFILE_START), - (unsigned long)&TARFILE_SIZE); - if (status != RTEMS_SUCCESSFUL) - { - printf("Error while untaring from memory\n"); - } - -#endif - 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 - -/* 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 - -/* 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 - -#endif diff --git a/src/bsp/pc-rtems/src/bsp_setupfs.c b/src/bsp/pc-rtems/src/bsp_mount_setupfs.c similarity index 94% rename from src/bsp/pc-rtems/src/bsp_setupfs.c rename to src/bsp/pc-rtems/src/bsp_mount_setupfs.c index 312842c5a..fdc91aafc 100644 --- a/src/bsp/pc-rtems/src/bsp_setupfs.c +++ b/src/bsp/pc-rtems/src/bsp_mount_setupfs.c @@ -19,13 +19,12 @@ /* * \file * - * OSAL BSP set up file system + * OSAL BSP set up file system with user mount */ /* ** Include Files */ -/* TODO clean these */ #include #include #include @@ -45,8 +44,13 @@ #include #endif -/* TODO break up and if there's config move to inc dir supporting overrides */ -#include "pcrtems_bsp_internal.h" +#include "bsp-impl.h" +#include "bsp_setupfs.h" + +/* + * The location which the general purpose file system will be mounted + */ +#define RTEMS_USER_FS_MOUNTPOINT "/mnt" /* ** External Declarations diff --git a/src/bsp/pc-rtems/src/bsp_no_cmdline.c b/src/bsp/pc-rtems/src/bsp_no_cmdline.c new file mode 100644 index 000000000..63e24886f --- /dev/null +++ b/src/bsp/pc-rtems/src/bsp_no_cmdline.c @@ -0,0 +1,32 @@ +/************************************************************************ + * 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 + * + * OSAL BSP no command line implementation + */ + +#include + +#include "bsp_cmdline.h" + +void OS_BSP_CmdLine(void) +{ + printf("RTEMS_NO_CMDLINE:TRUE, command line not implemented"); +} diff --git a/src/bsp/pc-rtems/src/bsp_no_shell.c b/src/bsp/pc-rtems/src/bsp_no_shell.c index 948775cfc..5a94ca045 100644 --- a/src/bsp/pc-rtems/src/bsp_no_shell.c +++ b/src/bsp/pc-rtems/src/bsp_no_shell.c @@ -23,11 +23,8 @@ */ #include - -/* TODO needs the global, but may want to split this up */ #include "pcrtems_bsp_internal.h" - -/* TODO add bsp_shell.h */ +#include "bsp_shell.h" void OS_BSP_Shell(void) { diff --git a/src/bsp/pc-rtems/src/bsp_setupfs.h b/src/bsp/pc-rtems/src/bsp_setupfs.h new file mode 100644 index 000000000..3295c7d27 --- /dev/null +++ b/src/bsp/pc-rtems/src/bsp_setupfs.h @@ -0,0 +1,31 @@ +/************************************************************************ + * 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 + * + * Purpose: + * Header file for bsp setup file system + */ + +#ifndef BSP_SETUPFS_H +#define BSP_SETUPFS_H + +void OS_BSP_SetupFS(void); + +#endif diff --git a/src/bsp/pc-rtems/src/bsp_shell.c b/src/bsp/pc-rtems/src/bsp_shell.c index 80f27fdff..369f693b3 100644 --- a/src/bsp/pc-rtems/src/bsp_shell.c +++ b/src/bsp/pc-rtems/src/bsp_shell.c @@ -25,7 +25,6 @@ /* ** Include Files */ -/* TODO clean these */ #include #include #include @@ -33,21 +32,18 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -/* TODO needs the global, but may want to split this up */ #include "pcrtems_bsp_internal.h" -/* TODO add bsp_shell.h */ +#include "bsp_shell.h" + +/* + * By default put the shell at the same priority + * as the utility task which handles OS_printf() + */ +#define RTEMS_SHELL_PRIORITY OS_UTILITYTASK_PRIORITY /* ** External Declarations diff --git a/src/bsp/pc-rtems/src/bsp_shell.h b/src/bsp/pc-rtems/src/bsp_shell.h new file mode 100644 index 000000000..d721e0703 --- /dev/null +++ b/src/bsp/pc-rtems/src/bsp_shell.h @@ -0,0 +1,31 @@ +/************************************************************************ + * 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 + * + * Purpose: + * Header file for bsp shell + */ + +#ifndef BSP_SHELL_H +#define BSP_SHELL_H + +void OS_BSP_Shell(void); + +#endif diff --git a/src/bsp/pc-rtems/src/bsp_start.c b/src/bsp/pc-rtems/src/bsp_start.c index 8116db5bf..4f88a0240 100644 --- a/src/bsp/pc-rtems/src/bsp_start.c +++ b/src/bsp/pc-rtems/src/bsp_start.c @@ -25,7 +25,6 @@ /* ** Include Files */ -/* TODO clean these */ #include #include #include @@ -34,24 +33,22 @@ #include #include #include -#include -#include -#include #include -#include -#include -#include #include "pcrtems_bsp_internal.h" -/* TODO add bsp_setupfs.h */ -void OS_BSP_SetupFS(void); +#include "bsp_setupfs.h" +#include "bsp_shell.h" +#include "bsp_cmdline.h" -/* TODO add bsp_shell.h */ -void OS_BSP_Shell(void); - -/* TODO add bsp_cmdline.h */ -void OS_BSP_CmdLine(void); +/* + * Handle the differences between RTEMS 5 and 4.11 copyright notice + */ +#ifdef OS_RTEMS_4_DEPRECATED +#define OSAL_BSP_COPYRIGHT_NOTICE _Copyright_Notice +#else +#define OSAL_BSP_COPYRIGHT_NOTICE rtems_get_copyright_notice() +#endif /* ** Global variables @@ -63,13 +60,13 @@ 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()); /* Process command line based on selected implementation */ - // TODO uncomment OS_BSP_CmdLine(); + OS_BSP_CmdLine(); printf("\n"); printf("*** End RTEMS info ***\n\n"); @@ -86,7 +83,7 @@ void OS_BSP_Setup(void) } /* Set up file system based on selected implementation */ - // TODO uncomment OS_BSP_SetupFS(); + OS_BSP_SetupFS(); /* * Start the shell now based on selected implementation diff --git a/src/bsp/pc-rtems/src/bsp_start.h b/src/bsp/pc-rtems/src/bsp_start.h index 1d57d881f..264930588 100644 --- a/src/bsp/pc-rtems/src/bsp_start.h +++ b/src/bsp/pc-rtems/src/bsp_start.h @@ -20,14 +20,12 @@ * \file * * Purpose: - * Header file for bsp_start.c + * Header file for bsp start */ #ifndef BSP_START_H #define BSP_START_H -/* TODO consider just adding all these to a generic bsp header... not worth separating */ - void OS_BSPMain(void); -#endif /* BSP_START_H */ +#endif diff --git a/src/bsp/pc-rtems/src/bsp_tarfs_setupfs.c b/src/bsp/pc-rtems/src/bsp_tarfs_setupfs.c new file mode 100644 index 000000000..17ecbe335 --- /dev/null +++ b/src/bsp/pc-rtems/src/bsp_tarfs_setupfs.c @@ -0,0 +1,43 @@ +/************************************************************************ + * 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 + * + * OSAL BSP set up file system with tarfs + */ +#include +#include +#include "bsp_setupfs.h" + +/* Tar file symbols */ +extern int _binary_tarfile_start; +extern int _binary_tarfile_size; + +void OS_BSP_SetupFS(void) +{ + int status; + + /* Initialize the file system using tarfs */ + printf("Populating Root file system from TAR file.\n"); + status = Untar_FromMemory((unsigned char *)(&_binary_tarfile_start), (unsigned long)&_binary_tarfile_size); + if (status != UNTAR_SUCCESSFUL) + { + printf("Error while untaring from memory\n"); + } +} diff --git a/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h b/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h index 3cc6fcabc..8949d5297 100644 --- a/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h +++ b/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h @@ -25,45 +25,14 @@ #ifndef PCRTEMS_BSP_INTERNAL_H #define PCRTEMS_BSP_INTERNAL_H -/* -** OSAL includes -*/ #include "bsp-impl.h" - #include /* - * BSP compile-time tuning - */ -#define RTEMS_MAX_USER_OPTIONS 4 -#define RTEMS_MAX_CMDLINE 256 - -/* - * Handle the differences between RTEMS 5 and 4.11 copyright notice + * BSP types */ -#ifdef OS_RTEMS_4_DEPRECATED -#define OSAL_BSP_COPYRIGHT_NOTICE _Copyright_Notice -#else -#define OSAL_BSP_COPYRIGHT_NOTICE rtems_get_copyright_notice() -#endif - -/* - * The location which the general purpose file system will be mounted - */ -#define RTEMS_USER_FS_MOUNTPOINT "/mnt" - -/* - * By default put the shell at the same priority - * as the utility task which handles OS_printf() - */ -#define RTEMS_SHELL_PRIORITY OS_UTILITYTASK_PRIORITY - -/* -** BSP types -*/ typedef struct { - char UserArgBuffer[RTEMS_MAX_CMDLINE]; bool BatchMode; rtems_id AccessMutex; } OS_BSP_PcRtemsGlobalData_t; @@ -73,4 +42,4 @@ typedef struct */ extern OS_BSP_PcRtemsGlobalData_t OS_BSP_PcRtemsGlobal; -#endif /* PCRTEMS_BSP_INTERNAL_H */ +#endif