This is Unofficial EPICS BASE Doxygen Site
rtems_init.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <rtems.h>
#include <rtems/malloc.h>
#include <rtems/error.h>
#include <rtems/stackchk.h>
#include <rtems/rtems_bsdnet.h>
#include <rtems/imfs.h>
#include <librtemsNfs.h>
#include <bsp.h>
#include "epicsVersion.h"
#include "epicsThread.h"
#include "epicsTime.h"
#include "epicsExit.h"
#include "envDefs.h"
#include "errlog.h"
#include "logClient.h"
#include "osiUnistd.h"
#include "iocsh.h"
#include "osdTime.h"
#include "epicsMemFs.h"
#include "epicsRtemsInitHooks.h"
+ Include dependency graph for rtems_init.c:

Go to the source code of this file.

Macros

#define RTEMS_VERSION_INT   VERSION_INT(__RTEMS_MAJOR__, __RTEMS_MINOR__, 0, 0)
 
#define NFS_INIT   rpcUdpInit(); nfsInit(0,0);
 

Functions

int main (int argc, char **argv)
 
void LogFatal (const char *msg,...)
 
void * mustMalloc (int size, const char *msg)
 
const epicsMemFS *epicsRtemsFSImage __attribute__ ((weak))
 
int epicsRtemsMountLocalFilesystem (char **argv) __attribute__((weak))
 
void zoneset (const char *zone)
 
rtems_task Init (rtems_task_argument ignored)
 

Variables

const epicsMemFSepicsRtemsFSImage = (void*)&epicsRtemsFSImage
 
rtems_configuration_table Configuration
 
struct rtems_bsdnet_config rtems_bsdnet_config
 
const void * rtemsConfigArray []
 

Macro Definition Documentation

#define NFS_INIT   rpcUdpInit(); nfsInit(0,0);

Definition at line 213 of file rtems_init.c.

#define RTEMS_VERSION_INT   VERSION_INT(__RTEMS_MAJOR__, __RTEMS_MINOR__, 0, 0)

Definition at line 50 of file rtems_init.c.

Function Documentation

int cexpdebug __attribute__ ( (weak)  )
int epicsRtemsMountLocalFilesystem ( char **  argv)

Definition at line 130 of file rtems_init.c.

131 {
133  return -1; /* no FS image provided. */
134  else if(epicsRtemsFSImage==NULL)
135  return 0; /* no FS image provided, but none is needed. */
136  else {
137  printf("***** Using compiled in file data *****\n");
138  if (epicsMemFsLoad(epicsRtemsFSImage) != 0) {
139  printf("Can't unpack tar filesystem\n");
140  return -1;
141  } else {
142  argv[1] = "/";
143  return 0;
144  }
145  }
146 }
#define printf
Definition: epicsStdio.h:41
#define NULL
Definition: catime.c:38
int epicsMemFsLoad(const epicsMemFS *fs)
Definition: epicsMemFs.c:22
const epicsMemFS * epicsRtemsFSImage
Definition: rtems_init.c:124
rtems_task Init ( rtems_task_argument  ignored)

Definition at line 565 of file rtems_init.c.

