コード例 #1
0
void avmb1_handle_new_ncci(avmb1_card * card,
			   __u16 appl, __u32 ncci, __u32 winsize)
{
	avmb1_ncci *np;
	if (!VALID_APPLID(appl)) {
		printk(KERN_ERR "avmb1_handle_new_ncci: illegal appl %d\n", appl);
		return;
	}
	if ((np = (avmb1_ncci *) kmalloc(sizeof(avmb1_ncci), GFP_ATOMIC)) == 0) {
		printk(KERN_ERR "avmb1_handle_new_ncci: alloc failed ncci 0x%x\n", ncci);
		return;
	}
	if (winsize > CAPI_MAXDATAWINDOW) {
		printk(KERN_ERR "avmb1_handle_new_ncci: winsize %d too big, set to %d\n",
		       winsize, CAPI_MAXDATAWINDOW);
		winsize = CAPI_MAXDATAWINDOW;
	}
	np->applid = appl;
	np->ncci = ncci;
	np->winsize = winsize;
	mq_init(np);
	np->next = APPL(appl)->nccilist;
	APPL(appl)->nccilist = np;
	printk(KERN_INFO "b1capi: appl %d ncci 0x%x up\n", appl, ncci);

}
コード例 #2
0
ファイル: dev.c プロジェクト: GaloisInc/tower-camkes-odroid
void can_tx__init(void)
{
	printf("CAN device started...\n");

	queue_lock_wait();
	mq_init(MSG_QUEUE_SIZE);
}
コード例 #3
0
ファイル: sched.c プロジェクト: nesl/umpu
// Initialize the scheduler
void sched_init(uint8_t cond)
{
  register uint8_t i = 0;
  if(cond != SOS_BOOT_NORMAL) {
	//! iterate through module_list and check for memory bug
  }
  mq_init(&schedpq);
  //! initialize all bins to be empty
  for(i = 0; i < SCHED_NUMBER_BINS; i++) {
		mod_bin[i] = NULL;
  }
  for(i = 0; i < SCHED_PID_SLOTS; i++) {
		pid_pool[i] = 0;
  }
  sched_register_kernel_module(&sched_module, sos_get_header_address(sched_mod_header), mod_bin);

	for(i = 0; i < SCHED_NUM_INTS; i++) {
		int_array[i] = NULL;
	}
	//
	// Initialize PID stack
	//
	pid_sp = pid_stack;
	// initialize short message
	short_msg.data = short_msg.payload;
	short_msg.daddr = node_address;
	short_msg.saddr = node_address;
	short_msg.len = 3;
}
コード例 #4
0
static void controllercb_new_ncci(struct capi_ctr * card,
					__u16 appl, __u32 ncci, __u32 winsize)
{
	struct capi_ncci *np;
	if (!VALID_APPLID(appl)) {
		printk(KERN_ERR "avmb1_handle_new_ncci: illegal appl %d\n", appl);
		return;
	}
	if ((np = (struct capi_ncci *) kmalloc(sizeof(struct capi_ncci), GFP_ATOMIC)) == 0) {
		printk(KERN_ERR "capi_new_ncci: alloc failed ncci 0x%x\n", ncci);
		return;
	}
	if (winsize > CAPI_MAXDATAWINDOW) {
		printk(KERN_ERR "capi_new_ncci: winsize %d too big, set to %d\n",
		       winsize, CAPI_MAXDATAWINDOW);
		winsize = CAPI_MAXDATAWINDOW;
	}
	np->applid = appl;
	np->ncci = ncci;
	np->winsize = winsize;
	mq_init(np);
	np->next = APPL(appl)->nccilist;
	APPL(appl)->nccilist = np;
	APPL(appl)->nncci++;
	printk(KERN_INFO "kcapi: appl %d ncci 0x%x up\n", appl, ncci);

	notify_push(KCI_NCCIUP, CARDNR(card), appl, ncci);
}
コード例 #5
0
ファイル: file.c プロジェクト: ChunHungLiu/rtenv-plus
int
file_mknod(int fd, int driver_pid, struct file *files[], int dev,
           struct memory_pool *memory_pool, struct event_monitor *event_monitor)
{
    int result;
	switch(dev) {
	case S_IFIFO:
		result = fifo_init(fd, driver_pid, files, memory_pool, event_monitor);
		break;
	case S_IMSGQ:
		result = mq_init(fd, driver_pid, files, memory_pool, event_monitor);
		break;
	case S_IFBLK:
	    result = block_init(fd, driver_pid, files, memory_pool, event_monitor);
	    break;
	case S_IFREG:
	    result = regfile_init(fd, driver_pid, files, memory_pool, event_monitor);
	    break;
	default:
		result = -1;
	}

