?? usbehcdrhemulation.c
字號:
/* usbEhcdRhEmulation.c - USB EHCI HCD Roothub Emulation */
/* Copyright 2003 Wind River Systems, Inc. */
/*
Modification history
--------------------
01d,23Jul03,Incorporated the changes after testing on MIPS.
01c,12Jul03,gpd updated status to USBHST_SUCCESS in setconfig request.
01b,26jun03,psp changing the code to WRS standards.
01a,25apr03,ram written.
*/
/*
DESCRIPTION
This contains functions which handle the requests to the Root hub
INCLUDE FILES: usb2/usbOsal.h usb2/usbHst.h usb2/usbEhcdDataStructures.h
usb2/usbEhcdRhEmulation.h usb2/usbEhcdHal.h usb2/usbEhcdUtil.h
usb2/usbHcdInstr.h
*/
/*
INTERNAL
*******************************************************************************
* Filename : usbEhcdRhEmulate.c
*
* Copyright :
*
* THE COPYRIGHT IN THE CONTENTS OF THIS SOFTWARE VEST WITH WIPRO
* LIMITED A COMPANY INCORPORATED UNDER THE LAWS OF INDIA AND HAVING
* ITS REGISTERED OFFICE AT DODDAKANNELLI SARJAPUR ROAD BANGALORE
* 560 035. DISTRIBUTION OR COPYING OF THIS SOFTWARE BY
* ANY INDIVIDUAL OR ENTITY OTHER THAN THE ADDRESSEE IS STRICTLY
* PROHIBITED AND MAY INCUR LEGAL LIABILITY. IF YOU ARE NOT THE
* ADDRESSEE PLEASE NOTIFY US IMMEDIATELY BY PHONE OR BY RETURN EMAIL.
* THE ADDRESSEE IS ADVISED TO MAINTAIN THE PROPRIETARY INTERESTS OF
* THIS COPYRIGHT AS PER APPLICABLE LAWS.
*
*
* Description : This contains functions which handle the requests to
* the Root hub.
*
*
******************************************************************************/
#include "usb2/usbOsal.h"
#include "usb2/usbHst.h"
#include "usb2/usbEhcdDataStructures.h"
#include "usb2/usbEhcdRhEmulation.h"
#include "usb2/usbEhcdHal.h"
#include "usb2/usbEhcdUtil.h"
#include "usb2/usbHcdInstr.h"
/* globals */
/* Device Descriptor value for the Root hub */
UCHAR gRHDeviceDescriptor[] = {
0x12, /* bLength */
0x01, /* Device Descriptor type */
0x00, 0x02, /* bcdUSB - USB 2.0 */
0x09, /* Hub DeviceClass */
0x00, /* bDeviceSubClass */
0x01, /* bDeviceProtocol High Speed single TT support*/
0x40, /* Max packet size is 64 */
0x00, 0x00, /* idVendor */
0x00, 0x00, /* idProduct */
0x00, 0x00, /* bcdDevice */
0x00, /* iManufacturer */
0x00, /* iProduct */
0x00, /* iSerialNumber */
0x01 /* 1 configuration */
};
/*
* Descriptor structure returned on a request for
* Configuration descriptor for the Root hub.
* This includes the Configuration descriptor, interface descriptor and
* the endpoint descriptor
*/
UCHAR gRHConfigDescriptor[] = {
/* Configuration descriptor */
0x09, /* bLength */
0x02, /*
* Configuration descriptor
* type
*/
0x19, 0x00, /* wTotalLength */
0x01, /* 1 interface */
0x01, /* bConfigurationValue */
0x00, /* iConfiguration */
0xE0, /* bmAttributes */
0x00, /* bMaxPower */
/* Interface Descriptor */
0x09, /* bLength */
0x04, /*
* Interface Descriptor
* type
*/
0x00, /* bInterfaceNumber */
0x00, /* bAlternateSetting */
0x01, /* bNumEndpoints */
0x09, /* bInterfaceClass */
0x00, /* bInterfaceSubClass */
0x00, /* bInterfaceProtocol */
0x00, /* iInterface */
/* Endpoint Descriptor */
0x07, /* bLength */
0x05, /*
* Endpoint Descriptor
* Type
*/
0x81, /* bEndpointAddress */
0x03, /* bmAttributes */
0x08, 0x00, /* wMaxPacketSize */
0x0C /* bInterval - 255 ms*/
};
/* Function to process a control transfer request */
USBHST_STATUS
usbEhcdRhProcessControlRequest(pUSB_EHCD_DATA pHCDData,
pUSBHST_URB pURB);
/* Function to process an interrupt transfer request */
USBHST_STATUS
usbEhcdRhProcessInterruptRequest(pUSB_EHCD_DATA pHCDData,
pUSBHST_URB pURB);
/* Function to process a standard request */
USBHST_STATUS
usbEhcdRhProcessStandardRequest(pUSB_EHCD_DATA pHCDData,
pUSBHST_URB pURB);
/* Function to process a class specific request */
USBHST_STATUS
usbEhcdRhProcessClassSpecificRequest(pUSB_EHCD_DATA pHCDData,
pUSBHST_URB pURB);
USBHST_STATUS usbEhcdRhClearPortFeature(pUSB_EHCD_DATA pHCDData,
pUSBHST_URB pURB);
USBHST_STATUS usbEhcdRhGetHubDescriptor(pUSB_EHCD_DATA pHCDData,
pUSBHST_URB pURB);
USBHST_STATUS usbEhcdRhGetPortStatus(pUSB_EHCD_DATA pHCDData,
pUSBHST_URB pURB);
USBHST_STATUS usbEhcdRhSetPortFeature(pUSB_EHCD_DATA pHCDData,
pUSBHST_URB pURB);
/***************************************************************************
*
* usbEhcdRhCreatePipe - creates a pipe specific to an endpoint.
*
* This routine creates a pipe specific to an endpoint.
*
* RETURNS: USBHST_SUCCESS if the pipe was created successfully.
* USBHST_INVALID_PARAMETER if the parameters are not valid.
* USBHST_INSUFFICIENT_MEMORY if the memory allocation for the pipe failed.
*
* ERRNO:
* None.
*/
USBHST_STATUS usbEhcdRhCreatePipe
(
pUSB_EHCD_DATA pHCDData, /* Ptr to HCD block */
UINT8 uDeviceAddress, /* Device Address */
UINT8 uDeviceSpeed, /* Device Speed */
UCHAR *pEndpointDescriptor, /* Ptr to EndPoint Descriptor */
UINT32 *puPipeHandle /* Ptr to pipe handle */
)
{
/* To hold the status of the function call */
USBHST_STATUS Status = USBHST_FAILURE;
/* Pointer to the Endpoint Descriptor */
pUSBHST_ENDPOINT_DESCRIPTOR pEndpointDesc = NULL;
OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdRhCreatePipe - Entry\n",0,0,0,0);
/* Check the validity of the parameters */
if ((NULL == pHCDData) ||
(USB_EHCD_MAX_DEVICE_ADDRESS < uDeviceAddress) ||
(NULL == pEndpointDescriptor) ||
(NULL == puPipeHandle) ||
(USBHST_HIGH_SPEED != uDeviceSpeed))
{
OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdRhCreatePipe - parameters are not valid\n",0,0,0,0);
return USBHST_INVALID_PARAMETER;
}
/* Extract the endpoint descriptor */
pEndpointDesc = (pUSBHST_ENDPOINT_DESCRIPTOR)pEndpointDescriptor;
/* Switch based on the endpoint type */
switch(pEndpointDesc->bmAttributes & USB_EHCD_ENDPOINT_TYPE_MASK)
{
case USBHST_CONTROL_TRANSFER:/* Control endpoint */
{
/* If the endpoint number is not 0, it is an error */
if (0 != (pEndpointDesc->bEndpointAddress &
USB_EHCD_ENDPOINT_NUMBER_MASK))
{
return USBHST_INVALID_REQUEST;
}
else
{
/* Allocate memory for the control endpoint */
pHCDData->RHData.pControlPipe =
(pUSB_EHCD_PIPE)OS_MALLOC(sizeof(USB_EHCD_PIPE));
/* Check if memory allocation is successful */
if (NULL == pHCDData->RHData.pControlPipe)
{
OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdRhCreatePipe - Memory not\
allocated for control pipe\n",0,0,0,0);
return USBHST_INSUFFICIENT_MEMORY;
}
/* Initialize the memory allocated */
USB_EHCD_PIPE_INITIALIZE(pHCDData->RHData.pControlPipe);
/* Populate the fields of the control pipe - Start */
/* Copy the endpoint address */
pHCDData->RHData.pControlPipe->uEndpointAddress =
pEndpointDesc->bEndpointAddress;
/* Copy the address */
pHCDData->RHData.pControlPipe->uAddress = uDeviceAddress;
/* Update the speed */
pHCDData->RHData.pControlPipe->uSpeed = USBHST_HIGH_SPEED;
/* Update the endpoint type */
pHCDData->RHData.pControlPipe->uEndpointType =
USBHST_CONTROL_TRANSFER;
/* Populate the fields of the control pipe - End */
/* Update the pipe handle information */
*(puPipeHandle) = (UINT32)pHCDData->RHData.pControlPipe;
Status = USBHST_SUCCESS;
}
break;
}
case USBHST_INTERRUPT_TRANSFER:/* Interrupt endpoint */
{
/* Allocate memory for the interrupt endpoint */
pHCDData->RHData.pInterruptPipe =
(pUSB_EHCD_PIPE)OS_MALLOC(sizeof(USB_EHCD_PIPE));
/* Check if memory allocation is successful */
if (NULL == pHCDData->RHData.pInterruptPipe)
{
OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdRhCreatePipe - Memory not\
allocated for interrupt pipe\n",0,0,0,0);
return USBHST_INSUFFICIENT_MEMORY;
}
/* Initialize the memory allocated */
USB_EHCD_PIPE_INITIALIZE(pHCDData->RHData.pInterruptPipe);
/* Populate the fields of the interrupt pipe - Start */
/* Copy the endpoint address */
pHCDData->RHData.pInterruptPipe->uEndpointAddress =
pEndpointDesc->bEndpointAddress;
/* Copy the address */
pHCDData->RHData.pInterruptPipe->uAddress = uDeviceAddress;
/* Update the speed */
pHCDData->RHData.pInterruptPipe->uSpeed = USBHST_HIGH_SPEED;
/* Update the endpoint type */
pHCDData->RHData.pInterruptPipe->uEndpointType =
USBHST_INTERRUPT_TRANSFER;
/* Populate the fields of the interrupt pipe - End */
/* Update the pipe handle information */
*(puPipeHandle) = (UINT32)pHCDData->RHData.pInterruptPipe;
Status = USBHST_SUCCESS;
break;
}
default:
{
Status = USBHST_INVALID_REQUEST;
}
}
/* End of switch */
OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdRhCreatePipe - Exit\n",0,0,0,0);
return Status;
}
/* End of function usbEhcdRhCreatePipe() */
/***************************************************************************
*
* usbEhcdRHDeletePipe - deltes a pipe specific to an endpoint.
*
* This routine deletes a pipe specific to an endpoint.
*
* RETURNS: USBHST_SUCCESS if the pipe was deleted successfully.
* USBHST_INVALID_PARAMETER if the parameters are not valid.
*
* ERRNO:
* None.
*/
USBHST_STATUS usbEhcdRHDeletePipe
(
pUSB_EHCD_DATA pHCDData, /* Ptr to HCD block */
UINT32 uPipeHandle /* Pipe Handle Identifier */
)
{
/* To hold the pointer to the pipe */
pUSB_EHCD_PIPE pHCDPipe = NULL;
OS_LOG_MESSAGE_LOW(EHCD,"usbEhcdRHDeletePipe - Entry\n",0,0,0,0);
/* Check the validity of the parameters */
if ((NULL == pHCDData) ||
(0 == uPipeHandle))
{
OS_LOG_MESSAGE_HIGH(EHCD,"usbEhcdRHDeletePipe - Parameters not valid\n",0,0,0,0);
return USBHST_INVALID_PARAMETER;
}
/* Extract the USB_EHCD_PIPE pointer */
pHCDPipe = (pUSB_EHCD_PIPE)uPipeHandle;
/* Check if it is a control pipe delete request */
if (pHCDPipe == pHCDData->RHData.pControlPipe)
{
OS_FREE(pHCDData->RHData.pControlPipe);
pHCDData->RHData.pControlPipe = NULL;
}
/* Check if it is an interrupt pipe delete request */
else if (pHCDPipe == pHCDData->RHData.pInterruptPipe)
{
/* Pointer to the request information */
pUSB_EHCD_REQUEST_INFO pRequestInfo = NULL;
/* Pointer to the temporary request information */
pUSB_EHCD_REQUEST_INFO pTempRequestInfo = NULL;
/* Exclusively access the list */
OS_WAIT_FOR_EVENT(pHCDData->RequestSynchEventID, OS_WAIT_INFINITE);
/* Set the flag indicating that the pipe is deleted */
pHCDPipe->PipeDeletedFlag = TRUE;
/* Release the exclusive access */
OS_RELEASE_EVENT(pHCDData->RequestSynchEventID);
/* Remove the requests queued for the endpoint */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -