Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/luna68k/dev Use explicit struct to represent RX que...



details:   https://anonhg.NetBSD.org/src/rev/83e9ff40f9d2
branches:  trunk
changeset: 372405:83e9ff40f9d2
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Tue Nov 22 16:17:29 2022 +0000

description:
Use explicit struct to represent RX queue buffer data structure.

No binary change.

Maybe the similar change should be applied to MI com(4) and zsc(4)?

diffstat:

 sys/arch/luna68k/dev/siotty.c |  40 ++++++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 16 deletions(-)

diffs (109 lines):

diff -r da2ba072a804 -r 83e9ff40f9d2 sys/arch/luna68k/dev/siotty.c
--- a/sys/arch/luna68k/dev/siotty.c     Tue Nov 22 15:57:03 2022 +0000
+++ b/sys/arch/luna68k/dev/siotty.c     Tue Nov 22 16:17:29 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siotty.c,v 1.51 2021/09/25 15:18:38 tsutsui Exp $ */
+/* $NetBSD: siotty.c,v 1.52 2022/11/22 16:17:29 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.51 2021/09/25 15:18:38 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.52 2022/11/22 16:17:29 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "siotty.h"
@@ -76,6 +76,13 @@
        { -1,   0, },
 };
 
+struct siotty_rxqdata {
+       uint8_t data;
+       uint8_t stat;
+};
+
+typedef struct siotty_rxqdata rxqdata_t;
+
 struct siotty_softc {
        device_t        sc_dev;
        struct tty      *sc_tty;
@@ -86,10 +93,10 @@
        u_int           sc_hwflags;
 #define        SIOTTY_HW_CONSOLE       0x0001
 
-       uint8_t         *sc_rbuf;
-       uint8_t         *sc_rbufend;
-       uint8_t * volatile sc_rbget;
-       uint8_t * volatile sc_rbput;
+       rxqdata_t       *sc_rbuf;
+       rxqdata_t       *sc_rbufend;
+       rxqdata_t * volatile sc_rbget;
+       rxqdata_t * volatile sc_rbput;
        volatile u_int  sc_rbavail;
 
        uint8_t         *sc_tba;
@@ -192,8 +199,9 @@
 
        aprint_normal("\n");
 
-       sc->sc_rbuf = kmem_alloc(siotty_rbuf_size * 2, KM_SLEEP);
-       sc->sc_rbufend = sc->sc_rbuf + (siotty_rbuf_size * 2);
+       sc->sc_rbuf = kmem_alloc(siotty_rbuf_size * sizeof(rxqdata_t),
+           KM_SLEEP);
+       sc->sc_rbufend = sc->sc_rbuf + siotty_rbuf_size;
        sc->sc_rbput = sc->sc_rbget = sc->sc_rbuf;
        sc->sc_rbavail = siotty_rbuf_size;
 
@@ -217,7 +225,7 @@
 {
        struct siotty_softc *sc;
        struct sioreg *sio;
-       uint8_t *put, *end;
+       rxqdata_t *put, *end;
        uint8_t c;
        uint16_t rr;
        int cc;
@@ -241,9 +249,9 @@
                                c = sio->sio_data;
                                cn_check_magic(sc->sc_tty->t_dev, c,
                                    siotty_cnm_state);
-                               put[0] = c;
-                               put[1] = rr & 0xff;
-                               put += 2;
+                               put->data = c;
+                               put->stat = rr & 0xff;
+                               put++;
                                if (put >= end)
                                        put = sc->sc_rbuf;
                                cc--;
@@ -294,7 +302,7 @@
 static void
 siotty_rxsoft(struct siotty_softc *sc, struct tty *tp)
 {
-       uint8_t *get, *end;
+       rxqdata_t *get, *end;
        u_int cc, scc;
        unsigned int code;
        uint8_t stat;
@@ -309,15 +317,15 @@
        }
 
        while (cc > 0) {
-               code = get[0];
-               stat = get[1];
+               code = get->data;
+               stat = get->stat;
                if ((stat & RR_FRAMING) != 0)
                        code |= TTY_FE;
                else if ((stat & RR_PARITY) != 0)
                        code |= TTY_PE;
 
                (*tp->t_linesw->l_rint)(code, tp);
-               get += 2;
+               get++;
                if (get >= end)
                        get = sc->sc_rbuf;
                cc--;



Home | Main Index | Thread Index | Old Index