Clean up formatting.

Allow for more semaphores -- sequencers use a whole bunch!
This commit is contained in:
W. Eric Norum
2000-04-11 01:15:48 +00:00
parent 0c09c096db
commit a785881d9f
+231 -231
View File
@@ -1,6 +1,6 @@
/*
* RTEMS startup task for EPICS
* $Id$
* $Id$
* Author: W. Eric Norum
* eric@cls.usask.ca
* (306) 966-6055
@@ -34,24 +34,24 @@
*/
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_EXECUTIVE_RAM_SIZE (700*1024)
#define CONFIGURE_MAXIMUM_TASKS 60
#define CONFIGURE_MAXIMUM_SEMAPHORES 180
#define CONFIGURE_MAXIMUM_TIMERS 50
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 30
#define CONFIGURE_EXECUTIVE_RAM_SIZE (700*1024)
#define CONFIGURE_MAXIMUM_TASKS 80
#define CONFIGURE_MAXIMUM_SEMAPHORES 220
#define CONFIGURE_MAXIMUM_TIMERS 50
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 30
#define CONFIGURE_MICROSECONDS_PER_TICK 20000
#define CONFIGURE_MICROSECONDS_PER_TICK 20000
#define CONFIGURE_INIT_TASK_PRIORITY 220
#define NETWORK_TASK_PRIORITY 120
#define NETWORK_TASK_PRIORITY 120
#define CONFIGURE_INIT
#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
RTEMS_NO_TIMESLICE | \
RTEMS_NO_ASR | \
RTEMS_INTERRUPT_LEVEL(0))
RTEMS_NO_TIMESLICE | \
RTEMS_NO_ASR | \
RTEMS_INTERRUPT_LEVEL(0))
#define CONFIGURE_INIT_TASK_INITIAL_ATTRIBUTES (RTEMS_FLOATING_POINT | \
RTEMS_LOCAL)
RTEMS_LOCAL)
#define CONFIGURE_INIT_TASK_STACK_SIZE (12*1024)
rtems_task Init (rtems_task_argument argument);
@@ -68,23 +68,23 @@ rtems_driver_address_table Device_drivers[] = {
*/
extern void rtems_bsdnet_loopattach();
static struct rtems_bsdnet_ifconfig loopback_config = {
"lo0", /* name */
rtems_bsdnet_loopattach, /* attach function */
NULL, /* link to next interface */
"127.0.0.1", /* IP address */
"255.0.0.0", /* IP net mask */
"lo0", /* name */
rtems_bsdnet_loopattach, /* attach function */
NULL, /* link to next interface */
"127.0.0.1", /* IP address */
"255.0.0.0", /* IP net mask */
};
static struct rtems_bsdnet_ifconfig netdriver_config = {
RTEMS_BSP_NETWORK_DRIVER_NAME, /* name */
RTEMS_BSP_NETWORK_DRIVER_ATTACH, /* attach function */
RTEMS_BSP_NETWORK_DRIVER_NAME, /* name */
RTEMS_BSP_NETWORK_DRIVER_ATTACH, /* attach function */
&loopback_config, /* link to next interface */
};
struct rtems_bsdnet_config rtems_bsdnet_config = {
&netdriver_config, /* Network interface */
rtems_bsdnet_do_bootp, /* Use BOOTP to get network configuration */
NETWORK_TASK_PRIORITY, /* Network task priority */
150*1024, /* MBUF space */
300*1024, /* MBUF cluster space */
&netdriver_config, /* Network interface */
rtems_bsdnet_do_bootp, /* Use BOOTP to get network configuration */
NETWORK_TASK_PRIORITY, /* Network task priority */
150*1024, /* MBUF space */
300*1024, /* MBUF cluster space */
};
/*
@@ -98,11 +98,11 @@ struct rtems_bsdnet_config rtems_bsdnet_config = {
static void
delayedPanic (const char *msg)
{
rtems_interval ticksPerSecond;
rtems_interval ticksPerSecond;
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
rtems_task_wake_after (ticksPerSecond);
rtems_panic (msg);
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
rtems_task_wake_after (ticksPerSecond);
rtems_panic (msg);
}
/*
@@ -111,12 +111,12 @@ delayedPanic (const char *msg)
void
LogFatal (const char *msg, ...)
{
va_list ap;
va_list ap;
va_start (ap, msg);
vsyslog (LOG_ALERT, msg, ap);
va_end (ap);
delayedPanic (msg);
va_start (ap, msg);
vsyslog (LOG_ALERT, msg, ap);
va_end (ap);
delayedPanic (msg);
}
/*
@@ -125,8 +125,8 @@ LogFatal (const char *msg, ...)
void
LogRtemsFatal (const char *msg, rtems_status_code sc)
{
syslog (LOG_ALERT, "%s: %s", msg, rtems_status_text (sc));
delayedPanic (msg);
syslog (LOG_ALERT, "%s: %s", msg, rtems_status_text (sc));
delayedPanic (msg);
}
/*
@@ -135,8 +135,8 @@ LogRtemsFatal (const char *msg, rtems_status_code sc)
void
LogNetFatal (const char *msg, int err)
{
syslog (LOG_ALERT, "%s: %d", msg, err);
delayedPanic (msg);
syslog (LOG_ALERT, "%s: %d", msg, err);
delayedPanic (msg);
}
/*
@@ -150,39 +150,39 @@ LogNetFatal (const char *msg, int err)
static char *
rtems_tftp_path (const char *name)
{
char *path;
int pathsize = 200;
int l;
char *path;
int pathsize = 200;
int l;
if ((path = malloc (pathsize)) == NULL)
LogFatal ("Can't create TFTP path name -- no memory.\n");
strcpy (path, "/TFTP/");
l = strlen (path);
if (inet_ntop (AF_INET, &rtems_bsdnet_bootp_server_address, &path[l], pathsize - l) == NULL)
LogFatal ("Can't convert BOOTP server name");
l = strlen (path);
strcpy (&path[l], "/epics/");
l = strlen (path);
if (gethostname (&path[l], pathsize - l) || (path[l] == '\0'))
LogFatal ("Can't get host name");
l = strlen (path);
path[l++] = '/';
for (;;) {
if (name[0] == '.') {
if (name[1] == '/') {
name += 2;
continue;
}
if ((name[1] == '.') && (name[2] == '/')) {
name += 3;
continue;
}
}
break;
}
path = realloc (path, l + 1 + strlen (name));
strcpy (&path[l], name);
return path;
if ((path = malloc (pathsize)) == NULL)
LogFatal ("Can't create TFTP path name -- no memory.\n");
strcpy (path, "/TFTP/");
l = strlen (path);
if (inet_ntop (AF_INET, &rtems_bsdnet_bootp_server_address, &path[l], pathsize - l) == NULL)
LogFatal ("Can't convert BOOTP server name");
l = strlen (path);
strcpy (&path[l], "/epics/");
l = strlen (path);
if (gethostname (&path[l], pathsize - l) || (path[l] == '\0'))
LogFatal ("Can't get host name");
l = strlen (path);
path[l++] = '/';
for (;;) {
if (name[0] == '.') {
if (name[1] == '/') {
name += 2;
continue;
}
if ((name[1] == '.') && (name[2] == '/')) {
name += 3;
continue;
}
}
break;
}
path = realloc (path, l + 1 + strlen (name));
strcpy (&path[l], name);
return path;
}
/*
@@ -196,77 +196,77 @@ rtems_tftp_path (const char *name)
long
rtems_showStats (unsigned int level)
{
rtems_bsdnet_show_if_stats ();
rtems_bsdnet_show_mbuf_stats ();
if (level >= 1) {
rtems_bsdnet_show_inet_routes ();
}
if (level >= 2) {
rtems_bsdnet_show_ip_stats ();
rtems_bsdnet_show_icmp_stats ();
rtems_bsdnet_show_udp_stats ();
rtems_bsdnet_show_tcp_stats ();
}
return 0;
rtems_bsdnet_show_if_stats ();
rtems_bsdnet_show_mbuf_stats ();
if (level >= 1) {
rtems_bsdnet_show_inet_routes ();
}
if (level >= 2) {
rtems_bsdnet_show_ip_stats ();
rtems_bsdnet_show_icmp_stats ();
rtems_bsdnet_show_udp_stats ();
rtems_bsdnet_show_tcp_stats ();
}
return 0;
}
long
rtems_showSem (void)
{
Semaphore_Control *sem;
int i;
int n;
Semaphore_Control *sem;
int i;
int n;
n = 0;
for (i = 0 ; i < _Semaphore_Information.maximum ; i++) {
sem = (Semaphore_Control *)_Semaphore_Information.local_table[i];
if (sem) {
char *cp = sem->Object.name;
char cbuf[4];
int j;
n = 0;
for (i = 0 ; i < _Semaphore_Information.maximum ; i++) {
sem = (Semaphore_Control *)_Semaphore_Information.local_table[i];
if (sem) {
char *cp = sem->Object.name;
char cbuf[4];
int j;
for (j = 0 ; j < 4 ; j++) {
unsigned char c = cp[j];
if (isprint (c))
cbuf[j] = c;
else
cbuf[j] = ' ';
}
printf ("%4.4s%9x%5x%5d", cbuf, sem->Object.id,
sem->attribute_set,
sem->attribute_set & RTEMS_BINARY_SEMAPHORE ?
sem->Core_control.mutex.lock :
sem->Core_control.semaphore.count);
n++;
if ((n % 3) == 0)
printf ("\n");
else
printf (" ");
}
}
if ((n % 3) != 0)
printf ("\n");
printf ("%d/%d\n", n, _Semaphore_Information.maximum);
return 0;
for (j = 0 ; j < 4 ; j++) {
unsigned char c = cp[j];
if (isprint (c))
cbuf[j] = c;
else
cbuf[j] = ' ';
}
printf ("%4.4s%9x%5x%5d", cbuf, sem->Object.id,
sem->attribute_set,
sem->attribute_set & RTEMS_BINARY_SEMAPHORE ?
sem->Core_control.mutex.lock :
sem->Core_control.semaphore.count);
n++;
if ((n % 3) == 0)
printf ("\n");
else
printf (" ");
}
}
if ((n % 3) != 0)
printf ("\n");
printf ("%d/%d\n", n, _Semaphore_Information.maximum);
return 0;
}
/*
* Dummy commands
* RTEMS does not yet support full NFS.
* RTEMS does not support dynamic loading.
* RTEMS does not yet support full NFS.
* RTEMS does not support dynamic loading.
*/
long
rtems_cdCommand (char *name)
{
printf ("`cd' command ignored.\n");
return 0;
printf ("`cd' command ignored.\n");
return 0;
}
long
rtems_ldCommand (char *name)
{
printf ("`ld' command ignored.\n");
return 0;
printf ("`ld' command ignored.\n");
return 0;
}
/*
@@ -277,67 +277,67 @@ rtems_ldCommand (char *name)
long
rtems_registerRecordDeviceDriver (char *name)
{
extern DBBASE *pdbbase;
int registerRecordDeviceDriver(DBBASE *pdbbase);
extern DBBASE *pdbbase;
int registerRecordDeviceDriver(DBBASE *pdbbase);
if (strcmp (name, "pdbbase") == 0)
return registerRecordDeviceDriver (pdbbase);
errlogPrintf ("Don't know how to registerRecordDeviceDriver(%s)\n", name);
cantProceed ("registerRecordDeviceDriver");
return -1;
if (strcmp (name, "pdbbase") == 0)
return registerRecordDeviceDriver (pdbbase);
errlogPrintf ("Don't know how to registerRecordDeviceDriver(%s)\n", name);
cantProceed ("registerRecordDeviceDriver");
return -1;
}
long
rtems_dbLoadDatabase (char *name)
{
char *cp = rtems_tftp_path (name);
int dbLoadDatabase (char *filename, char *path, char *substitutions);
char *cp = rtems_tftp_path (name);
int dbLoadDatabase (char *filename, char *path, char *substitutions);
dbLoadDatabase (cp, "/", NULL);
free (cp);
return 0;
dbLoadDatabase (cp, "/", NULL);
free (cp);
return 0;
}
long
rtems_dbLoadRecords (char *name, char *substitutions)
{
char *cp = rtems_tftp_path (name);
int dbLoadRecords (char* pfilename, char* substitutions);
char *cp = rtems_tftp_path (name);
int dbLoadRecords (char* pfilename, char* substitutions);
dbLoadRecords (cp, substitutions);
free (cp);
return 0;
dbLoadRecords (cp, substitutions);
free (cp);
return 0;
}
void
rtems_runScript (const char *name)
{
char *cp;
FILE *fp;
char *cp;
FILE *fp;
cp = rtems_tftp_path (name);
fp = fopen (cp, "r");
if (fp == NULL) {
printf ("Can't open script (%s)\n", name);
}
else {
CommandInterpreter (NULL, fp, name);
fclose (fp);
}
free (cp);
cp = rtems_tftp_path (name);
fp = fopen (cp, "r");
if (fp == NULL) {
printf ("Can't open script (%s)\n", name);
}
else {
CommandInterpreter (NULL, fp, name);
fclose (fp);
}
free (cp);
}
void
rtems_reboot (const char *name)
{
int c;
int c;
printf ("Are you sure you want to reboot the IOC? ");
fflush (stdout);
if ((c = getchar ()) == 'Y')
LogFatal ("Reboot");
while ((c != '\n') && (c != EOF))
c = getchar ();
printf ("Are you sure you want to reboot the IOC? ");
fflush (stdout);
if ((c = getchar ()) == 'Y')
LogFatal ("Reboot");
while ((c != '\n') && (c != EOF))
c = getchar ();
}
/*
@@ -345,43 +345,43 @@ rtems_reboot (const char *name)
*/
typedef long (*cmd)();
static const struct CommandTableEntry CommandTable[] = {
{ "<",
"Redirect command",
"*", (cmd)rtems_runScript, 2, 2
},
{ "Reboot",
"Rebot IOC",
NULL, (cmd)rtems_reboot, 1, 1
},
{ "cd",
"Change directories",
NULL, rtems_cdCommand, 2, 2
},
{ "ld",
"Load object module",
NULL, rtems_ldCommand, 3, 3
},
{ "dbLoadDatabase",
"Load database",
"*", rtems_dbLoadDatabase, 2, 2
},
{ "dbLoadRecords",
"Load database records",
"**", rtems_dbLoadRecords, 2, 3
},
{ "registerRecordDeviceDriver",
"Register device driver",
"*", rtems_registerRecordDeviceDriver, 2, 2
},
{ "network",
"Show network statistics",
"i", rtems_showStats, 1, 2
},
{ "semaphore",
"Show semaphores",
"", rtems_showSem, 1, 1
},
{ NULL }
{ "<",
"Redirect command",
"*", (cmd)rtems_runScript, 2, 2
},
{ "Reboot",
"Rebot IOC",
NULL, (cmd)rtems_reboot, 1, 1
},
{ "cd",
"Change directories",
NULL, rtems_cdCommand, 2, 2
},
{ "ld",
"Load object module",
NULL, rtems_ldCommand, 3, 3
},
{ "dbLoadDatabase",
"Load database",
"*", rtems_dbLoadDatabase, 2, 2
},
{ "dbLoadRecords",
"Load database records",
"**", rtems_dbLoadRecords, 2, 3
},
{ "registerRecordDeviceDriver",
"Register device driver",
"*", rtems_registerRecordDeviceDriver, 2, 2
},
{ "network",
"Show network statistics",
"i", rtems_showStats, 1, 2
},
{ "semaphore",
"Show semaphores",
"", rtems_showSem, 1, 1
},
{ NULL }
};
/*
@@ -390,47 +390,47 @@ static const struct CommandTableEntry CommandTable[] = {
rtems_task
Init (rtems_task_argument ignored)
{
void registerBaseCommands (void);
void registerBaseCommands (void);
/*
* Create a reasonable environment
*/
putenv ("TERM=xterm");
putenv ("PS1=rtems> ");
putenv ("HISTSIZE=10");
putenv ("IFS= \t,()");
/*
* Create a reasonable environment
*/
putenv ("TERM=xterm");
putenv ("PS1=rtems> ");
putenv ("HISTSIZE=10");
putenv ("IFS= \t,()");
/*
* Start network
*/
printf ("***** Initializing network *****\n");
rtems_bsdnet_initialize_network ();
printf ("***** Initializing TFTP *****\n");
rtems_bsdnet_initialize_tftp_filesystem ();
printf ("***** Initializing NTP *****\n");
rtems_bsdnet_synchronize_ntp (0, 0);
printf ("***** Initializing syslog *****\n");
openlog ("IOC", LOG_CONS, LOG_DAEMON);
syslog (LOG_NOTICE, "IOC started.");
/*
* Start network
*/
printf ("***** Initializing network *****\n");
rtems_bsdnet_initialize_network ();
printf ("***** Initializing TFTP *****\n");
rtems_bsdnet_initialize_tftp_filesystem ();
printf ("***** Initializing NTP *****\n");
rtems_bsdnet_synchronize_ntp (0, 0);
printf ("***** Initializing syslog *****\n");
openlog ("IOC", LOG_CONS, LOG_DAEMON);
syslog (LOG_NOTICE, "IOC started.");
/*
* Do some RTEMS initializations
*/
clockInit ();
threadInit ();
/*
* Do some RTEMS initializations
*/
clockInit ();
threadInit ();
/*
* Run the EPICS startup script
*/
printf ("***** Executing EPICS startup script *****\n");
registerBaseCommands ();
CommandInterpreterRegisterCommands (CommandTable);
rtems_runScript ("st.cmd");
/*
* Run the EPICS startup script
*/
printf ("***** Executing EPICS startup script *****\n");
registerBaseCommands ();
CommandInterpreterRegisterCommands (CommandTable);
rtems_runScript ("st.cmd");
/*
* Everything's running!
*/
threadSleep (2.0);
CommandInterpreter (NULL, NULL, NULL);
rtems_task_suspend (RTEMS_SELF);
/*
* Everything's running!
*/
threadSleep (2.0);
CommandInterpreter (NULL, NULL, NULL);
rtems_task_suspend (RTEMS_SELF);
}