Skip to content

Commit 21ceb0e

Browse files
author
Jacob Hageman
committed
Fix #1349, Break up pc-rtems to support generic configuration
1 parent 0291622 commit 21ceb0e

File tree

10 files changed

+570
-255
lines changed

10 files changed

+570
-255
lines changed

src/bsp/pc-rtems/CMakeLists.txt

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,41 @@
44
#
55
######################################################################
66

7+
# Basic set of files
8+
set(OS_BSP_SRCLIST
9+
src/bsp_console.c
10+
src/bsp_start.c
11+
)
12+
13+
# If not dynamic loading, include Init and config
14+
if (NOT RTEMS_DYNAMIC_LOAD)
15+
list(APPEND OS_BSP_SRCLIST
16+
src/bsp_init.c
17+
src/bsp_setupfs.c # TODO move to only if enabled
18+
)
19+
20+
# TODO could add the two flags for FS support vs adding from include
21+
22+
# Link the RTEMS BSP with the "rtemscpu" system library
23+
target_link_libraries(osal_public_api INTERFACE
24+
rtemscpu
25+
)
26+
endif ()
27+
28+
if (RTEMS_NO_SHELL)
29+
list(APPEND OS_BSP_SRCLIST
30+
src/bsp_no_shell.c
31+
)
32+
else ()
33+
list(APPEND OS_BSP_SRCLIST
34+
src/bsp_shell.c
35+
)
36+
endif ()
37+
38+
# TODO add the cmdline if not RTEMS_NO_CMDLINE
39+
740
add_library(osal_pc-rtems_impl OBJECT
8-
src/bsp_start.c
9-
src/bsp_console.c
41+
${OS_BSP_SRCLIST}
1042
)
1143

1244
# This definition is needed for the gethostname call
@@ -16,9 +48,4 @@ target_compile_definitions(osal_public_api INTERFACE
1648
_BSD_SOURCE
1749
)
1850

19-
# Link the RTEMS BSP with the "rtemscpu" system library
20-
target_link_libraries(osal_public_api INTERFACE
21-
rtemscpu
22-
)
23-
2451
set_property(TARGET osal_pc-rtems_impl PROPERTY OSAL_EXPECTED_OSTYPE "rtems")

src/bsp/pc-rtems/src/bsp_cmdline.c

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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+
/* TODO clean these */
29+
#include <stdio.h>
30+
#include <stdlib.h>
31+
#include <string.h>
32+
#include <errno.h>
33+
#include <ctype.h>
34+
#include <bsp.h>
35+
#include <rtems.h>
36+
#include <rtems/bdbuf.h>
37+
#include <rtems/blkdev.h>
38+
#include <rtems/diskdevs.h>
39+
#include <rtems/bdpart.h>
40+
#include <rtems/error.h>
41+
#include <rtems/ramdisk.h>
42+
#include <rtems/dosfs.h>
43+
#include <rtems/fsmount.h>
44+
45+
/* TODO remove or refactor? Still needs global */
46+
#include "pcrtems_bsp_internal.h"
47+
48+
void OS_BSP_CmdLine(void)
49+
{
50+
const char *cmdlinestr;
51+
const char *cmdp;
52+
char * cmdi, *cmdo;
53+
54+
cmdlinestr = bsp_cmdline();
55+
56+
/*
57+
* Parse command line string (passed in from bootloader)
58+
*
59+
* Known arguments are handled here, and unknown args are
60+
* saved for the UT application.
61+
*
62+
* Batch mode is intended for non-interactive execution.
63+
*
64+
* It does two things:
65+
* - do not start the shell task
66+
* - when tests are complete, shutdown the executive
67+
*
68+
* The BSP should be configured with these options to
69+
* make this most useful:
70+
* USE_COM1_AS_CONSOLE=1
71+
* BSP_PRESS_KEY_FOR_RESET=0
72+
* BSP_RESET_BOARD_AT_EXIT=1
73+
*
74+
* This way all the test output will be sent to COM1
75+
* and then immediately resets the CPU when done.
76+
*
77+
* When running under QEMU the "-no-reboot" flag is
78+
* also useful to shutdown QEMU rather than resetting.
79+
*/
80+
if (cmdlinestr != NULL)
81+
{
82+
printf(" Bootloader Command Line: %s\n", cmdlinestr);
83+
84+
cmdp = cmdlinestr;
85+
cmdo = NULL;
86+
cmdi = NULL;
87+
88+
while (1)
89+
{
90+
if (isgraph((int)*cmdp))
91+
{
92+
if (cmdo == NULL)
93+
{
94+
cmdo = OS_BSP_PcRtemsGlobal.UserArgBuffer;
95+
}
96+
else
97+
{
98+
++cmdo;
99+
}
100+
if (cmdi == NULL)
101+
{
102+
cmdi = cmdo;
103+
}
104+
*cmdo = *cmdp;
105+
}
106+
else if (cmdi != NULL)
107+
{
108+
++cmdo;
109+
*cmdo = 0;
110+
if (strcmp(cmdi, "--batch-mode") == 0)
111+
{
112+
OS_BSP_PcRtemsGlobal.BatchMode = true;
113+
}
114+
else if (OS_BSP_Global.ArgC < RTEMS_MAX_USER_OPTIONS)
115+
{
116+
/* save other args for app */
117+
OS_BSP_Global.ArgV[OS_BSP_Global.ArgC] = cmdi;
118+
++OS_BSP_Global.ArgC;
119+
}
120+
cmdi = NULL;
121+
}
122+
123+
if (*cmdp == 0)
124+
{
125+
break;
126+
}
127+
128+
++cmdp;
129+
}
130+
}
131+
}

