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
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,
- reg