forked from Imagelibrary/rtems
libmisc: More useful default configuration
The dummy.c was a de-facto default configuration. Rename it to default-configuration.c. Use unlimited objects and the stack checker. This makes it easier for new RTEMS users which will likely use this file if they just work with the usual main() function as the application entry point. Provide proper arguments for main() using the BSP command line. Add spare user extensions and drivers. Do not initialize the network by default. Delete bspinit.c.
This commit is contained in:
@@ -6,7 +6,7 @@ DIST_SUBDIRS = @libbsp_cpu_subdir@
|
||||
EXTRA_DIST = MERGE.PROCEDURE bsp.am
|
||||
|
||||
# shared
|
||||
EXTRA_DIST += shared/bootcard.c shared/bspclean.c shared/bspinit.c \
|
||||
EXTRA_DIST += shared/bootcard.c shared/bspclean.c \
|
||||
shared/bsplibc.c shared/bsppost.c shared/console-polled.c \
|
||||
shared/console.c shared/gnatinstallhandler.c shared/sbrk.c \
|
||||
shared/tod.c
|
||||
|
||||
@@ -147,7 +147,6 @@ libbsp_a_SOURCES += ../../i386/shared/irq/idt.c
|
||||
libbsp_a_SOURCES += ../../i386/shared/irq/irq.c
|
||||
libbsp_a_SOURCES += ../../i386/shared/irq/irq_init.c
|
||||
libbsp_a_SOURCES += ../../shared/bootcard.c
|
||||
libbsp_a_SOURCES += ../../shared/bspinit.c
|
||||
libbsp_a_SOURCES += ../../shared/sbrk.c
|
||||
libbsp_a_SOURCES += startup/ldsegs.S
|
||||
libbsp_a_SOURCES += ../../i386/shared/irq/irq_asm.S
|
||||
|
||||
@@ -32,7 +32,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsppredriverhook.c \
|
||||
startup/bspgetcpuclockspeed.c ../../shared/bsppretaskinghook.c \
|
||||
../../shared/bspgetworkarea.c startup/init5235.c startup/bspstart.c \
|
||||
../../shared/bootcard.c ../../shared/sbrk.c ../../shared/setvec.c \
|
||||
../../shared/gnatinstallhandler.c ../../shared/bspinit.c \
|
||||
../../shared/gnatinstallhandler.c \
|
||||
startup/copyvectors.c
|
||||
# clock
|
||||
libbsp_a_SOURCES += clock/clock.c ../../../shared/clockdrv_shell.h
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2009.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <bsp.h>
|
||||
#include <bsp/bootcard.h>
|
||||
#ifdef RTEMS_NETWORKING
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Necessary prototypes
|
||||
*/
|
||||
rtems_task Init (rtems_task_argument arg);
|
||||
int main (int argc, char* argv[]);
|
||||
|
||||
/*
|
||||
* This routine calls main from a confdefs.h default Init task
|
||||
* set up. The bootcard will provide the task argument as
|
||||
* command line string (ASCIIZ).
|
||||
*/
|
||||
|
||||
rtems_task Init (rtems_task_argument arg)
|
||||
{
|
||||
const char* boot_cmdline = *((const char**) arg);
|
||||
char* cmdline = 0;
|
||||
char* command;
|
||||
int argc = 0;
|
||||
char** argv = NULL;
|
||||
int result = -124;
|
||||
|
||||
if (boot_cmdline) {
|
||||
cmdline = malloc (strlen (boot_cmdline) + 1);
|
||||
|
||||
if (cmdline) {
|
||||
strcpy (cmdline, boot_cmdline);
|
||||
|
||||
command = cmdline;
|
||||
|
||||
/*
|
||||
* Break the line up into arguments with "" being ignored.
|
||||
*/
|
||||
while (true) {
|
||||
command = strtok (command, " \t\r\n");
|
||||
if (command == NULL)
|
||||
break;
|
||||
argc++;
|
||||
command = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* If there are arguments, allocate enough memory for the argv
|
||||
* array to be passed into main().
|
||||
*
|
||||
* NOTE: If argc is 0, then argv will be NULL.
|
||||
*/
|
||||
argv = calloc (argc, sizeof (char*));
|
||||
|
||||
if (argv) {
|
||||
int a;
|
||||
|
||||
command = cmdline;
|
||||
argv[0] = command;
|
||||
|
||||
for (a = 1; a < argc; a++) {
|
||||
command += strlen (command) + 1;
|
||||
argv[a] = command;
|
||||
}
|
||||
} else
|
||||
argc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RTEMS_NETWORKING
|
||||
rtems_bsdnet_initialize_network ();
|
||||
#endif
|
||||
|
||||
result = main (argc, argv);
|
||||
|
||||
free (argv);
|
||||
free (cmdline);
|
||||
|
||||
exit (result);
|
||||
}
|
||||
|
||||
/*
|
||||
* By making this a weak alias and a user can provide there own.
|
||||
*/
|
||||
|
||||
void Init (rtems_task_argument arg) __attribute__ ((weak));
|
||||
@@ -36,7 +36,6 @@ libbsp_a_SOURCES += ../../sparc/shared/bsppretaskinghook.c
|
||||
libbsp_a_SOURCES += ../../shared/bsppost.c
|
||||
libbsp_a_SOURCES += ../../shared/bspstart.c
|
||||
libbsp_a_SOURCES += ../../shared/bootcard.c
|
||||
libbsp_a_SOURCES += ../../shared/bspinit.c
|
||||
libbsp_a_SOURCES += ../../shared/sbrk.c
|
||||
libbsp_a_SOURCES += startup/setvec.c
|
||||
libbsp_a_SOURCES += startup/spurious.c
|
||||
|
||||
@@ -57,7 +57,6 @@ libbsp_a_SOURCES += ../../shared/sbrk.c
|
||||
libbsp_a_SOURCES += startup/setvec.c
|
||||
libbsp_a_SOURCES += startup/spurious.c
|
||||
libbsp_a_SOURCES += startup/bspidle.c
|
||||
libbsp_a_SOURCES += ../../shared/bspinit.c
|
||||
libbsp_a_SOURCES += startup/bspdelay.c
|
||||
libbsp_a_SOURCES += ../../sparc/shared/startup/early_malloc.c
|
||||
libbsp_a_SOURCES += ../../sparc/shared/startup/bsp_fatal_exit.c
|
||||
|
||||
@@ -39,7 +39,7 @@ libbsp_a_SOURCES += ../../shared/bsplibc.c \
|
||||
../../sparc/shared/startup/bspgetworkarea.c ../../shared/sbrk.c \
|
||||
startup/setvec.c \
|
||||
startup/spurious.c startup/bspidle.S startup/bspdelay.c \
|
||||
../../shared/bspinit.c ../../sparc/shared/startup/early_malloc.c
|
||||
../../sparc/shared/startup/early_malloc.c
|
||||
libbsp_a_SOURCES += startup/cpucounter.c
|
||||
libbsp_a_SOURCES += ../../sparc/shared/startup/bsp_fatal_exit.c
|
||||
libbsp_a_SOURCES += startup/bsp_fatal_halt.c
|
||||
|
||||
@@ -35,11 +35,8 @@ noinst_LIBRARIES += libdevnull.a
|
||||
libdevnull_a_SOURCES = devnull/devnull.c devnull/devnull.h \
|
||||
devnull/devzero.c devnull/devzero.h
|
||||
|
||||
## dummy
|
||||
EXTRA_DIST += dummy/README
|
||||
|
||||
noinst_LIBRARIES += libdummy.a
|
||||
libdummy_a_SOURCES = dummy/dummy.c dummy/dummy-networking.c
|
||||
libdummy_a_SOURCES = dummy/default-configuration.c dummy/dummy-networking.c
|
||||
|
||||
## dumpbuf
|
||||
noinst_LIBRARIES += libdumpbuf.a
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
dummy.rel
|
||||
=========
|
||||
|
||||
A relocatible objects which contains a dummy configuration for RTEMS.
|
||||
|
||||
Helps linking standard c-program code with RTEMS, which shall *not* be run
|
||||
on a target, such as configure script code fragments generated by autoconf's
|
||||
AC_TRY_LINK.
|
||||
|
||||
Example:
|
||||
|
||||
tar xzvf somepkg.tar.gz
|
||||
cd somepkg
|
||||
|
||||
LDFLAGS=/usr/local/rtems/<cpu>-rtems/<bsp>/lib/dummy.rel \
|
||||
CC="<cpu>-rtems-gcc \
|
||||
-B/usr/local/rtems/<cpu>-rtems/<bsp>/lib/ -specs bsp_specs -qrtems" \
|
||||
CC_FOR_BUILD="gcc" \
|
||||
configure --host=<cpu>-rtems --build=i686-pc-linux-gnu
|
||||
make
|
||||
|
||||
History:
|
||||
Starting dummy.c with a copy of rtems-19990528/c/src/tests/samples/minimum/init.c
|
||||
105
cpukit/libmisc/dummy/default-configuration.c
Normal file
105
cpukit/libmisc/dummy/default-configuration.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Default configuration file
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2008.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
int main( int argc, char **argv );
|
||||
|
||||
static void Init( rtems_task_argument arg )
|
||||
{
|
||||
const char *boot_cmdline = *((const char **) arg);
|
||||
char *cmdline = NULL;
|
||||
int argc = 0;
|
||||
char **argv = NULL;
|
||||
int result;
|
||||
|
||||
if ( boot_cmdline != NULL ) {
|
||||
size_t n = strlen( boot_cmdline ) + 1;
|
||||
|
||||
cmdline = malloc( n );
|
||||
if ( cmdline != NULL ) {
|
||||
char* command;
|
||||
|
||||
memcpy( cmdline, boot_cmdline, n);
|
||||
|
||||
command = cmdline;
|
||||
|
||||
/*
|
||||
* Break the line up into arguments with "" being ignored.
|
||||
*/
|
||||
while ( true ) {
|
||||
command = strtok( command, " \t\r\n" );
|
||||
if ( command == NULL )
|
||||
break;
|
||||
|
||||
++argc;
|
||||
command = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* If there are arguments, allocate enough memory for the argv
|
||||
* array to be passed into main().
|
||||
*
|
||||
* NOTE: If argc is 0, then argv will be NULL.
|
||||
*/
|
||||
argv = calloc( argc, sizeof( *argv ) );
|
||||
if ( argv != NULL ) {
|
||||
int a;
|
||||
|
||||
command = cmdline;
|
||||
argv[ 0 ] = command;
|
||||
|
||||
for ( a = 1; a < argc; ++a ) {
|
||||
command += strlen( command ) + 1;
|
||||
argv[ a ] = command;
|
||||
}
|
||||
} else {
|
||||
argc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = main( argc, argv );
|
||||
|
||||
free( argv );
|
||||
free( cmdline );
|
||||
|
||||
exit( result );
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
|
||||
/* This is enough to get a basic main() up. */
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
#define CONFIGURE_UNIFIED_WORK_AREAS
|
||||
#define CONFIGURE_UNLIMITED_OBJECTS
|
||||
#define CONFIGURE_STACK_CHECKER_ENABLED
|
||||
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
|
||||
#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 8
|
||||
#define CONFIGURE_MAXIMUM_DRIVERS 16
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
|
||||
|
||||
/* Include basic device drivers needed to call delays */
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_DISABLE_BSP_SETTINGS
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Dummy configuration file
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2008.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
int main( int, char **, char **);
|
||||
|
||||
/* configuration information */
|
||||
|
||||
/* This is enough to get a basic main() up. */
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
#define CONFIGURE_MAXIMUM_TASKS 10
|
||||
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
|
||||
#define CONFIGURE_INIT_TASK_ENTRY_POINT (void *)main
|
||||
|
||||
/* Include basic device drivers needed to call delays */
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_DISABLE_BSP_SETTINGS
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
ACLOCAL_AMFLAGS = -I ../aclocal
|
||||
|
||||
_SUBDIRS = POSIX
|
||||
_SUBDIRS += defaultconfig01
|
||||
_SUBDIRS += pwdgrp02
|
||||
_SUBDIRS += shell01
|
||||
_SUBDIRS += pwdgrp01
|
||||
|
||||
@@ -67,6 +67,7 @@ AM_CONDITIONAL(DLTESTS,[test x"$TEST_LIBDL" = x"yes"])
|
||||
|
||||
# Explicitly list all Makefiles here
|
||||
AC_CONFIG_FILES([Makefile
|
||||
defaultconfig01/Makefile
|
||||
pwdgrp02/Makefile
|
||||
shell01/Makefile
|
||||
pwdgrp01/Makefile
|
||||
|
||||
19
testsuites/libtests/defaultconfig01/Makefile.am
Normal file
19
testsuites/libtests/defaultconfig01/Makefile.am
Normal file
@@ -0,0 +1,19 @@
|
||||
rtems_tests_PROGRAMS = defaultconfig01
|
||||
defaultconfig01_SOURCES = init.c
|
||||
|
||||
dist_rtems_tests_DATA = defaultconfig01.scn defaultconfig01.doc
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../automake/compile.am
|
||||
include $(top_srcdir)/../automake/leaf.am
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
|
||||
LINK_OBJS = $(defaultconfig01_OBJECTS)
|
||||
LINK_LIBS = $(defaultconfig01_LDLIBS)
|
||||
|
||||
defaultconfig01$(EXEEXT): $(defaultconfig01_OBJECTS) $(defaultconfig01_DEPENDENCIES)
|
||||
@rm -f defaultconfig01$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
11
testsuites/libtests/defaultconfig01/defaultconfig01.doc
Normal file
11
testsuites/libtests/defaultconfig01/defaultconfig01.doc
Normal file
@@ -0,0 +1,11 @@
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: defaultconfig01
|
||||
|
||||
directives:
|
||||
|
||||
- main()
|
||||
|
||||
concepts:
|
||||
|
||||
- Make sure the default configuration works.
|
||||
2
testsuites/libtests/defaultconfig01/defaultconfig01.scn
Normal file
2
testsuites/libtests/defaultconfig01/defaultconfig01.scn
Normal file
@@ -0,0 +1,2 @@
|
||||
*** BEGIN OF TEST DEFAULTCONFIG 1 ***
|
||||
*** END OF TEST DEFAULTCONFIG 1 ***
|
||||
59
testsuites/libtests/defaultconfig01/init.c
Normal file
59
testsuites/libtests/defaultconfig01/init.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2014 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <bsp.h>
|
||||
|
||||
#include "tmacros.h"
|
||||
|
||||
const char rtems_test_name[] = "DEFAULTCONFIG 1";
|
||||
|
||||
static void install_bsp_extension(void)
|
||||
{
|
||||
#ifdef BSP_INITIAL_EXTENSION
|
||||
static const rtems_extensions_table bsp_ext = BSP_INITIAL_EXTENSION;
|
||||
|
||||
rtems_status_code sc;
|
||||
rtems_id id;
|
||||
|
||||
sc = rtems_extension_create(
|
||||
rtems_build_name('B', 'S', 'P', ' '),
|
||||
&bsp_ext,
|
||||
&id
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
install_bsp_extension();
|
||||
|
||||
for (i = 0; i < argc; ++i) {
|
||||
printf("argv[%i] = %s\n", i, argv[i]);
|
||||
}
|
||||
|
||||
TEST_END();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user