阅读:2345回复:1
usb鼠标调试问题,请能人指点
主要问题,目前只想把鼠标驱动起来,基于powerpc的,运用它的usbTool工具调试,能加载USBD,也可以attach ohci主控器,调用usrUsbMseInit()也是返回成功,按理应该显示有/usbMo这个设备,但却没有,不知道具体是什么情况。
其他的问题: 1、首先编译的话,因为是基于powerpc会出现一些错误,如果是基于pentium就完全正确通过,可能是实现上还有些地方依赖体系结构吧,个人理解,也就是一些全局变量没找到,通过查找for pentium的代码把这些变量的定义补上后,编译通过了,是不是这个原因导致的开始提到的问题。 2、网上找了下,我现在用的tornador2.2.1版本,说可以支持ehci主控器驱动的,但我的配置栏里却没有支持,只提供uhci和ohci的支持,也就是只支持usb1.1的协议了,是不是还该安什么补丁,或者只是tornador plateform ID v2.0 有这部分代码,但好像plateform ID v2.0 又没有针对powerpc的版本,不过计划先找到pid2.0 for pentium安上试试了,看能不能直接把这部分代码自己移植下。 |
|
沙发#
发布于:2008-04-17 13:12
引用FiNALS的回答(原帖地址http://www.cevx.com/bbs/dispbbs.asp?boardID=6&ID=11932&page=1),看来我也理解错误了,我以为只要usrUsbMseInit就会产生/usbMo设备,其实应该物理上连接usb鼠标,才会真正通过usbMseDrvAttachCallback的相应处理安装设备,具体的设备安装函数是usbMseDevCreate,它被usbMseDrvAttachCallback调用,也就是说只要usrUsbMseInit成功执行,应该插上usb鼠标就能自动安装设备了,但我已经物理插入usb鼠标了,也没反应,看来还得从别的地方找原因了:
附上其中 几个函数的代码: /***************************************************************************** * * usrUsbMseInit - initialize the USB mouse driver * * This function initializes the USB mouse driver and registers for attach * callbacks. * * RETURNS: Nothing */ void usrUsbMseInit (void) { /* Check if driver already installed */ if (usbMseDrvNum > 0) { printf ("Mouse already initilaized.\n"); } if (usbMouseDevInit () == OK) { pReportlocal = OSS_MALLOC (sizeof (HID_MSE_BOOT_REPORT)); if (pReportlocal == NULL) printf ("usrUsbMseInit () could not allocate memory\n"); printf ("usbMouseDevInit() returned OK\n"); if (usbMouseDynamicAttachRegister (usbMseDrvAttachCallback, (void *) NULL) != OK) { printf ("usbMouseDynamicAttachRegister() returned ERROR\n"); } } else printf ("usbMouseDevInit() returned ERROR\n"); } /************************************************************************* * * usbMseDrvAttachCallback - receives attach callbacks from mouse SIO driver * * RETURNS: N/A */ LOCAL void usbMseDrvAttachCallback ( void * arg, /* caller-defined argument */ SIO_CHAN *pChan, /* pointer to affected SIO_CHAN */ UINT16 attachCode /* defined as USB_KBD_xxxx */ ) { USB_MSE_DEV * pUsbMseDev = NULL; /* mouse device */ char mseName [MSE_NAME_LEN_MAX]; /* mouse name */ if (attachCode == USB_MSE_ATTACH) { if (usbMouseSioChanLock (pChan) != OK) { printf("usbMouseSioChanLock () returned ERROR\n"); } else { sprintf (mseName, "%s%d", USB_MSE_NAME, mseCount); if (usbMseDevCreate (mseName, pChan) != OK) { printf("usbMseDevCreate() returned ERROR\n"); } /* now we can increment the counter */ mseCount++; if (usbMseDevFind (pChan, &pUsbMseDev) != OK) { printf("usbMseDevFind() returned ERROR\n"); return; } if ((*pChan->pDrvFuncs->callbackInstall) (pChan, SIO_CALLBACK_PUT_MOUSE_REPORT, (STATUS (*) (void *, ...)) usbMseRptCallback, NULL) != OK) { printf("usbMseRptCallback () failed to install\n"); } printf("USB Mouse attached as %s\n", mseName); } } else if (attachCode == USB_MSE_REMOVE) { /* find the related device */ if (usbMseDevFind (pChan, &pUsbMseDev) != OK) { printf ("usbMseDevFind could not find channel 0x%d", (UINT) pChan); return; } /* delete the device */ usbMseDevDelete (pUsbMseDev); if (usbMouseSioChanUnlock (pChan) != OK) { printf("usbMouseSioChanUnlock () returned ERROR\n"); return; } printf ("USB Mouse %s removed\n", mseName); } } /******************************************************************************* * * usbMseDevCreate - create a VxWorks device for an USB mouse * * This routine creates a device on a specified serial channel. Each channel * to be used should have exactly one device associated with it by calling * this routine. * * For instance, to create the device "/ /0", the proper call would be: * .CS * usbMseDevCreate ("/usbMo/0", pSioChan); * .CE * Where pSioChan is the address of the underlying SIO_CHAN serial channel * descriptor (defined in sioLib.h). * This routine is typically called by the USB mouse driver, when it detects * an insertion of a USB mouse. * * RETURNS: OK, or ERROR if the driver is not installed, or the * device already exists, or failed to allocate memory. */ STATUS usbMseDevCreate ( char * name, /* name to use for this device */ SIO_CHAN * pSioChan /* pointer to core driver structure */ ) { USB_MSE_NODE * pUsbMseNode = NULL; /* pointer to device node */ USB_MSE_DEV * pUsbMseDev = NULL; /* pointer to USB device */ /* Create the mutex semaphores */ usbMseMutex = semMCreate (SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE); usbMseListMutex = semMCreate (SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE); /* initialize the linked list */ lstInit (&usbMseList); usbMseDrvNum = iosDrvInstall ((FUNCPTR) NULL, (FUNCPTR) usbMseDevDelete, (FUNCPTR) usbMseOpen, (FUNCPTR) usbMseClose, (FUNCPTR) usbMseRead, (FUNCPTR) usbMseWrite, (FUNCPTR) usbMseIoctl); if (usbMseDrvNum <= 0) { errnoSet (S_ioLib_NO_DRIVER); return (ERROR); } if (pSioChan == (SIO_CHAN *) ERROR) { return (ERROR); } /* allocate memory for the device */ if ((pUsbMseDev = (USB_MSE_DEV *) calloc (1, sizeof (USB_MSE_DEV))) == NULL) return (ERROR); pUsbMseDev->pSioChan = pSioChan; /* allocate memory for this node, and populate it */ pUsbMseNode = (USB_MSE_NODE *) calloc (1, sizeof (USB_MSE_NODE)); /* record useful information */ pUsbMseNode->pUsbMseDev = pUsbMseDev; pUsbMseDev->pUsbMseNode = pUsbMseNode; /* add the node to the list */ USB_MSE_LIST_SEM_TAKE (WAIT_FOREVER); lstAdd (&usbMseList, (NODE *) pUsbMseNode); USB_MSE_LIST_SEM_GIVE; /* allow for select support */ selWakeupListInit (&pUsbMseDev->selList); /* start the device in the only supported mode */ sioIoctl (pUsbMseDev->pSioChan, SIO_MODE_SET, (void *) SIO_MODE_INT); /* add the device to the I/O system */ return (iosDevAdd (&pUsbMseDev->ioDev, name, usbMseDrvNum)); } |
|