	if (result == 0) {
	    files[fd]->fd = fd;
    }

	return result;
}
コード例 #6
0
ファイル: vmac.c プロジェクト: nesl/sos-2x
/*************************************************************************
 * Initiate the radio and mac                                            *
 *************************************************************************/
void mac_init()
{
	Radio_Init();
#ifdef RADIO_CHANNEL
	Radio_Set_Channel(RADIO_CHANNEL);
#else
	Radio_Set_Channel(13);
#endif

#ifdef SOS_USE_PREEMPTION
	ker_register_module(sos_get_header_address(mod_header));
#else
	sched_register_kernel_module(&vmac_module, sos_get_header_address(mod_header), NULL);
#endif

	// Timer needs to be done after reigsteration
	ker_permanent_timer_init(&wakeup_timer, RADIO_PID, WAKEUP_TIMER_TID, TIMER_ONE_SHOT);

	mq_init(&vmac_pq);	//! Initialize sending queue
	resetSeq();		//set seq_count 0
	resetRetries(); 	//set retries 0

	//enable interrupt for receiving data
	Radio_SetPackRecvedCallBack(_MacRecvCallBack);
	Radio_Enable_Interrupt();
}
コード例 #7
0
/*===========================================================================*
 *				blockdriver_announce			     *
 *===========================================================================*/
void blockdriver_announce(int type)
{
/* Announce we are up after a fresh start or a restart. */
  int r;
  char key[DS_MAX_KEYLEN];
  char label[DS_MAX_KEYLEN];
  char *driver_prefix = "drv.blk.";

  /* Callers are allowed to use ipc_sendrec to communicate with drivers.
   * For this reason, there may blocked callers when a driver restarts.
   * Ask the kernel to unblock them (if any). Note that most block drivers
   * will not restart statefully, and thus will skip this code.
   */
  if (type == SEF_INIT_RESTART) {
	if ((r = sys_statectl(SYS_STATE_CLEAR_IPC_REFS)) != OK)
		panic("blockdriver_init: sys_statectl failed: %d", r);
  }

  /* Publish a driver up event. */
  if ((r = ds_retrieve_label_name(label, sef_self())) != OK)
	panic("blockdriver_init: unable to get own label: %d", r);

  snprintf(key, DS_MAX_KEYLEN, "%s%s", driver_prefix, label);
  if ((r = ds_publish_u32(key, DS_DRIVER_UP, DSF_OVERWRITE)) != OK)
	panic("blockdriver_init: unable to publish driver up event: %d", r);

  /* Expect an open for any device before serving regular driver requests. */
  clear_open_devs();

  /* Initialize or reset the message queue. */
  mq_init();
}
コード例 #8
0
ファイル: reader.c プロジェクト: knusbaum/Wily
int
readerInit(void)
{
	if ((wilyfd = get_connect()) < 0) {
		DPRINT("Could not connect to wily");
		return 1;
	}
	mq_init(wilyq, wilyfd);
	return 0;
}
コード例 #9
0
ファイル: hive_cell.c プロジェクト: acmercyj/hive
static struct cell *
cell_create() {
	struct cell *c = malloc(sizeof(*c));
	c->lock = 0;
	c->ref = 0;
	c->L = NULL;
	c->quit = 0;
	mq_init(&c->mq);

	return c;
}
コード例 #10
0
ファイル: radio.c プロジェクト: nesl/sos-2x
void radio_init()
{
	send_sock = socket(AF_INET, SOCK_DGRAM, 0);

	if( send_sock < 0 ) {
		perror("socket in radio.c");
		exit(1);
	}

	interrupt_add_read_fd(topo_self.sock, recv_thread);
	
	mq_init(&senddoneq);
}
コード例 #11
0
ファイル: inet.c プロジェクト: EchoLiao/minix-study
PRIVATE void nw_init()
{
	mq_init();
	qp_init();
	bf_init();
	clck_init();
	sr_init();
	eth_init();
	arp_init();
	psip_init();
	ip_init();
	tcp_init();
	udp_init();
}
コード例 #12
0
ファイル: inet.c プロジェクト: 54niyu/minix
PRIVATE void nw_init()
{
#if DEBUG & 256
 { where(); printf("starting mq_init()\n"); }
#endif
	mq_init();
#if DEBUG & 256
 { where(); printf("starting bf_init()\n"); }
#endif
	bf_init();
#if DEBUG & 256
 { where(); printf("starting clck_init()\n"); }
#endif
	clck_init();
#if DEBUG & 256
 { where(); printf("starting sr_init()\n"); }
#endif
	sr_init();
#if DEBUG & 256
 { where(); printf("starting eth_init()\n"); }
#endif
	eth_init();
#if DEBUG & 256
 { where(); printf("starting arp_init()\n"); }
#endif
#if ENABLE_ARP
	arp_init();
#endif
#if DEBUG & 256
 { where(); printf("starting ip_init()\n"); }
#endif
#if ENABLE_IP
	ip_init();
#endif
#if DEBUG & 256
 { where(); printf("starting tcp_init()\n"); }
#endif
#if ENABLE_TCP
	tcp_init();
#endif
#if DEBUG & 256
 { where(); printf("starting udp_init()\n"); }
#endif
#if ENABLE_UDP
	udp_init();
#endif
}
コード例 #13
0
ファイル: mq_recv.c プロジェクト: pittzheng/Code_Learning
int main ( int argc, char *argv[] )
{
    int i       ;
    
    if ( mq_init() == -1 ) 
    {
        DEBUG_PRINTF("mq_init failed %s\n", "hello");
        return EXIT_FAILURE;
    }

    mq_recv_msg_noblock( MODULE_CONF_MGR_RETRIEVE);

/*    for(i=0; i< MODULE_MAX; i++)*/
/*    {*/
/*        DEBUG_PRINTF("id[i]=%d\n", mq_get_id(MODULE_CONF_MGR_STORE + i));*/
/*    }*/

    mq_unload();
    return EXIT_SUCCESS;
}
コード例 #14
0
ファイル: capilib.c プロジェクト: johnny/CobraDroidBeta
void capilib_new_ncci(struct list_head *head, u16 applid, u32 ncci, u32 winsize)
{
	struct capilib_ncci *np;

	np = kmalloc(sizeof(*np), GFP_ATOMIC);
	if (!np) {
		printk(KERN_WARNING "capilib_new_ncci: no memory.\n");
		return;
	}
	if (winsize > CAPI_MAXDATAWINDOW) {
		printk(KERN_ERR "capi_new_ncci: winsize %d too big\n",
		       winsize);
		winsize = CAPI_MAXDATAWINDOW;
	}
	np->applid = applid;
	np->ncci = ncci;
	np->winsize = winsize;
	mq_init(np);
	list_add_tail(&np->list, head);
	DBG("kcapi: appl %d ncci 0x%x up", applid, ncci);
}
コード例 #15
0
ファイル: mq_send.c プロジェクト: pittzheng/Code_Learning
int main ( int argc, char *argv[] )
{
    MQ_MODULE_E src, dest;
    char send_data[64];
    char recv_data[64];

    memset(send_data, '\0', sizeof(send_data));
    memset(recv_data, '\0', sizeof(recv_data));

    src = MODULE_CAPI_RETRIEVE;
    dest = MODULE_CONF_MGR_RETRIEVE;

    strcpy(send_data, "send1");

    if ( mq_init() == -1 ) 
    {
        DEBUG_PRINTF("mq_init failed\n");
        return EXIT_FAILURE;
    }

    if ( mq_send_msg(src, dest, send_data, sizeof(send_data), MQ_PRIO_1) < 0) 
    {
        DEBUG_PRINTF("mq_send_msg failed\n");
        return EXIT_FAILURE;
    }

    strcpy(send_data, "send2");

    if ( mq_send_msg(src, dest, send_data, sizeof(send_data), MQ_PRIO_2) < 0) 
    {
        DEBUG_PRINTF("mq_send_msg failed\n");
        return EXIT_FAILURE;
    }


    mq_unload();
    return EXIT_SUCCESS;
}
コード例 #16
0
ファイル: if_ppp.c プロジェクト: DavidAlphaFox/openbsd-kernel
int
ppp_clone_create(struct if_clone *ifc, int unit)
{
    struct ppp_softc *sc;
    int s;

    sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO);
    if (!sc)
	return (ENOMEM);

    sc->sc_unit = unit;
    snprintf(sc->sc_if.if_xname, sizeof sc->sc_if.if_xname, "%s%d",
	ifc->ifc_name, unit);
    sc->sc_if.if_softc = sc;
    sc->sc_if.if_mtu = PPP_MTU;
    sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
    sc->sc_if.if_type = IFT_PPP;
    sc->sc_if.if_hdrlen = PPP_HDRLEN;
    sc->sc_if.if_ioctl = pppsioctl;
    sc->sc_if.if_output = pppoutput;
    sc->sc_if.if_start = ppp_ifstart;
    IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN);
    mq_init(&sc->sc_inq, IFQ_MAXLEN, IPL_NET);
    IFQ_SET_MAXLEN(&sc->sc_fastq, IFQ_MAXLEN);
    ppp_pkt_list_init(&sc->sc_rawq, IFQ_MAXLEN);
    IFQ_SET_READY(&sc->sc_if.if_snd);
    if_attach(&sc->sc_if);
    if_alloc_sadl(&sc->sc_if);
#if NBPFILTER > 0
    bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
#endif
    s = splnet();
    LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_list);
    splx(s);

    return (0);
}
コード例 #17
0
ファイル: media.c プロジェクト: RuralHunter/showtime
media_pipe_t *
mp_create(const char *name, int flags)
{
  media_pipe_t *mp;
  prop_t *p;

  mp = calloc(1, sizeof(media_pipe_t));
  mp->mp_cancellable = cancellable_create();

  mp->mp_vol_ui = 1.0f;

  mp->mp_satisfied = -1;
  mp->mp_epoch = 1;

  mp->mp_mb_pool = pool_create("packet headers",
			       sizeof(media_buf_t),
			       POOL_ZERO_MEM);

  mp->mp_flags = flags;

  hts_mutex_lock(&media_mutex);
  LIST_INSERT_HEAD(&media_pipelines, mp, mp_global_link);
  num_media_pipelines++;
  hts_mutex_unlock(&media_mutex);


  TAILQ_INIT(&mp->mp_eq);

  atomic_set(&mp->mp_refcount, 1);

  mp->mp_buffer_limit = 1 * 1024 * 1024;

  mp->mp_name = name;

  hts_mutex_init(&mp->mp_mutex);
  hts_mutex_init(&mp->mp_clock_mutex);

  hts_mutex_init(&mp->mp_overlay_mutex);
  TAILQ_INIT(&mp->mp_overlay_queue);
  TAILQ_INIT(&mp->mp_spu_queue);

  hts_cond_init(&mp->mp_backpressure, &mp->mp_mutex);

  mp->mp_prop_root = prop_create(media_prop_sources, NULL);
  mp->mp_prop_metadata    = prop_create(mp->mp_prop_root, "metadata");

  mp->mp_prop_primary = prop_create(mp->mp_prop_root, "primary");

  mp->mp_prop_io = prop_create(mp->mp_prop_root, "io");
  mp->mp_prop_notifications = prop_create(mp->mp_prop_root, "notifications");
  mp->mp_prop_url         = prop_create(mp->mp_prop_root, "url");


  mp->mp_setting_root = prop_create(mp->mp_prop_root, "settings");

  //--------------------------------------------------
  // Video

  mp->mp_prop_video = prop_create(mp->mp_prop_root, "video");
  mp->mp_setting_video_root = prop_create(mp->mp_prop_video, "settings");
  mq_init(&mp->mp_video, mp->mp_prop_video, &mp->mp_mutex, mp);

  //--------------------------------------------------
  // Audio

  mp->mp_prop_audio = prop_create(mp->mp_prop_root, "audio");
  mp->mp_setting_audio_root = prop_create(mp->mp_prop_audio, "settings");
  mq_init(&mp->mp_audio, mp->mp_prop_audio, &mp->mp_mutex, mp);
  mp->mp_prop_audio_track_current = prop_create(mp->mp_prop_audio, "current");
  mp->mp_prop_audio_track_current_manual =
    prop_create(mp->mp_prop_audio, "manual");
  mp->mp_prop_audio_tracks = prop_create(mp->mp_prop_metadata, "audiostreams");
  prop_linkselected_create(mp->mp_prop_audio_tracks,
                           mp->mp_prop_audio, "active", NULL);

  prop_set_string(mp->mp_prop_audio_track_current, "audio:off");


  mp_track_mgr_init(mp,
                    &mp->mp_audio_track_mgr,
                    mp->mp_prop_audio_tracks,
                    MEDIA_TRACK_MANAGER_AUDIO,
                    mp->mp_prop_audio_track_current,
                    prop_create(mp->mp_prop_audio, "sorted"));

  //--------------------------------------------------
  // Subtitles

  p = prop_create(mp->mp_prop_root, "subtitle");
  mp->mp_setting_subtitle_root = prop_create(p, "settings");
  mp->mp_prop_subtitle_track_current = prop_create(p, "current");
  mp->mp_prop_subtitle_track_current_manual = prop_create(p, "manual");
  mp->mp_prop_subtitle_tracks = prop_create(mp->mp_prop_metadata,
					    "subtitlestreams");
  prop_linkselected_create(mp->mp_prop_subtitle_tracks, p, "active", NULL);


  prop_set_string(mp->mp_prop_subtitle_track_current, "sub:off");
  mp_add_track_off(mp->mp_prop_subtitle_tracks, "sub:off");

  mp_track_mgr_init(mp,
                    &mp->mp_subtitle_track_mgr,
                    mp->mp_prop_subtitle_tracks,
                    MEDIA_TRACK_MANAGER_SUBTITLES,
                    mp->mp_prop_subtitle_track_current,
                    prop_create(p, "sorted"));

  //--------------------------------------------------
  // Buffer

  p = prop_create(mp->mp_prop_root, "buffer");
  mp->mp_prop_buffer_current = prop_create(p, "current");
  prop_set_int(mp->mp_prop_buffer_current, 0);

  mp->mp_prop_buffer_limit = prop_create(p, "limit");
  prop_set_int(mp->mp_prop_buffer_limit, mp->mp_buffer_limit);

  mp->mp_prop_buffer_delay = prop_create(p, "delay");



  //

  mp->mp_prop_playstatus  = prop_create(mp->mp_prop_root, "playstatus");
  mp->mp_prop_pausereason = prop_create(mp->mp_prop_root, "pausereason");
  mp->mp_prop_currenttime = prop_create(mp->mp_prop_root, "currenttime");
  mp->mp_prop_fps = prop_create(mp->mp_prop_root, "fps");

  prop_set_float_clipping_range(mp->mp_prop_currenttime, 0, 10e6);

  mp->mp_prop_avdelta     = prop_create(mp->mp_prop_root, "avdelta");
  prop_set_float(mp->mp_prop_avdelta, 0);

  mp->mp_prop_svdelta     = prop_create(mp->mp_prop_root, "svdelta");
  prop_set_float(mp->mp_prop_svdelta, 0);

  mp->mp_prop_shuffle     = prop_create(mp->mp_prop_root, "shuffle");
  prop_set_int(mp->mp_prop_shuffle, 0);
  mp->mp_prop_repeat      = prop_create(mp->mp_prop_root, "repeat");
  prop_set_int(mp->mp_prop_repeat, 0);

  mp->mp_prop_avdiff      = prop_create(mp->mp_prop_root, "avdiff");
  mp->mp_prop_avdiff_error= prop_create(mp->mp_prop_root, "avdiffError");

  mp->mp_prop_canSkipBackward =
    prop_create(mp->mp_prop_root, "canSkipBackward");

  mp->mp_prop_canSkipForward =
    prop_create(mp->mp_prop_root, "canSkipForward");

  mp->mp_prop_canSeek =
    prop_create(mp->mp_prop_root, "canSeek");

  mp->mp_prop_canPause =
    prop_create(mp->mp_prop_root, "canPause");

  mp->mp_prop_canEject =
    prop_create(mp->mp_prop_root, "canEject");

  mp->mp_prop_canShuffle =
    prop_create(mp->mp_prop_root, "canShuffle");

  mp->mp_prop_canRepeat =
    prop_create(mp->mp_prop_root, "canRepeat");

  prop_set_int(prop_create(mp->mp_prop_root, "canStop"), 1);

  mp->mp_prop_ctrl = prop_create(mp->mp_prop_root, "ctrl");

  mp->mp_prop_model = prop_create(mp->mp_prop_root, "model");

  mp->mp_sub_currenttime =
    prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
		   PROP_TAG_CALLBACK, mp_seek_by_propchange, mp,
                   PROP_TAG_LOCKMGR, mp_lockmgr,
                   PROP_TAG_MUTEX, mp,
		   PROP_TAG_ROOT, mp->mp_prop_currenttime,
		   NULL);

  mp->mp_sub_eventsink =
    prop_subscribe(0,
		   PROP_TAG_NAME("media", "eventSink"),
                   PROP_TAG_CALLBACK_EVENT, media_eventsink, mp,
                   PROP_TAG_LOCKMGR, mp_lockmgr,
                   PROP_TAG_MUTEX, mp,
		   PROP_TAG_NAMED_ROOT, mp->mp_prop_root, "media",
		   NULL);


  if(media_pipe_init_extra != NULL)
    media_pipe_init_extra(mp);

  return mp;
}
コード例 #18
0
ファイル: dev.c プロジェクト: SEL4PROJ/camkes-arm-vm
void can__init(void)
{
	printf("CAN device started...\n");
	mq_init(MSG_QUEUE_SIZE);
}