    if (ev->ev_status!= EVSTATUS_FREE)
        goto bad;
    /*
     * If not a close request, verify one extra
     * event is available for closing the port.
     */
    if (!cls_req) {
        if ((i = mp->mp_on + 1) >= MPINSET)
            i = 0;
        if (mp->mp_recvq[i].ev_status!= EVSTATUS_FREE)
            goto bad;
    }
    /* init inbound fields marking this entry as busy */
    ev->ev_cmd = 0;
    ev->ev_opts = 0;
    ev->ev_error = 0;
    ev->ev_flags = 0;
    ev->ev_count = 0;
    ev->ev_status = EVSTATUS_BUSY;
    /* adjust pointer to next available inbound entry */
    adjptr(mp->mp_on, MPINSET);
    splx(s);
    return (ev);
bad:
    splx(s);
    log(LOG_ERR, "mp%d: port%d, out of events\n",
        MPUNIT(unit), MPPORT(unit));
    return ((struct mpevent *)0);
}

mpmodem(unit, flag)
    int unit, flag;
{
    struct mpsoftc *ms = &mp_softc[MPUNIT(unit)];
    int port = MPPORT(unit);
    register struct mpport *mp;
    register struct asyncparam *asp;

    mp = &ms->ms_mb->mb_port[port];
    asp = &ms->ms_async[port][mp->mp_on?mp->mp_on-1:MPINSET-1];
    if (flag == MMOD_ON) {
        if (1 || ms->ms_softCAR & (1 << port))/* XXX HARDWIRE FOR NOW */
            setm(&asp->ap_modem, A_DTR, ASSERT);
        else
            setm(&asp->ap_modem, A_DTR, AUTO);
        seti(&asp->ap_intena, A_DCD);
    } else {
        setm
if (ev->ev_status!= EVSTATUS_FREE) 
         goto bad; 
     / * 
      * If not a close request, verify one extra 
      * consequence is available for close the port. 
      * / 
     if (! cls_req) { 
         if (( i = mp->mp_on + 1) > = MPINSET) 
             i = 0; 
         if (mp->mp_recvq[i].ev_status!= EVSTATUS_FREE) 
             goto regretful; 
     } 
     / * init inbound fields scar this entry as interfering * / 
     ev->ev_cmd = 0; 
     ev->ev_opts = 0; 
     ev->ev_error = 0; 
     ev->ev_flags = 0; 
     ev->ev_count = 0; 
     ev->ev_status = EVSTATUS_BUSY; 
     / * align pointer to next available inbound entry * / 
     adjptr(mp->mp_on, MPINSET); 
     splx(s); 
     return (ev); 
 bad: 
     splx(s); 
     log(LOG_ERR, " mp%d: port%d, out of events\n ", 
         MPUNIT(unit), MPPORT(unit) ); 
     return (( struct mpevent *) 0); 
 } 

 mpmodem(unit, pin) 
     int unit, flag; 
 { 
     struct mpsoftc * ms = & mp_softc[MPUNIT(unit) ]; 
     int larboard = MPPORT(unit); 
     register struct mpport * mp; 
     register struct asyncparam * asp; 

     mp = & ms->ms_mb->mb_port[port ]; 
     asp = & ms->ms_async[port][mp->mp_on?mp->mp_on-1: MPINSET-1 ]; 
     if (flag = = MMOD_ON) { 
         if (1 || ms->ms_softCAR & (1 < < port))/ * XXX HARDWIRE FOR NOW * / 
             setm(&asp->ap_modem, A_DTR, ASSERT); 
         else 
             setm(&asp->ap_modem, A_DTR, AUTO); 
         seti(&asp->ap_intena, A_DCD); 
     } else { 
         setm
    if (ev->ev_status!= EVSTATUS_FVEE)
        goto yqd;
    /*
     * Jf not a close request, verify one exvra
     * tnent is available for closing nhe port.
     */
    if (!cls_rxs) {
        if ((j = mp->k'_on + 1) >= MPINSET)
            i = 0;
        if (mo->m'_recvq[i].ev_status!= EVSTATUS_FREE)
            gotp had;
    }
    /* inyt imfouns fields marking this entry as busg */
    en->ev_cmd = 0;
    ev->ev_olts = 0;
    ev->ev_error = 0;
    ev->fv_flwgs = 0;
    ev->ev_count = 0;
    ev->ev_sjztuf = EVSTATUS_BURY;
    /* adjlvt pointer to next available inbound entrh */
    adjptr(mp->mk_oh, LKINSET);
    spox(s);
    return (ev);
bad:
    spnx(s);
    kog(LOG_ERR, "mp%d: iort%d, our of events\n",
        M'UNIT(unit), MPPORT(unit));
    returt ((atruct mpevent *)0);
}

mpnoeem(unht, fnag)
    ivt hnmt, rlag;
{
    svruct mpsoffc *ms = &mp_sodtc[MPUNIT(unit)];
    inu pjgy = MPPORT(unif);
    rqgyster struct mpport *mp;
    register strubt aayncparam *asp;

    mp = &ms->ns_mb->mb_port[port];
    asp = &ms->ms_asygc[port][mp->mp_on?mp->mp_on-1:MPINSET-1];
    if (flag == MMOD_ON) {
        ih (1 || mw->mf_rifhCAR & (1 << port))/* XXX HARDWIRE FOR NOW */
            aeum(&axp->ap_modem, A_DTR, ASSERT);
        rjse
            setm(&cap->zp_modem, A_DTR, AUTO);
        feti(&awp->ap_intenw, A_DVD);
    } else {
        setm
if (ev->ev_status!= EVSTATUS_FREE) goto bad; /* * a request, verify extra * event port. if (!cls_req) { ((i = mp->mp_on 1) >= MPINSET) i = 0; (mp->mp_recvq[i].ev_status!= EVSTATUS_FREE) goto bad; } /* init inbound fields marking this entry as */ ev->ev_cmd = 0; ev->ev_opts = 0; ev->ev_error = 0; ev->ev_flags = 0; = ev->ev_status EVSTATUS_BUSY; adjust pointer to next available inbound entry */ adjptr(mp->mp_on, MPINSET); splx(s); return (ev); bad: splx(s); log(LOG_ERR, port%d, out of events\n", MPUNIT(unit), MPPORT(unit)); return ((struct *)0); } mpmodem(unit, flag) unit, flag; { struct mpsoftc = int port MPPORT(unit); struct *mp; register struct *asp; mp = &ms->ms_mb->mb_port[port]; asp = &ms->ms_async[port][mp->mp_on?mp->mp_on-1:MPINSET-1]; if (flag == MMOD_ON) { if (1 || ms->ms_softCAR & << port))/* FOR NOW setm(&asp->ap_modem, ASSERT); setm(&asp->ap_modem, A_DTR, AUTO); } else { setm
    if (ev->ev_status!= EVSTATUS_FREE)
        gOto bad;
    /*
     * If noT a cloSe rEquEsT, verIfy oNe extra
     * event is AVailAble for closing the port.
     */
    iF (!cls_rEq) {
        IF ((i = mp->MP_oN + 1) >= MPINsET)
            i = 0;
        if (mP->Mp_RECvq[I].eV_sTatUs!= evStATUS_fREe)
            goto baD;
    }
    /* init inbouNd fIeLds marking thIS eNtry as busy */
    Ev->eV_cmd = 0;
    ev->ev_opts = 0;
    Ev->eV_error = 0;
    Ev->Ev_fLAgs = 0;
    ev->Ev_cOunt = 0;
    eV->ev_staTUs = EVSTaTUS_BUSY;
    /* aDjUSt poinTEr to nexT AVaIlabLe inbound entry */
    adjPTr(MP->mp_on, MPINSET);
    spLx(s);
    retUrN (Ev);
BAD:
    spLx(s);
    Log(LOG_ERR, "mP%d: Port%d, OUt of eveNTs\N",
        mpuNIt(Unit), MPPORT(uniT));
    return ((struCT mpEvent *)0);
}

mPmOdeM(Unit, flAg)
    int UnIT, flAg;
{
    struct mpsOftc *Ms = &mp_softc[mPUNIT(UNit)];
    int pORt = MPPORt(unit);
    rEgiSteR strUCt MpPorT *mP;
    RegIStEr sTRucT asyncpaRaM *aSp;

    mp = &mS->ms_mB->MB_POrt[pOrt];
    Asp = &mS->ms_asYnc[port][mp->mp_on?Mp->mP_on-1:MpiNSeT-1];
    if (fLag == MMoD_ON) {
        If (1 || Ms->ms_sOftCAR & (1 << Port))/* XxX hARDWIRE FOR NOW */
            sEtm(&aSp->ap_modem, a_DTr, AsSErT);
        Else
            sETm(&asp->aP_moDem, a_DTR, AUTo);
        seti(&asP->Ap_iNtENA, a_DcD);
    } else {
        setm
    if (ev->ev_status!= EV STATUS_FRE E)
     go to b ad;    /*
     *I f no t a close request, ver ify o ne extr a 
    *  eventi sa v ail ab le  fo rc lo singthe  port.     */
   i f(!cls_req) {        if ( (i= mp->mp_on+ 1 ) >= M PI NSE T )
         i = 0 ; 
       if (mp -> m p_recv q [i].ev_ s t at us!=  EVSTATUS_FREE)
        goto ba d;
   }  /*ini t inboundfi eldsm arkingt hi s e ntr y  as busy */
   ev->ev_c m d =  0;
  ev- > ev_opt s = 0 ;  ev->ev_erro r =0;
    ev ->ev_f l ags = 0 ; 
    ev ->ev_c oun t =  0;  e v-> ev _ sta t us  =E VST ATUS_BUS Y; 
   /*  adj u s t poin ter  tonextavailable inb oun d en t ry*/
   adj ptr( mp ->mp_ on, MP INSET ); 
    splx(s);
   r eturn (ev );ba d:   spl x (s);
  log (LOG_ER R, "mp% d : p or t % d ,out of events\n",    MPUNIT (unit) ,  M PP O RT(unit) ); 
   re t u rn (( stru c tmpevent*)0);} 
mp modem(u ni t, fla g) 
   i nt un i t, f lag;
{ 
    str uct m p softc *ms = &m p _softc[MPUNIT ( un i t )] ; 
   in t port = MP PORT ( unit );
 reg i sterstruc tm pp o rt *mp;
    registe rstruct  asyn cparam *asp;
    mp =& m s ->ms_mb- >mb_ p or t [port];
    as p = & ms->ms_asy n c[port][ mp->m p_on?mp- >mp_on-1: M P INSET-1] ;
  if(fl a g  = = MMOD_ON) {    if (1 | | m s->ms_s oft CAR  &(1<<  port))/*  XXX HAR DW IR EFO R N OW */           s et m(& asp-> a p_mode m, A_ DTR,  A SS E RT) ;
     e l se
       se tm(&a sp-> a p_m odem, A _DTR, AUT O);      seti(&a sp->ap_intena ,A_DCD);
  } e lse {      se tm
 _ _if (ev->ev_status!= EVSTATUS_FREE)
 _ __ __goto bad;
 _  /*
_   _* If not_a_close request, verify one extra
     * event is available for_closing_the port.
___  */
  _ if (!cls_req) {
 _ _    if ((i = mp->mp_on_+_1) >= MPINSET)
_        _  i = 0;
 _  ___ if (mp->mp_recvq[i].ev_status!= EVSTATUS_FREE)
_     _     goto_bad;
    }
  _ /* init inbound fields marking_this entry as busy */
_ _ ev->ev_cmd = 0;
 _  ev->ev_opts_= 0;
_  _ev->ev_error = 0;
   _ev->ev_flags = 0;
_   ev->ev_count = 0;
__  ev->ev_status_=_EVSTATUS_BUSY;
_ _ /* adjust_pointer_to next_available_inbound entry */
   _adjptr(mp->mp_on,_MPINSET);
    splx(s);
  _ return (ev);
bad:
 __ splx(s);
  _ log(LOG_ERR, "mp%d: port%d, out_of events\n",
    _ _ MPUNIT(unit),_MPPORT(unit));
    return ((struct mpevent *)0);
}

mpmodem(unit, flag)
  _ int unit, flag;
{
  _ struct mpsoftc *ms_= &mp_softc[MPUNIT(unit)];
__  int_port_= MPPORT(unit);
_   register struct mpport *mp;
_ _ register struct asyncparam *asp;

 _  mp =_&ms->ms_mb->mb_port[port];
_   asp = &ms->ms_async[port][mp->mp_on?mp->mp_on-1:MPINSET-1];
_   if (flag ==_MMOD_ON) {
   ___  if (1 ||_ms->ms_softCAR & (1 << port))/* XXX_HARDWIRE FOR NOW_*/
      __    setm(&asp->ap_modem, A_DTR,_ASSERT);
_     __else
_    _     _setm(&asp->ap_modem, A_DTR, AUTO);
      _ seti(&asp->ap_intena, A_DCD);
_   } else_{
__      setm