--- Gnu-Mach/device/chario.c 2020/09/02 04:36:57 1.1.1.1 +++ Gnu-Mach/device/chario.c 2020/09/02 04:45:32 1.1.1.4 @@ -1,25 +1,25 @@ -/* +/* * Mach Operating System * Copyright (c) 1993-1988 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ @@ -43,21 +43,24 @@ #include #include +#include #include #include #include -#include "device_reply.h" +#include #include /* If you change these, check that tty_outq_size and tty_inq_size * is greater than largest tthiwat entry. */ -short tthiwat[16] = - { 100,100,100,100,100,100,100,200,200,400,400,400,650,650,1300,2000 }; -short ttlowat[16] = - { 30, 30, 30, 30, 30, 30, 30, 50, 50,120,120,120,125,125, 125, 125 }; +short tthiwat[NSPEEDS] = + { 100,100,100,100,100,100,100,200,200,400,400,400,650,650,1300,2000, + 2000,2000 }; +short ttlowat[NSPEEDS] = + { 30, 30, 30, 30, 30, 30, 30, 50, 50,120,120,120,125,125, 125, 125, + 125,125 }; /* * forward declarations @@ -65,7 +68,6 @@ short ttlowat[16] = 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); @@ -87,12 +89,12 @@ 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 */ +const int tty_inq_size = 4096; /* big nuf */ +const int tty_outq_size = 2048; /* Must be bigger that tthiwat */ int pdma_default = 1; /* turn pseudo dma on by default */ /* - * compute pseudo-dma tables + * compute pseudo-dma tables */ int pdma_timeouts[NSPEEDS]; /* how many ticks in timeout */ @@ -111,7 +113,7 @@ void chario_init(void) 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); @@ -121,6 +123,8 @@ void chario_init(void) 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); for (i = B0; i < B300; i++) pdma_water_mark[i] = 0; @@ -142,8 +146,10 @@ void chario_init(void) pdma_water_mark[B9600] = i; pdma_water_mark[EXTA] = i; /* >14400 baud */ pdma_water_mark[EXTB] = i; /* >19200 baud */ + pdma_water_mark[B57600] = i; + pdma_water_mark[B115200] = i; - return; + return; } /* @@ -208,7 +214,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); @@ -248,12 +254,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; @@ -339,10 +345,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) || @@ -370,7 +376,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; @@ -384,8 +390,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; @@ -424,7 +430,7 @@ io_return_t char_read( rc = D_IO_QUEUED; goto out; } - + ior->io_residual = ior->io_count - q_to_b(&tp->t_inq, ior->io_data, (int)ior->io_count); @@ -445,10 +451,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); @@ -477,7 +483,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; @@ -491,9 +497,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 @@ -533,7 +539,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)) { @@ -558,8 +564,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); @@ -590,7 +596,7 @@ 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 */ natural_t *count) /* out */ @@ -600,7 +606,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) @@ -636,7 +642,7 @@ 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, natural_t count) @@ -646,7 +652,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; @@ -689,7 +695,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; @@ -744,9 +750,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); @@ -759,7 +765,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) { /* @@ -796,7 +802,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) { @@ -810,7 +816,7 @@ void tty_flush( tty_queue_completion(&tp->t_delayed_write); } } - + /* * Restart character output after a delay timeout. * Calls device start routine - must be on master CPU. @@ -819,9 +825,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); @@ -843,7 +849,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) { /* @@ -867,7 +873,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) { /* @@ -887,15 +893,16 @@ void tty_output( * Send any buffered recvd chars up to user */ void ttypush( - register struct tty *tp) + void * _tp) { + struct tty *tp = _tp; spl_t s = spltty(); - register int state; + int state; simple_lock(&tp->t_lock); /* - The pdma timeout has gone off. + The pdma timeout has gone off. If no character has been received since the timeout was set, push any pending characters up. If any characters were received in the last interval @@ -968,15 +975,15 @@ void ttyinput( } else { /* - * Not enough characters. - * If no timeout is set, initiate the timeout + * Not enough characters. + * If no timeout is set, initiate the timeout * Otherwise set the character received during timeout interval * flag. * One alternative approach would be just to reset the timeout * 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) @@ -999,11 +1006,11 @@ void ttyinput( */ void ttyinput_many( struct tty *tp, - unsigned char *chars, + char *chars, int count) { /* - * Do not want to overflow input queue + * Do not want to overflow input queue */ if (tp->t_inq.c_cc < tp->t_inq.c_hog) count -= b_to_q( chars, count, &tp->t_inq); @@ -1073,6 +1080,7 @@ boolean_t ttymodem( * * Tty must be locked and on master. */ +void tty_cts( struct tty * tp, boolean_t cts_up)