src/bsp/pc-rtems/src/bsp_console.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
************************************************************************/
1818

1919
/*
20-
* File: bsp_console.c
20+
* \file
2121
*
22-
* Purpose:
2322
* OSAL BSP debug console abstraction
2423
*/
2524

src/bsp/pc-rtems/src/bsp_init.c

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
* RTEMS main entry point
23+
* Configures RTEMS and wraps OS_BSPMain for use in a stand alone executable
24+
*/
25+
26+
/*
27+
** Include Files
28+
*/
29+
#include "bsp_start.h"
30+
#include "bsp-impl.h"
31+
#include <rtems.h>
32+
33+
/*
34+
** A simple entry point to start from the loader
35+
*/
36+
rtems_task Init(rtems_task_argument ignored)
37+
{
38+
OS_BSPMain();
39+
}
40+
41+
/* configuration information */
42+
43+
/*
44+
** RTEMS OS Configuration definitions
45+
*/
46+
#define TASK_INTLEVEL 0
47+
#define CONFIGURE_INIT
48+
#define CONFIGURE_INIT_TASK_ATTRIBUTES \
49+
(RTEMS_FLOATING_POINT | RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR | RTEMS_INTERRUPT_LEVEL(TASK_INTLEVEL))
50+
#define CONFIGURE_INIT_TASK_STACK_SIZE (20 * 1024)
51+
#define CONFIGURE_INIT_TASK_PRIORITY 10
52+
53+
/*
54+
* Note that these resources are shared with RTEMS itself (e.g. the init task, the shell)
55+
* so they should be allocated slightly higher than the user limits in osconfig.h
56+
*
57+
* Many RTEMS services use tasks internally, including the idle task, BSWP, ATA driver,
58+
* low level console I/O, the shell, TCP/IP network stack, and DHCP (if enabled).
59+
* Many of these also use semaphores for synchronization.
60+
*
61+
* Budgeting for additional:
62+
* 8 internal tasks
63+
* 2 internal timers
64+
* 4 internal queues
65+
* 16 internal semaphores
66+
*
67+
*/
68+
#define CONFIGURE_MAXIMUM_TASKS (OS_MAX_TASKS + 8)
69+
#define CONFIGURE_MAXIMUM_TIMERS (OS_MAX_TIMERS + 2)
70+
#define CONFIGURE_MAXIMUM_SEMAPHORES (OS_MAX_BIN_SEMAPHORES + OS_MAX_COUNT_SEMAPHORES + OS_MAX_MUTEXES + 16)
71+
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES (OS_MAX_QUEUES + 4)
72+
#define CONFIGURE_MAXIMUM_DRIVERS 10
73+
#define CONFIGURE_MAXIMUM_POSIX_KEYS 4
74+
#ifdef OS_RTEMS_4_DEPRECATED
75+
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8)
76+
#else
77+
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8)
78+
#endif
79+
80+
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
81+
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
82+
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
83+
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
84+
#define CONFIGURE_FILESYSTEM_RFS
85+
#define CONFIGURE_FILESYSTEM_IMFS
86+
#define CONFIGURE_FILESYSTEM_DOSFS
87+
#define CONFIGURE_FILESYSTEM_DEVFS
88+
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
89+
90+
/* TODO figure out how to switch these if needed
91+
#define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER
92+
#define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER */
93+
94+
#define CONFIGURE_EXECUTIVE_RAM_SIZE (8 * 1024 * 1024)
95+
#define CONFIGURE_MICROSECONDS_PER_TICK 10000
96+
#define CONFIGURE_ATA_DRIVER_TASK_PRIORITY 9
97+
98+
#include <rtems/confdefs.h>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 no shell implementation
23+
*/
24+
25+
#include <stdio.h>
26+
27+
/* TODO needs the global, but may want to split this up */
28+
#include "pcrtems_bsp_internal.h"
29+
30+
/* TODO add bsp_shell.h */
31+
32+
void OS_BSP_Shell(void)
33+
{
34+
printf("RTEMS_NO_SHELL:TRUE, shell not implemented");
35+
OS_BSP_PcRtemsGlobal.BatchMode = true;
36+
}

0 commit comments

Comments
 (0)