当前位置: 首页>>代码示例>>C++>>正文


C++ devctl函数代码示例

本文整理汇总了C++中devctl函数的典型用法代码示例。如果您正苦于以下问题:C++ devctl函数的具体用法?C++ devctl怎么用?C++ devctl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了devctl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ftinit

static int
ftinit(Serialport *p)
{
	Serial *ser;
	uint timerval;
	int res;

	ser = p->s;
	if(p->isjtag){
		res = ftdiwrite(p, FTSETFLOWCTRL, 0, FTDISABLEFLOWCTRL);
		if(res < 0)
			return -1;
		res = ftdiread(p, FTSETLATENCYTIMER, 0, (uchar *)&timerval,
			FTLATENCYTIMERSZ);
		if(res < 0)
			return -1;
		dsprint(2, "serial: jtag latency timer is %d\n", timerval);
		timerval = 2;
		ftdiwrite(p, FTLATENCYDEFAULT, 0, FTSETLATENCYTIMER);
		res = ftdiread(p, FTSETLATENCYTIMER, 0, (uchar *)&timerval,
			FTLATENCYTIMERSZ);
		if(res < 0)
			return -1;

		dsprint(2, "serial: jtag latency timer set to %d\n", timerval);
		/* may be unnecessary */
		devctl(p->epin,  "timeout 5000");
		devctl(p->epout, "timeout 5000");
		/* 0xb is the mask for lines. plug dependant? */
		ftdiwrite(p, BMMPSSE|0x0b, 0, FTSETBITMODE);
	}
	incref(ser->dev);
	threadcreate(statusreader, p, 8*1024);
	return 0;
}
开发者ID:99years,项目名称:plan9,代码行数:35,代码来源:ftdi.c

示例2: plseteps

static int
plseteps(Serialport *p)
{
	devctl(p->epin,  "maxpkt 256");
	devctl(p->epout, "maxpkt 256");
	return 0;
}
开发者ID:dalmonian,项目名称:harvey,代码行数:7,代码来源:prolific.c

示例3: do_attach

static pid_t
do_attach (pid_t pid)
{
  procfs_status status;
  struct sigevent event;

  if (nto_inferior.ctl_fd != -1)
    {
      close (nto_inferior.ctl_fd);
      init_nto_inferior (&nto_inferior);
    }
  xsnprintf (nto_inferior.nto_procfs_path, PATH_MAX - 1, "/proc/%d/as", pid);
  nto_inferior.ctl_fd = open (nto_inferior.nto_procfs_path, O_RDWR);
  if (nto_inferior.ctl_fd == -1)
    {
      TRACE ("Failed to open %s\n", nto_inferior.nto_procfs_path);
      init_nto_inferior (&nto_inferior);
      return -1;
    }
  if (devctl (nto_inferior.ctl_fd, DCMD_PROC_STOP, &status, sizeof (status), 0)
      != EOK)
    {
      do_detach ();
      return -1;
    }
  nto_inferior.pid = pid;
  /* Define a sigevent for process stopped notification.  */
  event.sigev_notify = SIGEV_SIGNAL_THREAD;
  event.sigev_signo = SIGUSR1;
  event.sigev_code = 0;
  event.sigev_value.sival_ptr = NULL;
  event.sigev_priority = -1;
  devctl (nto_inferior.ctl_fd, DCMD_PROC_EVENT, &event, sizeof (event), 0);

  if (devctl (nto_inferior.ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status),
	      0) == EOK
      && (status.flags & _DEBUG_FLAG_STOPPED))
    {
      ptid_t ptid;
      struct process_info *proc;

      kill (pid, SIGCONT);
      ptid = ptid_build (status.pid, status.tid, 0);
      the_low_target.arch_setup ();
      proc = add_process (status.pid, 1);
      proc->tdesc = nto_tdesc;
      TRACE ("Adding thread: pid=%d tid=%ld\n", status.pid,
	     ptid_get_lwp (ptid));
      nto_find_new_threads (&nto_inferior);
    }
  else
    {
      do_detach ();
      return -1;
    }

  return pid;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:58,代码来源:nto-low.c

