Beispiel #1
0
static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
{
	struct netvsc_driver *net_drv_obj = &g_netvsc_drv.drv_obj;
	struct driver_context *drv_ctx = &g_netvsc_drv.drv_ctx;
	int ret;

	DPRINT_ENTER(NETVSC_DRV);

	vmbus_get_interface(&net_drv_obj->Base.VmbusChannelInterface);

	net_drv_obj->RingBufferSize = ring_size * PAGE_SIZE;
	net_drv_obj->OnReceiveCallback = netvsc_recv_callback;
	net_drv_obj->OnLinkStatusChanged = netvsc_linkstatus_callback;

	/* Callback to client driver to complete the initialization */
	drv_init(&net_drv_obj->Base);

	drv_ctx->driver.name = net_drv_obj->Base.name;
	memcpy(&drv_ctx->class_id, &net_drv_obj->Base.deviceType,
	       sizeof(struct hv_guid));

	drv_ctx->probe = netvsc_probe;
	drv_ctx->remove = netvsc_remove;

	/* The driver belongs to vmbus */
	ret = vmbus_child_driver_register(drv_ctx);

	DPRINT_EXIT(NETVSC_DRV);

	return ret;
}
Beispiel #2
0
static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
{
	struct netvsc_driver *net_drv_obj = &g_netvsc_drv.drv_obj;
	struct driver_context *drv_ctx = &g_netvsc_drv.drv_ctx;
	int ret;

	net_drv_obj->ring_buf_size = ring_size * PAGE_SIZE;
	net_drv_obj->recv_cb = netvsc_recv_callback;
	net_drv_obj->link_status_change = netvsc_linkstatus_callback;

	/* Callback to client driver to complete the initialization */
	drv_init(&net_drv_obj->base);

	drv_ctx->driver.name = net_drv_obj->base.name;
	memcpy(&drv_ctx->class_id, &net_drv_obj->base.deviceType,
	       sizeof(struct hv_guid));

	drv_ctx->probe = netvsc_probe;
	drv_ctx->remove = netvsc_remove;

	/* The driver belongs to vmbus */
	ret = vmbus_child_driver_register(drv_ctx);

	return ret;
}
Beispiel #3
0
/*
 * devo_attach: attach(9e)
 */
static int
drv_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
{
    if (cmd != DDI_ATTACH)
        return (DDI_FAILURE);

    ASSERT(ddi_get_instance(dip) == 0);
    drv_init();
    drv_set_opt(dip);

    /*
     * Create control node. DLPI provider nodes will be created on demand.
     */
    if (ddi_create_minor_node(dip, DLD_CONTROL_MINOR_NAME, S_IFCHR,
                              DLD_CONTROL_MINOR, DDI_PSEUDO, 0) != DDI_SUCCESS)
        return (DDI_FAILURE);

    dld_dip = dip;

    /*
     * Log the fact that the driver is now attached.
     */
    ddi_report_dev(dip);
    return (DDI_SUCCESS);
}
static int __devinit gpu_probe(struct platform_device *pdev)
#endif
{
    int ret = -ENODEV;
    struct resource* res;

    gcmkHEADER();

    res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "gpu_irq");

    if (!res)
    {
        printk(KERN_ERR "%s: No irq line supplied.\n",__FUNCTION__);
        goto gpu_probe_fail;
    }

    irqLine = res->start;

    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gpu_base");

    if (!res)
    {
        printk(KERN_ERR "%s: No register base supplied.\n",__FUNCTION__);
        goto gpu_probe_fail;
    }

    registerMemBase = res->start;
    registerMemSize = res->end - res->start + 1;

    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gpu_mem");

    if (!res)
    {
        printk(KERN_ERR "%s: No memory base supplied.\n",__FUNCTION__);
        goto gpu_probe_fail;
    }

    contiguousBase = res->start;
    contiguousSize = res->end - res->start + 1;

/*####modified for marvell-bg2*/
    ret = drv_get_dts_for_gpu();
    /*if there is no gpu2d, it will also return error*/
/*####end for marvell-bg2*/

    ret = drv_init();

    if (!ret)
    {
        platform_set_drvdata(pdev, galDevice);

        gcmkFOOTER_NO();
        return ret;
    }

gpu_probe_fail:
    gcmkFOOTER_ARG(KERN_INFO "Failed to register gpu driver: %d\n", ret);
    return ret;
}
PUBLIC void main(void) 
{	
	int r, caller, proc_nr, chan;
	message mess;

	drv_init();

	/* Here is the main loop of the dma driver.  It waits for a message, 
     carries it out, and sends a reply. */
	printf("%s up and running\n", drv.DriverName);
	
	while(1) {
		receive(ANY, &mess);
		caller = mess.m_source;
		proc_nr = mess.PROC_NR;

		/* Now carry out the work. */
		switch(mess.m_type) {
			case DEV_OPEN:		/* open the special file ( = parameter) */
        r = msg_open(mess.DEVICE);break;
        
			case DEV_CLOSE:		/* close the special file ( = parameter) */
        r = msg_close(mess.DEVICE); break;
        
			case DEV_IOCTL:		
        r = msg_ioctl(&mess); break; 
        
			case DEV_READ:		
        msg_read(&mess); continue; /* don't reply */
        
			case DEV_WRITE:		
        msg_write(&mess); continue; /* don't reply */
        
      case DEV_STATUS:	
        msg_status(&mess);continue; /* don't reply */
        
			case HARD_INT:
        msg_hardware();continue;  /* don't reply */
        
			case SYS_SIG:		  
        msg_sig_stop(); continue; /* don't reply */
        
			default:          
        r = EINVAL;	dprint("%s: %d uncaught msg!\n", mess.m_type ,drv.DriverName);
        break;
		}
		/* Finally, prepare and send the reply message. */
		reply(TASK_REPLY, caller, proc_nr, r);
	}
	
}
void ap_init(void)
{
  u32 *p_stack = NULL;
  RET_CODE ret = SUCCESS;

  drv_init();

  p_stack = (u32 *)mtos_malloc(SYS_APP_TASK_STK_SIZE);
  MT_ASSERT(p_stack != NULL);


  ret = mtos_task_create((u8 *)"APP",
                         app_proc,
                         (void *)0,
                         SYS_APP_TASK_PRIORITY,
                         p_stack,
                         SYS_APP_TASK_STK_SIZE);
}
Beispiel #7
0
int main()
{
    int err;
  
    puts("socksrv started");
    err = init();
    if(err == 0) {
        puts("init ok");
        err = drv_init();
        if(err == DRV_OK) {
            puts("driver ok");
            main_loop();
            puts("done");
        } else {
            puts("ERROR: driver init");
        }
        drv_shutdown();
    } else {
        puts("ERROR: init");
    }
    cleanup();
    puts("ready");
}
Beispiel #8
0
static int __devinit gpu_probe(struct platform_device *pdev)
#endif
{
    int ret = -ENODEV;
    gcsMODULE_PARAMETERS moduleParam = {
#if gcdMULTI_GPU || gcdMULTI_GPU_AFFINITY
#else
        .irqLine            = irqLine,
        .registerMemBase    = registerMemBase,
        .registerMemSize    = registerMemSize,
#endif
        .irqLine2D          = irqLine2D,
        .registerMemBase2D  = registerMemBase2D,
        .registerMemSize2D  = registerMemSize2D,
        .irqLineVG          = irqLineVG,
        .registerMemBaseVG  = registerMemBaseVG,
        .registerMemSizeVG  = registerMemSizeVG,
        .contiguousSize     = contiguousSize,
        .contiguousBase     = contiguousBase,
        .bankSize           = bankSize,
        .fastClear          = fastClear,
        .compression        = compression,
        .powerManagement    = powerManagement,
        .gpuProfiler        = gpuProfiler,
        .signal             = signal,
        .baseAddress        = baseAddress,
        .physSize           = physSize,
        .logFileSize        = logFileSize,
        .recovery           = recovery,
        .stuckDump          = stuckDump,
        .showArgs           = showArgs,
        .gpu3DMinClock      = gpu3DMinClock,
    };

    gcmkHEADER();

    platform.device = pdev;

    if (platform.ops->getPower)
    {
        if (gcmIS_ERROR(platform.ops->getPower(&platform)))
        {
            gcmkFOOTER_NO();
            return ret;
        }
    }

    if (platform.ops->adjustParam)
    {
        /* Override default module param. */
        platform.ops->adjustParam(&platform, &moduleParam);

        /* Update module param because drv_init() uses them directly. */
        _UpdateModuleParam(&moduleParam);
    }

    ret = drv_init();

    if (!ret)
    {
        platform_set_drvdata(pdev, galDevice);

        gcmkFOOTER_NO();
        return ret;
    }

    gcmkFOOTER_ARG(KERN_INFO "Failed to register gpu driver: %d\n", ret);
    return ret;
}
static int __devinit gpu_probe(struct platform_device *pdev)
#endif
{
    int ret = -ENODEV;
    struct resource* res;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
	struct contiguous_mem_pool *pool;
	struct reset_control *rstc;
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
	struct device_node *dn =pdev->dev.of_node;
	const u32 *prop;
#else
	struct viv_gpu_platform_data *pdata;
#endif
    gcmkHEADER();

    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phys_baseaddr");
    if (res)
        baseAddress = res->start;

    res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq_3d");
    if (res)
        irqLine = res->start;

    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "iobase_3d");
    if (res)
    {
        registerMemBase = res->start;
        registerMemSize = res->end - res->start + 1;
    }

    res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq_2d");
    if (res)
        irqLine2D = res->start;

    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "iobase_2d");
    if (res)
    {
        registerMemBase2D = res->start;
        registerMemSize2D = res->end - res->start + 1;
    }

    res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq_vg");
    if (res)
        irqLineVG = res->start;

    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "iobase_vg");
    if (res)
    {
        registerMemBaseVG = res->start;
        registerMemSizeVG = res->end - res->start + 1;
    }

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
	pool = devm_kzalloc(&pdev->dev, sizeof(*pool), GFP_KERNEL);
	if (!pool)
		return -ENOMEM;
	pool->size = contiguousSize;
	init_dma_attrs(&pool->attrs);
	dma_set_attr(DMA_ATTR_WRITE_COMBINE, &pool->attrs);
	pool->virt = dma_alloc_attrs(&pdev->dev, pool->size, &pool->phys,
				     GFP_KERNEL, &pool->attrs);
	if (!pool->virt) {
		dev_err(&pdev->dev, "Failed to allocate contiguous memory\n");
		return -ENOMEM;
	}
	contiguousBase = pool->phys;
	dev_set_drvdata(&pdev->dev, pool);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
	prop = of_get_property(dn, "contiguousbase", NULL);
	if(prop)
		contiguousBase = *prop;
	of_property_read_u32(dn,"contiguoussize", (u32 *)&contiguousSize);
#else
    pdata = pdev->dev.platform_data;
    if (pdata) {
        contiguousBase = pdata->reserved_mem_base;
        contiguousSize = pdata->reserved_mem_size;
     }
#endif
    if (contiguousSize == 0)
       gckOS_Print("Warning: No contiguous memory is reserverd for gpu.!\n ");
    ret = drv_init(&pdev->dev);

    if (!ret)
    {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
	rstc = devm_reset_control_get(&pdev->dev, "gpu3d");
	galDevice->rstc[gcvCORE_MAJOR] = IS_ERR(rstc) ? NULL : rstc;

	rstc = devm_reset_control_get(&pdev->dev, "gpu2d");
	galDevice->rstc[gcvCORE_2D] = IS_ERR(rstc) ? NULL : rstc;

	rstc = devm_reset_control_get(&pdev->dev, "gpuvg");
	galDevice->rstc[gcvCORE_VG] = IS_ERR(rstc) ? NULL : rstc;
#endif
        platform_set_drvdata(pdev, galDevice);

#if gcdENABLE_FSCALE_VAL_ADJUST
        if (galDevice->kernels[gcvCORE_MAJOR])
            REG_THERMAL_NOTIFIER(&thermal_hot_pm_notifier);
#endif
        gcmkFOOTER_NO();
        return ret;
    }
#if gcdENABLE_FSCALE_VAL_ADJUST
    UNREG_THERMAL_NOTIFIER(&thermal_hot_pm_notifier);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
	dma_free_attrs(&pdev->dev, pool->size, pool->virt, pool->phys,
		       &pool->attrs);
