📄 usbtargdefaultpipe.c
字号:
/* WindView Instrumentation */ USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE, "usbTargSetupErpCallback entered ...", USB_TARG_WV_FILTER); /* Validate parameters */ if ((pErp == NULL) || (pErp->targPtr == NULL)) { /* Invalid ERP */ return; } /* Retrive the targTcd from erp structure */ pTcd = (pTARG_TCD)pErp->targPtr; /* Acquire the mutex */ OSS_MUTEX_TAKE (pTcd->tcdMutex, OSS_BLOCK); /* Check if there is some control erp pending already */ if (pTcd->controlErpPending) /* Cancel the default control Erp */ usbHalTcdErpCancel ( &pTcd->tcdNexus , &pTcd->defaultControlErp); /* Release the mutex */ OSS_MUTEX_RELEASE ( pTcd->tcdMutex ); if (pErp->result == OK) { /* Parse the setup packet to examine it */ if (usbParseSetupPacket (pTcd) == ERROR) { /* Stall default endpoints */ cntlEndpointStall ( pTcd ); /* Acquire the mutex */ OSS_MUTEX_TAKE (pTcd->tcdMutex, OSS_BLOCK); /* Initialize the setup ERP */ initSetupErp(pTcd); /* Submit the Erp */ usbHalTcdErpSubmit ( &pTcd->tcdNexus , &pTcd->setupErp); /* Release the mutex */ OSS_MUTEX_RELEASE (pTcd->tcdMutex); } } else { /* * If the request is cancelled, return from the function * without issuing the ERP again */ if (pErp->result == S_usbTcdLib_ERP_CANCELED) return; /* Stall default endpoints */ cntlEndpointStall ( pTcd ); /* Acquire the mutex */ OSS_MUTEX_TAKE (pTcd->tcdMutex, OSS_BLOCK); /* Initialize the setup ERP */ initSetupErp(pTcd); /* Submit the Erp */ usbHalTcdErpSubmit ( &pTcd->tcdNexus , &pTcd->setupErp); /* Release the mutex */ OSS_MUTEX_RELEASE (pTcd->tcdMutex); } /* WindView Instrumentation */ USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE, "usbTargSetupErpCallback exiting ...", USB_TARG_WV_FILTER); return; }/********************************************************************************* usbTargDataOUTErpCallback - called on completion of OUT data transfer** This function is called on completion of OUT data transfer. If control* ERP is not pending it submits a setup packet on the default control* pipe. If control Erp is pending and no error has occured it initializes* the status ERP and submits it, else it re-submits the setup packet.** RETURNS: N/A** ERRNO:* None** \NOMANUAL*/LOCAL VOID usbTargDataOUTErpCallback ( pUSB_ERP pErp /* Pointer to ERP structure */ ) { pTARG_TCD pTcd = NULL; /* TARG_TCD */ /* WindView Instrumentation */ USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE, "usbTargDataOUTErpCallback entered ...", USB_TARG_WV_FILTER); /* Validate Parameter */ if ((pErp == NULL) || (pErp->targPtr == NULL)) { /* Invalid ERP */ return; } /* Retrive the targTcd from erp structure */ pTcd = (pTARG_TCD)pErp->targPtr; /* Acquire Mutex */ OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK); /* Check if there is some control erp pending already */ if (pTcd->controlErpPending) { /* Release Mutex */ OSS_MUTEX_RELEASE (pTcd->tcdMutex); /* Call the user callback */ if (pErp->userCallback != NULL ) (*pErp->userCallback) (pErp); if (pErp->result == OK) { /* Take the Mutex */ OSS_MUTEX_TAKE (pTcd->tcdMutex, OSS_BLOCK); /* Re-initialize the default control erp */ initStatusErp ( pTcd ); /* submit the erp */ if (submitCntlErp (pTcd) != OK) { /* Release Mutex and return */ OSS_MUTEX_RELEASE (pTcd->tcdMutex ); return; } /* Release Mutex */ OSS_MUTEX_RELEASE (pTcd->tcdMutex ); } else { /* * If the ERP is cancelled, return from * the function */ if (pErp->result == S_usbTcdLib_ERP_CANCELED) return; /* Take the Mutex */ OSS_MUTEX_TAKE (pTcd->tcdMutex, OSS_BLOCK); /* Stall default endpoints */ cntlEndpointStall ( pTcd ); /* Initialize the setup ERP */ initSetupErp(pTcd); /* Submit the Erp */ usbHalTcdErpSubmit ( &pTcd->tcdNexus , &pTcd->setupErp); /* Release the mutex */ OSS_MUTEX_RELEASE (pTcd->tcdMutex); } } else { /* Stall default endpoints */ cntlEndpointStall ( pTcd ); /* Initialize the setup ERP */ initSetupErp(pTcd); /* Submit the Erp */ usbHalTcdErpSubmit ( &pTcd->tcdNexus , &pTcd->setupErp); /* Release the mutex */ OSS_MUTEX_RELEASE (pTcd->tcdMutex); } /* WindView Instrumentation */ USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE, "usbTargDataOUTErpCallback exiting ...", USB_TARG_WV_FILTER); return; }/********************************************************************************* usbTargDataINErpCallback - called on completion of In data transfer** This function is called on completion of In data transfer. If control* ERP is not pending it submits a setup packet on the default control* pipe. If control Erp is pending and no error has occured it initializes* the status ERP and submits it on control out pipe. On error it re-submits * the Setup ERP.** RETURNS: N/A** ERRNO:* None** \NOMANUAL*/LOCAL VOID usbTargDataINErpCallback ( pUSB_ERP pErp /* Pointer to ERP structure */ ) { pTARG_TCD pTcd = NULL; /* TARG_TCD */ /* WindView Instrumentation */ USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE, "usbTargDataINErpCallback entered ...", USB_TARG_WV_FILTER); /* Validate Parameter */ if ((pErp == NULL) || (pErp->targPtr == NULL)) { /* Invalid ERP */ return; } /* Retrive the targTcd from erp structure */ pTcd = (pTARG_TCD)pErp->targPtr; /* Acquire Mutex */ OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK); /* Check if there is some control erp pending already */ if (pTcd->controlErpPending) { /* Release Mutex */ OSS_MUTEX_RELEASE (pTcd->tcdMutex); if (pErp->result == OK) { /* Take the Mutex */ OSS_MUTEX_TAKE (pTcd->tcdMutex, OSS_BLOCK); /* Re-initialize the default control erp */ initStatusErp ( pTcd ); pTcd->defaultControlErp.pPipeHandle = pTcd->defaultControlPipeOUT; pTcd->defaultControlErp.bfrList[0].pid = USB_PID_OUT; /* submit the erp */ if (submitCntlErp (pTcd) != OK) { /* Release Mutex */ OSS_MUTEX_RELEASE (pTcd->tcdMutex ); return; } /* Release Mutex */ OSS_MUTEX_RELEASE (pTcd->tcdMutex ); } else { /* * If the ERP is cancelled, return from * the function */ if (pErp->result == S_usbTcdLib_ERP_CANCELED) return; /* Take the Mutex */ OSS_MUTEX_TAKE (pTcd->tcdMutex, OSS_BLOCK); /* Stall default endpoints */ cntlEndpointStall ( pTcd ); /* Initialize the setup ERP */ initSetupErp(pTcd); /* Submit the Erp */ usbHalTcdErpSubmit ( &pTcd->tcdNexus , &pTcd->setupErp); /* Release the mutex */ OSS_MUTEX_RELEASE (pTcd->tcdMutex); } } else { /* Stall default endpoints */ cntlEndpointStall ( pTcd ); /* Initialize the setup ERP */ initSetupErp(pTcd); /* Submit the Erp */ usbHalTcdErpSubmit ( &pTcd->tcdNexus , &pTcd->setupErp); /* Release the mutex */ OSS_MUTEX_RELEASE (pTcd->tcdMutex); } /* WindView Instrumentation */ USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE, "usbTargDataINErpCallback exiting ...", USB_TARG_WV_FILTER); return; }/********************************************************************************* usbTargStatusErpCallback - called on completion of status stage** This function is called on completion of the status stage. It initialize * the Setup ERP and submits it to receive the next setup packet from* host.** RETURNS: N/A** ERRNO:* None** \NOMANUAL*/LOCAL VOID usbTargStatusErpCallback ( pUSB_ERP pErp /* Pointer to ERP structure */ ) { pTARG_TCD pTcd = NULL; /* TARG_TCD */ /* WindView Instrumentation */ USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE, "usbTargStatusErpCallback entered ...", USB_TARG_WV_FILTER); /* Validate Parameter */ if ((pErp == NULL) || (pErp->targPtr == NULL)) { /* Invalid ERP */ return; } /* Retrive the targTcd from erp structure */ pTcd = (pTARG_TCD)pErp->targPtr; OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK); if (pTcd->controlErpPending) pTcd->controlErpPending = FALSE; /* * If the ERP is cancelled, return from * the function */ if (pErp->result == S_usbTcdLib_ERP_CANCELED) { OSS_MUTEX_RELEASE (pTcd->tcdMutex); return; } /* Initialize the setup ERP */ initSetupErp(pTcd); /* Submit the setup ERP */ usbHalTcdErpSubmit(&pTcd->tcdNexus,&pTcd->setupErp); OSS_MUTEX_RELEASE (pTcd->tcdMutex); /* WindView Instrumentation */ USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE, "usbTargStatusErpCallback exiting ...", USB_TARG_WV_FILTER); return ; }/********************************************************************************* usbTargFeatureClear - processes a CLEAR_FEATURE request** This function is called when a CLEAR_FEATURE request is received from * the host.** RETURNS: OK if setup packet valid, else ERROR if invalid** ERRNO:* None** \NOMANUAL*/LOCAL STATUS usbTargFeatureClear ( pTARG_TCD pTcd /* Pointer to the TCD */ ) { STATUS status = OK; pUSB_SETUP pSetup = (pUSB_SETUP) pTcd->setupBfr; /* USB_SETUP */ /* packet */ UINT16 feature = FROM_LITTLEW (pSetup->value); /* feature to */ /* clear */ UINT16 index = FROM_LITTLEW (pSetup->index); /* index */ /* WindView Instrumentation */ USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE, "usbTargFeatureClear entered ...", USB_TARG_WV_FILTER); /* * If the callback is not registered by the target application, * return an ERROR */ if (pTcd->pCallbacks->featureClear == NULL) { cntlEndpointStall ( pTcd ); return ERROR; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -