bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] device: cleanup of the TTY io


From: Marin Ramesa
Subject: [PATCH] device: cleanup of the TTY io
Date: Sun, 08 Sep 2013 18:10:45 +0200

From tty.h I removed the ifdef and the include for luna88k, I
guess this was an architecture that is no longer supported as I can not
find the refrenced code in the gnumach source tree. From chario.c I 
removed forward declarations that have prototypes in tty.h. Next, I 
qualified all the constants with the const keyword, in this way there 
will be a warning from the compiler if their values get changed later 
in the code. I also removed the _PR calculation and broke it into two 
calculations (_PR_T and _PR_WM) that I wrote in tty.h, in this way they 
can be used by other parts of the code and we get rid of the confusing 
undef and redefinition in the chario_init(). Finaly, I dropped the 
register keyword as I can see that the newer functions, even in the 
same file by the same author, do not use it.
* device/tty.h [luna88k]: Remove ifdef and include for nonexistent header files.
New _PR_T calculation.
New _PR_WM calculation.
* device/chario.c (tty_flush): Remove forward declaration (prototype is in 
tty.h).
(ttstart): Likewise.
Qualify constants as constants.
(chario_init): Remove _PR calculation and the associated undef and break it in 
two in tty.h.
Drop the register keyword.



From 93dd68cc7c96dadde44fcd452e4aaf22cea7aecc Mon Sep 17 00:00:00 2001
From: Marin Ramesa <mpr@hi.t-com.hr>
Date: Sun, 8 Sep 2013 16:30:27 +0200
Subject: [PATCH 2/2] Cleanup of the TTY I/O.

---
 device/chario.c | 122 +++++++++++++++++++++++++++-----------------------------
 device/tty.h    |   7 ++--
 2 files changed, 61 insertions(+), 68 deletions(-)

diff --git a/device/chario.c b/device/chario.c
index d7c092e..efc024e 100644
--- a/device/chario.c
+++ b/device/chario.c
@@ -68,11 +68,9 @@ short        ttlowat[NSPEEDS] =
 void   queue_delayed_reply(
        queue_t, io_req_t, boolean_t (*)(io_req_t));
 void   tty_output(struct tty *);
-void   tty_flush(struct tty *, int);
 boolean_t char_open_done(io_req_t);
 boolean_t char_read_done(io_req_t);
 boolean_t char_write_done(io_req_t);
-void   ttstart(struct tty *tp);
 
 /*
  * Fake 'line discipline' switch for the benefit of old code
@@ -91,9 +89,9 @@ struct ldisc_switch   linesw[] = {
 /*
  * Sizes for input and output circular buffers.
  */
-int    tty_inq_size = 4096;    /* big nuf */
-int    tty_outq_size = 2048;   /* Must be bigger that tthiwat */
-int    pdma_default = 1;       /* turn pseudo dma on by default */
+const int      tty_inq_size = 4096;    /* big nuf */
+const int      tty_outq_size = 2048;   /* Must be bigger that tthiwat */
+const int      pdma_default = 1;       /* turn pseudo dma on by default */
 
 /*
  * compute pseudo-dma tables
@@ -109,24 +107,23 @@ void chario_init(void)
      time for a character to show up if data is coming in at full data rate
      plus a little slack. 2 ticks is considered slack
      Below 300 baud we just glob a character at a time */
-#define _PR(x) ((hz/x) + 2)
 
   int i;
 
   for (i = B0; i < B300; i++)
     pdma_timeouts[i] = 0;
 
-  pdma_timeouts[B300] = _PR(30);
-  pdma_timeouts[B600] = _PR(60);
-  pdma_timeouts[B1200] = _PR(120);
-  pdma_timeouts[B1800] = _PR(180);
-  pdma_timeouts[B2400] = _PR(240);
-  pdma_timeouts[B4800] = _PR(480);
-  pdma_timeouts[B9600] = _PR(960);
-  pdma_timeouts[EXTA]  = _PR(1440); /* >14400 baud */
-  pdma_timeouts[EXTB]  = _PR(1920); /* >19200 baud */
-  pdma_timeouts[B57600] = _PR(5760);
-  pdma_timeouts[B115200] = _PR(11520);
+  pdma_timeouts[B300] = _PR_T(30);
+  pdma_timeouts[B600] = _PR_T(60);
+  pdma_timeouts[B1200] = _PR_T(120);
+  pdma_timeouts[B1800] = _PR_T(180);
+  pdma_timeouts[B2400] = _PR_T(240);
+  pdma_timeouts[B4800] = _PR_T(480);
+  pdma_timeouts[B9600] = _PR_T(960);
+  pdma_timeouts[EXTA]  = _PR_T(1440); /* >14400 baud */
+  pdma_timeouts[EXTB]  = _PR_T(1920); /* >19200 baud */
+  pdma_timeouts[B57600] = _PR_T(5760);
+  pdma_timeouts[B115200] = _PR_T(11520);
 
   for (i = B0; i < B300; i++)
     pdma_water_mark[i] = 0;
