static int bsd_socket(cyg_nstab_entry *nste, int domain, int type, int protocol, cyg_file *file) { int error = 0; struct socket *so; error = socreate(domain, &so, type, protocol, (struct proc *)&proc0); if( error == ENOERR) { cyg_selinit(&so->so_rcv.sb_sel); cyg_selinit(&so->so_snd.sb_sel); file->f_flag |= CYG_FREAD|CYG_FWRITE; file->f_type = CYG_FILE_TYPE_SOCKET; file->f_ops = &bsd_sock_fileops; file->f_offset = 0; file->f_data = (CYG_ADDRWORD)so; file->f_xops = (CYG_ADDRWORD)&bsd_sockops; } return error; }
static bool ts_init(struct cyg_devtab_entry *tab) { cyg_uint32 _dummy; // Initialize SSP interface #if 0 while (*(volatile cyg_uint32 *)AAEC_SSP_SR & AAEC_SSP_SR_RNE) { _dummy = *(volatile cyg_uint32 *)AAEC_SSP_DR; // Drain FIFO } #endif *(volatile cyg_uint32 *)AAEC_SSP_CR0 = (1 << AAEC_SSP_CR0_SSE) | // SSP enable (37 << AAEC_SSP_CR0_SCR) | // Serial clock rate (AAEC_SSP_CR0_FRF_NAT << AAEC_SSP_CR0_FRF) | // MicroWire ((12-1) << AAEC_SSP_CR0_SIZE); // 12 bit words *(volatile cyg_uint32 *)AAEC_SSP_CR1 = (1 << AAEC_SSP_CR1_FEN); // Enable FIFO *(volatile cyg_uint32 *)AAEC_SSP_CPSR = 2; // Clock prescale *(volatile cyg_uint32 *)AAEC_PFDDR &= ~(1<<0); // TS uses port F bit 0 cyg_drv_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_TS); cyg_selinit(&ts_select_info); return true; }
static void serial_init(serial_channel *chan) { if (chan->init) return; if (chan->out_cbuf.len != 0) { #ifdef CYGDBG_IO_INIT diag_printf("Set output buffer - buf: %x len: %d\n", chan->out_cbuf.data, chan->out_cbuf.len); #endif chan->out_cbuf.waiting = false; chan->out_cbuf.abort = false; #ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING chan->out_cbuf.blocking = true; #endif chan->out_cbuf.pending = 0; cyg_drv_mutex_init(&chan->out_cbuf.lock); cyg_drv_cond_init(&chan->out_cbuf.wait, &chan->out_cbuf.lock); chan->out_cbuf.low_water = chan->out_cbuf.len / 4; #ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT cyg_selinit( &chan->out_cbuf.selinfo ); #endif } if (chan->in_cbuf.len != 0) { cbuf_t *cbuf = &chan->in_cbuf; #ifdef CYGDBG_IO_INIT diag_printf("Set input buffer - buf: %x len: %d\n", cbuf->data, cbuf->len); #endif cbuf->waiting = false; cbuf->abort = false; #ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING cbuf->blocking = true; #endif #ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT cyg_selinit( &cbuf->selinfo ); #endif #ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL cbuf->low_water = (CYGNUM_IO_SERIAL_FLOW_CONTROL_LOW_WATER_PERCENT * cbuf->len) / 100; cbuf->high_water = (CYGNUM_IO_SERIAL_FLOW_CONTROL_HIGH_WATER_PERCENT * cbuf->len) / 100; # ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE // But make sure it is at least 35 below buffer size, to allow // for 16 byte fifos, twice, plus some latency before s/w flow // control can kick in. This doesn't apply to h/w flow control // as it is near-instaneous if ( (cbuf->len - cbuf->high_water) < 35 ) cbuf->high_water = cbuf->len - 35; // and just in case... if ( cbuf->high_water <= 0 ) cbuf->high_water = 1; if ( cbuf->low_water > cbuf->high_water ) cbuf->low_water = cbuf->high_water; # endif #endif cyg_drv_mutex_init(&cbuf->lock); cyg_drv_cond_init(&cbuf->wait, &cbuf->lock); } #ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS chan->status_callback = NULL; #endif #ifdef CYGDBG_USE_ASSERTS #if CYGINT_IO_SERIAL_BLOCK_TRANSFER chan->in_cbuf.block_mode_xfer_running = false; chan->out_cbuf.block_mode_xfer_running = false; #endif // CYGINT_IO_SERIAL_BLOCK_TRANSFER #endif // CYGDBG_USE_ASSERTS #ifdef CYGPKG_NET_BLUEZ_STACK //diag_printf("sizeof(serial_channel) = %d cbuf_t %d\n", sizeof(serial_channel), sizeof(cbuf_t)); //diag_printf("chan->in_cbuf.data=%x,in_cbuf.len=%x,chan->out_cbuf.data=%x\n",chan->in_cbuf.data,chan->in_cbuf.len,chan->out_cbuf.data); chan->receive = 0;//clyu chan->tty_ldisc = NULL; #endif chan->init = true; }
static int bsd_accept(cyg_file *fp, cyg_file *new_fp, struct sockaddr *name, socklen_t *anamelen) { socklen_t namelen = 0; int error = 0, s; struct socket *head, *so; struct sockaddr *sa; if( anamelen != NULL) namelen = *anamelen; s = splsoftnet(); head = (struct socket *)fp->f_data; if ((head->so_options & SO_ACCEPTCONN) == 0) { splx(s); return (EINVAL); } if ((head->so_state & SS_NBIO) && TAILQ_EMPTY(&head->so_comp)) { splx(s); return (EWOULDBLOCK); } while (TAILQ_EMPTY(&head->so_comp) && head->so_error == 0) { if (head->so_state & SS_CANTRCVMORE) { head->so_error = ECONNABORTED; break; } error = tsleep((caddr_t)&head->so_timeo, PSOCK | PCATCH, "netcon", 0); if (error) { splx(s); return (error); } } if (head->so_error) { error = head->so_error; head->so_error = 0; splx(s); return (error); } /* * At this point we know that there is at least one connection * ready to be accepted. Remove it from the queue prior to * allocating the file descriptor for it since falloc() may * block allowing another process to accept the connection * instead. */ so = TAILQ_FIRST(&head->so_comp); TAILQ_REMOVE(&head->so_comp, so, so_list); head->so_qlen--; #if 0 // FIXME fflag = lfp->f_flag; error = falloc(p, &nfp, &fd); if (error) { /* * Probably ran out of file descriptors. Put the * unaccepted connection back onto the queue and * do another wakeup so some other process might * have a chance at it. */ TAILQ_INSERT_HEAD(&head->so_comp, so, so_list); head->so_qlen++; wakeup_one(&head->so_timeo); splx(s); goto done; } fhold(nfp); p->p_retval[0] = fd; /* connection has been removed from the listen queue */ KNOTE(&head->so_rcv.sb_sel.si_note, 0); #endif so->so_state &= ~SS_COMP; so->so_head = NULL; cyg_selinit(&so->so_rcv.sb_sel); cyg_selinit(&so->so_snd.sb_sel); new_fp->f_type = DTYPE_SOCKET; new_fp->f_flag |= FREAD|FWRITE; new_fp->f_offset = 0; new_fp->f_ops = &bsd_sock_fileops; new_fp->f_data = (CYG_ADDRWORD)so; new_fp->f_xops = (CYG_ADDRWORD)&bsd_sockops; sa = 0; error = soaccept(so, &sa); if (error) { /* * return a namelen of zero for older code which might * ignore the return value from accept. */ if (name != NULL) { *anamelen = 0; } goto noconnection; } if (sa == NULL) { namelen = 0; if (name) goto gotnoname; splx(s); error = 0; goto done; } if (name) { if (namelen > sa->sa_len) namelen = sa->sa_len; #ifdef COMPAT_OLDSOCK if (compat) ((struct osockaddr *)sa)->sa_family = sa->sa_family; #endif error = copyout(sa, (caddr_t)name, namelen); if (!error) gotnoname: *anamelen = namelen; } noconnection: #if 0 // FIXME /* * close the new descriptor, assuming someone hasn't ripped it * out from under us. */ if (error) { if (fdp->fd_ofiles[fd] == nfp) { fdp->fd_ofiles[fd] = NULL; fdrop(nfp, p); } } splx(s); /* * Release explicitly held references before returning. */ done: if (nfp != NULL) fdrop(nfp, p); fdrop(lfp, p); return (error); m_freem(nam); #else done: #endif splx(s); return (error); }
void gx3113_panel_mod_init(void) { char_dev_register(&gx3113_panel_dev, PANEL_NAME, NULL); cyg_selinit(&sg_PanelSignal); }
static int bsd_accept ( cyg_file *fp, cyg_file *new_fp, struct sockaddr *name, socklen_t *anamelen ) { struct mbuf *nam; socklen_t namelen = 0; int error = 0, s; register struct socket *so; if( anamelen != NULL ) namelen = *anamelen; s = splsoftnet(); so = (struct socket *)fp->f_data; if ((so->so_options & SO_ACCEPTCONN) == 0) { splx(s); return (EINVAL); } if ((so->so_state & SS_NBIO) && so->so_qlen == 0) { splx(s); return (EWOULDBLOCK); } while (so->so_qlen == 0 && so->so_error == 0) { if (so->so_state & SS_CANTRCVMORE) { so->so_error = ECONNABORTED; break; } error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH, netcon, 0); if (error) { splx(s); return (error); } } if (so->so_error) { error = so->so_error; so->so_error = 0; splx(s); return (error); } { struct socket *aso = so->so_q; if (soqremque(aso, 1) == 0) panic("accept"); so = aso; } cyg_selinit(&so->so_rcv.sb_sel); cyg_selinit(&so->so_snd.sb_sel); new_fp->f_type = DTYPE_SOCKET; new_fp->f_flag |= FREAD|FWRITE; new_fp->f_offset = 0; new_fp->f_ops = &bsd_sock_fileops; new_fp->f_data = (CYG_ADDRWORD)so; new_fp->f_xops = (CYG_ADDRWORD)&bsd_sockops; nam = m_get(M_WAIT, MT_SONAME); (void) soaccept(so, nam); if (name) { if (namelen > nam->m_len) namelen = nam->m_len; /* SHOULD COPY OUT A CHAIN HERE */ if ((error = copyout(mtod(nam, caddr_t), (caddr_t)name, namelen)) == 0) *anamelen = namelen; } m_freem(nam); splx(s); return (error); }
static bool ts_init(struct cyg_devtab_entry *tab) { cyg_selinit(&ts_select_info); return true; }