示例4: portreset

static void
portreset(Hub *h, int p)
{
	int sts;
	Dev *d, *nd;
	Port *pp;

	d = h->dev;
	pp = &h->port[p];
	nd = pp->dev;
	dprint(2, "%s: %s: port %d: resetting\n", argv0, d->dir, p);
	if(hubfeature(h, p, Fportreset, 1) < 0){
		dprint(2, "%s: %s: port %d: reset: %r\n", argv0, d->dir, p);
		goto Fail;
	}
	sleep(Resetdelay);
	sts = portstatus(h, p);
	if(sts < 0)
		goto Fail;
	if((sts & PSenable) == 0){
		dprint(2, "%s: %s: port %d: not enabled?\n", argv0, d->dir, p);
		hubfeature(h, p, Fportenable, 1);
		sts = portstatus(h, p);
		if((sts & PSenable) == 0)
			goto Fail;
	}
	nd = pp->dev;
	opendevdata(nd, ORDWR);
	if(usbcmd(nd, Rh2d|Rstd|Rdev, Rsetaddress, nd->id, 0, nil, 0) < 0){
		dprint(2, "%s: %s: port %d: setaddress: %r\n", argv0, d->dir, p);
		goto Fail;
	}
	if(devctl(nd, "address") < 0){
		dprint(2, "%s: %s: port %d: set address: %r\n", argv0, d->dir, p);
		goto Fail;
	}
	if(usbcmd(nd, Rh2d|Rstd|Rdev, Rsetconf, 1, 0, nil, 0) < 0){
		dprint(2, "%s: %s: port %d: setconf: %r\n", argv0, d->dir, p);
		unstall(nd, nd, Eout);
		if(usbcmd(nd, Rh2d|Rstd|Rdev, Rsetconf, 1, 0, nil, 0) < 0)
			goto Fail;
	}
	if(nd->dfd >= 0)
		close(nd->dfd);
	return;
Fail:
	pp->state = Pdisabled;
	pp->sts = 0;
	if(pp->hub != nil)
		pp->hub = nil;	/* hub closed by enumhub */
	hubfeature(h, p, Fportenable, 0);
	if(nd != nil)
		devctl(nd, "detach");
	closedev(nd);
}
开发者ID:elbing,项目名称:harvey,代码行数:55,代码来源:usbd.c

示例5: writeinfo

static void
writeinfo(Dev *d)
{
	char buf[128];
	char *s;
	char *se;
	Usbdev *ud;
	Conf *c;
	Iface *ifc;
	int i, j;

	ud = d->usb;
	s = buf;
	se = buf+sizeof(buf);
	s = seprint(s, se, "info %s csp %#08ux", classname(ud->class), ud->csp);
	for(i = 0; i < ud->nconf; i++){
		c = ud->conf[i];
		if(c == nil)
			break;
		for(j = 0; j < nelem(c->iface); j++){
			ifc = c->iface[j];
			if(ifc == nil)
				break;
			if(ifc->csp != ud->csp)
				s = seprint(s, se, " csp %#08ulx", ifc->csp);
		}
	}
	s = seprint(s, se, " vid %06#x did %06#x", ud->vid, ud->did);
	seprint(s, se, " %q %q", ud->vendor, ud->product);
	devctl(d, "%s", buf);
}
开发者ID:dancrossnyc,项目名称:harvey,代码行数:31,代码来源:dev.c

示例6: twl4030_i2c_read