566 {
567  int result;
568  char *argv[3] = { NULL, NULL, NULL };
569  char *cp;
570  rtems_task_priority newpri;
571  rtems_status_code sc;
572  rtems_time_of_day now;
573 
574  /*
575  * Explain why we're here
576  */
577  logReset();
578 
579  /*
580  * Architecture-specific hooks
581  */
583  delayedPanic("epicsRtemsInitPreSetBootConfigFromNVRAM");
584  if (rtems_bsdnet_config.bootp == NULL) {
585  extern void setBootConfigFromNVRAM(void);
587  }
589  delayedPanic("epicsRtemsInitPostSetBootConfigFromNVRAM");
590 
591  /*
592  * Override RTEMS configuration
593  */
594  rtems_task_set_priority (
595  RTEMS_SELF,
597  &newpri);
598 
599  /*
600  * Create a reasonable environment
601  */
602  initConsole ();
603  putenv ("TERM=xterm");
604  putenv ("IOCSH_HISTSIZE=20");
605 
606  /*
607  * Display some OS information
608  */
609  printf("\n***** RTEMS Version: %s *****\n",
610  rtems_get_version_string());
611 
612  /*
613  * Start network
614  */
615  if ((cp = getenv("EPICS_TS_NTP_INET")) != NULL)
616  rtems_bsdnet_config.ntp_server[0] = cp;
617  if (rtems_bsdnet_config.network_task_priority == 0)
618  {
619  unsigned int p;
622  {
623  rtems_bsdnet_config.network_task_priority = epicsThreadGetOssPriorityValue(p);
624  }
625  }
626  printf("\n***** Initializing network *****\n");
627  rtems_bsdnet_initialize_network();
628  printf("\n***** Setting up file system *****\n");
629  initialize_remote_filesystem(argv, initialize_local_filesystem(argv));
630  fixup_hosts();
631 
632  /*
633  * More environment: iocsh prompt and hostname
634  */
635  {
636  char hostname[1024];
637  gethostname(hostname, 1023);
638  char *cp = mustMalloc(strlen(hostname)+3, "iocsh prompt");
639  sprintf(cp, "%s> ", hostname);
640  epicsEnvSet ("IOCSH_PS1", cp);
641  epicsEnvSet("IOC_NAME", hostname);
642  }
643 
644  /*
645  * Use BSP-supplied time of day if available otherwise supply default time.
646  * It is very likely that other time synchronization facilities in EPICS
647  * will soon override this value.
648  */
649  if (rtems_clock_get(RTEMS_CLOCK_GET_TOD,&now) != RTEMS_SUCCESSFUL) {
650  now.year = 2001;
651  now.month = 1;
652  now.day = 1;
653  now.hour = 0;
654  now.minute = 0;
655  now.second = 0;
656  now.ticks = 0;
657  if ((sc = rtems_clock_set (&now)) != RTEMS_SUCCESSFUL)
658  printf ("***** Can't set time: %s\n", rtems_status_text (sc));
659  }
660  if (getenv("TZ") == NULL) {
661  const char *tzp = envGetConfigParamPtr(&EPICS_TZ);
662  if (!tzp || *tzp)
663  printf("Warning: No timezone information, times will be displayed in UTC.\n");
664  else
665  epicsEnvSet("TZ", tzp);
666  }
667  tzset();
668  osdTimeRegister();
669 
670  /*
671  * Run the EPICS startup script
672  */
673  printf ("***** Preparing EPICS application *****\n");
674  iocshRegisterRTEMS ();
675  set_directory (argv[1]);
676  epicsEnvSet ("IOC_STARTUP_SCRIPT", argv[1]);
677  atexit(exitHandler);
678  errlogFlush();
679  printf ("***** Starting EPICS application *****\n");
680  result = main ((sizeof argv / sizeof argv[0]) - 1, argv);
681  printf ("***** IOC application terminating *****\n");
682  epicsThreadSleep(1.0);
683  epicsExit(result);
684 }
void errlogFlush(void)
Definition: errlog.c:529
pvac::PutEvent result
Definition: clientSync.cpp:117
LIBCOM_API const ENV_PARAM EPICS_TZ
int epicsRtemsInitPreSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config)
struct rtems_bsdnet_config rtems_bsdnet_config
LIBCOM_API const char *epicsStdCall envGetConfigParamPtr(const ENV_PARAM *pParam)
Get a configuration parameter&#39;s value or default string.
Definition: envSubr.c:81
#define printf
Definition: epicsStdio.h:41
#define NULL
Definition: catime.c:38
void osdTimeRegister(void)
Definition: osdTime.cpp:36
LIBCOM_API void epicsStdCall epicsEnvSet(const char *name, const char *value)
Set an environment variable&#39;s value.
Definition: osdEnv.c:35
#define epicsThreadPriorityIocsh
Definition: epicsThread.h:84
int main(int argc, char **argv)
Definition: acctstMain.c:17
int epicsThreadGetOssPriorityValue(unsigned int osiPriority)
Definition: osdThread.c:98
LIBCOM_API void epicsExit(int status)
Calls epicsExitCallAtExits(), then the OS exit() routine.
Definition: epicsExit.c:182
int putenv(char *)
LIBCOM_API epicsThreadBooleanStatus epicsStdCall epicsThreadHighestPriorityLevelBelow(unsigned int priority, unsigned *pPriorityJustBelow)
Definition: osdThread.c:740
LIBCOM_API void epicsStdCall epicsThreadSleep(double seconds)
Block the calling thread for at least the specified time.
Definition: osdThread.c:790
#define epicsThreadPriorityScanLow
Definition: epicsThread.h:82
void setBootConfigFromNVRAM(void)
void * mustMalloc(int size, const char *msg)
Definition: rtems_init.c:105
int epicsRtemsInitPostSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config)
void LogFatal ( const char *  msg,
  ... 
)

