Ejemplo n.º 1
0
int send_msg_fifo(int *s, msg_t *fmsg){
  int   ret 	= 0, ret1;
  int  taille = sizeof(msg_head_t)  ;
  msg("write on fifos %d, msg %p\n",*s,fmsg);    
  if ( fmsg == NULL )
    return -1 ;
  // envoi le header 


  ret1 = rtf_put (*s,(char*) &(fmsg->head) , taille);
  if(ret1 <0){
    msg("rtf_put H ERR %d\n",ret1);
    rtf_reset(*s);
    return ret1;
  }
  ret=ret1;
  // envoi les datas si elles sont definis
  if ( fmsg->data != NULL ){
    ret1 += rtf_put (*s,(char*) fmsg->data, fmsg->head.size);
    if(ret1 <0){
      msg("rtf_put D ERR %d\n",ret1);
      rtf_reset(*s);
      return ret1;
    }
  }
  ret+=ret1;
  return ret;
}
Ejemplo n.º 2
0
/*------------------------------------------------------------------------------*/
int L3_xface_init(void) {
  /*------------------------------------------------------------------------------*/

  int ret = 0;

#ifdef USER_MODE

  int sock;
  LOG_D(RRC, "[L3_XFACE] init de l'interface \n");

  if (open_socket (&S_rrc, RRC_RRM_SOCK_PATH, RRM_RRC_SOCK_PATH, 0) == -1)
    return (-1);

  if (S_rrc.s == -1) {
    return (-1);
  }

  socket_setnonblocking (S_rrc.s);
  msg ("Interface Connected... RRM-RRC\n");
  return 0;

#else

  ret=rtf_create(RRC2RRM_FIFO,32768);

  if (ret < 0) {
    msg("[openair][MAC][INIT] Cannot create RRC2RRM fifo %d (ERROR %d)\n",RRC2RRM_FIFO,ret);

    return(-1);
  }
  else {
    msg("[openair][MAC][INIT] Created RRC2RRM fifo %d\n",RRC2RRM_FIFO);
    rtf_reset(RRC2RRM_FIFO);
  }

  ret=rtf_create(RRM2RRC_FIFO,32768);

  if (ret < 0) {
    msg("[openair][MAC][INIT] Cannot create RRM2RRC fifo %d (ERROR %d)\n",RRM2RRC_FIFO,ret);

    return(-1);
  }
  else {
    msg("[openair][MAC][INIT] Created RRC2RRM fifo %d\n",RRM2RRC_FIFO);
    rtf_reset(RRM2RRC_FIFO);
  }

  return(0);

#endif
}
Ejemplo n.º 3
0
static void init(scicos_block *block)
{
  int sizeData = sizeof(float)*(block->nin+1);
  int dim = block->ipar[1]/sizeData*sizeData;
  rtf_create(block->ipar[0],dim);
  rtf_reset(block->ipar[0]);
}
Ejemplo n.º 4
0
static void *intr_handler(void *args)
{
	RT_TASK *mytask;
	RTIME period;
	int playfifo, cntrfifo;
	char data;
#ifdef U_LAW
	int go=1;
	int divisor = DIVISOR;
#else
	char temp;
#endif
	rt_allow_nonroot_hrt();
	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);

#ifdef U_LAW
	if (iopl(3)) {
	  printf("iopl() failed/n");
	  exit(1);
	}  
	outb_p(0x92, 0x43); /* binary, mode1, LSB only, ch 2 */
	/* You can make this bigger, but then you start to get
	 * clipping, which sounds bad.  29 is good */

	/* VOLUME SETTING */
	pcsp_calc_vol(70);

	port61 = inb(0x61) | 0x3;
#else
	ioperm(PORT_ADR, 1, 1);
#endif

 	if (!(mytask = rt_task_init_schmod(nam2num("SOUND"), 1, 0, 0, SCHED_FIFO, 0xF))) {
		printf("CANNOT INIT SOUND TASK\n");
		exit(1);
	}
	playfifo = 0;
	cntrfifo = 1;
	rtf_create(playfifo, 8192); /* 1s buffer */
	rtf_reset(playfifo);
	rtf_create(cntrfifo, 1000);
	rtf_reset(cntrfifo);

	rt_set_oneshot_mode();
	start_rt_timer(0);
	period = nano2count(PERIOD);

	printf("\nINIT SOUND TASK\n");

	mlockall(MCL_CURRENT | MCL_FUTURE);
	
#ifdef HARDREALTIME
	rt_make_hard_real_time();