static int twl4030_i2c_read(int fd, uint8_t addr, uint8_t reg, uint8_t * val)
{
    struct send_recv
    {
        i2c_sendrecv_t hdr;
        uint8_t buf[2];
    } twl4030_rd_data;

    /*Read the Registers Current Value */
    twl4030_rd_data.buf[0] = reg;
    twl4030_rd_data.hdr.send_len = 1;
    twl4030_rd_data.hdr.recv_len = 1;

    twl4030_rd_data.hdr.slave.addr = addr;
    twl4030_rd_data.hdr.slave.fmt = I2C_ADDRFMT_7BIT;
    twl4030_rd_data.hdr.stop = 1;

    if (devctl(fd, DCMD_I2C_SENDRECV, &twl4030_rd_data, sizeof(twl4030_rd_data), NULL))
    {
        slogf(_SLOGC_SIM_MMC, _SLOG_ERROR, "BEAGLE MMCSD: twl4030_i2c_read fail");
        return -1;
    }

    *val = twl4030_rd_data.buf[0];

    return 0;
}
开发者ID:tyrantyr,项目名称:onda_qnx,代码行数:27,代码来源:sim_bs.c

示例7: PM_saveConsoleState

void PMAPI PM_saveConsoleState(void *stateBuf,int console_id)
{
#ifdef __QNXNTO__
    int     fd;
    int     flags;

    if ((fd = open("/dev/con1", O_RDWR)) == -1)
        return;
    flags = _CONCTL_INVISIBLE_CHG | _CONCTL_INVISIBLE;
    devctl(fd, DCMD_CHR_SERCTL, &flags, sizeof flags, 0);
    close(fd);
#else
    uchar   *buf = &((uchar*)stateBuf)[PM_getVGAStateSize()];

    /* Save QNX 4 console state */
    console_read(cc, -1, 0, NULL, 0,
        (int *)buf+1, (int *)buf+2, NULL);
    *(int *)buf = console_ctrl(cc, -1,
        CONSOLE_NORESIZE | CONSOLE_NOSWITCH | CONSOLE_INVISIBLE,
        CONSOLE_NORESIZE | CONSOLE_NOSWITCH | CONSOLE_INVISIBLE);

    /* Save state of VGA registers */
    PM_saveVGAState(stateBuf);
#endif
}
开发者ID:BackupTheBerlios,项目名称:uuu,代码行数:25,代码来源:pm.c

示例8: shared_memory_open

static void* shared_memory_open(const IPC_str *name, int size)
{
    DEBUG_PRINT("%s( %s, 0x%x )\n", __FUNCTION__, name, size);

    int fd = ipc_driver_handle();
    if(fd < 0) {
        DEBUG_PRINT("%s(): IPC driver was not opened\n", __FUNCTION__);
        return NULL;
    }

    struct ipc_create_t ipc_create_param;
    memset(&ipc_create_param,0,sizeof(ipc_create_param));

    ipc_create_param.handle = NULL;
    ipc_create_param.value = size;
    snprintf(ipc_create_param.name, sizeof(ipc_create_param.name), "%s", name);

    int res = devctl(fd,IOCTL_IPC_SHM_OPEN,&ipc_create_param, sizeof(ipc_create_param), NULL);
    if(res < 0) {
        DEBUG_PRINT("%s(): Error register shared memory", __FUNCTION__ );
        return NULL;
    }

    return ipc_create_param.handle;
}
开发者ID:insys-projects,项目名称:gipcy,代码行数:25,代码来源:shmipc.cpp

示例9: nto_stopped_by_watchpoint

