Skip to content

Commit 0309e72

Browse files
committed
Fix nasa#1349 nasa#1447, Break up pc-rtems to support generic configuration and add tarfs support
1 parent 342d7e3 commit 0309e72

16 files changed

+1103
-0
lines changed

src/bsp/generic-rtems/CMakeLists.txt

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
######################################################################
2+
#
3+
# CMAKE build recipe for PC-RTEMS Board Support Package (BSP)
4+
#
5+
######################################################################
6+
7+
# Basic set of files
8+
set(OS_BSP_SRCLIST
9+
src/bsp_console.c
10+
src/bsp_init.c
11+
src/bsp_start.c
12+
)
13+
14+
# Source select file system setup implementation
15+
if (RTEMS_INCLUDE_TARFS)
16+
list(APPEND OS_BSP_SRCLIST
17+
src/bsp_tarfs_setupfs.c
18+
)
19+
else ()
20+
# NOTE: rtems config needs to define supporting configuration (FILESYSTEM and DRIVERs)
21+
list(APPEND OS_BSP_SRCLIST
22+
src/bsp_mount_setupfs.c
23+
)
24+
endif ()
25+
26+
# Link rtemscpu to osal public api if not dynamic loading
27+
if (NOT RTEMS_DYNAMIC_LOAD)
28+
target_link_libraries(osal_public_api INTERFACE
29+
rtemscpu
30+
)
31+
endif ()
32+
33+
if (RTEMS_NO_SHELL)
34+
list(APPEND OS_BSP_SRCLIST
35+
src/bsp_no_shell.c
36+
)
37+
else ()
38+
list(APPEND OS_BSP_SRCLIST
39+
src/bsp_shell.c
40+
)
41+
endif ()
42+
43+
if (RTEMS_NO_CMDLINE)
44+
list(APPEND OS_BSP_SRCLIST
45+
src/bsp_no_cmdline.c
46+
)
47+
else ()
48+
list(APPEND OS_BSP_SRCLIST
49+
src/bsp_cmdline.c
50+
)
51+
endif ()
52+
53+
add_library(osal_pc-rtems_impl OBJECT
54+
${OS_BSP_SRCLIST}
55+
)
56+
57+
# This definition is needed for the gethostname call
58+
# By defining this, it avoids the need to use the -std=gnu99
59+
# instead of the preferred -std=c99 GCC switch
60+
target_compile_definitions(osal_public_api INTERFACE
61+
_BSD_SOURCE
62+
)
63+
64+
set_property(TARGET osal_pc-rtems_impl PROPERTY OSAL_EXPECTED_OSTYPE "rtems")
65+
66+
# The list of header files that control configuration
67+
set(BSP_RTEMS_CONFIG_FILE_LIST
68+
bsp_rtems_cfg.h
69+
)
70+
71+
# Create wrappers around all the config header files
72+
# This makes them individually overridable by the missions, without modifying
73+
# the distribution default copies
74+
foreach(BSP_RTEMS_CFGFILE ${BSP_RTEMS_CONFIG_FILE_LIST})
75+
get_filename_component(CFGKEY "${BSP_RTEMS_CFGFILE}" NAME_WE)
76+
if (DEFINED BSP_RTEMS_CFGFILE_SRC_${CFGKEY})
77+
set(DEFAULT_SOURCE GENERATED_FILE "${BSP_RTEMS_CFGFILE_SRC_${CFGKEY}}")
78+
else()
79+
set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${BSP_RTEMS_CFGFILE}")
80+
endif()
81+
generate_config_includefile(
82+
FILE_NAME "${BSP_RTEMS_CFGFILE}"
83+
${DEFAULT_SOURCE}
84+
)
85+
endforeach()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/************************************************************************
2+
* NASA Docket No. GSC-18,719-1, and identified as �~@~\core Flight System: Bootes�~@~]
3+
*
4+
* Copyright (c) 2020 United States Government as represented by the
5+
* Administrator of the National Aeronautics and Space Administration.
6+
* All Rights Reserved.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
9+
* not use this file except in compliance with the License. You may obtain
10+
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
************************************************************************/
18+
19+
/**
20+
* @file
21+
* Default RTEMS OS Configuration definitions
22+
*
23+
* @note
24+
* This file may be overridden/superseded by mission-provided definitions
25+
* by overriding this header.
26+
*/
27+
#ifndef BSP_RTEMS_CFG_H
28+
#define BSP_RTEMS_CFG_H
29+
30+
#include "osconfig.h"
31+
32+
#define TASK_INTLEVEL 0
33+
#define CONFIGURE_INIT
34+
#define CONFIGURE_INIT_TASK_ATTRIBUTES \
35+
(RTEMS_FLOATING_POINT | RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR | RTEMS_INTERRUPT_LEVEL(TASK_INTLEVEL))
36+
#define CONFIGURE_INIT_TASK_STACK_SIZE (20 * 1024)
37+
#define CONFIGURE_INIT_TASK_PRIORITY 10
38+
39+
/*
40+
* Note that these resources are shared with RTEMS itself (e.g. the init task, the shell)
41+
* so they should be allocated slightly higher than the user limits in osconfig.h
42+
*
43+
* Many RTEMS services use tasks internally, including the idle task, BSWP, ATA driver,
44+
* low level console I/O, the shell, TCP/IP network stack, and DHCP (if enabled).
45+
* Many of these also use semaphores for synchronization.
46+
*
47+
* Budgeting for additional:
48+
* 8 internal tasks
49+
* 2 internal timers
50+
* 4 internal queues
51+
* 16 internal semaphores
52+
*
53+
*/
54+
#define CONFIGURE_MAXIMUM_TASKS (OS_MAX_TASKS + 8)
55+
#define CONFIGURE_MAXIMUM_TIMERS (OS_MAX_TIMERS + 2)
56+
#define CONFIGURE_MAXIMUM_SEMAPHORES (OS_MAX_BIN_SEMAPHORES + OS_MAX_COUNT_SEMAPHORES + OS_MAX_MUTEXES + 16)
57+
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES (OS_MAX_QUEUES + 4)
58+
#define CONFIGURE_MAXIMUM_DRIVERS 10
59+
#define CONFIGURE_MAXIMUM_POSIX_KEYS 4
60+
#ifdef OS_RTEMS_4_DEPRECATED
61+
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8)
62+
#else
63+
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8)
64+
#endif
65+
66+
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
67+
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
68+
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
69+
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
70+
#define CONFIGURE_FILESYSTEM_RFS
71+
#define CONFIGURE_FILESYSTEM_IMFS
72+
#define CONFIGURE_FILESYSTEM_DOSFS
73+
#define CONFIGURE_FILESYSTEM_DEVFS
74+
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
75+
#define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER
76+
#define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
77+
78+
#define CONFIGURE_EXECUTIVE_RAM_SIZE (8 * 1024 * 1024)
79+
#define CONFIGURE_MICROSECONDS_PER_TICK 10000
80+
#define CONFIGURE_ATA_DRIVER_TASK_PRIORITY 9
81+
82+
#endif
+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/************************************************************************
2+
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3+
*
4+
* Copyright (c) 2020 United States Government as represented by the
5+
* Administrator of the National Aeronautics and Space Administration.
6+
* All Rights Reserved.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
9+
* not use this file except in compliance with the License. You may obtain
10+
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
************************************************************************/
18+
19+
/*
20+
* \file
21+
*
22+
* OSAL BSP command line implementation
23+
*/
24+
25+
/*
26+
** Include Files
27+
*/
28+
#include <stdio.h>
29+
#include <stdlib.h>
30+
#include <string.h>
31+
#include <errno.h>
32+
#include <ctype.h>
33+
#include <bsp.h>
34+
#include <rtems.h>
35+
36+
#include "pcrtems_bsp_internal.h"
37+
38+
/*
39+
* BSP compile-time tuning
40+
*/
41+
#define RTEMS_MAX_USER_OPTIONS 4
42+
#define RTEMS_MAX_CMDLINE 256
43+
44+
void OS_BSP_CmdLine(void)
45+
{
46+
char userargbuffer[RTEMS_MAX_CMDLINE];
47+
const char *cmdlinestr;
48+
const char *cmdp;
49+
char * cmdi, *cmdo;
50+
51+
cmdlinestr = bsp_cmdline();
52+
53+
/*
54+
* Parse command line string (passed in from bootloader)
55+
*
56+
* Known arguments are handled here, and unknown args are
57+
* saved for the UT application.
58+
*
59+
* Batch mode is intended for non-interactive execution.
60+
*
61+
* It does two things:
62+
* - do not start the shell task
63+
* - when tests are complete, shutdown the executive
64+
*
65+
* The BSP should be configured with these options to
66+
* make this most useful:
67+
* USE_COM1_AS_CONSOLE=1
68+
* BSP_PRESS_KEY_FOR_RESET=0
69+
* BSP_RESET_BOARD_AT_EXIT=1
70+
*
71+
* This way all the test output will be sent to COM1
72+
* and then immediately resets the CPU when done.
73+
*
74+
* When running under QEMU the "-no-reboot" flag is
75+
* also useful to shutdown QEMU rather than resetting.
76+
*/
77+
if (cmdlinestr != NULL)
78+
{
79+
printf(" Bootloader Command Line: %s\n", cmdlinestr);
80+
81+
cmdp = cmdlinestr;
82+
cmdo = NULL;
83+
cmdi = NULL;
84+
85+
while (1)
86+
{
87+
if (isgraph((int)*cmdp))
88+
{
89+
if (cmdo == NULL)
90+
{
91+
cmdo = userargbuffer;
92+
}
93+
else
94+
{
95+
++cmdo;
96+
}
97+
if (cmdi == NULL)
98+
{
99+
cmdi = cmdo;
100+
}
101+
*cmdo = *cmdp;
102+
}
103+
else if (cmdi != NULL)
104+
{
105+
++cmdo;
106+
*cmdo = 0;
107+
if (strcmp(cmdi, "--batch-mode") == 0)
108+
{
109+
OS_BSP_PcRtemsGlobal.BatchMode = true;
110+
}
111+
else if (OS_BSP_Global.ArgC < RTEMS_MAX_USER_OPTIONS)
112+
{
113+
/* save other args for app */
114+
OS_BSP_Global.ArgV[OS_BSP_Global.ArgC] = cmdi;
115+
++OS_BSP_Global.ArgC;
116+
}
117+
cmdi = NULL;
118+
}
119+
120+
if (*cmdp == 0)
121+
{
122+
break;
123+
}
124+
125+
++cmdp;
126+
}
127+
}
128+
}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/************************************************************************
2+
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3+
*
4+
* Copyright (c) 2020 United States Government as represented by the
5+
* Administrator of the National Aeronautics and Space Administration.
6+
* All Rights Reserved.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
9+
* not use this file except in compliance with the License. You may obtain
10+
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
************************************************************************/
18+
19+
/**
20+
* \file
21+
*
22+
* Purpose:
23+
* Header file for bsp cmdline
24+
*/
25+
26+
#ifndef BSP_CMDLINE_H
27+
#define BSP_CMDLINE_H
28+
29+
void OS_BSP_CmdLine(void);
30+
31+
#endif
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/************************************************************************
2+
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
3+
*
4+
* Copyright (c) 2020 United States Government as represented by the
5+
* Administrator of the National Aeronautics and Space Administration.
6+
* All Rights Reserved.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
9+
* not use this file except in compliance with the License. You may obtain
10+
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
************************************************************************/
18+
19+
/*
20+
* \file
21+
*
22+
* OSAL BSP debug console abstraction
23+
*/
24+
25+
#include <string.h>
26+
#include <unistd.h>
27+
#include <sys/types.h>
28+
#include <sys/wait.h>
29+
30+
#include "pcrtems_bsp_internal.h"
31+
#include "bsp-impl.h"
32+
33+
/****************************************************************************************
34+
BSP CONSOLE IMPLEMENTATION FUNCTIONS
35+
****************************************************************************************/
36+
37+
/*----------------------------------------------------------------
38+
OS_BSP_ConsoleOutput_Impl
39+
See full description in header
40+
------------------------------------------------------------------*/
41+
void OS_BSP_ConsoleOutput_Impl(const char *Str, size_t DataLen)
42+
{
43+
/* writes the raw data directly to STDOUT_FILENO (unbuffered) */
44+
write(STDOUT_FILENO, Str, DataLen);
45+
}
46+
47+
/*----------------------------------------------------------------
48+
OS_BSP_ConsoleSetMode_Impl() definition
49+
See full description in header
50+
------------------------------------------------------------------*/
51+
void OS_BSP_ConsoleSetMode_Impl(uint32 ModeBits)
52+
{
53+
/* no-op on RTEMS */
54+
}

0 commit comments

Comments
 (0)