#endif	
	rt_task_make_periodic(mytask, rt_get_time() + 5*period, period);
	rtf_put(cntrfifo, &data, 1);

	rt_sleep(nano2count(100000000));

	while(1) {
#ifdef U_LAW
	  if (!(--divisor)) {
	    divisor = DIVISOR;
	    //cpu_used[hard_cpu_id()]++;
	    if (!(rtf_get(playfifo, &data, 1) > 0)) {
	      go=0;
	    }else{
	      go=1;
	    }
	  }
	  if(go){
	    outb(port61,0x61);
	    outb(port61^1,0x61);
	    outb(vl_tab[((unsigned int)data)&0xff], 0x42);
	  }
#else
	  if (rtf_get(playfifo, &data, 1) > 0) {
	    go=1;
	    data = filter(data);
	    temp = inb(PORT_ADR);            
	    temp &= 0xfd;
	    temp |= (data & 1) << 1;
	    outb(temp, PORT_ADR);
	  } else {
	    go=0;
	  }	
#endif
	  rt_task_wait_period();
	  if (go==0) { 
	  	if (rtf_get(cntrfifo, &data, 1) > 0) {
	    		break;
	    	}		
	  } 
	}
	
	stop_rt_timer();
	rt_make_soft_real_time();
	rtf_destroy(playfifo);
	rtf_destroy(cntrfifo);
	rt_task_delete(mytask);
	printf("\nEND SOUND TASK\n");
	return 0;
}
Ejemplo n.º 5
0
void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst, struct nas_priv *gpriv)
{
  //---------------------------------------------------------------------------
  struct pdcp_data_req_header_s     pdcph;
  struct nas_priv *priv=netdev_priv(nasdev[inst]);
#ifdef LOOPBACK_TEST
  int i;
#endif
  unsigned int bytes_wrote;
  //unsigned char j;
  // Start debug information
#ifdef NAS_DEBUG_SEND
  printk("NAS_COMMON_QOS_SEND - inst %d begin \n",inst);
#endif

  //  if (cx->state!=NAS_STATE_CONNECTED) // <--- A REVOIR
  //  {
  //    priv->stats.tx_dropped ++;
  //    printk("NAS_QOS_SEND: No connected, so message are dropped \n");
  //    return;
  //  }
  if (skb==NULL) {
#ifdef NAS_DEBUG_SEND
    printk("NAS_COMMON_QOS_SEND - input parameter skb is NULL \n");
#endif
    return;
  }

  if (gc==NULL) {
#ifdef NAS_DEBUG_SEND
    printk("NAS_COMMON_QOS_SEND - input parameter gc is NULL \n");
#endif
    return;
  }

  if (cx==NULL) {
#ifdef NAS_DEBUG_SEND
    printk("NAS_COMMON_QOS_SEND - input parameter cx is NULL \n");
#endif
    return;
  }

  // End debug information
  if (gc->rb==NULL) {
    gc->rb=nas_COMMON_search_rb(cx, gc->rab_id);

    if (gc->rb==NULL) {
      ++priv->stats.tx_dropped;
      printk("NAS_COMMON_QOS_SEND: No corresponding Radio Bearer, so message are dropped, rab_id=%u \n", gc->rab_id);
      return;
    }
  }

#ifdef NAS_DEBUG_SEND
  printk("NAS_COMMON_QOS_SEND #1 :");
  printk("lcr %u, rab_id %u, rab_id %u, skb_len %d\n", cx->lcr, (gc->rb)->rab_id, gc->rab_id,skb->len);
  nas_print_classifier(gc);
#endif
  pdcph.data_size  = skb->len;
  pdcph.rb_id      = (gc->rb)->rab_id;
  pdcph.inst       = inst;


#ifdef PDCP_USE_NETLINK
  bytes_wrote = nas_netlink_send((char *)&pdcph,NAS_PDCPH_SIZE);
#ifdef NAS_DEBUG_SEND
  printk("[NAS] Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n",
         bytes_wrote,skb->len);
#endif
#else
  bytes_wrote = rtf_put(NAS2PDCP_FIFO, &pdcph, NAS_PDCPH_SIZE);
#ifdef NAS_DEBUG_SEND
  printk("[NAS] Wrote %d bytes (header for %d byte skb) to PDCP fifo\n",
         bytes_wrote,skb->len);
#endif
#endif //PDCP_USE_NETLINK

  if (bytes_wrote != NAS_PDCPH_SIZE) {
    printk("NAS_COMMON_QOS_SEND: problem while writing PDCP's header (bytes wrote = %d )\n",bytes_wrote);
    printk("rb_id %d, Wrote %d, Header Size %lu\n", pdcph.rb_id , bytes_wrote, NAS_PDCPH_SIZE);
#ifndef PDCP_USE_NETLINK
    rtf_reset(NAS2PDCP_FIFO);
#endif //PDCP_USE_NETLINK
    return;
  }

#ifdef  PDCP_USE_NETLINK
  bytes_wrote += nas_netlink_send((char *)skb->data,skb->len);
#else
  bytes_wrote += rtf_put(NAS2PDCP_FIFO, skb->data, skb->len);
#endif //PDCP_USE_NETLINK

  if (bytes_wrote != skb->len+NAS_PDCPH_SIZE) {
    printk("NAS_COMMON_QOS_SEND: Inst %d, RB_ID %d: problem while writing PDCP's data, bytes_wrote = %d, Data_len %d, PDCPH_SIZE %lu\n",
           inst,
           pdcph.rb_id,
           bytes_wrote,
           skb->len,
           NAS_PDCPH_SIZE); // congestion
#ifndef PDCP_USE_NETLINK
    rtf_reset(NAS2PDCP_FIFO);
#endif //PDCP_USE_NETLINK
    return;
  }

#ifdef NAS_DEBUG_SEND
  printk("NAS_SEND: Sending packet of size %d to PDCP \n",skb->len);

  for (j=0; j<skb->len; j++)
    printk("%2x ",((unsigned char *)(skb->data))[j]);

  printk("\n");
#endif

  priv->stats.tx_bytes   += skb->len;
  priv->stats.tx_packets ++;
#ifdef NAS_DEBUG_SEND
  printk("NAS_COMMON_QOS_SEND - end \n");
#endif
}