static int
nto_stopped_by_watchpoint (void)
{
  int ret = 0;

  TRACE ("%s\n", __func__);
  if (nto_inferior.ctl_fd != -1 && current_inferior != NULL)
    {
      ptid_t ptid;

      ptid = thread_to_gdb_id (current_inferior);
      if (nto_set_thread (ptid))
	{
	  const int watchmask = _DEBUG_FLAG_TRACE_RD | _DEBUG_FLAG_TRACE_WR
				| _DEBUG_FLAG_TRACE_MODIFY;
	  procfs_status status;
	  int err;

	  err = devctl (nto_inferior.ctl_fd, DCMD_PROC_STATUS, &status,
			sizeof (status), 0);
	  if (err == EOK && (status.flags & watchmask))
	    ret = 1;
	}
    }
  TRACE ("%s: %s\n", __func__, ret ? "yes" : "no");
  return ret;
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:27,代码来源:nto-low.c

示例10: OsalDrv_map

/*!
 *  @brief  Function to map a memory region specific to the driver.
 *
 *  @sa     OsalDrv_close,OsalDrv_open
 */
UInt32
OsalDrv_map (UInt32 addr, UInt32 size, Bool isCached)
{
    UInt32 userAddr = (UInt32) NULL;
    OsalMemMap_CmdArgs args;

    GT_0trace (curTrace, GT_ENTER, "OsalDrv_map");

    if (OsalDrv_refCount == 1) {
        args.len = size;
        args.paddr = (off_t)addr;
        args.isCached = isCached;
		devctl(OsalDrv_handle, DCMD_OSALMEM_MMAP, &args, sizeof(args), NULL); 
        userAddr = (UInt32)(args.vaddr);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (userAddr == (UInt32) MAP_FAILED) {
            userAddr = (UInt32)NULL;
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "OsalDrv_map",
                                 OSALDRV_E_MAP,
                                 "Failed to map memory to user space!");
        }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }

    GT_1trace (curTrace, GT_LEAVE, "OsalDrv_map", userAddr);

    /*! @retval NULL Operation was successful. */
    /*! @retval valid-address Operation successfully completed. */
    return userAddr;
}
开发者ID:andreimironenko,项目名称:syslink,代码行数:37,代码来源:OsalDrv.c

示例11: OsalDrv_ioctl

/*!
 *  @brief  Function to invoke the APIs through ioctl.
 *
 *  @param  cmd     Command for driver ioctl
 *  @param  args    Arguments for the ioctl command
 *
 *  @sa
 */
Int
OsalDrv_ioctl (UInt32 cmd, Ptr args)
{
    Int status   = OSALDRV_SUCCESS;
    int osStatus = 0;
    TraceDrv_CmdArgs * cmdArgs = (TraceDrv_CmdArgs *) args;

    GT_2trace (curTrace, GT_ENTER, "OsalDrv_ioctl", cmd, args);

    GT_assert (curTrace, (OsalDrv_refCount > 0));

//    osStatus = ioctl (OsalDrv_handle, cmd, args);
    osStatus = devctl( OsalDrv_handle, DCMD_TRACEDRV_SETTRACE, cmdArgs, sizeof(TraceDrv_CmdArgs), NULL);
	
    if (osStatus < 0) {
        /*! @retval OSALDRV_E_OSFAILURE Driver ioctl failed */
        status = OSALDRV_E_OSFAILURE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "OsalDrv_ioctl",
                             status,
                             "Driver ioctl failed!");
    }
    else {
        /* First field in the structure is the API status. */
        status = ((TraceDrv_CmdArgs *) args)->apiStatus;
    }

    GT_1trace (curTrace, GT_LEAVE, "OsalDrv_ioctl", status);

    /*! @retval OSALDRV_SUCCESS Operation successfully completed. */
    return status;
}
开发者ID:andreimironenko,项目名称:syslink,代码行数:41,代码来源:OsalDrv.c

示例12: portdetach

static void
portdetach(Hub *h, int p)
{
	Dev *d;
	Port *pp;
	extern void usbfsgone(char*);
	d = h->dev;
	pp = &h->port[p];

	/*
	 * Clear present, so that we detect an attach on reconnects.
	 */
	pp->sts &= ~(PSpresent|PSenable);

	if(pp->state == Pdisabled)
		return;
	pp->state = Pdisabled;
	dprint(2, "%s: %s: port %d: detached\n", argv0, d->dir, p);

	if(pp->hub != nil){
		closehub(pp->hub);
		pp->hub = nil;
	}
	if(pp->devmaskp != nil)
		putdevnb(pp->devmaskp, pp->devnb);
	pp->devmaskp = nil;
	if(pp->dev != nil){
		devctl(pp->dev, "detach");
		usbfsgone(pp->dev->dir);
		closedev(pp->dev);
		pp->dev = nil;
	}
}
开发者ID:elbing,项目名称:harvey,代码行数:33,代码来源:usbd.c