@@ -135,15 +132,12 @@ void chario_init(void)
      (20% of the character rate). For the faster lines,
      we try to buffer 1/2 the input queue size */
 
-#undef _PR
-#define _PR(x) (0.20 * x)
-
-  pdma_water_mark[B300] = _PR(120);
-  pdma_water_mark[B600] = _PR(120);
-  pdma_water_mark[B1200] = _PR(120);
-  pdma_water_mark[B1800] = _PR(180);
-  pdma_water_mark[B2400] = _PR(240);
-  pdma_water_mark[B4800] = _PR(480);
+  pdma_water_mark[B300] = _PR_WM(120);
+  pdma_water_mark[B600] = _PR_WM(120);
+  pdma_water_mark[B1200] = _PR_WM(120);
+  pdma_water_mark[B1800] = _PR_WM(180);
+  pdma_water_mark[B2400] = _PR_WM(240);
+  pdma_water_mark[B4800] = _PR_WM(480);
   i = tty_inq_size/2;
   pdma_water_mark[B9600] = i;
   pdma_water_mark[EXTA]  = i; /* >14400 baud */
@@ -216,7 +210,7 @@ out:
 boolean_t char_open_done(
        io_req_t        ior)
 {
-       register struct tty *tp = (struct tty *)ior->io_dev_ptr;
+       struct tty *tp = (struct tty *)ior->io_dev_ptr;
        spl_t s = spltty();
 
        simple_lock(&tp->t_lock);
@@ -256,12 +250,12 @@ boolean_t tty_close_open_reply(
  * device needs to run on master.
  */
 io_return_t char_write(
-       register struct tty *   tp,
-       register io_req_t       ior)
+       struct tty *    tp,
+       io_req_t        ior)
 {
        spl_t           s;
-       register int    count;
-       register char   *data;
+       int             count;
+       char            *data;
        vm_offset_t     addr;
        io_return_t     rc = D_SUCCESS;
 
@@ -347,10 +341,10 @@ out:
  * May run on any CPU.
  */
 boolean_t char_write_done(
-       register io_req_t       ior)
+       io_req_t        ior)
 {
-       register struct tty *tp = (struct tty *)ior->io_dev_ptr;
-       register spl_t s = spltty();
+       struct tty *tp = (struct tty *)ior->io_dev_ptr;
+       spl_t s = spltty();
 
        simple_lock(&tp->t_lock);
        if (tp->t_outq.c_cc > TTHIWAT(tp) ||
@@ -378,7 +372,7 @@ boolean_t char_write_done(
 }
 
 boolean_t tty_close_write_reply(
-       register io_req_t       ior)
+       io_req_t        ior)
 {
        ior->io_residual = ior->io_count;
        ior->io_error = D_DEVICE_DOWN;
@@ -392,8 +386,8 @@ boolean_t tty_close_write_reply(
  * May run on any CPU - does not talk to device driver.
  */
 io_return_t char_read(
-       register struct tty *tp,
-       register io_req_t ior)
+       struct tty *tp,
+       io_req_t ior)
 {
        spl_t           s;
        kern_return_t   rc;
@@ -453,10 +447,10 @@ io_return_t char_read(
  * May run on any CPU - does not talk to device driver.
  */
 boolean_t char_read_done(
-       register io_req_t       ior)
+       io_req_t        ior)
 {
-       register struct tty *tp = (struct tty *)ior->io_dev_ptr;
-       register spl_t s = spltty();
+       struct tty *tp = (struct tty *)ior->io_dev_ptr;
+       spl_t s = spltty();
 
        simple_lock(&tp->t_lock);
 
@@ -485,7 +479,7 @@ boolean_t char_read_done(
 }
 
 boolean_t tty_close_read_reply(
-       register io_req_t       ior)
+       io_req_t        ior)
 {
        ior->io_residual = ior->io_count;
        ior->io_error = D_DEVICE_DOWN;
@@ -499,9 +493,9 @@ boolean_t tty_close_read_reply(
  * Iff modem control should run on master.
  */
 void ttyclose(
-       register struct tty *tp)
+       struct tty *tp)
 {
-       register io_req_t       ior;
+       io_req_t        ior;
 
        /*
         * Flush the read and write queues.  Signal
@@ -541,7 +535,7 @@ tty_queue_clean(
        ipc_port_t      port,
        boolean_t       (*routine)(io_req_t) )
 {
-       register io_req_t       ior;
+       io_req_t        ior;
 
        ior = (io_req_t)queue_first(q);
        while (!queue_end(q, (queue_entry_t)ior)) {
@@ -566,8 +560,8 @@ tty_portdeath(
        struct tty *    tp,
        ipc_port_t      port)
 {
-       register spl_t  spl = spltty();
-       register boolean_t      result;
+       spl_t   spl = spltty();
+       boolean_t       result;
 
        simple_lock(&tp->t_lock);
 
@@ -598,9 +592,9 @@ tty_portdeath(
  * May run on any CPU.
  */
 io_return_t tty_get_status(
-       register struct tty *tp,
+       struct tty *tp,
        dev_flavor_t    flavor,
-       int *           data,           /* pointer to OUT array */
+       int             *data,          /* pointer to OUT array */
        natural_t       *count)         /* out */
 {
        spl_t           s;
@@ -608,7 +602,7 @@ io_return_t tty_get_status(
        switch (flavor) {
            case TTY_STATUS:
            {
-               register struct tty_status *tsp =
+               struct tty_status *tsp =
                        (struct tty_status *) data;
 
                if (*count < TTY_STATUS_COUNT)
@@ -644,9 +638,9 @@ io_return_t tty_get_status(
  * device needs to run on master.
  */
 io_return_t tty_set_status(
-       register struct tty *tp,
+       struct tty *tp,
        dev_flavor_t    flavor,
-       int *           data,
+       int             *data,
        natural_t       count)
 {
        int     s;
@@ -654,7 +648,7 @@ io_return_t tty_set_status(
        switch (flavor) {
            case TTY_FLUSH:
            {
-               register int    flags;
+               int     flags;
                if (count < TTY_FLUSH_COUNT)
                    return D_INVALID_OPERATION;
 
@@ -697,7 +691,7 @@ io_return_t tty_set_status(
            case TTY_STATUS:
                /* set special characters and speed */
            {
-               register struct tty_status *tsp;
+               struct tty_status *tsp;
 
                if (count < TTY_STATUS_COUNT)
                    return D_INVALID_OPERATION;
@@ -752,9 +746,9 @@ void queue_delayed_reply(
  * TTY containing queue must be locked (at spltty).
  */
 void tty_queue_completion(
-       register queue_t        qh)
+       queue_t qh)
 {
-       register io_req_t       ior;
+       io_req_t        ior;
 
        while ((ior = (io_req_t)dequeue_head(qh)) != 0) {
            iodone(ior);
@@ -767,7 +761,7 @@ void tty_queue_completion(
  * we can initialize the queues here.
  */
 void ttychars(
-       register struct tty *tp)
+       struct tty *tp)
 {
        if ((tp->t_flags & TS_INIT) == 0) {
            /*
@@ -804,7 +798,7 @@ void ttychars(
  * device needs to run on master.
  */
 void tty_flush(
-       register struct tty *tp,
+       struct tty *tp,
        int     rw)
 {
        if (rw & D_READ) {
@@ -827,9 +821,9 @@ void tty_flush(
  *     What if device runs on a different CPU?
  */
 void ttrstrt(
-       register struct tty *tp)
+       struct tty *tp)
 {
-       register spl_t  s;
+       spl_t   s;
 
        s = spltty();
        simple_lock(&tp->t_lock);
@@ -851,7 +845,7 @@ void ttrstrt(
  * Must be on master CPU if device runs on master.
  */
 void ttstart(tp)
-       register struct tty *tp;
+       struct tty *tp;
 {
        if ((tp->t_state & (TS_TIMEOUT|TS_TTSTOP|TS_BUSY)) == 0) {
            /*
@@ -875,7 +869,7 @@ void ttstart(tp)
  * Must be on master CPU if device runs on master.
  */
 void tty_output(
-       register struct tty *tp)
+       struct tty *tp)
 {
        if ((tp->t_state & (TS_TIMEOUT|TS_TTSTOP|TS_BUSY)) == 0) {
            /*
@@ -897,9 +891,9 @@ void tty_output(
 void ttypush(
        void * _tp)
 {
-       register struct tty     *tp = _tp;
+       struct tty      *tp = _tp;
        spl_t   s = spltty();
-       register int    state;
+       int     state;
 
        simple_lock(&tp->t_lock);
 
@@ -985,7 +979,7 @@ void ttyinput(
         * into the future, but this involves making a timeout/untimeout
         * call on every character.
         */
-       register int ptime = pdma_timeouts[tp->t_ispeed];
+       int ptime = pdma_timeouts[tp->t_ispeed];
        if (ptime > 0)
          {
            if ((tp->t_state & TS_MIN_TO) == 0)
diff --git a/device/tty.h b/device/tty.h
index be28708..6b2fe3c 100644
--- a/device/tty.h
+++ b/device/tty.h
@@ -42,10 +42,6 @@
 #include <device/cirbuf.h>
 #include <device/io_req.h>
 
-#ifdef luna88k
-#include <luna88k/jtermio.h>
-#endif
-
 struct tty {
        decl_simple_lock_data(,t_lock)
        struct cirbuf   t_inq;          /* input buffer */
@@ -240,4 +236,7 @@ extern struct ldisc_switch  linesw[];
 
 extern void chario_init(void);
 
+#define _PR_T(x) ((hz/x) + 2)
+#define _PR_WM(x) (0.20 * x)
+
 #endif /* _DEVICE_TTY_H_ */
-- 
1.8.1.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]