BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / hp300 / dev / ct.c
index 3f3bcf4..4a508b3 100644 (file)
@@ -2,9 +2,35 @@
  * Copyright (c) 1982, 1990 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1982, 1990 The Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)ct.c        7.2 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)ct.c        7.3 (Berkeley) 5/4/91
  */
 
 #include "ct.h"
  */
 
 #include "ct.h"
  *     finish support of 9145
  */
 
  *     finish support of 9145
  */
 
-#include "sys/param.h"
-#include "sys/buf.h"
-#include "sys/ioctl.h"
-#include "sys/mtio.h"
-#include "sys/errno.h"
+#include "param.h"
+#include "buf.h"
+#include "ioctl.h"
+#include "mtio.h"
+#include "tprintf.h"
+#include "proc.h"
+
 #include "ctreg.h"
 #include "device.h"
 #include "ctreg.h"
 #include "device.h"
-#include "sys/user.h"
-#include "sys/tty.h"
-#include "sys/proc.h"
 
 /* number of eof marks to remember */
 #define EOFS   128
 
 /* number of eof marks to remember */
 #define EOFS   128
@@ -61,7 +86,7 @@ struct        ct_softc {
        int     sc_flags;
        short   sc_type;
        short   sc_punit;
        int     sc_flags;
        short   sc_type;
        short   sc_punit;
-       caddr_t sc_ctty;
+       tpr_t   sc_tpr;
        struct  devqueue sc_dq;
        int     sc_eofp;
        int     sc_eofs[EOFS];
        struct  devqueue sc_dq;
        int     sc_eofp;
        int     sc_eofs[EOFS];
@@ -231,8 +256,10 @@ ctreset(sc, hd)
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
-ctopen(dev, flag)
+ctopen(dev, flag, type, p)
        dev_t dev;
        dev_t dev;
+       int flag, type;
+       struct proc *p;
 {
        register struct ct_softc *sc = &ct_softc[UNIT(dev)];
        u_char stat;
 {
        register struct ct_softc *sc = &ct_softc[UNIT(dev)];
        u_char stat;
@@ -263,8 +290,7 @@ ctopen(dev, flag)
                      &stat, sizeof(stat));
        if (cc != sizeof(stat))
                return(EBUSY);
                      &stat, sizeof(stat));
        if (cc != sizeof(stat))
                return(EBUSY);
-       sc->sc_ctty = (caddr_t)(u.u_procp->p_flag&SCTTY ? 
-                       u.u_procp->p_session->s_ttyvp : 0);
+       sc->sc_tpr = tprintf_open(p);
        sc->sc_flags |= CTF_OPEN;
        return(0);
 }
        sc->sc_flags |= CTF_OPEN;
        return(0);
 }
@@ -292,7 +318,7 @@ ctclose(dev, flag)
        if ((minor(dev) & CT_NOREW) == 0)
                ctcommand(dev, MTREW, 1);
        sc->sc_flags &= ~(CTF_OPEN | CTF_WRT | CTF_WRTTN);
        if ((minor(dev) & CT_NOREW) == 0)
                ctcommand(dev, MTREW, 1);
        sc->sc_flags &= ~(CTF_OPEN | CTF_WRT | CTF_WRTTN);
-       sc->sc_ctty = NULL;
+       tprintf_close(sc->sc_tpr);
 #ifdef DEBUG
        if (ctdebug & CDB_FILES)
                printf("ctclose: flags %x\n", sc->sc_flags);
 #ifdef DEBUG
        if (ctdebug & CDB_FILES)
                printf("ctclose: flags %x\n", sc->sc_flags);
@@ -657,14 +683,14 @@ ctintr(unit)
                        }
                        if (sc->sc_stat.c_aef & 0x5800) {
                                if (sc->sc_stat.c_aef & 0x4000)
                        }
                        if (sc->sc_stat.c_aef & 0x5800) {
                                if (sc->sc_stat.c_aef & 0x4000)
-                                       tprintf(sc->sc_ctty,
+                                       tprintf(sc->sc_tpr,
                                                "ct%d: uninitialized media\n",
                                                unit);
                                if (sc->sc_stat.c_aef & 0x1000)
                                                "ct%d: uninitialized media\n",
                                                unit);
                                if (sc->sc_stat.c_aef & 0x1000)
-                                       tprintf(sc->sc_ctty,
+                                       tprintf(sc->sc_tpr,
                                                "ct%d: not ready\n", unit);
                                if (sc->sc_stat.c_aef & 0x0800)
                                                "ct%d: not ready\n", unit);
                                if (sc->sc_stat.c_aef & 0x0800)
-                                       tprintf(sc->sc_ctty,
+                                       tprintf(sc->sc_tpr,
                                                "ct%d: write protect\n", unit);
                        } else {
                                printf("ct%d err: v%d u%d ru%d bn%d, ",
                                                "ct%d: write protect\n", unit);
                        } else {
                                printf("ct%d err: v%d u%d ru%d bn%d, ",