示例13: nto_store_registers

static void
nto_store_registers (struct regcache *regcache, int regno)
{
  procfs_greg greg;
  int err;
  ptid_t ptid;

  TRACE ("%s (regno:%d)\n", __func__, regno);

  if (current_inferior == NULL)
    {
      TRACE ("current_inferior is NULL\n");
      return;
    }
  ptid = thread_to_gdb_id (current_inferior);
  if (!nto_set_thread (ptid))
    return;

  memset (&greg, 0, sizeof (greg));
  for  (regno = 0; regno != the_low_target.num_regs; ++regno)
    {
      const unsigned int regoffset
	= the_low_target.register_offset (regno);
      collect_register (regcache, regno, ((char *)&greg) + regoffset);
    }
  err = devctl (nto_inferior.ctl_fd, DCMD_PROC_SETGREG, &greg, sizeof (greg),
		0);
  if (err != EOK)
    TRACE ("Error: setting registers.\n");
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:30,代码来源:nto-low.c

示例14: main

int main(void)
{
    int data, fd, toggle = 1;

    /* Open the device we wish to manipulate. */
    if((fd = open ("/dev/kbd", O_RDONLY)) == -1)
    {
     	fprintf(stderr, "Error with open() on /dev/kbd.  Make sure exists.\n");
     	perror (NULL);
     	exit(EXIT_FAILURE);
    }

    while(1)
    {
    		switch(toggle)
    		{
        		case 1:
        		{
          		/*
           		Lets now turn on Num Lock and make sure that 
           		Caps and Scroll lock are turned off.
          		*/
          		data = (_CONCTL_NUM_CHG | _CONCTL_NUM) | _CONCTL_CAPS_CHG | _CONCTL_SCROLL_CHG;
          		break;
        		}
        		case 2:
        		{
          		/*
           		Turn off Num Lock and now turn on Caps Lock 
           		(Scroll lock is already off).
          		*/
          		data = _CONCTL_NUM_CHG | (_CONCTL_CAPS_CHG | _CONCTL_CAPS);
          		break;
        		}
        		case 3:
        		{
          		/*
           		Turn off Caps lock and turn on Scroll lock 
           		(Num lock is already off).
          		*/
          		data = _CONCTL_CAPS_CHG | (_CONCTL_SCROLL_CHG | _CONCTL_SCROLL);
          		toggle = 0;
          		break;
        		}
    		}

    		/* Explanation below. */
    		if (devctl (fd, DCMD_CHR_SERCTL, &data, sizeof(data), NULL))
    		{
        		fprintf(stderr, "Error setting KBD.\n");
        		perror (NULL);
        		exit(EXIT_FAILURE);
    		}

    		sleep(1);
    		toggle++;
    }

    return (1);
}
开发者ID:aditya7041,项目名称:My-Blog-Repository,代码行数:60,代码来源:DEVCTL.C

示例15: etherfree

static void
etherfree(Ether *e)
{
	int i;
	Buf *bp;

	if(e->free != nil)
		e->free(e);
	closedev(e->epin);
	closedev(e->epout);
	if(e->rc == nil){	/* not really started */
		free(e);
		return;
	}
	for(i = 0; i < e->nconns; i++)
		if(e->conns[i] != nil){
			while((bp = nbrecvp(e->conns[i]->rc)) != nil)
				free(bp);
			chanfree(e->conns[i]->rc);
			free(e->conns[i]);
		}
	shutdownchan(e->bc);
	shutdownchan(e->rc);
	shutdownchan(e->wc);
	e->epin = e->epout = nil;
	devctl(e->dev, "detach");
	free(e);
}
开发者ID:npe9,项目名称:harvey,代码行数:28,代码来源:ether.c


注:本文中的devctl函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。