#endif
    gcmkFOOTER_ARG(KERN_INFO "Failed to register gpu driver: %d\n", ret);
    return ret;
}
Beispiel #10
0
void draw_init() {
	drv_init();
	draw_clear_screen();
}	
int __devinit gpu_probe(struct platform_device *pdev)
{
    int ret = -ENODEV;
    struct resource* res;

    gcmkHEADER();

#ifdef CONFIG_G2D
#ifdef CONFIG_G2D_K3
    g2d_core_clk = clk_get(NULL, "clk_g2d");
    if (IS_ERR(g2d_core_clk)) {
        printk(KERN_ERR "Could not get clk_g2d!\n");
        return ret;
    }

	ret = clk_set_rate(g2d_core_clk,  480000000);
    if (ret) {
        printk(KERN_ERR "G2D, %s: failed to set G2D clk rete, G2D clk = %p \n", __func__, g2d_core_clk);
        return ret;
    }
#else

    g2d_core_clk = clk_get(NULL, CLK_5G2D_CORE_CLK);
    if (IS_ERR(g2d_core_clk)) {
        printk(KERN_ERR "Could not get g2d_core_clk!\n");
        goto gpu_probe_fail;
    }

    g2d_axi_clkhb = clk_get(NULL, CLK_4G2D_AXI_CLKHB);
    if (IS_ERR(g2d_axi_clkhb)) {
        printk(KERN_ERR "Could not get g2d_axi_clkhb!\n");
        goto gpu_probe_fail;
    }

    g2d_cfg_clk = clk_get(NULL, CLK_3G2D_CFG_CLK);
    if (IS_ERR(g2d_cfg_clk)) {
        printk(KERN_ERR "Could not get g2d_cfg_clk!\n");
        goto gpu_probe_fail;
    }

    if (clk_set_rate(g2d_core_clk,  G2D_CLK_RATE)) {
        printk(KERN_ERR "G2D, %s: failed to set G2D clk rete, G2D clk = %p \n", __func__, g2d_core_clk);
        goto gpu_probe_fail;
    }
#endif
    res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "g2d_irq");

    if (!res)
    {
        printk(KERN_ERR "%s: No irq line supplied.\n",__FUNCTION__);
        goto gpu_probe_fail;
    }

    irqLine = res->start;

    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "g2d_base");

    if (!res)
    {
        printk(KERN_ERR "%s: No register base supplied.\n",__FUNCTION__);
        goto gpu_probe_fail;
    }

    registerMemBase = res->start;
    registerMemSize = res->end - res->start + 1;
#endif

/*
    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gpu_mem");

    if (!res)
    {
        printk(KERN_ERR "%s: No memory base supplied.\n",__FUNCTION__);
        goto gpu_probe_fail;
    }

    contiguousBase = res->start;
    contiguousSize = res->end - res->start + 1;
*/
    ret = drv_init();

    if (!ret)
    {
        platform_set_drvdata(pdev, galDevice);

        gcmkFOOTER_NO();
        return ret;
    }

gpu_probe_fail:
    gcmkFOOTER_ARG(KERN_INFO "Failed to register gpu driver: %d\n", ret);
    return ret;
}
Beispiel #12
0
void rnv_init(void) {
  if(!initialized) {initialized=1;
    drv_init(); drv_verror_handler=&verror_handler_drv;
    windup();
  }
}
Beispiel #13
0
PUBLIC void main(void) 
{	
	int r, caller, proc_nr, chan;
	message mess, repl_mess;

	drv_init();

	/* Here is the main loop of the dma driver.  It waits for a message, 
	   carries it out, and sends a reply. */

	while(1) {
		receive(ANY, &mess);
		caller = mess.m_source;
		proc_nr = mess.IO_ENDPT;

		if (caller == RS_PROC_NR && mess.m_type == DEV_PING)
		{
			/* Got ping from RS. Just notify RS */
			notify(RS_PROC_NR);
			continue;
		}

		/* Now carry out the work. */
		switch(mess.m_type) {
			case DEV_OPEN:
				/* open the special file ( = parameter) */
				r = msg_open(mess.DEVICE);
				repl_mess.m_type = DEV_REVIVE;
				repl_mess.REP_ENDPT = mess.IO_ENDPT;
				repl_mess.REP_STATUS = r;
				send(caller, &repl_mess);

				continue;

			case DEV_CLOSE:
				/* close the special file ( = parameter) */
				r = msg_close(mess.DEVICE);
				repl_mess.m_type = DEV_CLOSE_REPL;
				repl_mess.REP_ENDPT = mess.IO_ENDPT;
				repl_mess.REP_STATUS = r;
				send(caller, &repl_mess);

				continue;

			case DEV_IOCTL_S:		
				r = msg_ioctl(&mess);

				if (r != SUSPEND)
				{
					repl_mess.m_type = DEV_REVIVE;
					repl_mess.REP_ENDPT = mess.IO_ENDPT;
					repl_mess.REP_IO_GRANT =
						(unsigned)mess.IO_GRANT;
					repl_mess.REP_STATUS = r;
					send(caller, &repl_mess);
				}
				continue;

			case DEV_READ_S:		
				msg_read(&mess); continue; /* don't reply */
			case DEV_WRITE_S:		
				msg_write(&mess); continue; /* don't reply */
			case DEV_STATUS:	
				msg_status(&mess);continue; /* don't reply */
			case DEV_REOPEN:
				/* reopen the special file ( = parameter) */
				r = msg_open(mess.DEVICE);
				repl_mess.m_type = DEV_REOPEN_REPL;
				repl_mess.REP_ENDPT = mess.IO_ENDPT;
				repl_mess.REP_STATUS = r;
				send(caller, &repl_mess);
				continue;
			case HARD_INT:
				msg_hardware();continue;  /* don't reply */
			case SYS_SIG:		  
				msg_sig_stop(); continue; /* don't reply */
			default:          
				dprint("%s: %d uncaught msg!\n",
					drv.DriverName, mess.m_type);
				continue;
		}

		/* Should not be here. Just continue. */
	}
}
static int __devinit gpu_probe(struct platform_device *pdev)
{
    int ret = -ENODEV;
    struct resource* res;

    gcmkHEADER();

    res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "gpu_irq");

    if (!res)
    {
        printk(KERN_ERR "%s: No irq line supplied.\n",__FUNCTION__);
        goto gpu_probe_fail;
    }

    irqLine = res->start;

    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gpu_base");

    if (!res)
    {
        printk(KERN_ERR "%s: No register base supplied.\n",__FUNCTION__);
        goto gpu_probe_fail;
    }

    registerMemBase = res->start;
    registerMemSize = res->end - res->start + 1;

