|
|
1.1 root 1: #include "vx.h"
2: #if NVX > 0
3: /*
4: * VIOC-X Modem control
5: */
6:
7: #include "../h/param.h"
8: #include "../h/file.h"
9: #include "../h/ioctl.h"
10: #include "../h/tty.h"
11: #include "../h/conf.h"
12: #include "../vba/vioc.h"
13: #include "../vba/vxdebug.h"
14:
15: #include "vbsc.h"
16: #if NVBSC > 0
17: #include "../bsc/bscio.h"
18: #include "../bsc/bsc.h"
19: extern char bscport[];
20: #endif
21:
22:
23: extern struct vcx vcx[] ;
24: extern struct tty vx_tty[];
25: extern struct vcmds v_cmds[] ;
26:
27: extern int vxstart() ;
28: extern struct vxcmd *vobtain() ;
29: extern struct vxcmd *nextcmd() ;
30:
31: long viocPC = 0;
32:
33: vcmodem(dev,flag)
34: dev_t dev ;
35: {
36: struct tty *tp ;
37: register struct vxcmd *cp ;
38: register struct vcx *xp ;
39: register struct vblok *kp ;
40: register port ;
41:
42: port = minor(dev) ;
43: tp = &vx_tty[port] ;
44: port &= 017 ;
45: xp = (struct vcx *)tp->t_addr ;
46: cp = vobtain(xp) ;
47: kp = VBAS(xp->v_nbr) ;
48:
49: /*
50: * Issue MODEM command
51: */
52: cp->cmd = MDMCTL ;
53: cp->par[0] = (flag == VMOD_ON) ? V_ENAB : V_DISAB ;
54: cp->par[1] = port;
55: vcmd(xp->v_nbr, &cp->cmd) ;
56: port -= xp->v_loport ;
57: if((kp->v_dcd >> port) & 1) {
58: if(flag == VMOD_ON)
59: tp->t_state |= TS_CARR_ON ;
60: return(1) ;
61: }
62: return(0) ;
63: }
64:
65:
66: /*
67: * VCMINTR called when an unsolicited interrup occurs signaling
68: * some change of modem control state.
69: */
70: vcmintr(n)
71: register n ; /* viocx number */
72: {
73: register struct vblok *kp ;
74: register struct tty *tp ;
75: register port ;
76:
77: kp = VBAS( n ) ;
78: port = kp->v_usdata[0] & 017 ;
79: tp = &vx_tty[port+n*16] ;
80:
81: #if NVBSC > 0
82: /*
83: * Check for change in DSR for BISYNC port.
84: */
85: if ((kp->v_ustat & DSR_CHG) && (bscport[port+n*16] & BISYNC)) {
86: register struct vcx *xp ;
87: register struct bsc *bp ;
88: extern struct bsc bsc[] ;
89:
90: bp = &bsc[((minor(tp->t_dev)) >> 4) & 0xf] ;
91: bp->b_hlflgs &= ~BSC_DSR ;
92: if (kp->v_ustat & DSR_ON)
93: bp->b_hlflgs |= BSC_DSR ;
94: }
95: if (bscport[port+n*16] & BISYNC) return;
96: #endif
97:
98: #ifdef VX_DEBUG
99: if (vxdebug & VXVCM)
100: printf("vcmintr: VX%d, port%lx, v_ustat: %lx, t_state: %lx\n",
101: n,port,kp->v_ustat&0xff,tp->t_state);
102: #endif
103:
104: if((kp->v_ustat & DCD_ON) && ((tp->t_state & TS_CARR_ON) == 0) ) {
105: tp->t_state |= TS_CARR_ON ;
106: wakeup((caddr_t)&tp->t_canq) ;
107: return ;
108: }
109:
110: if((kp->v_ustat & DCD_OFF) && (tp->t_state & TS_CARR_ON)) {
111: tp->t_state &= ~TS_CARR_ON ;
112: if(tp->t_state & TS_ISOPEN) {
113: register struct vcx *xp ;
114: register struct vcmds *cp ;
115: register struct vxcmd *cmdp ;
116:
117: ttyflush(tp, FREAD|FWRITE);
118: /* clear all pending trnansmits */
119: xp = &vcx[n];
120: if(tp->t_state&(TS_BUSY|TS_FLUSH) && xp->v_vers==V_NEW)
121: {
122: int i, cmdfound = 0;
123: cp = &v_cmds[n];
124: for(i = cp->v_empty; i!=cp->v_fill; ) {
125: cmdp = (struct vxcmd *)((long *)cp->cmdbuf[i]-1);
126: if((cmdp->cmd==XMITDTA || cmdp->cmd==XMITIMM)
127: && ((struct vxmit *)cmdp->par)->line == port) {
128: cmdfound++;
129: cmdp->cmd = FDTATOX ;
130: cmdp->par[1] = port ;
131: }
132: if(++i >= VC_CMDBUFL)
133: i = 0;
134: }
135: if(cmdfound)
136: tp->t_state &= ~(TS_BUSY|TS_FLUSH);
137: /* cmd is already in vioc, have to flush it */
138: else {
139: cmdp = vobtain(xp);
140: cmdp->cmd = FDTATOX ;
141: cmdp->par[1] = port ;
142: vcmd(n, &cmdp->cmd);
143: }
144: }
145: if((tp->t_flags&NOHANG)==0) {
146: gsignal(tp->t_pgrp, SIGHUP) ;
147: gsignal(tp->t_pgrp, SIGCONT);
148: }
149: }
150: return ;
151: }
152:
153: if((kp->v_ustat & BRK_CHR) && (tp->t_state & TS_ISOPEN) ) {
154: (*linesw[tp->t_line].l_rint)(tp->t_intrc & 0377, tp) ;
155: return ;
156: }
157: }
158: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.