Пример #1
0
static cyg_bool
serial_select(cyg_io_handle_t handle, cyg_uint32 which, CYG_ADDRWORD info)
{
#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT

    cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle;
    serial_channel *chan = (serial_channel *)t->priv;

    
    switch( which )
    {
    case CYG_FREAD:
        {
            cbuf_t *cbuf = &chan->in_cbuf;

            // Check for data in the input buffer. If there is none,
            // register the select operation, otherwise return true.

            if( cbuf->nb == 0 )
                cyg_selrecord( info, &cbuf->selinfo );
            else return true;
        }
        break;
        
    case CYG_FWRITE:
        {
            // Check for space in the output buffer. If there is none,
            // register the select operation, otherwise return true.

            cbuf_t *cbuf = &chan->out_cbuf;
            int space = cbuf->len - cbuf->nb;
#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL
            if ( (space < cbuf->low_water) ||
                 (chan->flow_desc.flags & CYG_SERIAL_FLOW_OUT_THROTTLED) )
                cyg_selrecord( info, &cbuf->selinfo );
#else
            if (space < cbuf->low_water)
                cyg_selrecord( info, &cbuf->selinfo );
#endif
            else return true;
        }
        break;

    case 0: // exceptions - none supported
        break;
    }
    return false;
#else

    // With no select support, we simply return true.
    return true;
#endif    
}
Пример #2
0
static int 
bsd_select(struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info)
{
    register struct socket *so = (struct socket *)fp->f_data;
    register int s = splsoftnet();

    switch (which) {

    case FREAD:
        if (soreadable(so)) {
            splx(s);
            return (1);
        }
        cyg_selrecord(info, &so->so_rcv.sb_sel);
        so->so_rcv.sb_flags |= SB_SEL;
        break;

    case FWRITE:
        if (sowriteable(so)) {
            splx(s);
            return (1);
        }
        cyg_selrecord(info, &so->so_snd.sb_sel);
        so->so_snd.sb_flags |= SB_SEL;
        break;

    case 0:
        if (so->so_oobmark || (so->so_state & SS_RCVATMARK)) {
            splx(s);
            return (1);
        }
        cyg_selrecord(info, &so->so_rcv.sb_sel);
        so->so_rcv.sb_flags |= SB_SEL;
        break;
    }
    splx(s);
    
    return ENOERR;
}
Пример #3
0
static cyg_bool  
ts_select(cyg_io_handle_t handle, 
          cyg_uint32 which, 
          cyg_addrword_t info)
{
    if (which == CYG_FREAD) {
        cyg_scheduler_lock();  // Prevent interaction with DSR code
        if (num_events > 0) {
            cyg_scheduler_unlock();  // Reallow interaction with DSR code
            return true;
        }        
        if (!ts_select_active) {
            ts_select_active = true;
            cyg_selrecord(info, &ts_select_info);
        }
        cyg_scheduler_unlock();  // Reallow interaction with DSR code
    }
    return false;
}
Пример #4
0
static cyg_bool _panel_select(cyg_io_handle_t handle, cyg_uint32 which, CYG_ADDRWORD info)
{
   cyg_bool retval = false;
        
   switch(which)
   {
     case CYG_FREAD:
        if(s_panel_key == 0)
            cyg_selrecord( info, &sg_PanelSignal);
        else retval = true;
        break;
     case CYG_FWRITE:    //write - not support
        break;
     case 0:             //exceptions - not support
        break;
     default:
        break;
   }
     return retval;
}