#if MRVL_USE_GPU_RESERVE_MEM
    gcmkPRINT(KERN_INFO "[galcore] info: GC use memblock to reserve video memory.\n");
    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gpu_mem");
    if (!res)
    {
        printk(KERN_ERR "%s: No gpu reserved memory supplied. res = %p\n",__FUNCTION__, res);
        goto gpu_probe_fail;
    }

    contiguousBase = res->start;
    contiguousSize = res->end - res->start + 1;
#endif

    printk("\n[galcore] GC Version: %s\n", _GC_VERSION_STRING_);
    printk("\ncontiguousBase:%08x, contiguousSize:%08x\n", (gctUINT32)contiguousBase, (gctUINT32)contiguousSize);

    pdevice = &pdev->dev;

    ret = drv_init();

    if (!ret)
    {
        platform_set_drvdata(pdev, galDevice);

#if MRVL_CONFIG_PROC
        create_gc_proc_file();
#endif

        create_gc_sysfs_file(pdev);

#if MRVL_CONFIG_ENABLE_GPUFREQ
        __enable_gpufreq(galDevice);
#endif

#if MRVL_CONFIG_ENABLE_EARLYSUSPEND
        register_early_suspend(&gpu_early_suspend_handler);
#endif

#if (MRVL_VIDEO_MEMORY_USE_TYPE == gcdMEM_TYPE_ION)
#if (gcdMEM_TYPE_IONAF_3_4_39 == 1)
        gc_ion_client = ion_client_create(pxa_ion_dev, "gc ion");
#else
        gc_ion_client = ion_client_create(pxa_ion_dev, ION_HEAP_CARVEOUT_MASK, "gc ion");
#endif
#endif

#if MRVL_CONFIG_USE_PM_RUNTIME
        pm_runtime_enable(&pdev->dev);
        pm_runtime_forbid(&pdev->dev);
#endif

        /* save device pointer to GALDEVICE */
        galDevice->dev = &pdev->dev;

        gcmkFOOTER_NO();
        return ret;
    }

gpu_probe_fail:
    gcmkFOOTER_ARG(KERN_INFO "Failed to register gpu driver: %d\n", ret);
    return ret;
}
Beispiel #15
0
/*
 *  ======== api_init ========
 *  Purpose:
 *      Module initialization used by Bridge API.
 */
bool api_init(void)
{
	bool ret = true;
	bool fdrv, fdev, fcod, fchnl, fmsg, fio;
	bool fmgr, fproc, fnode, fdisp, fstrm, frmm;

	if (api_c_refs == 0) {
		/* initialize driver and other modules */
		fdrv = drv_init();
		fmgr = mgr_init();
		fproc = proc_init();
		fnode = node_init();
		fdisp = disp_init();
		fstrm = strm_init();
		frmm = rmm_init();
		fchnl = chnl_init();
		fmsg = msg_mod_init();
		fio = io_init();
		fdev = dev_init();
		fcod = cod_init();
		ret = fdrv && fdev && fchnl && fcod && fmsg && fio;
		ret = ret && fmgr && fproc && frmm;
		if (!ret) {
			if (fdrv)
				drv_exit();

			if (fmgr)
				mgr_exit();

			if (fstrm)
				strm_exit();

			if (fproc)
				proc_exit();

			if (fnode)
				node_exit();

			if (fdisp)
				disp_exit();

			if (fchnl)
				chnl_exit();

			if (fmsg)
				msg_exit();

			if (fio)
				io_exit();

			if (fdev)
				dev_exit();

			if (fcod)
				cod_exit();

			if (frmm)
				rmm_exit();

		}
	}
	if (ret)
		api_c_refs++;

	return ret;
}