There placed minimal application based on RTEMS, Real Time Embedded Military System.
Source rtems-shell.tar.xz
/* * $Id: confapp.h,v 1.1 2007/12/02 10:13:59 root Exp root $ */ #ifndef _CONFIG_APP_H #define _CONFIG_APP_H 1 #define APP_USE_RC 1 #define APP_USE_MONITOR 1 #define APP_USE_TARFS 1 #define APP_USE_ATA 0 #undef APP_USE_RAMDISK #define APP_USE_LOGIN 1 #endif
/* * $Id: confrt.h,v 1.1 2007/12/02 10:13:59 root Exp root $ */ #ifndef _CONFIG_RTEMS_H #define _CONFIG_RTEMS_H 1 #include "config.h" #include <rtems.h> #include <bsp.h> #ifdef APP_USE_MONITOR #include <rtems/monitor.h> #endif #ifdef APP_USE_TARFS #include <rtems/untar.h> #endif #include <rtems/mkrootfs.h> #ifdef APP_USE_ATA #define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER 1 #define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER 1 #define CONFIGURE_ATA_DRIVER_TASK_PRIORITY 9 #endif #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER 1 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER 1 #define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK 1 #define CONFIGURE_EXECUTIVE_RAM_SIZE (1024*1024) #define CONFIGURE_FILESYSTEM_IMFS 1 #define CONFIGURE_FILESYSTEM_MSDOS 1 #define CONFIGURE_FILESYSTEM_RFS 1 #define CONFIGURE_FILESYSTEM_TFTPFS 1 #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_PRIORITY 120 #define CONFIGURE_INIT_TASK_STACK_SIZE (32*1024) #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 200 #define CONFIGURE_MAXIMUM_DRIVERS 10 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 128 #define CONFIGURE_MAXIMUM_PARTITIONS 2 #define CONFIGURE_MAXIMUM_SEMAPHORES 512 #define CONFIGURE_MAXIMUM_TASKS 1024 #define CONFIGURE_MAXIMUM_TIMERS 5 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1 #define CONFIGURE_MICROSECONDS_PER_TICK 10000 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_SHELL_COMMANDS_ALL 1 #define CONFIGURE_SHELL_COMMANDS_INIT 1 #define CONFIGURE_SHELL_MOUNT_MSDOS 1 #define CONFIGURE_SHELL_MOUNT_RFS 1 #define CONFIGURE_STACK_CHECKER_ENABLED 1 #define CONFIGURE_SWAPOUT_TASK_PRIORITY 10 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM 1 #define TASK_INTLEVEL 0 rtems_task Init(rtems_task_argument argument); #include <rtems/shellconfig.h> #include <rtems/confdefs.h> #endif
/* * Extern declarations for C structure representing binary file data.tar * WARNING: Automatically generated -- do not edit! */ #ifndef __data_h #define __data_h #include <sys/types.h> extern const unsigned char data_tar[]; extern const size_t data_tar_size; #endif
/* * Declarations for C structure representing binary file data.tar * WARNING: Automatically generated -- do not edit! */ #include <sys/types.h> const unsigned char data_tar[] = { 0x65, 0x74, 0x63, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const size_t data_tar_size = sizeof(data_tar);
/* * $Id: shell.h,v 1.1 2007/12/02 10:13:59 root Exp root $ */ int ramdisk_init(void);
/* * $Id: shell.h,v 1.1 2007/12/02 10:13:59 root Exp root $ */ #include <sys/stat.h> #include <fcntl.h> #include <rtems/ramdisk.h> #include <rtems/blkdev.h> #include <rtems/libio.h> #include "config.h" #include "ramdsk.h" #ifdef APP_USE_RAMDISK #define RAMDISK_BLOCK_SIZE (512) #define RAMDISK_BLOCK_COUNT (2048*2) #define RAMDISK_PATH "/dev/ramdisk" dev_t dev = 0; int ramdisk_init(void) { int st = 0; rtems_status_code sc; sc = rtems_disk_io_initialize(); if (sc == RTEMS_SUCCESSFUL) { sc = ramdisk_register(RAMDISK_BLOCK_SIZE, RAMDISK_BLOCK_COUNT, false, RAMDISK_PATH, &dev); if (sc == RTEMS_SUCCESSFUL) { return(0); } else { return((int)sc); } } else { return((int)sc); } } #endif
/* * $Id: shell.h,v 1.1 2007/12/02 10:13:59 root Exp root $ */ int shell_rc(void); int shell_start(void);
/* * $Id: shell.c,v 1.1 2007/12/02 10:13:59 root Exp root $ */ #include "config.h" #include <stdio.h> #include <stdlib.h> #include <bsp.h> #include <fcntl.h> #include <termios.h> #include <errno.h> #include <rtems/shell.h> #include <rtems/bdbuf.h> #include <rtems/error.h> #include "shell.h" #define SH_RC_STACK_SIZE (40*1024) #define SH_RC_PRIORITY 50 #define SH_RC_RUN_ONCE 0 #define SH_RC_WAIT 1 #define SH_RC_VERBOSE 0 #ifndef SH_RC_SCRIPT #define SH_RC_SCRIPT "/etc/rc" #endif int shell_rc (void){ #ifdef APP_USE_RC rtems_status_code sc; sc = rtems_shell_script("SHELL", SH_RC_STACK_SIZE, SH_RC_PRIORITY, SH_RC_SCRIPT, "stdout", SH_RC_RUN_ONCE, SH_RC_WAIT, SH_RC_VERBOSE); if (sc != RTEMS_SUCCESSFUL) { printf ("Error running shell script: %s (%d)\n", rtems_status_text (sc), sc); } #endif return(0); } #define SHELL_STACK_SIZE (20*1024) #define SHELL_PRIORITY 20 #define SHELL_RUN_ONCE 0 #define SHELL_WAIT 1 #ifdef APP_USE_LOGIN #define SHELL_LOGIN_PTR rtems_shell_login_check #else #define SHELL_LOGIN_PTR NULL #endif int shell_start (void) { rtems_status_code sc; sc = rtems_shell_init("SHELL", SHELL_STACK_SIZE, SHELL_PRIORITY, "/dev/console", SHELL_RUN_ONCE, SHELL_WAIT, SHELL_LOGIN_PTR); if (sc != RTEMS_SUCCESSFUL) { printf ("Error starting shell: %s (%d)\n", rtems_status_text(sc), sc); } return(0); } /* EOF */
/* * $Id: init.c,v 1.1 2007/12/02 10:13:59 root Exp root $ */ #include <stdio.h> #include <stdlib.h> #include <netinet/in.h> #include <rtems/dosfs.h> #include <ctype.h> #include <rtems/bdpart.h> #include <rtems/libcsupport.h> #include <rtems/fsmount.h> #include "config.h" #include "shell.h" #include "ramdsk.h" #include "confrt.h" #include "data.h" rtems_task Init(rtems_task_argument ignored) { int st; rtems_status_code sc; printf("\nBoot RTEMS kernel...\n\n"); #ifndef APP_USE_LOGIN printf("%s \n", _RTEMS_version); printf("%s \n\n", _Copyright_Notice); #endif printf("Unpacking tar filesystem.\n"); if(Untar_FromMemory((void *)data_tar, data_tar_size) != 0) { printf("Can't unpack tar filesystem\n"); exit(1); } #ifdef APP_USE_RAMDISK printf("Setup ramdisk..."); if ((st = ramdisk_init()) == 0) { printf("Ok\n"); } else { printf("Error\n"); } #endif #ifdef APP_USE_RC printf("Execute local commands.\n"); st = shell_rc(); #endif while (1) { printf("Start RTEMS shell.\n"); st = shell_start(); } printf("End the RTEMS init task.\n"); sc = rtems_task_delete(RTEMS_SELF); printf( "Error: rtems_task_delete return status: %d.\n", st); exit(1); }