⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtems.c.cfe

📁 osapi 2.0 操作系统抽象层 "系统抽象层"使得你可以实现一种对于RTOS、CPU和所运行产品物理特性完全透明的软件。使用这种公共通用接口
💻 CFE
字号:
//// FSW-EXEC Core RTEMS startup///*** Includes*/#include <rtems.h>#include <bsp.h>#include <stdio.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#include <ostypes.h>#include <osapi.h>/* ** Includes for file system*/#include <imfs.h>#include <rtems/mkrootfs.h>//#include <rtems/untar.h>// Include bsdnet#include <rtems/rtems_bsdnet.h>#include <sys/domain.h>#include <sys/mbuf.h>#include <sys/socketvar.h>#include <sys/socket.h>#include <sys/sockio.h>#include <sys/callout.h>#include <sys/proc.h>#include <sys/ioctl.h>#include <net/if.h>#include <net/route.h>#include <netinet/in.h>#include <vm/vm.h>#include <arpa/inet.h>#include <net/netisr.h>#include <net/route.h>struct rtems_bsdnet_config	rtems_bsdnet_config;// network config itemsstruct rtems_bsdnet_ifconfig	if1cfg;extern int rtems_dec21140_driver_attach(struct rtems_bsdnet_ifconfig *, int);// localhost interface config itemsstruct rtems_bsdnet_ifconfig	locfg;extern int rtems_bsdnet_loopattach(void);// end net/*** Prototypes*/rtems_task Init( rtems_task_argument ignored );extern int OS_fswExecMain( int startType, int modeId );/*** RTEMS OS Configuration defintions*/#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_MAXIMUM_TASKS         20 #define CONFIGURE_MAXIMUM_TIMERS        3#define CONFIGURE_MAXIMUM_SEMAPHORES    8 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 30#define CONFIGURE_MAXIMUM_POSIX_THREADS         CONFIGURE_MAXIMUM_TASKS#define CONFIGURE_MAXIMUM_POSIX_TIMERS          CONFIGURE_MAXIMUM_TIMERS#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES      CONFIGURE_MAXIMUM_SEMAPHORES#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES  CONFIGURE_MAXIMUM_MESSAGE_QUEUES#define CONFIGURE_MAXIMUM_POSIX_MUTEXES         5 #define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 5 #define CONFIGURE_MAXIMUM_POSIX_KEYS           5 #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS        10#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_LIBIO_MAXIMUM_FILE_DESCRIPTORS    100#define CONFIGURE_MICROSECONDS_PER_TICK         10000/*** This include file must be AFTER the ** configuration data.*/#include <confdefs.h>/*** Definitions & Prototypes*/extern rtems_configuration_table BSP_Configuration;extern unsigned32 _end;void OS_create_fake_1hz(void);/*** Function: Init** Purpose: RTEMS Entry Point*/ rtems_task Init( rtems_task_argument ignored ){   printf("\n\n");   printf( "\n\n*** RTEMS Info ***\n" );   printf("%s", _Copyright_Notice );   printf("%s\n\n", _RTEMS_version );   printf(" Workspace base %08X\n", (unsigned32)BSP_Configuration.work_space_start );   printf(" Workspace size %d\n",   BSP_Configuration.work_space_size );   printf("  Workspace top %08X\n", (unsigned32)BSP_Configuration.work_space_start                                     + BSP_Configuration.work_space_size );   printf("\n");   printf( "*** End RTEMS info ***\n\n" );   rtems_create_root_fs();   printf( "\n\n*** Configuring network... ***\n\n" );   sleep(1);   memset(&rtems_bsdnet_config,0,sizeof(struct rtems_bsdnet_config));   memset(&locfg,  0, sizeof(struct rtems_bsdnet_ifconfig));   memset(&if1cfg, 0, sizeof(struct rtems_bsdnet_ifconfig));   rtems_bsdnet_config.network_task_priority    = 1;   rtems_bsdnet_config.mbuf_bytecount           = 128*1024;   rtems_bsdnet_config.mbuf_cluster_bytecount   = 256*1024;   rtems_bsdnet_config.hostname = "pDH";   rtems_bsdnet_config.domainname = "gsfc.nasa.gov";   rtems_bsdnet_config.gateway = "192.168.1.1";   rtems_bsdnet_config.name_server[0]= "192.168.1.1";   //rtems_bsdnet_config.name_server[1]= "";   //rtems_bsdnet_config.ntp_server[0] = "192.168.1.1";   rtems_bsdnet_config.ifconfig = &locfg;   locfg.name = "lo0";   locfg.attach = rtems_bsdnet_loopattach;   locfg.ip_address= "127.0.0.1";   locfg.ip_netmask= "255.0.0.0";   locfg.next = &if1cfg;   if1cfg.name = "dc1";   if1cfg.ip_address= "192.168.1.6";   if1cfg.ip_netmask= "255.255.255.0";   if1cfg.attach = rtems_dec21140_driver_attach;   if1cfg.rbuf_count = if1cfg.xbuf_count = 32;   if( rtems_bsdnet_initialize_network() == -1 )   {      perror("network init");      exit(0);   }   sleep(1);   printf("\nHostname is %s.%s\n", rtems_bsdnet_config.hostname, rtems_bsdnet_config.domainname );   {      struct rtems_bsdnet_ifconfig *if1;      for( if1 = &locfg; if1; if1 = if1->next )      {         printf("   device %s, netmask %s, address %s\n", if1->name, if1->ip_netmask, if1->ip_address );      }   }   printf("   gateway %s, dns1 %s, dns2 %s\n\n\n", rtems_bsdnet_config.gateway,                                                   rtems_bsdnet_config.name_server[0],                                                    rtems_bsdnet_config.name_server[1] );   // end network init ---------------------------------------------------------   OS_create_fake_1hz();   /*   ** Pass in the Restart type   */   OS_fswExecMain(OS_COLD,OS_PROM);   // OS_fswExecMain(OS_POWER_ON,OS_PROM);      /*   ** End the RTEMS init thread    */}/********************************************************************************** Fake 1hz timer routines* Start an RTEMS timer that calls the 1hz ISR code **********************************************************************************/extern void OS_1HzISRShell(void);rtems_timer_service_routine MyTimer(      rtems_id  timer_id,      void      *user_data){                                                                                                             rtems_status_code rtemsStatus;    rtemsStatus = rtems_timer_reset(timer_id);   OS_1HzISRShell();}	    void OS_create_fake_1hz(void){   rtems_status_code rtemsStatus;   rtems_name        timerName;   rtems_id          timerId;   /*   ** Create a timer    */   timerName = rtems_build_name('T','M','R','0');   rtemsStatus = rtems_timer_create(timerName, &timerId);   if (rtemsStatus != RTEMS_SUCCESSFUL )   {       printf("Timer Create Failed\n");       return;   }                                                                                                          /*                           ** Activate the timer                                                                                      */                                                                                                         rtemsStatus = rtems_timer_fire_after ( timerId, 100, MyTimer, 0);      if (rtemsStatus != RTEMS_SUCCESSFUL )                                                                       {                                                                                                               printf("Timer fire_after call Failed\n");          return;                                                                                                 }                                                                                                           else                                                                                                        {                                                                                                               printf("Timer activated.\n");    }                                                                                                       }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -