コード例 #1
0
/* ************************************************************************
 * ************************************************************************
 *   I N I T
 * ************************************************************************
 * ************************************************************************ */
static int __init rtnetproxy_init_module(void)
{
    int err;

    /* Initialize the proxy's rtskb pool (JK) */
    if (rtskb_pool_init(&rtskb_pool, proxy_rtskbs) < proxy_rtskbs) {
        rtskb_pool_release(&rtskb_pool);
        return -ENOMEM;
    }

    dev_rtnetproxy.init = rtnetproxy_init;
    SET_MODULE_OWNER(&dev_rtnetproxy);

    /* Define the name for this unit */
    err=dev_alloc_name(&dev_rtnetproxy,"rtproxy");

    if(err<0) {
        rtskb_pool_release(&rtskb_pool);
        return err;
    }
    err = register_netdev(&dev_rtnetproxy);
    if (err<0) {
        rtskb_pool_release(&rtskb_pool);
        return err;
    }

    /* Initialize the ringbuffers: */
    memset(&ring_rtskb_kernel_rtnet, 0, sizeof(ring_rtskb_kernel_rtnet));
    memset(&ring_rtskb_rtnet_kernel, 0, sizeof(ring_rtskb_rtnet_kernel));
    memset(&ring_skb_kernel_rtnet, 0, sizeof(ring_skb_kernel_rtnet));
    memset(&ring_skb_rtnet_kernel, 0, sizeof(ring_skb_rtnet_kernel));

    /* Init the task for transmission */
    rtdm_sem_init(&rtnetproxy_sem, 0);
    rtdm_task_init(&rtnetproxy_thread, "rtnetproxy",
                   rtnetproxy_transmit_thread, 0,
                   RTDM_TASK_LOWEST_PRIORITY, 0);

    /* Register srq */
    rtdm_nrtsig_init(&rtnetproxy_signal, rtnetproxy_signal_handler);

    /* rtNet stuff: */
    rt_ip_register_fallback(rtnetproxy_recv);

    printk("rtnetproxy installed as \"%s\"\n", dev_rtnetproxy.name);

    return 0;
}
コード例 #2
0
int __init __switchtest_init(void)
{
	int err;

	err = rtdm_nrtsig_init(&rtswitch_wake_utask,
			       rtswitch_utask_waker, NULL);
	if (err)
		return err;

	do {
		snprintf(device.device_name, RTDM_MAX_DEVNAME_LEN, "rttest%d",
			 start_index);
		err = rtdm_dev_register(&device);

		start_index++;
	} while (err == -EEXIST);

	return err;
}
コード例 #3
0
ファイル: rtdmtest.c プロジェクト: jan-kiszka/rtdm-native
static int rtdmtest_open(struct rtdm_dev_context *context,
			 rtdm_user_info_t *user_info, int oflags)
{
	struct rtdmtest_context *ctx;

	ctx = (struct rtdmtest_context *)context->dev_private;

	ctx->event.state = 0;
	rtdm_event_init(&ctx->event, 0);
	rtdm_sem_init(&ctx->sem, 0);
	rtdm_lock_count = 0;
	rtdm_mutex_init(&ctx->mutex);
	init_MUTEX(&ctx->nrt_mutex);
	if (rtdm_nrtsig_init(&ctx->nrtsig, rtdmtest_nrtsig_handler)) {
	    printk("rtdm_nrtsig_init failed\n");
	    return -EINVAL;
	}

	return 0;
}
コード例 #4
0
static int rtswitch_open(struct rtdm_dev_context *context,
			 rtdm_user_info_t *user_info,
			 int oflags)
{
	rtswitch_context_t *ctx = (rtswitch_context_t *) context->dev_private;
	int err;

	ctx->tasks = NULL;
	ctx->tasks_count = ctx->next_index = ctx->cpu = ctx->switches_count = 0;
	init_MUTEX(&ctx->lock);
	ctx->failed = 0;
	ctx->error.last_switch.from = ctx->error.last_switch.to = -1;
	ctx->pause_us = 0;

	err = rtdm_nrtsig_init(&ctx->wake_utask, rtswitch_utask_waker, ctx);
	if (err)
		return err;

	rtdm_timer_init(&ctx->wake_up_delay, timed_wake_up, "switchtest timer");

	return 0;
}