summaryrefslogtreecommitdiffstats
path: root/c/src/exec/libcsupport
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-05-27 16:11:52 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-05-27 16:11:52 +0000
commit5adf355aa3cf66dc768d502b5a4855d734ce9d49 (patch)
treeb90fcecbc3f776a903655a4b97e1a9769bfb7983 /c/src/exec/libcsupport
parentSplit out polled io, debug puts, and console reserve resources to (diff)
downloadrtems-5adf355aa3cf66dc768d502b5a4855d734ce9d49.tar.bz2
Split initialization and reserve resources from termios to reduce
size of mininum application.
Diffstat (limited to 'c/src/exec/libcsupport')
-rw-r--r--c/src/exec/libcsupport/src/termios.c74
-rw-r--r--c/src/exec/libcsupport/src/termiosinitialize.c50
-rw-r--r--c/src/exec/libcsupport/src/termiosreserveresources.c28
3 files changed, 93 insertions, 59 deletions
diff --git a/c/src/exec/libcsupport/src/termios.c b/c/src/exec/libcsupport/src/termios.c
index d816957fd0..6d334ecd23 100644
--- a/c/src/exec/libcsupport/src/termios.c
+++ b/c/src/exec/libcsupport/src/termios.c
@@ -141,55 +141,11 @@ struct rtems_termios_tty {
#define FL_MDXON 0x200 /* input controlled with XON/XOFF protocol */
#define FL_MDXOF 0x400 /* output controlled with XON/XOFF protocol */
-static struct rtems_termios_tty *ttyHead, *ttyTail;
-static rtems_id ttyMutex;
+extern struct rtems_termios_tty *rtems_termios_ttyHead;
+extern struct rtems_termios_tty *rtems_termios_ttyTail;
+extern rtems_id rtems_termios_ttyMutex;
/*
- * Reserve enough resources to open every physical device once.
- */
-
-static int first_time; /* assumed to be zeroed by BSS initialization */
-
-void
-rtems_termios_reserve_resources (
- rtems_configuration_table *configuration,
- rtems_unsigned32 number_of_devices
- )
-{
- rtems_api_configuration_table *rtems_config;
-
- if (!configuration)
- rtems_fatal_error_occurred (0xFFF0F001);
- rtems_config = configuration->RTEMS_api_configuration;
- if (!rtems_config)
- rtems_fatal_error_occurred (0xFFF0F002);
- if (!first_time)
- rtems_config->maximum_semaphores += 1;
- first_time = 1;
- rtems_config->maximum_semaphores += (4 * number_of_devices);
-}
-
-void
-rtems_termios_initialize (void)
-{
- rtems_status_code sc;
-
- /*
- * Create the mutex semaphore for the tty list
- */
- if (!ttyMutex) {
- sc = rtems_semaphore_create (
- rtems_build_name ('T', 'R', 'm', 'i'),
- 1,
- RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
- RTEMS_NO_PRIORITY,
- &ttyMutex);
- if (sc != RTEMS_SUCCESSFUL)
- rtems_fatal_error_occurred (sc);
- }
-}
-
-/*
* Open a termios device
*/
rtems_status_code
@@ -207,10 +163,10 @@ rtems_termios_open (
/*
* See if the device has already been opened
*/
- sc = rtems_semaphore_obtain (ttyMutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+ sc = rtems_semaphore_obtain (rtems_termios_ttyMutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
return sc;
- for (tty = ttyHead ; tty != NULL ; tty = tty->forw) {
+ for (tty = rtems_termios_ttyHead ; tty != NULL ; tty = tty->forw) {
if ((tty->major == major) && (tty->minor == minor))
break;
}
@@ -222,13 +178,13 @@ rtems_termios_open (
*/
tty = calloc (1, sizeof (struct rtems_termios_tty));
if (tty == NULL) {
- rtems_semaphore_release (ttyMutex);
+ rtems_semaphore_release (rtems_termios_ttyMutex);
return RTEMS_NO_MEMORY;
}
- tty->forw = ttyHead;
- ttyHead = tty;
- if (ttyTail == NULL)
- ttyTail = tty;
+ tty->forw = rtems_termios_ttyHead;
+ rtems_termios_ttyHead = tty;
+ if (rtems_termios_ttyTail == NULL)
+ rtems_termios_ttyTail = tty;
tty->minor = minor;
tty->major = major;
@@ -317,7 +273,7 @@ rtems_termios_open (
args->iop->data1 = tty;
if (!tty->refcount++ && tty->device.firstOpen)
(*tty->device.firstOpen)(major, minor, arg);
- rtems_semaphore_release (ttyMutex);
+ rtems_semaphore_release (rtems_termios_ttyMutex);
return RTEMS_SUCCESSFUL;
}
@@ -353,7 +309,7 @@ rtems_termios_close (void *arg)
struct rtems_termios_tty *tty = args->iop->data1;
rtems_status_code sc;
- sc = rtems_semaphore_obtain (ttyMutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+ sc = rtems_semaphore_obtain (rtems_termios_ttyMutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred (sc);
if (--tty->refcount == 0) {
@@ -361,11 +317,11 @@ rtems_termios_close (void *arg)
if (tty->device.lastClose)
(*tty->device.lastClose)(tty->major, tty->minor, arg);
if (tty->forw == NULL)
- ttyTail = tty->back;
+ rtems_termios_ttyTail = tty->back;
else
tty->forw->back = tty->back;
if (tty->back == NULL)
- ttyHead = tty->forw;
+ rtems_termios_ttyHead = tty->forw;
else
tty->back->forw = tty->forw;
rtems_semaphore_delete (tty->isem);
@@ -375,7 +331,7 @@ rtems_termios_close (void *arg)
rtems_semaphore_delete (tty->rawInBufSemaphore);
free (tty);
}
- rtems_semaphore_release (ttyMutex);
+ rtems_semaphore_release (rtems_termios_ttyMutex);
return RTEMS_SUCCESSFUL;
}
diff --git a/c/src/exec/libcsupport/src/termiosinitialize.c b/c/src/exec/libcsupport/src/termiosinitialize.c
new file mode 100644
index 0000000000..f6e73787c9
--- /dev/null
+++ b/c/src/exec/libcsupport/src/termiosinitialize.c
@@ -0,0 +1,50 @@
+/*
+ * Termios initialization routine
+ *
+ * Author:
+ * W. Eric Norum
+ * Saskatchewan Accelerator Laboratory
+ * University of Saskatchewan
+ * Saskatoon, Saskatchewan, CANADA
+ * eric@skatter.usask.ca
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <rtems.h>
+#include <rtems/libio.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <termios.h>
+#include <unistd.h>
+
+struct rtems_termios_tty *rtems_termios_ttyHead;
+struct rtems_termios_tty *rtems_termios_ttyTail;
+rtems_id rtems_termios_ttyMutex;
+
+void
+rtems_termios_initialize (void)
+{
+ rtems_status_code sc;
+
+ /*
+ * Create the mutex semaphore for the tty list
+ */
+ if (!rtems_termios_ttyMutex) {
+ sc = rtems_semaphore_create (
+ rtems_build_name ('T', 'R', 'm', 'i'),
+ 1,
+ RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
+ RTEMS_NO_PRIORITY,
+ &rtems_termios_ttyMutex);
+ if (sc != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred (sc);
+ }
+}
diff --git a/c/src/exec/libcsupport/src/termiosreserveresources.c b/c/src/exec/libcsupport/src/termiosreserveresources.c
new file mode 100644
index 0000000000..2d9c05c988
--- /dev/null
+++ b/c/src/exec/libcsupport/src/termiosreserveresources.c
@@ -0,0 +1,28 @@
+/*
+ * Reserve enough resources to open every physical device once.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+
+static int first_time; /* assumed to be zeroed by BSS initialization */
+
+void rtems_termios_reserve_resources (
+ rtems_configuration_table *configuration,
+ rtems_unsigned32 number_of_devices
+)
+{
+ rtems_api_configuration_table *rtems_config;
+
+ if (!configuration)
+ rtems_fatal_error_occurred (0xFFF0F001);
+ rtems_config = configuration->RTEMS_api_configuration;
+ if (!rtems_config)
+ rtems_fatal_error_occurred (0xFFF0F002);
+ if (!first_time)
+ rtems_config->maximum_semaphores += 1;
+ first_time = 1;
+ rtems_config->maximum_semaphores += (4 * number_of_devices);
+}
+