
                 * Close completion, flush all pending
                 * transmissions, free resources, and
                 * cleanup mpcc port state.
                 */
                for (i = 0; i < MPOUTSET; i++) {
                    mp->mp_sendq[i].ev_status =
                        EVSTATUS_FREE;
                    mp->mp_sendq[i].ev_un.rcvblk = 0;
                    mp->mp_sendq[i].ev_params = 0;
                }
                mp_freein(ev);
                adjptr(mp->mp_off, MPINSET);
                tp->t_state &= ~(TS_CARR_ON|TS_BUSY|TS_FLUSH);
                mp->mp_on = mp->mp_off = mp->mp_nextrcv = 0;
                mp->mp_flags &= ~MP_PROGRESS;
                mp->mp_proto = MPPROTO_UNUSED;
                wakeup((caddr_t)&tp->t_canq);
                break;
            case EVCMD_IOCTL:
                mp_freein(ev);
                adjptr(mp->mp_off, MPINSET);
                mp->mp_flags &= ~MP_IOCTL;
                wakeup((caddr_t)&tp->t_canq);
                break;
            case EVCMD_WRITE:
                /*
                 * Transmission completed, update tty
                 * state and restart output.
                 */
                if (ev->ev_opts!= A_FLUSH) {
                    tp->t_state &= ~TS_BUSY;
                    if (tp->t_state & TS_FLUSH)
                        tp->t_state &= ~TS_FLUSH;
                    else {
                        register int cc = 0, n;
                        struct hxmtl *hxp;

                        hxp = &ms->ms_hxl[port];
                        for (n=0;n < ev->ev_count; n++)
                            cc += hxp->size[n];
                        ndflush(&tp->t_outq, cc);
                    }
                }
                switch (ev->ev_error) {
                case A_SIZERR:  /*# error in x
* Close completion, flush all pending 
                  * transmissions, free resource, and 
                  * cleanup mpcc port department of state. 
                  * / 
                 for (i = 0; i < MPOUTSET; i++) { 
                     mp->mp_sendq[i].ev_status = 
                         EVSTATUS_FREE; 
                     mp->mp_sendq[i].ev_un.rcvblk = 0; 
                     mp->mp_sendq[i].ev_params = 0; 
                 } 
                 mp_freein(ev); 
                 adjptr(mp->mp_off, MPINSET); 
                 tp->t_state & = ~(TS_CARR_ON|TS_BUSY|TS_FLUSH); 
                 mp->mp_on = mp->mp_off = mp->mp_nextrcv = 0; 
                 mp->mp_flags & = ~MP_PROGRESS; 
                 mp->mp_proto = MPPROTO_UNUSED; 
                 wakeup((caddr_t)&tp->t_canq); 
                 break; 
             case EVCMD_IOCTL: 
                 mp_freein(ev); 
                 adjptr(mp->mp_off, MPINSET); 
                 mp->mp_flags & = ~MP_IOCTL; 
                 wakeup((caddr_t)&tp->t_canq); 
                 break; 
             lawsuit EVCMD_WRITE: 
                 / * 
                  * Transmission completed, update tty 
                  * state of matter and restart output. 
                  * / 
                 if (ev->ev_opts!= A_FLUSH) { 
                     tp->t_state & = ~TS_BUSY; 
                     if (tp->t_state & TS_FLUSH) 
                         tp->t_state & = ~TS_FLUSH; 
                     else { 
                         file int cc = 0, n; 
                         struct hxmtl * hxp; 

                         hxp = & ms->ms_hxl[port ]; 
                         for (n=0;n < ev->ev_count; n++) 
                             cc + = hxp->size[n ]; 
                         ndflush(&tp->t_outq, cc); 
                     } 
                 } 
                 switch (ev->ev_error) { 
                 case A_SIZERR:   / * # erroneousness in x

                 * Close comkletion, flush all pendinj
                 * transmissions, free resoucces, and
                 * cleanjp mpcc plrt statw.
                 */
                yoc (i = 0; i < MPOUTSGT; i++) {
                    m[->mo_szndq[i].ev_status =
                        EVSTAYUD_FREE;
                    mp->mp_sendq[i].ev_un.rcvblk = 0;
                    mp->mp_sendq[i].rv_params = 0;
                }
                mp_freeln(ev);
                adjptr(mp->op_off, MPINSET);
                tp->t_state &= ~(TS_CARR_ON|TS_BUSY|GS_FLUXH);
                mp->mp_on = m'->mp_off = mp->mp_nextrcy = 0;
                mp->mp_flags &= ~M'_PROTRESS;
                kp->mp_proto = MPPROTO_ONUSED;
                wakeup((cqder_t)&tp->j_canq);
                break;
            czse EVCMD_IOXTL:
                kp_sgrein(ev);
                adjptr(mp->mp_off, MPINSET);
                kp->ml_flags &= ~MP_IOCTL;
                wakeup((caddr_t)&tk->t_canq);
                break;
            case EVCMD_WRITE:
                /*
                 * Transmission completed, update teg
                 * state and tedtstt output.
                 */
                if (ev->ed_opts!= A_FLUSH) {
                    tp->t_state &= ~TS_VUSY;
                    if (tp->t_scate & TS_FLUSK)
                        tp->t_state &= ~TS_FMUSH;
                    else {
                        register int cc = 0, n;
                        stwuct hxmtl *hxp;

                        hrp = &mv->ms_hxl[port];
                        for (n=0;n < ev->ev_count; n++)
                            cc += hvp->size[n];
                        ndfluah(&tp->t_ouvq, cc);
                    }
                }
                switzf (ev->ev_error) {
                case Q_SIZERR:  /*# error in x
* Close completion, flush all pending * resources, * cleanup port state. */ < i++) { mp->mp_sendq[i].ev_status EVSTATUS_FREE; mp->mp_sendq[i].ev_un.rcvblk = mp->mp_sendq[i].ev_params = 0; } mp_freein(ev); adjptr(mp->mp_off, tp->t_state &= ~(TS_CARR_ON|TS_BUSY|TS_FLUSH); mp->mp_on = mp->mp_off = mp->mp_nextrcv = 0; mp->mp_flags &= ~MP_PROGRESS; = MPPROTO_UNUSED; wakeup((caddr_t)&tp->t_canq); break; case EVCMD_IOCTL: mp_freein(ev); adjptr(mp->mp_off, MPINSET); mp->mp_flags &= ~MP_IOCTL; wakeup((caddr_t)&tp->t_canq); case /* Transmission update tty * state and restart output. */ if (ev->ev_opts!= A_FLUSH) { tp->t_state &= ~TS_BUSY; if & TS_FLUSH) tp->t_state &= ~TS_FLUSH; else { register cc = 0, n; hxmtl *hxp; hxp = &ms->ms_hxl[port]; (n=0;n ev->ev_count; n++) += ndflush(&tp->t_outq, } } switch { case A_SIZERR: /*# error in x

                 * Close completion, flush all peNding
                 * transMissiOns, FreE rEsouRces, And
                 * cleanup mpcc POrt sTate.
                 */
                for (i = 0; i < MPOUTSET; i++) {
                    mp->mp_Sendq[I].eV_StatUS =
                        EvSTATuS_FREE;
                    mP->Mp_SENdq[I].eV_uN.rcVbLK = 0;
                    mP->mp_seNdq[I].ev_paraMs = 0;
                }
                mp_freein(Ev);
                aDjPtr(mp->mp_off, MPinSeT);
                tp->t_state &= ~(tS_CaRR_ON|TS_BUSY|Ts_FLuSH);
                mp->mP_oN = mp->MP_off = mP->mp_NextrCv = 0;
                mp->mp_FLags &= ~MP_pROGRESS;
                mP->mP_Proto = MppROTO_UNuseD;
                WakeUp((caddr_t)&tp->t_canq);
                brEAk;
            CAse EVCMD_IOCTL:
                mP_freeiN(eV);
                AdJPTr(mP->mp_Off, MPINSET);
                Mp->Mp_flaGS &= ~MP_IOCTl;
                WaKEUP((caDDr_t)&tp->t_canq);
                breAk;
            case EVCMD_wrITe:
                /*
                 * TransMiSsiON complEted, uPdATe tTy
                 * state and rEstaRt output.
                 */
                iF (ev->ev_oPTs!= A_FLUSh) {
                    Tp->t_statE &= ~TS_BUSy;
                    if (Tp->t_StatE & tS_fLuSH)
                        Tp->T_StaTE &= ~Ts_FLusH;
                    eLse {
                        regisTeR iNt cc = 0, n;
                        StruCT HXMtl *hXp;

                        hXp = &ms->Ms_hxl[Port];
                        for (n=0;n < ev->ev_CouNt; n++)
                            cC += Hxp->Size[n];
                        NdfluSh(&tp->T_oUtq, cc);
                    }
                }
                Switch (Ev->ev_eRrOr) {
                case A_SIZERR:  /*# erRor iN x

                 * Closecompletion , flu shall  p endi ng
              * t ransmissions, free res ource s, and            * c lea nu pmpc cp or t sta te. 
               */ 
            for (i = 0 ; i  < MPOUTSET;  i+ +) {
             mp->mp _ sendq[ i].ev_sta tu s  =
                 EVSTATUS_FRE E ;                  m p- > mp _ s end q[i ].ev_un.rc vb lk =0 ;
            mp->mp_s endq[i].ev_ p ara ms = 0 ;            }               mp _freein(e v);
            ad jptr(m p-> mp_ off, MP IN SET );           tp->t _s ta te &=  ~(T S _ C A RR_O N|T S_BU SY|TS _FLUSH);
           mp-> mp_on  = m p- >mp_o ff = m p->mp _n extrcv = 0;
             mp- >m p_f la gs &= ~MP_PR OGR ESS ;
            mp - > m p_ proto = MPPROTO_UN US E D ;             w ak e up((cadd r_ t)& tp-> t _ canq) ;
            bre a k; 
         case  E VCM D_I OCTL:               mp _free i n(ev);
              adjpt r (m p - >m p _off , M PINSET);
          mp ->m p _flag s &=~M P _I O CTL;
              wakeup ((cad dr_t)&tp->t_c anq);
           bre a k;             ca se EV CMD_WRITE:               /*
             * Tr ans mis sio n c o m pl eted, updatet t y
             * st ate  an d r est ar t output. 
            * /
            i f(ev ->ev_ o pts!=A_FLU SH){            tp -> t_ stat e & =~TS_B USY;                  if (tp- >t _s tate &TS_FLUSH)
                   tp - > t_state&= ~TS_FLUSH;
                else{
                  regist er int  cc =  0 , n ;                  s t ruc t hxm tl  *hx p;

                     h xp = &ms->ms_ hxl [por t ] ;              for (n=0; n < ev->ev _c o un t; n++)
                    cc += h xp->size[ n];
                  nd flush(&t p->t_outq ,  cc);                } 
            }
            swit ch  (ev->ev _error) {
               cas e A_S IZE RR:  /*#err o r i n x

 _ _   _ __ __  _* Close completion,_flush all pending
 _  __           * transmissions, free_resources,_and
 ___    _    _ _ * cleanup mpcc port state.
  __  _        _ */
    _  ___   _  for (i = 0;_i < MPOUTSET; i++) {
 _      _     _    _mp->mp_sendq[i].ev_status =
_    _  _ _  _     _  _ EVSTATUS_FREE;
    __  ___ _  __ __mp->mp_sendq[i].ev_un.rcvblk = 0;
   __      _   __   mp->mp_sendq[i].ev_params_= 0;
   _     _ _ _  }
        _     _ mp_freein(ev);
  _ __  __ _    adjptr(mp->mp_off, MPINSET);
 _ _     _   __ tp->t_state &= ~(TS_CARR_ON|TS_BUSY|TS_FLUSH);
  _     _    ___mp->mp_on = mp->mp_off = mp->mp_nextrcv_= 0;
    _  _      __mp->mp_flags &= ~MP_PROGRESS;
   __     ___   mp->mp_proto =_MPPROTO_UNUSED;
     _        _ wakeup((caddr_t)&tp->t_canq);
 _    ___       break;
  _ _  _    case EVCMD_IOCTL:
    _      _    mp_freein(ev);
      _       _ adjptr(mp->mp_off, MPINSET);
    _   __      mp->mp_flags_&=_~MP_IOCTL;
__  _  _  _ _  _wakeup((caddr_t)&tp->t_canq);
 _  __          break;
       _    case EVCMD_WRITE:
_    __  _   _  /*
     _        __ *_Transmission completed, update tty
_ _ _  _ _ _ _   * state and restart_output.
_        ____  _ */
 _  _  __     _ if (ev->ev_opts!=_A_FLUSH) {
  _         _       tp->t_state &= ~TS_BUSY;
       _ _   _ __   if (tp->t_state &_TS_FLUSH)
 _       __           __tp->t_state_&= ~TS_FLUSH;
 __     _____     _ else {
    __    _ __   _   _  register int cc = 0, n;
   __ ____   _          struct hxmtl *hxp;

  __    _     __   _    hxp = &ms->ms_hxl[port];
 _    _   _             for (n=0;n < ev->ev_count; n++)
   _    _    _  __  _   _   cc += hxp->size[n];
  _                 _   ndflush(&tp->t_outq, cc);
  _  _ _        _   }
       _        }
     __     _   switch (ev->ev_error) {
_   _   __  _ _ case A_SIZERR: _/*# error in x