Definition at line 94 of file rtems_init.c.

95 {
96  va_list ap;
97 
98  va_start (ap, msg);
99  errlogVprintf (msg, ap);
100  va_end (ap);
101  delayedPanic (msg);
102 }
int errlogVprintf(const char *pFormat, va_list pvar)
Definition: errlog.c:144
int main ( int  argc,
char **  argv 
)

Definition at line 17 of file acctstMain.c.

18 {
19  unsigned progressLoggingLevel;
20  unsigned channelCount;
21  unsigned repetitionCount;
22  enum ca_preemptive_callback_select preempt;
23  int aBoolean;
24 
25 
26  if ( argc < 2 || argc > 6 ) {
27  printf ("usage: %s <PV name> [progress logging level] [channel count] "
28  "[repetition count] [enable preemptive callback]\n",
29  argv[0] );
30  return 1;
31  }
32 
33  if ( argc >= 3 ) {
34  progressLoggingLevel = atoi ( argv[2] );
35  }
36  else {
37  progressLoggingLevel = 0;
38  }
39 
40  if ( argc >= 4 ) {
41  channelCount = atoi ( argv[3] );
42  }
43  else {
44  channelCount = 20000;
45  }
46 
47  if ( argc >= 5 ) {
48  repetitionCount = atoi ( argv[4] );
49  }
50  else {
51  repetitionCount = 1;
52  }
53 
54  if ( argc >= 6 ) {
55  aBoolean = atoi ( argv[5] );
56  }
57  else {
58  aBoolean = 0;
59  }
60  if ( aBoolean ) {
62  }
63  else {
65  }
66 
67  acctst ( argv[1], progressLoggingLevel, channelCount, repetitionCount, preempt );
68 
69  return 0;
70 }
ca_preemptive_callback_select
Definition: cadef.h:175
#define printf
Definition: epicsStdio.h:41
int acctst(const char *pName, unsigned interestLevel, unsigned channelCount, unsigned repetitionCount, enum ca_preemptive_callback_select select)
Definition: acctst.c:3398
void* mustMalloc ( int  size,
const char *  msg 
)

Definition at line 105 of file rtems_init.c.

106 {
107  void *p;
108 
109  if ((p = malloc (size)) == NULL)
110  LogFatal ("Can't allocate space for %s.\n", msg);
111  return p;
112 }
#define NULL
Definition: catime.c:38
void LogFatal(const char *msg,...)
Definition: rtems_init.c:94
void zoneset ( const char *  zone)

Definition at line 491 of file rtems_init.c.

492 {
493  if(zone)
494  setenv("TZ", zone, 1);
495  else
496  unsetenv("TZ");
497  tzset();
498 }

Variable Documentation

rtems_configuration_table Configuration
const epicsMemFS* epicsRtemsFSImage = (void*)&epicsRtemsFSImage

Definition at line 124 of file rtems_init.c.

struct rtems_bsdnet_config rtems_bsdnet_config

Definition at line 116 of file rtems_netconfig.c.

const void* rtemsConfigArray[]
Initial value:
= {
}
struct rtems_bsdnet_config rtems_bsdnet_config
rtems_configuration_table Configuration

Definition at line 547 of file rtems_init.c.