#include "UsbPeim.h"\r
#include "PeiUsbLib.h"\r
\r
-/**\r
- Get a given usb descriptor.\r
-\r
- @param PeiServices General-purpose services that are available to every PEIM.\r
- @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r
- @param Value Request Value.\r
- @param Index Request Index.\r
- @param DescriptorLength Request descriptor Length.\r
- @param Descriptor Request descriptor.\r
-\r
-\r
- @retval EFI_SUCCESS Usb descriptor is obtained successfully.\r
- @retval EFI_DEVICE_ERROR Cannot get the usb descriptor due to a hardware error.\r
- @retval Others Other failure occurs.\r
-\r
-**/\r
-EFI_STATUS\r
-PeiUsbGetDescriptor (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN PEI_USB_IO_PPI *UsbIoPpi,\r
- IN UINT16 Value,\r
- IN UINT16 Index,\r
- IN UINT16 DescriptorLength,\r
- OUT VOID *Descriptor\r
- )\r
-{\r
- EFI_USB_DEVICE_REQUEST DevReq;\r
-\r
- ASSERT (UsbIoPpi != NULL);\r
-\r
- DevReq.RequestType = USB_DEV_GET_DESCRIPTOR_REQ_TYPE;\r
- DevReq.Request = USB_DEV_GET_DESCRIPTOR;\r
- DevReq.Value = Value;\r
- DevReq.Index = Index;\r
- DevReq.Length = DescriptorLength;\r
-\r
- return UsbIoPpi->UsbControlTransfer (\r
- PeiServices,\r
- UsbIoPpi,\r
- &DevReq,\r
- EfiUsbDataIn,\r
- PcdGet32 (PcdUsbTransferTimeoutValue),\r
- Descriptor,\r
- DescriptorLength\r
- );\r
-}\r
-\r
-/**\r
- Set a usb device with a specified address.\r
-\r
- @param PeiServices General-purpose services that are available to every PEIM.\r
- @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r
- @param AddressValue The address to assign.\r
-\r
- @retval EFI_SUCCESS Usb device address is set successfully.\r
- @retval EFI_DEVICE_ERROR Cannot set the usb address due to a hardware error.\r
- @retval Others Other failure occurs.\r
-\r
-**/\r
-EFI_STATUS\r
-PeiUsbSetDeviceAddress (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN PEI_USB_IO_PPI *UsbIoPpi,\r
- IN UINT16 AddressValue\r
- )\r
-{\r
- EFI_USB_DEVICE_REQUEST DevReq;\r
-\r
- ASSERT (UsbIoPpi != NULL);\r
-\r
- DevReq.RequestType = USB_DEV_SET_ADDRESS_REQ_TYPE;\r
- DevReq.Request = USB_DEV_SET_ADDRESS;\r
- DevReq.Value = AddressValue;\r
- DevReq.Index = 0;\r
- DevReq.Length = 0;\r
-\r
- return UsbIoPpi->UsbControlTransfer (\r
- PeiServices,\r
- UsbIoPpi,\r
- &DevReq,\r
- EfiUsbNoData,\r
- PcdGet32 (PcdUsbTransferTimeoutValue),\r
- NULL,\r
- 0\r
- );\r
-}\r
\r
/**\r
Clear a given usb feature.\r
);\r
}\r
\r
-/**\r
- Configure a usb device to Configuration 1.\r
-\r
- @param PeiServices General-purpose services that are available to every PEIM.\r
- @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r
-\r
- @retval EFI_SUCCESS Usb device is set to use Configuration 1 successfully.\r
- @retval EFI_DEVICE_ERROR Cannot set the usb device due to a hardware error.\r
- @retval Others Other failure occurs.\r
-\r
-**/\r
-EFI_STATUS\r
-PeiUsbSetConfiguration (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN PEI_USB_IO_PPI *UsbIoPpi\r
- )\r
-{\r
- EFI_USB_DEVICE_REQUEST DevReq;\r
- ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
-\r
- DevReq.RequestType = USB_DEV_SET_CONFIGURATION_REQ_TYPE;\r
- DevReq.Request = USB_DEV_SET_CONFIGURATION;\r
- DevReq.Value = 1;\r
-\r
- return UsbIoPpi->UsbControlTransfer (\r
- PeiServices,\r
- UsbIoPpi,\r
- &DevReq,\r
- EfiUsbNoData,\r
- PcdGet32 (PcdUsbTransferTimeoutValue),\r
- NULL,\r
- 0\r
- );\r
-}\r
\r
/**\r
Clear Endpoint Halt.\r
return Status;\r
}\r
\r
-/**\r
- Judge if the port is connected with a usb device or not.\r
-\r
- @param PortStatus The usb port status gotten.\r
\r
- @retval TRUE A usb device is connected with the port.\r
- @retval FALSE No usb device is connected with the port.\r
-\r
-**/\r
-BOOLEAN\r
-IsPortConnect (\r
- IN UINT16 PortStatus\r
- )\r
-{\r
- //\r
- // return the bit 0 value of PortStatus\r
- //\r
- if ((PortStatus & USB_PORT_STAT_CONNECTION) != 0) {\r
- return TRUE;\r
- } else {\r
- return FALSE;\r
- }\r
-}\r
-\r
-/**\r
- Judge if the port is connected with a low-speed usb device or not.\r
-\r
- @param PortStatus The usb port status gotten.\r
-\r
- @retval TRUE A low-speed usb device is connected with the port.\r
- @retval FALSE No low-speed usb device is connected with the port.\r
-\r
-**/\r
-BOOLEAN\r
-IsPortLowSpeedDeviceAttached (\r
- IN UINT16 PortStatus\r
- )\r
-{\r
- //\r
- // return the bit 9 value of PortStatus\r
- //\r
- if ((PortStatus & USB_PORT_STAT_LOW_SPEED) != 0) {\r
- return TRUE;\r
- } else {\r
- return FALSE;\r
- }\r
-}\r
-\r
-/**\r
- Judge if the port is in "connection change" status or not.\r
-\r
- @param PortChangeStatus The usb port change status gotten.\r
-\r
- @retval TRUE The port is in "connection change" status.\r
- @retval FALSE The port is NOT in "connection change" status.\r
-\r
-**/\r
-BOOLEAN\r
-IsPortConnectChange (\r
- IN UINT16 PortChangeStatus\r
- )\r
-{\r
- //\r
- // return the bit 0 value of PortChangeStatus\r
- //\r
- if ((PortChangeStatus & USB_PORT_STAT_C_CONNECTION) != 0) {\r
- return TRUE;\r
- } else {\r
- return FALSE;\r
- }\r
-}\r
EfiUsbEndpoint\r
} EFI_USB_RECIPIENT;\r
\r
-/**\r
- Get a given usb descriptor.\r
-\r
- @param PeiServices General-purpose services that are available to every PEIM.\r
- @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r
- @param Value Request Value.\r
- @param Index Request Index.\r
- @param DescriptorLength Request descriptor Length.\r
- @param Descriptor Request descriptor.\r
-\r
-\r
- @retval EFI_SUCCESS Usb descriptor is obtained successfully.\r
- @retval EFI_DEVICE_ERROR Cannot get the usb descriptor due to a hardware error.\r
- @retval Others Other failure occurs.\r
-\r
-**/\r
-EFI_STATUS\r
-PeiUsbGetDescriptor (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN PEI_USB_IO_PPI *UsbIoPpi,\r
- IN UINT16 Value,\r
- IN UINT16 Index,\r
- IN UINT16 DescriptorLength,\r
- OUT VOID *Descriptor\r
- );\r
-\r
-/**\r
- Set a usb device with a specified address.\r
-\r
- @param PeiServices General-purpose services that are available to every PEIM.\r
- @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r
- @param AddressValue The address to assign.\r
-\r
- @retval EFI_SUCCESS Usb device address is set successfully.\r
- @retval EFI_DEVICE_ERROR Cannot set the usb address due to a hardware error.\r
- @retval Others Other failure occurs.\r
-\r
-**/\r
-EFI_STATUS\r
-PeiUsbSetDeviceAddress (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN PEI_USB_IO_PPI *UsbIoPpi,\r
- IN UINT16 AddressValue\r
- );\r
\r
/**\r
Clear a given usb feature.\r
IN UINT16 Target\r
);\r
\r
-/**\r
- Configure a usb device to Configuration 1.\r
-\r
- @param PeiServices General-purpose services that are available to every PEIM.\r
- @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r
-\r
- @retval EFI_SUCCESS Usb device is set to use Configuration 1 successfully.\r
- @retval EFI_DEVICE_ERROR Cannot set the usb device due to a hardware error.\r
- @retval Others Other failure occurs.\r
-\r
-**/\r
-EFI_STATUS\r
-PeiUsbSetConfiguration (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN PEI_USB_IO_PPI *UsbIoPpi\r
- );\r
\r
/**\r
Clear Endpoint Halt.\r
IN UINT8 EndpointAddress\r
);\r
\r
-/**\r
- Judge if the port is connected with a usb device or not.\r
-\r
- @param PortStatus The usb port status gotten.\r
-\r
- @retval TRUE A usb device is connected with the port.\r
- @retval FALSE No usb device is connected with the port.\r
-\r
-**/\r
-BOOLEAN\r
-IsPortConnect (\r
- IN UINT16 PortStatus\r
- );\r
-\r
-/**\r
- Judge if the port is connected with a low-speed usb device or not.\r
-\r
- @param PortStatus The usb port status gotten.\r
\r
- @retval TRUE A low-speed usb device is connected with the port.\r
- @retval FALSE No low-speed usb device is connected with the port.\r
\r
-**/\r
-BOOLEAN\r
-IsPortLowSpeedDeviceAttached (\r
- IN UINT16 PortStatus\r
- );\r
\r
-/**\r
- Judge if the port is in "connection change" status or not.\r
-\r
- @param PortChangeStatus The usb port change status gotten.\r
-\r
- @retval TRUE The port is in "connection change" status.\r
- @retval FALSE The port is NOT in "connection change" status.\r
-\r
-**/\r
-BOOLEAN\r
-IsPortConnectChange (\r
- IN UINT16 PortChangeStatus\r
- );\r
#endif\r