summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Bus/Usb/UsbBus/Dxe
diff options
context:
space:
mode:
Diffstat (limited to 'EdkModulePkg/Bus/Usb/UsbBus/Dxe')
-rw-r--r--EdkModulePkg/Bus/Usb/UsbBus/Dxe/ComponentName.c133
-rw-r--r--EdkModulePkg/Bus/Usb/UsbBus/Dxe/UsbBus.msa96
-rw-r--r--EdkModulePkg/Bus/Usb/UsbBus/Dxe/hub.c507
-rw-r--r--EdkModulePkg/Bus/Usb/UsbBus/Dxe/hub.h138
-rw-r--r--EdkModulePkg/Bus/Usb/UsbBus/Dxe/usb.c825
-rw-r--r--EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbbus.c3719
-rw-r--r--EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbbus.h1203
-rw-r--r--EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbio.c1183
-rw-r--r--EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbutil.c554
-rw-r--r--EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbutil.h94
10 files changed, 0 insertions, 8452 deletions
diff --git a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/ComponentName.c b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/ComponentName.c
deleted file mode 100644
index 1233eaccec..0000000000
--- a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/ComponentName.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-Module Name:
-
- ComponentName.c
-
-Abstract:
-
---*/
-
-#include "usbbus.h"
-
-//
-// EFI Component Name Protocol
-//
-EFI_COMPONENT_NAME_PROTOCOL gUsbBusComponentName = {
- UsbBusComponentNameGetDriverName,
- UsbBusComponentNameGetControllerName,
- "eng"
-};
-
-STATIC EFI_UNICODE_STRING_TABLE mUsbBusDriverNameTable[] = {
- { "eng", (CHAR16 *) L"USB Bus Driver" },
- { NULL , NULL }
-};
-
-EFI_STATUS
-EFIAPI
-UsbBusComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-/*++
-
- Routine Description:
- Retrieves a Unicode string that is the user readable name of the EFI Driver.
-
- Arguments:
- This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
- Language - A pointer to a three character ISO 639-2 language identifier.
- This is the language of the driver name that that the caller
- is requesting, and it must match one of the languages specified
- in SupportedLanguages. The number of languages supported by a
- driver is up to the driver writer.
- DriverName - A pointer to the Unicode string to return. This Unicode string
- is the name of the driver specified by This in the language
- specified by Language.
-
- Returns:
- EFI_SUCCESS - The Unicode string for the Driver specified by This
- and the language specified by Language was returned
- in DriverName.
- EFI_INVALID_PARAMETER - Language is NULL.
- EFI_INVALID_PARAMETER - DriverName is NULL.
- EFI_UNSUPPORTED - The driver specified by This does not support the
- language specified by Language.
-
---*/
-{
- return LookupUnicodeString (
- Language,
- gUsbBusComponentName.SupportedLanguages,
- mUsbBusDriverNameTable,
- DriverName
- );
-}
-
-EFI_STATUS
-EFIAPI
-UsbBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle, OPTIONAL
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-/*++
-
- Routine Description:
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by an EFI Driver.
-
- Arguments:
- This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
- ControllerHandle - The handle of a controller that the driver specified by
- This is managing. This handle specifies the controller
- whose name is to be returned.
- ChildHandle - The handle of the child controller to retrieve the name
- of. This is an optional parameter that may be NULL. It
- will be NULL for device drivers. It will also be NULL
- for a bus drivers that wish to retrieve the name of the
- bus controller. It will not be NULL for a bus driver
- that wishes to retrieve the name of a child controller.
- Language - A pointer to a three character ISO 639-2 language
- identifier. This is the language of the controller name
- that that the caller is requesting, and it must match one
- of the languages specified in SupportedLanguages. The
- number of languages supported by a driver is up to the
- driver writer.
- ControllerName - A pointer to the Unicode string to return. This Unicode
- string is the name of the controller specified by
- ControllerHandle and ChildHandle in the language specified
- by Language from the point of view of the driver specified
- by This.
-
- Returns:
- EFI_SUCCESS - The Unicode string for the user readable name in the
- language specified by Language for the driver
- specified by This was returned in DriverName.
- EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
- EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
- EFI_INVALID_PARAMETER - Language is NULL.
- EFI_INVALID_PARAMETER - ControllerName is NULL.
- EFI_UNSUPPORTED - The driver specified by This is not currently managing
- the controller specified by ControllerHandle and
- ChildHandle.
- EFI_UNSUPPORTED - The driver specified by This does not support the
- language specified by Language.
-
---*/
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/UsbBus.msa b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/UsbBus.msa
deleted file mode 100644
index bc7715dfd6..0000000000
--- a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/UsbBus.msa
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <MsaHeader>
- <ModuleName>UsbBus</ModuleName>
- <ModuleType>DXE_DRIVER</ModuleType>
- <GuidValue>240612B7-A063-11d4-9A3A-0090273FC14D</GuidValue>
- <Version>1.0</Version>
- <Abstract>Component description file for UsbBus module</Abstract>
- <Description>This module provides support for USB bus enumeration and USB IO protocol implementation</Description>
- <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>
- <License>All rights reserved. This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
- <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
- </MsaHeader>
- <ModuleDefinitions>
- <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
- <BinaryModule>false</BinaryModule>
- <OutputFileBasename>UsbBus</OutputFileBasename>
- </ModuleDefinitions>
- <LibraryClassDefinitions>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>DebugLib</Keyword>
- </LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>UefiDriverModelLib</Keyword>
- </LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>UefiDriverEntryPoint</Keyword>
- </LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>BaseLib</Keyword>
- </LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>UefiLib</Keyword>
- </LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>BaseMemoryLib</Keyword>
- </LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>EdkUsbLib</Keyword>
- </LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>ReportStatusCodeLib</Keyword>
- </LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>MemoryAllocationLib</Keyword>
- </LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>UefiBootServicesTableLib</Keyword>
- </LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>DevicePathLib</Keyword>
- </LibraryClass>
- </LibraryClassDefinitions>
- <SourceFiles>
- <Filename>usbbus.h</Filename>
- <Filename>usbutil.h</Filename>
- <Filename>hub.h</Filename>
- <Filename>usbbus.c</Filename>
- <Filename>usbio.c</Filename>
- <Filename>usb.c</Filename>
- <Filename>usbutil.c</Filename>
- <Filename>hub.c</Filename>
- <Filename>ComponentName.c</Filename>
- </SourceFiles>
- <PackageDependencies>
- <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
- <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
- </PackageDependencies>
- <Protocols>
- <Protocol Usage="BY_START">
- <ProtocolCName>gEfiUsbIoProtocolGuid</ProtocolCName>
- </Protocol>
- <Protocol Usage="SOMETIMES_CONSUMED">
- <ProtocolCName>gEfiUsb2HcProtocolGuid</ProtocolCName>
- </Protocol>
- <Protocol Usage="SOMETIMES_CONSUMED">
- <ProtocolCName>gEfiUsbHcProtocolGuid</ProtocolCName>
- </Protocol>
- <Protocol Usage="TO_START">
- <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
- </Protocol>
- </Protocols>
- <Externs>
- <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
- <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
- <Extern>
- <DriverBinding>gUsbBusDriverBinding</DriverBinding>
- <ComponentName>gUsbBusComponentName</ComponentName>
- </Extern>
- </Externs>
-</ModuleSurfaceArea>
diff --git a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/hub.c b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/hub.c
deleted file mode 100644
index fd9e673b6c..0000000000
--- a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/hub.c
+++ /dev/null
@@ -1,507 +0,0 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- Module Name:
-
- Hub.c
-
- Abstract:
-
- Usb Hub Request
-
- Revision History
-
---*/
-
-#include "usbbus.h"
-
-EFI_STATUS
-HubGetPortStatus (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 Port,
- OUT UINT32 *PortStatus
- )
-/*++
-
- Routine Description:
- Get a given hub port status
-
- Arguments:
- UsbIo - EFI_USB_IO_PROTOCOL instance
- Port - Usb hub port number (starting from 1).
- PortStatus - Current Hub port status and change status.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE
- EFI_TIME_OUT
- EFI_INVALID_PARAMETER
-
---*/
-{
- EFI_USB_DEVICE_REQUEST DevReq;
- EFI_STATUS EfiStatus;
- UINT32 UsbStatus;
- UINT32 Timeout;
-
- ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
-
- //
- // Fill Device request packet
- //
- DevReq.RequestType = HUB_GET_PORT_STATUS_REQ_TYPE;
- DevReq.Request = HUB_GET_PORT_STATUS;
- DevReq.Value = 0;
- DevReq.Index = Port;
- DevReq.Length = sizeof (UINT32);
-
- Timeout = 3000;
-
- EfiStatus = UsbIo->UsbControlTransfer (
- UsbIo,
- &DevReq,
- EfiUsbDataIn,
- Timeout,
- PortStatus,
- sizeof (UINT32),
- &UsbStatus
- );
-
- return EfiStatus;
-}
-
-EFI_STATUS
-HubSetPortFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 Port,
- IN UINT8 Value
- )
-/*++
-
- Routine Description:
- Set specified feature to a give hub port
-
- Arguments:
- UsbIo - EFI_USB_IO_PROTOCOL instance
- Port - Usb hub port number (starting from 1).
- Value - New feature value.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE
- EFI_TIME_OUT
- EFI_INVALID_PARAMETER
-
---*/
-{
- EFI_USB_DEVICE_REQUEST DevReq;
- EFI_STATUS EfiStatus;
- UINT32 UsbStatus;
- UINT32 Timeout;
-
- ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
-
- //
- // Fill Device request packet
- //
- DevReq.RequestType = HUB_SET_PORT_FEATURE_REQ_TYPE;
- DevReq.Request = HUB_SET_PORT_FEATURE;
- DevReq.Value = Value;
- DevReq.Index = Port;
- DevReq.Length = 0;
-
- Timeout = 3000;
- EfiStatus = UsbIo->UsbControlTransfer (
- UsbIo,
- &DevReq,
- EfiUsbNoData,
- Timeout,
- NULL,
- 0,
- &UsbStatus
- );
-
- return EfiStatus;
-}
-
-EFI_STATUS
-HubClearPortFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 Port,
- IN UINT8 Value
- )
-/*++
-
- Routine Description:
- Clear a specified feature of a given hub port
-
- Arguments:
- UsbIo - EFI_USB_IO_PROTOCOL instance
- Port - Usb hub port number (starting from 1).
- Value - Feature value that will be cleared from
- that hub port.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE
- EFI_TIME_OUT
- EFI_INVALID_PARAMETER
-
---*/
-{
- EFI_USB_DEVICE_REQUEST DevReq;
- EFI_STATUS EfiStatus;
- UINT32 UsbStatus;
- UINT32 Timeout;
-
- ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
-
- //
- // Fill Device request packet
- //
- DevReq.RequestType = HUB_CLEAR_FEATURE_PORT_REQ_TYPE;
- DevReq.Request = HUB_CLEAR_FEATURE_PORT;
- DevReq.Value = Value;
- DevReq.Index = Port;
- DevReq.Length = 0;
-
- Timeout = 3000;
- EfiStatus = UsbIo->UsbControlTransfer (
- UsbIo,
- &DevReq,
- EfiUsbNoData,
- Timeout,
- NULL,
- 0,
- &UsbStatus
- );
-
- return EfiStatus;
-}
-
-EFI_STATUS
-HubGetHubStatus (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- OUT UINT32 *HubStatus
- )
-/*++
-
- Routine Description:
- Get Hub Status
-
- Arguments:
- UsbIo - EFI_USB_IO_PROTOCOL instance
- HubStatus - Current Hub status and change status.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE
- EFI_TIME_OUT
-
---*/
-{
- EFI_USB_DEVICE_REQUEST DevReq;
- EFI_STATUS EfiStatus;
- UINT32 UsbStatus;
- UINT32 Timeout;
-
- ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
-
- //
- // Fill Device request packet
- //
- DevReq.RequestType = HUB_GET_HUB_STATUS_REQ_TYPE;
- DevReq.Request = HUB_GET_HUB_STATUS;
- DevReq.Value = 0;
- DevReq.Index = 0;
- DevReq.Length = sizeof (UINT32);
-
- Timeout = 3000;
- EfiStatus = UsbIo->UsbControlTransfer (
- UsbIo,
- &DevReq,
- EfiUsbDataIn,
- Timeout,
- HubStatus,
- sizeof (UINT32),
- &UsbStatus
- );
-
- return EfiStatus;
-}
-
-EFI_STATUS
-HubSetHubFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 Value
- )
-/*++
-
- Routine Description:
- Set a specified feature to the hub
-
- Arguments:
- UsbIo - EFI_USB_IO_PROTOCOL instance
- Value - Feature value that will be set to the hub.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE
- EFI_TIME_OUT
-
---*/
-{
- EFI_USB_DEVICE_REQUEST DevReq;
- EFI_STATUS EfiStatus;
- UINT32 UsbStatus;
- UINT32 Timeout;
-
- ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
-
- //
- // Fill Device request packet
- //
- DevReq.RequestType = HUB_SET_HUB_FEATURE_REQ_TYPE;
- DevReq.Request = HUB_SET_HUB_FEATURE;
- DevReq.Value = Value;
- DevReq.Index = 0;
- DevReq.Length = 0;
-
- Timeout = 3000;
- EfiStatus = UsbIo->UsbControlTransfer (
- UsbIo,
- &DevReq,
- EfiUsbNoData,
- Timeout,
- NULL,
- 0,
- &UsbStatus
- );
-
- return EfiStatus;
-}
-
-EFI_STATUS
-HubClearHubFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 Value
- )
-/*++
-
- Routine Description:
- Set a specified feature to the hub
-
- Arguments:
- UsbIo - EFI_USB_IO_PROTOCOL instance
- Value - Feature value that will be cleared from the hub.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE
- EFI_TIME_OUT
-
---*/
-{
- EFI_USB_DEVICE_REQUEST DevReq;
- EFI_STATUS EfiStatus;
- UINT32 UsbStatus;
- UINT32 Timeout;
-
- ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
-
- //
- // Fill Device request packet
- //
- DevReq.RequestType = HUB_CLEAR_FEATURE_REQ_TYPE;
- DevReq.Request = HUB_CLEAR_FEATURE;
- DevReq.Value = Value;
- DevReq.Index = 0;
- DevReq.Length = 0;
-
- Timeout = 3000;
- EfiStatus = UsbIo->UsbControlTransfer (
- UsbIo,
- &DevReq,
- EfiUsbNoData,
- Timeout,
- NULL,
- 0,
- &UsbStatus
- );
-
- return EfiStatus;
-
-}
-
-EFI_STATUS
-GetHubDescriptor (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINTN DescriptorSize,
- OUT EFI_USB_HUB_DESCRIPTOR *HubDescriptor
- )
-/*++
-
- Routine Description:
- Get the hub descriptor
-
- Arguments:
- UsbIo - EFI_USB_IO_PROTOCOL instance
- DescriptorSize - The length of Hub Descriptor buffer.
- HubDescriptor - Caller allocated buffer to store the hub descriptor
- if successfully returned.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE
- EFI_TIME_OUT
-
---*/
-{
- EFI_USB_DEVICE_REQUEST DevReq;
- EFI_STATUS EfiStatus;
- UINT32 UsbStatus;
- UINT32 Timeout;
-
- ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
-
- //
- // Fill Device request packet
- //
- DevReq.RequestType = USB_RT_HUB | 0x80;
- DevReq.Request = HUB_GET_DESCRIPTOR;
- DevReq.Value = USB_DT_HUB << 8;
- DevReq.Index = 0;
- DevReq.Length = (UINT16) DescriptorSize;
-
- Timeout = 3000;
- EfiStatus = UsbIo->UsbControlTransfer (
- UsbIo,
- &DevReq,
- EfiUsbDataIn,
- Timeout,
- HubDescriptor,
- (UINT16) DescriptorSize,
- &UsbStatus
- );
-
- return EfiStatus;
-
-}
-
-EFI_STATUS
-DoHubConfig (
- IN USB_IO_CONTROLLER_DEVICE *HubController
- )
-/*++
-
- Routine Description:
- Configure the hub
-
- Arguments:
- HubController - Indicating the hub controller device that
- will be configured
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_USB_HUB_DESCRIPTOR HubDescriptor;
- EFI_STATUS Status;
- EFI_USB_HUB_STATUS HubStatus;
- UINTN Index;
- UINT32 PortStatus;
-
- UsbIo = &HubController->UsbIo;
-
- ZeroMem (&HubDescriptor, sizeof (HubDescriptor));
-
- //
- // First get the hub descriptor length
- //
- Status = GetHubDescriptor (UsbIo, 2, &HubDescriptor);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // First get the whole descriptor, then
- // get the number of hub ports
- //
- Status = GetHubDescriptor (
- UsbIo,
- HubDescriptor.Length,
- &HubDescriptor
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((gUSBErrorLevel, "Get hub descriptor fail\n"));
- return EFI_DEVICE_ERROR;
- }
-
- HubController->DownstreamPorts = HubDescriptor.NbrPorts;
-
- Status = HubGetHubStatus (UsbIo, (UINT32 *) &HubStatus);
- if (EFI_ERROR (Status)) {
- DEBUG ((gUSBErrorLevel, "Get hub status fail when configure\n"));
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Get all hub ports status
- //
- for (Index = 0; Index < HubController->DownstreamPorts; Index++) {
-
- Status = HubGetPortStatus (UsbIo, (UINT8) (Index + 1), &PortStatus);
- if (EFI_ERROR (Status)) {
- continue;
- }
- }
- //
- // Power all the hub ports
- //
- for (Index = 0; Index < HubController->DownstreamPorts; Index++) {
- Status = HubSetPortFeature (
- UsbIo,
- (UINT8) (Index + 1),
- EfiUsbPortPower
- );
- if (EFI_ERROR (Status)) {
- continue;
- }
- }
-
- //
- // Clear Hub Status Change
- //
- Status = HubGetHubStatus (UsbIo, (UINT32 *) &HubStatus);
- if (EFI_ERROR (Status)) {
- DEBUG ((gUSBErrorLevel, "Get hub status fail\n"));
- return EFI_DEVICE_ERROR;
- } else {
- //
- // Hub power supply change happens
- //
- if (HubStatus.HubChange & HUB_CHANGE_LOCAL_POWER) {
- HubClearHubFeature (UsbIo, C_HUB_LOCAL_POWER);
- }
- //
- // Hub change overcurrent happens
- //
- if (HubStatus.HubChange & HUB_CHANGE_OVERCURRENT) {
- HubClearHubFeature (UsbIo, C_HUB_OVER_CURRENT);
- }
- }
-
- return EFI_SUCCESS;
-
-}
diff --git a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/hub.h b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/hub.h
deleted file mode 100644
index 4545d71c6a..0000000000
--- a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/hub.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- Module Name:
-
- Hub.h
-
- Abstract:
-
- Constants definitions for Usb Hub
-
- Revision History
-
---*/
-
-#ifndef _HUB_H
-#define _HUB_H
-
-//
-// Hub feature numbers
-//
-#define C_HUB_LOCAL_POWER 0
-#define C_HUB_OVER_CURRENT 1
-
-//
-// Hub class code & sub class code
-//
-#define CLASS_CODE_HUB 0x09
-#define SUB_CLASS_CODE_HUB 0
-
-//
-// Hub Status & Hub Change bit masks
-//
-#define HUB_STATUS_LOCAL_POWER 0x0001
-#define HUB_STATUS_OVERCURRENT 0x0002
-
-#define HUB_CHANGE_LOCAL_POWER 0x0001
-#define HUB_CHANGE_OVERCURRENT 0x0002
-
-//
-// Hub Characteristics
-//
-#define HUB_CHAR_LPSM 0x0003
-#define HUB_CHAR_COMPOUND 0x0004
-#define HUB_CHAR_OCPM 0x0018
-
-//
-// Hub specific request
-//
-#define HUB_CLEAR_FEATURE 0x01
-#define HUB_CLEAR_FEATURE_REQ_TYPE 0x20
-
-#define HUB_CLEAR_FEATURE_PORT 0x01
-#define HUB_CLEAR_FEATURE_PORT_REQ_TYPE 0x23
-
-#define HUB_GET_BUS_STATE 0x02
-#define HUB_GET_BUS_STATE_REQ_TYPE 0xA3
-
-#define HUB_GET_DESCRIPTOR 0x06
-#define HUB_GET_DESCRIPTOR_REQ_TYPE 0xA0
-
-#define HUB_GET_HUB_STATUS 0x00
-#define HUB_GET_HUB_STATUS_REQ_TYPE 0xA0
-
-#define HUB_GET_PORT_STATUS 0x00
-#define HUB_GET_PORT_STATUS_REQ_TYPE 0xA3
-
-#define HUB_SET_DESCRIPTOR 0x07
-#define HUB_SET_DESCRIPTOR_REQ_TYPE 0x20
-
-#define HUB_SET_HUB_FEATURE 0x03
-#define HUB_SET_HUB_FEATURE_REQ_TYPE 0x20
-
-#define HUB_SET_PORT_FEATURE 0x03
-#define HUB_SET_PORT_FEATURE_REQ_TYPE 0x23
-
-#pragma pack(1)
-typedef struct usb_hub_status {
- UINT16 HubStatus;
- UINT16 HubChange;
-} EFI_USB_HUB_STATUS;
-#pragma pack()
-
-EFI_STATUS
-HubGetPortStatus (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 Port,
- OUT UINT32 *PortStatus
- );
-
-EFI_STATUS
-HubSetPortFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 Port,
- IN UINT8 Value
- );
-
-EFI_STATUS
-HubSetHubFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 Value
- );
-
-EFI_STATUS
-HubGetHubStatus (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- OUT UINT32 *HubStatus
- );
-
-EFI_STATUS
-HubClearPortFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 Port,
- IN UINT8 Value
- );
-
-EFI_STATUS
-HubClearHubFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 Value
- );
-
-EFI_STATUS
-GetHubDescriptor (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINTN DescriptorSize,
- OUT EFI_USB_HUB_DESCRIPTOR *HubDescriptor
- );
-
-#endif
diff --git a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usb.c b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usb.c
deleted file mode 100644
index 272161083b..0000000000
--- a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usb.c
+++ /dev/null
@@ -1,825 +0,0 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- Module Name:
-
- Usb.c
-
- Abstract:
-
- Parse usb device configurations.
-
- Revision History
-
---*/
-
-#include "usbbus.h"
-
-//
-// Here are some internal helper functions
-//
-STATIC
-EFI_STATUS
-GetExpectedDescriptor (
- IN UINT8 *Buffer,
- IN UINTN Length,
- IN UINT8 DescType,
- IN UINT8 DescLength,
- OUT UINTN *ParsedBytes
- );
-
-STATIC
-EFI_STATUS
-ParseThisEndpoint (
- IN ENDPOINT_DESC_LIST_ENTRY *EndpointEntry,
- IN UINT8 *Buffer,
- IN UINTN BufferLength,
- OUT UINTN *ParsedBytes
- );
-
-STATIC
-EFI_STATUS
-ParseThisInterface (
- IN INTERFACE_DESC_LIST_ENTRY *InterfaceEntry,
- IN UINT8 *Buffer,
- IN UINTN *BufferLen,
- OUT UINTN *ParsedBytes
- );
-
-STATIC
-EFI_STATUS
-ParseThisConfig (
- IN CONFIG_DESC_LIST_ENTRY *ConfigDescEntry,
- IN UINT8 *Buffer,
- IN UINTN Length
- );
-
-//
-// Implementations
-//
-BOOLEAN
-IsHub (
- IN USB_IO_CONTROLLER_DEVICE *Dev
- )
-/*++
-
- Routine Description:
- Tell if a usb controller is a hub controller.
-
- Arguments:
- Dev - UsbIoController device structure.
-
- Returns:
- TRUE/FALSE
---*/
-{
- EFI_USB_INTERFACE_DESCRIPTOR Interface;
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
- UINT8 Index;
-
- if (Dev == NULL) {
- return FALSE;
- }
-
- UsbIo = &Dev->UsbIo;
-
- UsbIo->UsbGetInterfaceDescriptor (
- UsbIo,
- &Interface
- );
-
- //
- // Check classcode
- //
- if (Interface.InterfaceClass != 0x09) {
- return FALSE;
- }
-
- //
- // Check protocol
- //
- if (Interface.InterfaceProtocol != 0x0) {
- return FALSE;
- }
-
- for (Index = 0; Index < Interface.NumEndpoints; Index++) {
- UsbIo->UsbGetEndpointDescriptor (
- UsbIo,
- Index,
- &EndpointDescriptor
- );
-
- if ((EndpointDescriptor.EndpointAddress & 0x80) == 0) {
- continue;
- }
-
- if (EndpointDescriptor.Attributes != 0x03) {
- continue;
- }
-
- Dev->HubEndpointAddress = EndpointDescriptor.EndpointAddress;
- return TRUE;
- }
-
- return FALSE;
-}
-
-EFI_STATUS
-UsbGetStringtable (
- IN USB_IO_DEVICE *Dev
- )
-/*++
-
- Routine Description:
- Get the string table stored in a usb device.
-
- Arguments:
- Dev - UsbIoController device structure.
-
- Returns:
- EFI_SUCCESS
- EFI_UNSUPPORTED
- EFI_OUT_OF_RESOURCES
-
---*/
-{
- EFI_STATUS Result;
- UINT32 Status;
- EFI_USB_SUPPORTED_LANGUAGES *LanguageTable;
- UINT8 *Buffer;
- UINT8 *ptr;
- UINTN Index;
- UINTN LangTableSize;
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT16 TempBuffer;
-
- UsbIo = &(Dev->UsbController[0]->UsbIo);
-
- //
- // We get first 2 byte of langID table,
- // so we can have the whole table length
- //
- Result = UsbGetString (
- UsbIo,
- 0,
- 0,
- &TempBuffer,
- 2,
- &Status
- );
- if (EFI_ERROR (Result)) {
- return EFI_UNSUPPORTED;
- }
-
- LanguageTable = (EFI_USB_SUPPORTED_LANGUAGES *) &TempBuffer;
-
- if (LanguageTable->Length == 0) {
- return EFI_UNSUPPORTED;
- }
- //
- // If length is 2, then there is no string table
- //
- if (LanguageTable->Length == 2) {
- return EFI_UNSUPPORTED;
- }
-
- Buffer = AllocateZeroPool (LanguageTable->Length);
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // Now we get the whole LangID table
- //
- Result = UsbGetString (
- UsbIo,
- 0,
- 0,
- Buffer,
- LanguageTable->Length,
- &Status
- );
- if (EFI_ERROR (Result)) {
- gBS->FreePool (Buffer);
- return EFI_UNSUPPORTED;
- }
-
- LanguageTable = (EFI_USB_SUPPORTED_LANGUAGES *) Buffer;
-
- //
- // ptr point to the LangID table
- //
- ptr = Buffer + 2;
- LangTableSize = (LanguageTable->Length - 2) / 2;
-
- for (Index = 0; Index < LangTableSize && Index < USB_MAXLANID; Index++) {
- Dev->LangID[Index] = *((UINT16 *) ptr);
- ptr += 2;
- }
-
- gBS->FreePool (Buffer);
- LanguageTable = NULL;
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-UsbGetAllConfigurations (
- IN USB_IO_DEVICE *UsbIoDevice
- )
-/*++
-
- Routine Description:
- This function is to parse all the configuration descriptor.
-
- Arguments:
- UsbIoDevice - USB_IO_DEVICE device structure.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
- EFI_OUT_OF_RESOURCES
-
---*/
-{
- EFI_STATUS Result;
- UINT32 Status;
- UINTN Index;
- UINTN TotalLength;
- UINT8 *Buffer;
- CONFIG_DESC_LIST_ENTRY *ConfigDescEntry;
- EFI_USB_IO_PROTOCOL *UsbIo;
-
- InitializeListHead (&UsbIoDevice->ConfigDescListHead);
- UsbIo = &(UsbIoDevice->UsbController[0]->UsbIo);
-
- for (Index = 0; Index < UsbIoDevice->DeviceDescriptor.NumConfigurations; Index++) {
- ConfigDescEntry = NULL;
-
- ConfigDescEntry = AllocateZeroPool (sizeof (CONFIG_DESC_LIST_ENTRY));
- if (ConfigDescEntry == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // 1st only get 1st 4 bytes config descriptor,
- // so we can know the whole length
- //
- Result = UsbGetDescriptor (
- UsbIo,
- (UINT16) ((USB_DT_CONFIG << 8) | Index),
- 0,
- 4,
- &ConfigDescEntry->CongfigDescriptor,
- &Status
- );
- if (EFI_ERROR (Result)) {
- DEBUG ((gUSBErrorLevel, "First get config descriptor error\n"));
- gBS->FreePool (ConfigDescEntry);
- return EFI_DEVICE_ERROR;
- }
-
- TotalLength = ConfigDescEntry->CongfigDescriptor.TotalLength;
-
- Buffer = AllocateZeroPool (TotalLength);
- if (Buffer == NULL) {
- gBS->FreePool (ConfigDescEntry);
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Then we get the total descriptors for this configuration
- //
- Result = UsbGetDescriptor (
- UsbIo,
- (UINT16) ((USB_DT_CONFIG << 8) | Index),
- 0,
- (UINT16) TotalLength,
- Buffer,
- &Status
- );
- if (EFI_ERROR (Result)) {
- DEBUG ((gUSBErrorLevel, "Get whole config descriptor error\n"));
- gBS->FreePool (ConfigDescEntry);
- gBS->FreePool (Buffer);
- return EFI_DEVICE_ERROR;
- }
-
- InitializeListHead (&ConfigDescEntry->InterfaceDescListHead);
-
- //
- // Parse this whole configuration
- //
- Result = ParseThisConfig (ConfigDescEntry, Buffer, TotalLength);
-
- if (EFI_ERROR (Result)) {
- //
- // Ignore this configuration, parse next one
- //
- gBS->FreePool (ConfigDescEntry);
- gBS->FreePool (Buffer);
- continue;
- }
-
- InsertTailList (&UsbIoDevice->ConfigDescListHead, &ConfigDescEntry->Link);
-
- gBS->FreePool (Buffer);
-
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-GetExpectedDescriptor (
- IN UINT8 *Buffer,
- IN UINTN Length,
- IN UINT8 DescType,
- IN UINT8 DescLength,
- OUT UINTN *ParsedBytes
- )
-/*++
-
- Routine Description:
- Get the start position of next wanted descriptor.
-
- Arguments:
- Buffer - Buffer to parse
- Length - Buffer length
- DescType - Descriptor type
- DescLength - Descriptor length
- ParsedBytes - Parsed Bytes to return
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- UINT16 DescriptorHeader;
- UINT8 Len;
- UINT8 *ptr;
- UINTN Parsed;
-
- Parsed = 0;
- ptr = Buffer;
-
- while (TRUE) {
- //
- // Buffer length should not less than Desc length
- //
- if (Length < DescLength) {
- return EFI_DEVICE_ERROR;
- }
- //
- // DescriptorHeader = *((UINT16 *)ptr), compatible with IPF
- //
- DescriptorHeader = (UINT16) ((*(ptr + 1) << 8) | *ptr);
-
- Len = ptr[0];
-
- //
- // Check to see if it is a start of expected descriptor
- //
- if (DescriptorHeader == ((DescType << 8) | DescLength)) {
- break;
- }
-
- if ((UINT8) (DescriptorHeader >> 8) == DescType) {
- if (Len > DescLength) {
- return EFI_DEVICE_ERROR;
- }
- }
- //
- // Descriptor length should be at least 2
- // and should not exceed the buffer length
- //
- if (Len < 2) {
- return EFI_DEVICE_ERROR;
- }
-
- if (Len > Length) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Skip this mismatch descriptor
- //
- Length -= Len;
- ptr += Len;
- Parsed += Len;
- }
-
- *ParsedBytes = Parsed;
-
- return EFI_SUCCESS;
-}
-
-
-STATIC
-EFI_STATUS
-ParseThisEndpoint (
- IN ENDPOINT_DESC_LIST_ENTRY *EndpointEntry,
- IN UINT8 *Buffer,
- IN UINTN BufferLength,
- OUT UINTN *ParsedBytes
- )
-/*++
-
- Routine Description:
- Get the start position of next wanted endpoint descriptor.
-
- Arguments:
- EndpointEntry - ENDPOINT_DESC_LIST_ENTRY
- Buffer - Buffer to parse
- BufferLength - Buffer Length
- ParsedBytes - Parsed Bytes to return
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- UINT8 *ptr;
- EFI_STATUS Status;
- UINTN SkipBytes;
-
- //
- // Skip some data for this interface
- //
- Status = GetExpectedDescriptor (
- Buffer,
- BufferLength,
- USB_DT_ENDPOINT,
- sizeof (EFI_USB_ENDPOINT_DESCRIPTOR),
- &SkipBytes
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ptr = Buffer + SkipBytes;
- *ParsedBytes = SkipBytes;
-
- CopyMem (
- &EndpointEntry->EndpointDescriptor,
- ptr,
- sizeof (EFI_USB_ENDPOINT_DESCRIPTOR)
- );
-
- *ParsedBytes += sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-ParseThisInterface (
- IN INTERFACE_DESC_LIST_ENTRY *InterfaceEntry,
- IN UINT8 *Buffer,
- IN UINTN *BufferLen,
- OUT UINTN *ParsedBytes
- )
-/*++
-
- Routine Description:
- Get the start position of next wanted interface descriptor.
-
- Arguments:
- InterfaceEntry - INTERFACE_DESC_LIST_ENTRY
- Buffer - Buffer to parse
- BufferLength - Buffer Length
- ParsedBytes - Parsed Bytes to return
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- UINT8 *ptr;
- UINTN SkipBytes;
- UINTN Index;
- UINTN Length;
- UINTN Parsed;
- ENDPOINT_DESC_LIST_ENTRY *EndpointEntry;
- EFI_STATUS Status;
-
- Parsed = 0;
-
- //
- // Skip some data for this interface
- //
- Status = GetExpectedDescriptor (
- Buffer,
- *BufferLen,
- USB_DT_INTERFACE,
- sizeof (EFI_USB_INTERFACE_DESCRIPTOR),
- &SkipBytes
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ptr = Buffer + SkipBytes;
- *ParsedBytes = SkipBytes;
-
- //
- // Copy the interface descriptor
- //
- CopyMem (
- &InterfaceEntry->InterfaceDescriptor,
- ptr,
- sizeof (EFI_USB_INTERFACE_DESCRIPTOR)
- );
-
- ptr = Buffer + sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
- *ParsedBytes += sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
-
- InitializeListHead (&InterfaceEntry->EndpointDescListHead);
-
- Length = *BufferLen - SkipBytes - sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
-
- for (Index = 0; Index < InterfaceEntry->InterfaceDescriptor.NumEndpoints; Index++) {
- EndpointEntry = AllocateZeroPool (sizeof (ENDPOINT_DESC_LIST_ENTRY));
- if (EndpointEntry == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // Parses all the endpoint descriptors within this interface.
- //
- Status = ParseThisEndpoint (EndpointEntry, ptr, Length, &Parsed);
-
- if (EFI_ERROR (Status)) {
- gBS->FreePool (EndpointEntry);
- return Status;
- }
-
- InsertTailList (
- &InterfaceEntry->EndpointDescListHead,
- &EndpointEntry->Link
- );
-
- Length -= Parsed;
- ptr += Parsed;
- *ParsedBytes += Parsed;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-ParseThisConfig (
- IN CONFIG_DESC_LIST_ENTRY *ConfigDescEntry,
- IN UINT8 *Buffer,
- IN UINTN Length
- )
-/*++
-
- Routine Description:
- Parse the current configuration descriptior.
-
- Arguments:
- ConfigDescEntry - CONFIG_DESC_LIST_ENTRY
- Buffer - Buffer to parse
- Length - Buffer Length
-
- Returns
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- UINT8 *ptr;
- UINT8 NumInterface;
- UINTN Index;
- INTERFACE_DESC_LIST_ENTRY *InterfaceEntry;
- UINTN SkipBytes;
- UINTN Parsed;
- EFI_STATUS Status;
- UINTN LengthLeft;
-
- Parsed = 0;
-
- //
- // First skip the current config descriptor;
- //
- Status = GetExpectedDescriptor (
- Buffer,
- Length,
- USB_DT_CONFIG,
- sizeof (EFI_USB_CONFIG_DESCRIPTOR),
- &SkipBytes
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ptr = Buffer + SkipBytes;
-
- CopyMem (
- &ConfigDescEntry->CongfigDescriptor,
- ptr,
- sizeof (EFI_USB_CONFIG_DESCRIPTOR)
- );
-
- NumInterface = ConfigDescEntry->CongfigDescriptor.NumInterfaces;
-
- //
- // Skip size of Configuration Descriptor
- //
- ptr += sizeof (EFI_USB_CONFIG_DESCRIPTOR);
-
- LengthLeft = Length - SkipBytes - sizeof (EFI_USB_CONFIG_DESCRIPTOR);
-
- for (Index = 0; Index < NumInterface; Index++) {
- //
- // Parse all Interface
- //
- InterfaceEntry = AllocateZeroPool (sizeof (INTERFACE_DESC_LIST_ENTRY));
- if (InterfaceEntry == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = ParseThisInterface (InterfaceEntry, ptr, &LengthLeft, &Parsed);
- if (EFI_ERROR (Status)) {
- gBS->FreePool (InterfaceEntry);
- return Status;
- }
-
- InsertTailList (
- &ConfigDescEntry->InterfaceDescListHead,
- &InterfaceEntry->Link
- );
-
- //
- // Parsed for next interface
- //
- LengthLeft -= Parsed;
- ptr += Parsed;
- }
- //
- // Parse for additional alt setting;
- //
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-UsbSetConfiguration (
- IN USB_IO_DEVICE *UsbIoDev,
- IN UINTN ConfigurationValue
- )
-/*++
-
- Routine Description:
- Set the device to a configuration value.
-
- Arguments:
- UsbIoDev - USB_IO_DEVICE to be set configuration
- ConfigrationValue - The configuration value to be set to that device
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- LIST_ENTRY *NextEntry;
- CONFIG_DESC_LIST_ENTRY *ConfigEntry;
- UINT32 Status;
- EFI_STATUS Result;
- EFI_USB_IO_PROTOCOL *UsbIo;
-
- UsbIo = &(UsbIoDev->UsbController[0]->UsbIo);
- NextEntry = UsbIoDev->ConfigDescListHead.ForwardLink;
-
- while (NextEntry != &UsbIoDev->ConfigDescListHead) {
- //
- // Get one entry
- //
- ConfigEntry = (CONFIG_DESC_LIST_ENTRY *) NextEntry;
- if (ConfigEntry->CongfigDescriptor.ConfigurationValue == ConfigurationValue) {
- //
- // Find one, set to the active configuration
- //
- UsbIoDev->ActiveConfig = ConfigEntry;
- break;
- }
-
- NextEntry = NextEntry->ForwardLink;
- }
- //
- // Next Entry should not be null
- //
- Result = UsbSetDeviceConfiguration (
- UsbIo,
- (UINT16) ConfigurationValue,
- &Status
- );
-
- return Result;
-}
-
-EFI_STATUS
-UsbSetDefaultConfiguration (
- IN USB_IO_DEVICE *UsbIoDev
- )
-/*++
-
- Routine Description:
- Set the device to a default configuration value.
-
- Arguments:
- UsbIoDev - USB_IO_DEVICE to be set configuration
-
- Returns
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- CONFIG_DESC_LIST_ENTRY *ConfigEntry;
- UINT16 ConfigValue;
- LIST_ENTRY *NextEntry;
-
- if (IsListEmpty (&UsbIoDev->ConfigDescListHead)) {
- return EFI_DEVICE_ERROR;
- }
-
- NextEntry = UsbIoDev->ConfigDescListHead.ForwardLink;
-
- ConfigEntry = (CONFIG_DESC_LIST_ENTRY *) NextEntry;
- ConfigValue = ConfigEntry->CongfigDescriptor.ConfigurationValue;
-
- return UsbSetConfiguration (UsbIoDev, ConfigValue);
-}
-
-VOID
-UsbDestroyAllConfiguration (
- IN USB_IO_DEVICE *UsbIoDevice
- )
-/*++
-
- Routine Description:
- Delete all configuration data when device is not used.
-
- Arguments:
- UsbIoDevice - USB_IO_DEVICE to be set configuration
-
- Returns:
- N/A
-
---*/
-{
- CONFIG_DESC_LIST_ENTRY *ConfigEntry;
- INTERFACE_DESC_LIST_ENTRY *InterfaceEntry;
- ENDPOINT_DESC_LIST_ENTRY *EndpointEntry;
- LIST_ENTRY *NextEntry;
-
- //
- // Delete all configuration descriptor data
- //
- ConfigEntry = (CONFIG_DESC_LIST_ENTRY *) UsbIoDevice->ConfigDescListHead.ForwardLink;
-
- while (ConfigEntry != (CONFIG_DESC_LIST_ENTRY *) &UsbIoDevice->ConfigDescListHead) {
- //
- // Delete all its interface descriptors
- //
- InterfaceEntry = (INTERFACE_DESC_LIST_ENTRY *) ConfigEntry->InterfaceDescListHead.ForwardLink;
-
- while (InterfaceEntry != (INTERFACE_DESC_LIST_ENTRY *) &ConfigEntry->InterfaceDescListHead) {
- //
- // Delete all its endpoint descriptors
- //
- EndpointEntry = (ENDPOINT_DESC_LIST_ENTRY *) InterfaceEntry->EndpointDescListHead.ForwardLink;
- while (EndpointEntry != (ENDPOINT_DESC_LIST_ENTRY *) &InterfaceEntry->EndpointDescListHead) {
- NextEntry = ((LIST_ENTRY *) EndpointEntry)->ForwardLink;
- RemoveEntryList ((LIST_ENTRY *) EndpointEntry);
- gBS->FreePool (EndpointEntry);
- EndpointEntry = (ENDPOINT_DESC_LIST_ENTRY *) NextEntry;
- }
-
- NextEntry = ((LIST_ENTRY *) InterfaceEntry)->ForwardLink;
- RemoveEntryList ((LIST_ENTRY *) InterfaceEntry);
- gBS->FreePool (InterfaceEntry);
- InterfaceEntry = (INTERFACE_DESC_LIST_ENTRY *) NextEntry;
- }
-
- NextEntry = ((LIST_ENTRY *) ConfigEntry)->ForwardLink;
- RemoveEntryList ((LIST_ENTRY *) ConfigEntry);
- gBS->FreePool (ConfigEntry);
- ConfigEntry = (CONFIG_DESC_LIST_ENTRY *) NextEntry;
- }
-}
diff --git a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbbus.c b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbbus.c
deleted file mode 100644
index 97c9f5efee..0000000000
--- a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbbus.c
+++ /dev/null
@@ -1,3719 +0,0 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- Module Name:
-
- UsbBus.c
-
- Abstract:
-
- USB Bus Driver
-
- Revision History
-
---*/
-
-#include "usbbus.h"
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED UINTN gUSBDebugLevel = EFI_D_INFO;
-GLOBAL_REMOVE_IF_UNREFERENCED UINTN gUSBErrorLevel = EFI_D_ERROR;
-
-//
-// The UsbBusProtocol is just used to locate USB_BUS_CONTROLLER
-// structure in the UsbBusDriverControllerDriverStop(). Then we can
-// Close all opened protocols and release this structure.
-//
-STATIC EFI_GUID mUsbBusProtocolGuid = EFI_USB_BUS_PROTOCOL_GUID;
-
-EFI_DRIVER_BINDING_PROTOCOL gUsbBusDriverBinding = {
- UsbBusControllerDriverSupported,
- UsbBusControllerDriverStart,
- UsbBusControllerDriverStop,
- 0xa,
- NULL,
- NULL
-};
-
-//
-// Internal use only
-//
-STATIC
-EFI_STATUS
-ReportUsbStatusCode (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusController,
- IN EFI_STATUS_CODE_TYPE Type,
- IN EFI_STATUS_CODE_VALUE Code
- );
-
-STATIC
-USB_IO_CONTROLLER_DEVICE *
-CreateUsbIoControllerDevice (
- VOID
- );
-
-STATIC
-EFI_STATUS
-InitUsbIoController (
- IN USB_IO_CONTROLLER_DEVICE *UsbIoController
- );
-
-//
-// USB Device Configuration / Deconfiguration
-//
-STATIC
-EFI_STATUS
-UsbDeviceConfiguration (
- IN USB_IO_CONTROLLER_DEVICE *ParentHubController,
- IN EFI_HANDLE HostController,
- IN UINT8 ParentPort,
- IN USB_IO_DEVICE *UsbIoDevice
- );
-
-//
-// Usb Bus enumeration function
-//
-STATIC
-VOID
-RootHubEnumeration (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-STATIC
-VOID
-HubEnumeration (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-STATIC
-EFI_STATUS
-UsbSetTransactionTranslator (
- IN USB_IO_CONTROLLER_DEVICE *ParentHubController,
- IN UINT8 ParentPort,
- IN OUT USB_IO_DEVICE *Device
- );
-
-STATIC
-EFI_STATUS
-UsbUnsetTransactionTranslator (
- USB_IO_DEVICE *Device
- );
-
-STATIC
-EFI_STATUS
-IdentifyDeviceSpeed (
- USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- USB_IO_DEVICE *NewDevice,
- UINT8 Index
- );
-
-STATIC
-EFI_STATUS
-ReleasePortToCHC (
- USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- UINT8 PortNum
- );
-
-STATIC
-EFI_STATUS
-ResetRootPort (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 PortNum,
- IN UINT8 RetryTimes
- );
-
-STATIC
-EFI_STATUS
-ResetHubPort (
- IN USB_IO_CONTROLLER_DEVICE *UsbIoController,
- IN UINT8 PortIndex
- );
-
-STATIC
-EFI_STATUS
-ParentPortReset (
- IN USB_IO_CONTROLLER_DEVICE *UsbIoController,
- IN BOOLEAN ReConfigure,
- IN UINT8 RetryTimes
- );
-
-//
-// Following are address allocate and free functions
-//
-STATIC
-UINT8
-UsbAllocateAddress (
- IN UINT8 *AddressPool
- )
-/*++
-
- Routine Description:
- Allocate address for usb device
-
- Arguments:
- AddressPool - Pool of usb device address
-
- Returns:
- Usb device address
-
---*/
-{
- UINT8 ByteIndex;
- UINT8 BitIndex;
-
- for (ByteIndex = 0; ByteIndex < 16; ByteIndex++) {
- for (BitIndex = 0; BitIndex < 8; BitIndex++) {
- if ((AddressPool[ByteIndex] & (1 << BitIndex)) == 0) {
- //
- // Found one, covert to address, and mark it use
- //
- AddressPool[ByteIndex] = (UINT8) (AddressPool[ByteIndex] | (1 << BitIndex));
- return (UINT8) (ByteIndex * 8 + BitIndex);
- }
- }
- }
-
- return 0;
-
-}
-
-STATIC
-VOID
-UsbFreeAddress (
- IN UINT8 DevAddress,
- IN UINT8 *AddressPool
- )
-/*++
-
- Routine Description:
- Free address for usb device
-
- Arguments:
- DevAddress - Usb device address
- AddressPool - Pool of usb device address
-
- Returns:
- VOID
-
---*/
-{
- UINT8 WhichByte;
- UINT8 WhichBit;
- //
- // Locate the position
- //
- WhichByte = (UINT8) (DevAddress / 8);
- WhichBit = (UINT8) (DevAddress & 0x7);
-
- AddressPool[WhichByte] = (UINT8) (AddressPool[WhichByte] & (~(1 << WhichBit)));
-}
-
-EFI_STATUS
-EFIAPI
-UsbBusControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-/*++
-
- Routine Description:
- Test to see if this driver supports ControllerHandle. Any ControllerHandle
- that has UsbHcProtocol installed will be supported.
-
- Arguments:
- This - Protocol instance pointer.
- Controller - Handle of device to test
- RemainingDevicePath - Device Path Protocol instance pointer
-
- Returns:
- EFI_SUCCESS - This driver supports this device.
- EFI_UNSUPPORTED - This driver does not support this device.
-
---*/
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_USB2_HC_PROTOCOL *Usb2Hc;
- EFI_USB_HC_PROTOCOL *UsbHc;
- EFI_DEV_PATH_PTR Node;
-
- //
- // Check Device Path
- //
- if (RemainingDevicePath != NULL) {
- Node.DevPath = RemainingDevicePath;
- if (Node.DevPath->Type != MESSAGING_DEVICE_PATH ||
- Node.DevPath->SubType != MSG_USB_DP ||
- DevicePathNodeLength(Node.DevPath) != sizeof(USB_DEVICE_PATH)) {
- return EFI_UNSUPPORTED;
- }
- }
-
- //
- // Open the IO Abstraction(s) needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- //
- // Check whether USB Host Controller Protocol is already
- // installed on this handle. If it is installed, we can start
- // USB Bus Driver now.
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- (VOID **) &Usb2Hc,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
-
- if (EFI_ERROR (Status)) {
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- (VOID **) &UsbHc,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- return EFI_SUCCESS;
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-UsbBusControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-/*++
-
- Routine Description:
-
- Starting the Usb Bus Driver
-
- Arguments:
-
- This - Protocol instance pointer.
- Controller - Handle of device to test
- RemainingDevicePath - Not used
-
- Returns:
-
- EFI_SUCCESS - This driver supports this device.
- EFI_DEVICE_ERROR - This driver cannot be started due to device
- EFI_OUT_OF_RESOURCES- Can't allocate memory resources
-
---*/
-{
- EFI_STATUS Status;
- EFI_STATUS OpenStatus;
- USB_BUS_CONTROLLER_DEVICE *UsbBusDev;
- USB_IO_DEVICE *RootHub;
- USB_IO_CONTROLLER_DEVICE *RootHubController;
- UINT8 MaxSpeed;
- UINT8 PortNumber;
- UINT8 Is64BitCapable;
-
- //
- // Allocate USB_BUS_CONTROLLER_DEVICE structure
- //
- UsbBusDev = NULL;
- UsbBusDev = AllocateZeroPool (sizeof (USB_BUS_CONTROLLER_DEVICE));
- if (UsbBusDev == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- UsbBusDev->Signature = USB_BUS_DEVICE_SIGNATURE;
- UsbBusDev->AddressPool[0] = 1;
-
- //
- // Get the Device Path Protocol on Controller's handle
- //
- OpenStatus = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &UsbBusDev->DevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
-
- if (EFI_ERROR (OpenStatus)) {
- gBS->FreePool (UsbBusDev);
- return OpenStatus;
- }
- //
- // Locate the Host Controller Interface
- //
- OpenStatus = gBS->OpenProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- (VOID **) &(UsbBusDev->Usb2HCInterface),
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (OpenStatus)) {
-
- UsbBusDev->Hc2ProtocolSupported = FALSE;
- OpenStatus = gBS->OpenProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- (VOID **) &(UsbBusDev->UsbHCInterface),
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (OpenStatus)) {
- //
- // Report Status Code here since we will reset the host controller
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_USB | EFI_IOB_EC_CONTROLLER_ERROR,
- UsbBusDev->DevicePath
- );
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- gBS->FreePool (UsbBusDev);
- return OpenStatus;
- }
-
- DEBUG ((gUSBDebugLevel, "UsbHcProtocol Opened.\n"));
- } else {
- DEBUG ((gUSBDebugLevel, "Usb2HcProtocol Opened.\n"));
- UsbBusDev->Hc2ProtocolSupported = TRUE;
- }
-
- //
- // Attach EFI_USB_BUS_PROTOCOL to controller handle,
- // for locate UsbBusDev later
- //
- Status = gBS->InstallProtocolInterface (
- &Controller,
- &mUsbBusProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &UsbBusDev->BusIdentify
- );
-
- if (EFI_ERROR (Status)) {
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- if (UsbBusDev->Hc2ProtocolSupported) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- } else {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
-
- gBS->FreePool (UsbBusDev);
- return Status;
- }
- //
- // Add root hub to the tree
- //
- RootHub = NULL;
- RootHub = AllocateZeroPool (sizeof (USB_IO_DEVICE));
- if (RootHub == NULL) {
- gBS->UninstallProtocolInterface (
- Controller,
- &mUsbBusProtocolGuid,
- &UsbBusDev->BusIdentify
- );
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- if (UsbBusDev->Hc2ProtocolSupported) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- } else {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
-
- gBS->FreePool (UsbBusDev);
- return EFI_OUT_OF_RESOURCES;
- }
-
- RootHub->BusController = UsbBusDev;
- RootHub->DeviceAddress = UsbAllocateAddress (UsbBusDev->AddressPool);
-
- UsbBusDev->Root = RootHub;
-
- //
- // Allocate Root Hub Controller
- //
- RootHubController = CreateUsbIoControllerDevice ();
- if (RootHubController == NULL) {
- gBS->UninstallProtocolInterface (
- Controller,
- &mUsbBusProtocolGuid,
- &UsbBusDev->BusIdentify
- );
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- if (UsbBusDev->Hc2ProtocolSupported) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- } else {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
- gBS->FreePool (UsbBusDev);
- gBS->FreePool (RootHub);
- return EFI_OUT_OF_RESOURCES;
- }
-
- UsbVirtualHcGetCapability (
- UsbBusDev,
- &MaxSpeed,
- &PortNumber,
- &Is64BitCapable
- );
- RootHubController->DownstreamPorts = PortNumber;
- RootHubController->UsbDevice = RootHub;
- RootHubController->IsUsbHub = TRUE;
- RootHubController->DevicePath = UsbBusDev->DevicePath;
- RootHubController->HostController = Controller;
-
- RootHub->NumOfControllers = 1;
- RootHub->UsbController[0] = RootHubController;
- RootHub->DeviceSpeed = MaxSpeed;
-
- //
- // Report Status Code here since we will reset the host controller
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_IO_BUS_USB | EFI_IOB_PC_RESET,
- UsbBusDev->DevicePath
- );
-
- //
- // Reset USB Host Controller
- //
- UsbVirtualHcReset (
- UsbBusDev,
- EFI_USB_HC_RESET_GLOBAL
- );
-
- //
- // Report Status Code while we are going to bring up the Host Controller
- // and start bus enumeration
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_IO_BUS_USB | EFI_IOB_PC_ENABLE,
- UsbBusDev->DevicePath
- );
-
- //
- // Start USB Host Controller
- //
- UsbVirtualHcSetState (
- UsbBusDev,
- EfiUsbHcStateOperational
- );
-
- //
- // Create a timer to query root ports periodically
- //
- Status = gBS->CreateEvent (
- EVT_TIMER | EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- RootHubEnumeration,
- RootHubController,
- &RootHubController->HubNotify
- );
- if (EFI_ERROR (Status)) {
- gBS->UninstallProtocolInterface (
- Controller,
- &mUsbBusProtocolGuid,
- &UsbBusDev->BusIdentify
- );
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- } else {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
-
- gBS->FreePool (RootHubController);
- gBS->FreePool (RootHub);
- gBS->FreePool (UsbBusDev);
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // Before depending on the timer to check root ports periodically,
- // here we should check them immediately for the first time, or
- // there will be an interval between bus start and devices start.
- //
- gBS->SignalEvent (RootHubController->HubNotify);
-
- Status = gBS->SetTimer (
- RootHubController->HubNotify,
- TimerPeriodic,
- BUSPOLLING_PERIOD
- );
- if (EFI_ERROR (Status)) {
- gBS->UninstallProtocolInterface (
- Controller,
- &mUsbBusProtocolGuid,
- &UsbBusDev->BusIdentify
- );
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- } else {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
-
- gBS->CloseEvent (RootHubController->HubNotify);
- gBS->FreePool (RootHubController);
- gBS->FreePool (RootHub);
- gBS->FreePool (UsbBusDev);
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-//
-// Stop the bus controller
-//
-EFI_STATUS
-EFIAPI
-UsbBusControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-/*++
-
- Routine Description:
- Stop this driver on ControllerHandle. Support stoping any child handles
- created by this driver.
-
- Arguments:
- This - Protocol instance pointer.
- Controller - Handle of device to stop driver on
- NumberOfChildren - Number of Children in the ChildHandleBuffer
- ChildHandleBuffer - List of handles for the children we need to stop.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
- others
-
---*/
-{
- EFI_STATUS Status;
- USB_IO_DEVICE *Root;
- USB_IO_CONTROLLER_DEVICE *RootHubController;
- USB_BUS_CONTROLLER_DEVICE *UsbBusController;
- EFI_USB_BUS_PROTOCOL *UsbIdentifier;
- UINT8 Index2;
- USB_IO_CONTROLLER_DEVICE *UsbController;
- USB_IO_DEVICE *UsbIoDevice;
- USB_IO_CONTROLLER_DEVICE *HubController;
- UINTN Index;
- EFI_USB_IO_PROTOCOL *UsbIo;
-
- if (NumberOfChildren > 0) {
-
- for (Index = 0; Index < NumberOfChildren; Index++) {
- Status = gBS->OpenProtocol (
- ChildHandleBuffer[Index],
- &gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- //
- // We are here since the handle passed in does not support
- // UsbIo protocol. There are several reasons that will cause
- // this.
- // For combo device such as keyboard, it may have 2 devices
- // in one, namely, keyboard and mouse. If we deconfigure one
- // of them, the other will be freed at the same time. This will
- // cause the status error. But this is the correct behavior.
- // For hub device, if we deconfigure hub first, the other chile
- // device will be disconnected also, this will also provide us
- // a status error. Now we will only report EFI_SUCCESS since Uhc
- // driver will be disconnected at the second time.(pls see
- // CoreDisconnectController for details)
- //
- continue;
- }
-
- UsbController = USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (UsbIo);
- UsbIoDevice = UsbController->UsbDevice;
- HubController = UsbController->Parent;
- UsbDeviceDeConfiguration (UsbIoDevice);
- for (Index2 = 0; Index2 < HubController->DownstreamPorts; Index2++) {
- if (HubController->Children[Index2] == UsbIoDevice) {
- HubController->Children[Index2] = NULL;
- }
- }
- }
-
- return EFI_SUCCESS;
- }
- //
- // Get the USB_BUS_CONTROLLER_DEVICE
- //
- Status = gBS->OpenProtocol (
- Controller,
- &mUsbBusProtocolGuid,
- (VOID **) &UsbIdentifier,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
-
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- UsbBusController = USB_BUS_CONTROLLER_DEVICE_FROM_THIS (UsbIdentifier);
-
- //
- // Stop USB Host Controller
- //
-
- //
- // Report Status Code here since we will reset the host controller
- //
- ReportUsbStatusCode (
- UsbBusController,
- EFI_PROGRESS_CODE,
- EFI_IO_BUS_USB | EFI_IOB_PC_RESET
- );
-
- UsbVirtualHcSetState (
- UsbBusController,
- EfiUsbHcStateHalt
- );
-
- //
- // Deconfiguration all its devices
- //
- Root = UsbBusController->Root;
- RootHubController = Root->UsbController[0];
-
- gBS->CloseEvent (RootHubController->HubNotify);
-
- for (Index2 = 0; Index2 < RootHubController->DownstreamPorts; Index2++) {
- if (RootHubController->Children[Index2]) {
- UsbDeviceDeConfiguration (RootHubController->Children[Index2]);
- RootHubController->Children[Index2] = NULL;
- }
- }
-
- gBS->FreePool (RootHubController);
- gBS->FreePool (Root);
-
- //
- // Uninstall USB Bus Protocol
- //
- gBS->UninstallProtocolInterface (
- Controller,
- &mUsbBusProtocolGuid,
- &UsbBusController->BusIdentify
- );
-
- //
- // Close USB_HC_PROTOCOL & DEVICE_PATH_PROTOCOL
- // Opened by this Controller
- //
- if (UsbBusController->Hc2ProtocolSupported) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- } else {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- gBS->FreePool (UsbBusController);
-
- return EFI_SUCCESS;
-}
-//
-// USB Device Configuration
-//
-STATIC
-EFI_STATUS
-UsbDeviceConfiguration (
- IN USB_IO_CONTROLLER_DEVICE *ParentHubController,
- IN EFI_HANDLE HostController,
- IN UINT8 ParentPort,
- IN USB_IO_DEVICE *UsbIoDevice
- )
-/*++
-
- Routine Description:
- Configurate a new device attached to the usb bus
-
- Arguments:
- ParentHubController - Parent Hub which this device is connected.
- HostController - Host Controller handle
- ParentPort - Parent Hub port which this device is connected.
- UsbIoDevice - The device to be configured.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
- EFI_OUT_OF_RESOURCES
-
---*/
-{
- UINT8 DevAddress;
- UINT8 Index;
- EFI_STATUS Result;
- UINT32 Status;
- CHAR16 *StrManufacturer;
- CHAR16 *StrProduct;
- CHAR16 *StrSerialNumber;
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT8 NumOfInterface;
- USB_IO_CONTROLLER_DEVICE *FirstController;
- USB_BUS_CONTROLLER_DEVICE *UsbBusDev;
- USB_IO_CONTROLLER_DEVICE *UsbIoController;
-
- UsbBusDev = UsbIoDevice->BusController;
-
- UsbSetTransactionTranslator (
- ParentHubController,
- ParentPort,
- UsbIoDevice
- );
-
- //
- // Since a USB device must have at least on interface,
- // so create this instance first
- //
- FirstController = CreateUsbIoControllerDevice ();
- FirstController->UsbDevice = UsbIoDevice;
- UsbIoDevice->UsbController[0] = FirstController;
- FirstController->InterfaceNumber = 0;
- FirstController->ParentPort = ParentPort;
- FirstController->Parent = ParentHubController;
- FirstController->HostController = HostController;
-
- InitializeUsbIoInstance (FirstController);
-
- DEBUG ((gUSBDebugLevel, "Configuration Usb Device at 0x%x...\n", ParentPort));
-
- //
- // Ensure we used the correctly USB I/O instance
- //
- UsbIo = &FirstController->UsbIo;
-
- if (UsbIoDevice->DeviceSpeed != EFI_USB_SPEED_HIGH) {
- ParentPortReset (FirstController, FALSE, 0);
- }
-
- //
- // First retrieve the 1st 8 bytes of
- // in order to get the MaxPacketSize for Endpoint 0
- //
- for (Index = 0; Index < 3; Index++) {
-
- UsbIoDevice->DeviceDescriptor.MaxPacketSize0 = 8;
-
- gBS->Stall (100 * 1000);
-
- Result = UsbGetDescriptor (
- UsbIo,
- (USB_DT_DEVICE << 8),
- 0,
- 8,
- &UsbIoDevice->DeviceDescriptor,
- &Status
- );
- if (!EFI_ERROR (Result)) {
- DEBUG (
- (gUSBDebugLevel,
- "Get Device Descriptor Success, MaxPacketSize0 = 0x%x\n",
- UsbIoDevice->DeviceDescriptor.MaxPacketSize0)
- );
- break;
- }
-
- }
-
- if (Index == 3) {
- ReportUsbStatusCode (
- UsbBusDev,
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_USB | EFI_IOB_EC_READ_ERROR
- );
- DEBUG ((gUSBErrorLevel, "Get Device Descriptor Fail when configing\n"));
- gBS->FreePool (FirstController);
- return EFI_DEVICE_ERROR;
- }
-
- DevAddress = UsbAllocateAddress (UsbIoDevice->BusController->AddressPool);
- if (DevAddress == 0) {
- DEBUG ((gUSBErrorLevel, "Cannot allocate address\n"));
- gBS->FreePool (FirstController);
- return EFI_OUT_OF_RESOURCES;
- }
-
- Result = UsbSetDeviceAddress (UsbIo, DevAddress, &Status);
-
- if (EFI_ERROR (Result)) {
- DEBUG ((gUSBErrorLevel, "Set address error\n"));
- ReportUsbStatusCode (
- UsbBusDev,
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_USB | EFI_IOB_EC_WRITE_ERROR
- );
-
- UsbFreeAddress (
- DevAddress,
- UsbIoDevice->BusController->AddressPool
- );
-
- gBS->FreePool (FirstController);
- return EFI_DEVICE_ERROR;
- }
-
- UsbIoDevice->DeviceAddress = DevAddress;
-
- //
- // SetAddress Complete Time by Spec, Max 50ms
- //
- gBS->Stall (10 * 1000);
-
- //
- // Get the whole device descriptor
- //
- Result = UsbGetDescriptor (
- UsbIo,
- (USB_DT_DEVICE << 8),
- 0,
- sizeof (EFI_USB_DEVICE_DESCRIPTOR),
- &UsbIoDevice->DeviceDescriptor,
- &Status
- );
-
- if (EFI_ERROR (Result)) {
- DEBUG ((gUSBErrorLevel, "Get whole Device Descriptor error\n"));
- ReportUsbStatusCode (
- UsbBusDev,
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_USB | EFI_IOB_EC_READ_ERROR
- );
- UsbFreeAddress (
- DevAddress,
- UsbIoDevice->BusController->AddressPool
- );
-
- gBS->FreePool (FirstController);
- return EFI_DEVICE_ERROR;
- }
- //
- // Get & parse all configurations for this device, including
- // all configuration descriptors, all interface descriptors, all
- // endpoint descriptors
- //
- Result = UsbGetAllConfigurations (UsbIoDevice);
-
- if (EFI_ERROR (Result)) {
- DEBUG ((gUSBErrorLevel, "Failed to get device configuration\n"));
- ReportUsbStatusCode (
- UsbBusDev,
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_USB | EFI_IOB_EC_READ_ERROR
- );
- UsbFreeAddress (
- DevAddress,
- UsbIoDevice->BusController->AddressPool
- );
-
- gBS->FreePool (FirstController);
- return EFI_DEVICE_ERROR;
- }
- //
- // Set the 1st configuration value
- //
- Result = UsbSetDefaultConfiguration (UsbIoDevice);
- if (EFI_ERROR (Result)) {
- DEBUG ((gUSBErrorLevel, "Failed to set device configuration\n"));
- ReportUsbStatusCode (
- UsbBusDev,
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_USB | EFI_IOB_EC_WRITE_ERROR
- );
- UsbFreeAddress (
- DevAddress,
- UsbIoDevice->BusController->AddressPool
- );
-
- gBS->FreePool (FirstController);
- return EFI_DEVICE_ERROR;
- }
-
- UsbIoDevice->IsConfigured = TRUE;
-
- //
- // Get all string table if applicable
- //
- Result = UsbGetStringtable (UsbIoDevice);
- if (EFI_ERROR (Result)) {
- DEBUG ((gUSBDebugLevel, "Device doesn't support string table\n"));
- } else {
-
- StrManufacturer = NULL;
- UsbIo->UsbGetStringDescriptor (
- UsbIo,
- UsbIoDevice->LangID[0],
- (UsbIoDevice->DeviceDescriptor).StrManufacturer,
- &StrManufacturer
- );
-
- StrProduct = NULL;
- UsbIo->UsbGetStringDescriptor (
- UsbIo,
- UsbIoDevice->LangID[0],
- (UsbIoDevice->DeviceDescriptor).StrProduct,
- &StrProduct
- );
-
- StrSerialNumber = NULL;
- UsbIo->UsbGetStringDescriptor (
- UsbIo,
- UsbIoDevice->LangID[0],
- (UsbIoDevice->DeviceDescriptor).StrSerialNumber,
- &StrSerialNumber
- );
-
- if (StrManufacturer) {
- gBS->FreePool (StrManufacturer);
- }
-
- if (StrProduct) {
- gBS->FreePool (StrProduct);
- }
-
- if (StrSerialNumber) {
- gBS->FreePool (StrSerialNumber);
- }
- }
- //
- // Create USB_IO_CONTROLLER_DEVICE for
- // each detected interface
- //
- FirstController->CurrentConfigValue =
- UsbIoDevice->ActiveConfig->CongfigDescriptor.ConfigurationValue;
-
- NumOfInterface =
- UsbIoDevice->ActiveConfig->CongfigDescriptor.NumInterfaces;
- UsbIoDevice->NumOfControllers = NumOfInterface;
-
- Result = InitUsbIoController (FirstController);
- if (EFI_ERROR (Result)) {
- ReportUsbStatusCode (
- UsbBusDev,
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_USB | EFI_IOB_EC_INTERFACE_ERROR
- );
- gBS->FreePool (FirstController);
- UsbIoDevice->UsbController[0] = NULL;
- return EFI_DEVICE_ERROR;
- }
-
- for (Index = 1; Index < NumOfInterface; Index++) {
- UsbIoController = CreateUsbIoControllerDevice ();
- UsbIoController->UsbDevice = UsbIoDevice;
- UsbIoController->CurrentConfigValue =
- UsbIoDevice->ActiveConfig->CongfigDescriptor.ConfigurationValue;
- UsbIoController->InterfaceNumber = Index;
- UsbIoDevice->UsbController[Index] = UsbIoController;
- UsbIoController->ParentPort = ParentPort;
- UsbIoController->Parent = ParentHubController;
- UsbIoController->HostController = HostController;
-
- //
- // First copy the USB_IO Protocol instance
- //
- CopyMem (
- &UsbIoController->UsbIo,
- UsbIo,
- sizeof (EFI_USB_IO_PROTOCOL)
- );
-
- Result = InitUsbIoController (UsbIoController);
- if (EFI_ERROR (Result)) {
- ReportUsbStatusCode (
- UsbBusDev,
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_USB | EFI_IOB_EC_INTERFACE_ERROR
- );
- gBS->FreePool (UsbIoController);
- UsbIoDevice->UsbController[Index] = NULL;
- }
- }
-
- return EFI_SUCCESS;
-}
-//
-// USB Device DeConfiguration
-//
-EFI_STATUS
-UsbDeviceDeConfiguration (
- IN USB_IO_DEVICE *UsbIoDevice
- )
-/*++
-
- Routine Description:
- Remove Device, Device Handles, Uninstall Protocols.
-
- Arguments:
- UsbIoDevice - The device to be deconfigured.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- USB_IO_CONTROLLER_DEVICE *UsbController;
- UINT8 index;
- USB_IO_DEVICE *ChildDevice;
- UINT8 Index;
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_STATUS Status;
-
- //
- // Double check UsbIoDevice exists
- //
- if (UsbIoDevice == NULL) {
- return EFI_SUCCESS;
- }
-
- UsbUnsetTransactionTranslator (UsbIoDevice);
-
- for (index = 0; index < UsbIoDevice->NumOfControllers; index++) {
- //
- // Check if it is a hub, if so, de configuration all its
- // downstream ports
- //
- UsbController = UsbIoDevice->UsbController[index];
-
- //
- // Check the controller pointer
- //
- if (UsbController == NULL) {
- continue;
- }
-
- if (UsbController->IsUsbHub) {
-
- DEBUG ((gUSBDebugLevel, "Hub Deconfig, First Deconfig its downstream ports\n"));
-
- //
- // First Remove interrupt transfer request for the status
- // change port
- //
- UsbIo = &UsbController->UsbIo;
- UsbIo->UsbAsyncInterruptTransfer (
- UsbIo,
- UsbController->HubEndpointAddress,
- FALSE,
- 0,
- 0,
- NULL,
- NULL
- );
-
- if (NULL != UsbController->HubNotify) {
- gBS->CloseEvent (UsbController->HubNotify);
- }
-
- for (Index = 0; Index < UsbController->DownstreamPorts; Index++) {
- if (UsbController->Children[Index]) {
- ChildDevice = UsbController->Children[Index];
- UsbDeviceDeConfiguration (ChildDevice);
- UsbController->Children[Index] = NULL;
- }
- }
- }
- //
- // If the controller is managed by a device driver, we need to
- // disconnect them
- //
- if (UsbController->IsManagedByDriver) {
- gBS->DisconnectController (
- UsbController->Handle,
- NULL,
- NULL
- );
- }
-
- //
- // remove child handle reference to the USB_HC_PROTOCOL
- //
- if (UsbIoDevice->BusController->Hc2ProtocolSupported) {
- gBS->CloseProtocol (
- UsbController->HostController,
- &gEfiUsb2HcProtocolGuid,
- gUsbBusDriverBinding.DriverBindingHandle,
- UsbController->Handle
- );
- } else {
- gBS->CloseProtocol (
- UsbController->HostController,
- &gEfiUsbHcProtocolGuid,
- gUsbBusDriverBinding.DriverBindingHandle,
- UsbController->Handle
- );
- }
- //
- // Uninstall EFI_USB_IO_PROTOCOL & DEVICE_PATH_PROTOCOL
- // installed on this handle
- //
- Status = gBS->UninstallMultipleProtocolInterfaces (
- UsbController->Handle,
- &gEfiDevicePathProtocolGuid,
- UsbController->DevicePath,
- &gEfiUsbIoProtocolGuid,
- &UsbController->UsbIo,
- NULL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (UsbController->DevicePath != NULL) {
- gBS->FreePool (UsbController->DevicePath);
- }
-
- gBS->FreePool (UsbController);
- UsbIoDevice->UsbController[index] = NULL;
- }
- //
- // Free address for later use
- //
- UsbFreeAddress (
- UsbIoDevice->DeviceAddress,
- UsbIoDevice->BusController->AddressPool
- );
-
- //
- // Free all resouces allocated for all its configurations
- //
- UsbDestroyAllConfiguration (UsbIoDevice);
-
- if (UsbIoDevice) {
- gBS->FreePool (UsbIoDevice);
- UsbIoDevice = NULL;
- }
-
- return EFI_SUCCESS;
-}
-//
-// After interrupt complete, this function will be called,
-// This function need to be well-defined later
-//
-STATIC
-EFI_STATUS
-EFIAPI
-OnHubInterruptComplete (
- IN VOID *Data,
- IN UINTN DataLength,
- IN VOID *Context,
- IN UINT32 Result
- )
-/*++
-
- Routine Description:
- Whenever hub interrupt occurs, this routine will be called to check
- which event happens.
-
- Arguments:
- Data - Hub interrupt transfer data.
- DataLength - The length of the Data.
- Context - Hub Controller Device.
- Result - Hub interrupt transfer status.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- USB_IO_CONTROLLER_DEVICE *HubController;
- UINT8 Index;
- UINT8 *ptr;
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT32 UsbResult;
- BOOLEAN Disconnected;
- EFI_STATUS Status;
-
- HubController = (USB_IO_CONTROLLER_DEVICE *) Context;
- UsbIo = &HubController->UsbIo;
-
- //
- // If something error in this interrupt transfer,
- //
- if (Result != EFI_USB_NOERROR) {
- if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
- UsbClearEndpointHalt (
- UsbIo,
- HubController->HubEndpointAddress,
- &UsbResult
- );
- }
-
- //
- // Delete & Submit this interrupt again
- //
- UsbIo->UsbAsyncInterruptTransfer (
- UsbIo,
- HubController->HubEndpointAddress,
- FALSE,
- 0,
- 0,
- NULL,
- NULL
- );
-
- //
- // try to detect if the hub itself was disconnected or not
- //
- Status = IsDeviceDisconnected (
- HubController,
- &Disconnected
- );
-
- if (!EFI_ERROR (Status) && Disconnected == TRUE) {
- DEBUG ((gUSBErrorLevel, "Hub is disconnected\n"));
- return EFI_DEVICE_ERROR;
- }
- //
- // Hub ports < 7
- //
- UsbIo->UsbAsyncInterruptTransfer (
- UsbIo,
- HubController->HubEndpointAddress,
- TRUE,
- 100,
- 1,
- OnHubInterruptComplete,
- HubController
- );
-
- return EFI_DEVICE_ERROR;
- }
-
- if (DataLength == 0 || Data == NULL) {
- return EFI_SUCCESS;
- }
-
- //
- // Scan which port has status change
- // Bit 0 stands for hub itself, other bit stands for
- // the corresponding port
- //
- for (Index = 0; Index < DataLength * 8; Index++) {
- ptr = (UINT8 *) Data + Index / 8;
- if ((*ptr) & (1 << (Index & 0x7))) {
- HubController->StatusChangePort = Index;
- break;
- }
- }
- //
- // Signal hub notify event
- //
- gBS->SignalEvent (HubController->HubNotify);
-
- return EFI_SUCCESS;
-}
-//
-// USB Root Hub Enumerator
-//
-STATIC
-VOID
-EFIAPI
-RootHubEnumeration (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-/*++
-
- Routine Description:
-
- This is USB RootHub enumerator
-
- Arguments:
-
- Event - Indicating which event is signaled
- Context - actually it is a USB_IO_DEVICE
-
- Returns:
-
- VOID
-
---*/
-{
- USB_IO_CONTROLLER_DEVICE *HubController;
- EFI_USB_PORT_STATUS HubPortStatus;
- EFI_STATUS Status;
- UINT8 Index;
- USB_IO_DEVICE *UsbIoDev;
- USB_BUS_CONTROLLER_DEVICE *UsbBusDev;
- EFI_HANDLE HostController;
- USB_IO_DEVICE *OldUsbIoDevice;
- USB_IO_DEVICE *NewDevice;
- USB_IO_CONTROLLER_DEVICE *NewController;
- UINT8 Index2;
- EFI_USB_IO_PROTOCOL *UsbIo;
-
- HubController = (USB_IO_CONTROLLER_DEVICE *) Context;
- HostController = HubController->HostController;
- UsbBusDev = HubController->UsbDevice->BusController;
-
- //
- // Root hub has the address 1
- //
- UsbIoDev = HubController->UsbDevice;
-
- for (Index = 0; Index < HubController->DownstreamPorts; Index++) {
-
- UsbVirtualHcGetRootHubPortStatus (
- UsbBusDev,
- Index,
- (EFI_USB_PORT_STATUS *) &HubPortStatus
- );
-
- if (!IsPortConnectChange (HubPortStatus.PortChangeStatus)) {
- continue;
- }
- //
- // Clear root hub status change status
- //
- UsbVirtualHcClearRootHubPortFeature (
- UsbBusDev,
- Index,
- EfiUsbPortConnectChange
- );
-
- gBS->Stall (100 * 1000);
-
- UsbVirtualHcGetRootHubPortStatus (
- UsbBusDev,
- Index,
- (EFI_USB_PORT_STATUS *) &HubPortStatus
- );
-
- if (IsPortConnect (HubPortStatus.PortStatus)) {
-
- //
- // There is something connected to this port
- //
- DEBUG ((gUSBDebugLevel, "Something connected to Root Hub at Port0x%x\n", Index));
-
- ReportUsbStatusCode (
- UsbBusDev,
- EFI_PROGRESS_CODE,
- EFI_IO_BUS_USB | EFI_IOB_PC_HOTPLUG
- );
- //
- // if there is something physically detached, but still logically
- // attached...
- //
- OldUsbIoDevice = HubController->Children[Index];
-
- if (NULL != OldUsbIoDevice) {
- UsbDeviceDeConfiguration (OldUsbIoDevice);
- HubController->Children[Index] = NULL;
- }
-
- NewDevice = AllocateZeroPool (sizeof (USB_IO_DEVICE));
- if (NewDevice == NULL) {
- return ;
- }
- //
- // Initialize some fields by copying data from
- // its parents
- //
- NewDevice->DeviceDescriptor.MaxPacketSize0 = 8;
- NewDevice->BusController = UsbIoDev->BusController;
-
- //
- // Process of identify device speed
- //
- Status = IdentifyDeviceSpeed (
- UsbBusDev,
- NewDevice,
- Index
- );
- if (EFI_ERROR (Status)) {
- gBS->FreePool (NewDevice);
- continue;
- }
-
- //
- // Configure that device
- //
- Status = UsbDeviceConfiguration (
- HubController,
- HostController,
- Index,
- NewDevice
- );
- if (EFI_ERROR (Status)) {
- gBS->FreePool (NewDevice);
- return ;
- }
- //
- // Add this device to the usb bus tree
- //
- HubController->Children[Index] = NewDevice;
-
- for (Index2 = 0; Index2 < NewDevice->NumOfControllers; Index2++) {
- //
- // If this device is hub, add to the hub index
- //
- NewController = NewDevice->UsbController[Index2];
-
- Status = gBS->ConnectController (
- NewController->Handle,
- NULL,
- NULL,
- TRUE
- );
- //
- // If connect success, we need to disconnect when
- // stop the controller, otherwise we need not call
- // gBS->DisconnectController ()
- // This is used by those usb devices we don't plan
- // to support. We can allocate
- // controller handles for them, but we don't have
- // device drivers to manage them.
- //
- NewController->IsManagedByDriver = (BOOLEAN) (!EFI_ERROR (Status));
-
- if (IsHub (NewController)) {
-
- NewController->IsUsbHub = TRUE;
-
- //
- // Configure Hub Controller
- //
- Status = DoHubConfig (NewController);
- if (EFI_ERROR (Status)) {
- continue;
- }
- //
- // Create an event to do hub enumeration
- //
- gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- HubEnumeration,
- NewController,
- &NewController->HubNotify
- );
-
- //
- // Add request to do query hub status
- // change endpoint
- // Hub ports < 7
- //
- UsbIo = &NewController->UsbIo;
- UsbIo->UsbAsyncInterruptTransfer (
- UsbIo,
- NewController->HubEndpointAddress,
- TRUE,
- 100,
- 1,
- OnHubInterruptComplete,
- NewController
- );
-
- }
- }
- } else {
- //
- // Something disconnected from USB root hub
- //
- DEBUG ((gUSBDebugLevel, "Something disconnected from Root Hub at Port0x%x\n", Index));
-
- OldUsbIoDevice = HubController->Children[Index];
-
- UsbDeviceDeConfiguration (OldUsbIoDevice);
-
- HubController->Children[Index] = NULL;
-
- UsbVirtualHcClearRootHubPortFeature (
- UsbBusDev,
- Index,
- EfiUsbPortEnableChange
- );
- }
- }
-
- return ;
-}
-//
-// USB Root Hub Enumerator
-//
-STATIC
-VOID
-EFIAPI
-HubEnumeration (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-/*++
-
- Routine Description:
-
- This is Usb Hub enumerator
-
- Arguments:
-
- Event - Indicating which event is signaled
- Context - actually it is a USB_IO_DEVICE
-
- Returns:
-
- VOID
-
---*/
-{
- USB_IO_CONTROLLER_DEVICE *HubController;
- EFI_USB_PORT_STATUS HubPortStatus;
- EFI_STATUS Status;
- USB_BUS_CONTROLLER_DEVICE *UsbBusDev;
- EFI_HANDLE HostController;
- USB_IO_DEVICE *OldUsbIoDevice;
- USB_IO_DEVICE *NewDevice;
- USB_IO_CONTROLLER_DEVICE *NewController;
- UINT8 Index2;
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT8 StatusChangePort;
- UINT8 Number;
-
- HubController = (USB_IO_CONTROLLER_DEVICE *) Context;
- HostController = HubController->HostController;
- UsbBusDev = HubController->UsbDevice->BusController;
-
- //
- // Event from Hub, Get the hub controller handle
- //
- //
- // Get the status change endpoint
- //
- StatusChangePort = HubController->StatusChangePort;
-
- //
- // Clear HubController Status Change Bit
- //
- HubController->StatusChangePort = 0;
-
- if (StatusChangePort == 0) {
- //
- // Hub changes, we don't handle here
- //
- return ;
- }
- //
- // Check which event took place at that port
- //
- UsbIo = &HubController->UsbIo;
- Status = HubGetPortStatus (
- UsbIo,
- StatusChangePort,
- (UINT32 *) &HubPortStatus
- );
-
- if (EFI_ERROR (Status)) {
- return ;
- }
- //
- // Clear some change status
- //
- if (HubPortStatus.PortChangeStatus & USB_PORT_STAT_C_ENABLE) {
- //
- // Clear Hub port enable change
- //
- DEBUG ((gUSBDebugLevel, "Port Enable Change\n"));
- HubClearPortFeature (
- UsbIo,
- StatusChangePort,
- EfiUsbPortEnableChange
- );
-
- HubGetPortStatus (
- UsbIo,
- StatusChangePort,
- (UINT32 *) &HubPortStatus
- );
- }
-
- if (HubPortStatus.PortChangeStatus & USB_PORT_STAT_C_RESET) {
- //
- // Clear Hub reset change
- //
- DEBUG ((gUSBDebugLevel, "Port Reset Change\n"));
- HubClearPortFeature (
- UsbIo,
- StatusChangePort,
- EfiUsbPortResetChange
- );
-
- HubGetPortStatus (
- UsbIo,
- StatusChangePort,
- (UINT32 *) &HubPortStatus
- );
- }
-
- if (HubPortStatus.PortChangeStatus & USB_PORT_STAT_C_OVERCURRENT) {
- //
- // Clear Hub overcurrent change
- //
- DEBUG ((gUSBDebugLevel, "Port Overcurrent Change\n"));
- HubClearPortFeature (
- UsbIo,
- StatusChangePort,
- EfiUsbPortOverCurrentChange
- );
-
- HubGetPortStatus (
- UsbIo,
- StatusChangePort,
- (UINT32 *) &HubPortStatus
- );
- }
-
- if (IsPortConnectChange (HubPortStatus.PortChangeStatus)) {
- //
- // First clear port connection change
- //
- DEBUG ((gUSBDebugLevel, "Port Connection Change\n"));
- HubClearPortFeature (
- UsbIo,
- StatusChangePort,
- EfiUsbPortConnectChange
- );
-
- HubGetPortStatus (
- UsbIo,
- StatusChangePort,
- (UINT32 *) &HubPortStatus
- );
-
- if (IsPortConnect (HubPortStatus.PortStatus)) {
-
- DEBUG ((gUSBDebugLevel, "New Device Connect on Hub port \n"));
-
- ReportUsbStatusCode (
- UsbBusDev,
- EFI_PROGRESS_CODE,
- EFI_IO_BUS_USB | EFI_IOB_PC_HOTPLUG
- );
-
- //
- // if there is something physically detached, but still logically
- // attached...
- //
- OldUsbIoDevice = HubController->Children[StatusChangePort - 1];
-
- if (NULL != OldUsbIoDevice) {
- UsbDeviceDeConfiguration (OldUsbIoDevice);
- HubController->Children[StatusChangePort - 1] = NULL;
- }
-
- NewDevice = AllocateZeroPool (sizeof (USB_IO_DEVICE));
- if (NewDevice == NULL) {
- return ;
- }
- //
- // Initialize some fields
- //
- NewDevice->DeviceDescriptor.MaxPacketSize0 = 8;
- NewDevice->BusController = HubController->UsbDevice->BusController;
-
- //
- // There is something connected to this port,
- // reset that port
- //
- // Disable the enable bit in port status
- //
- HubClearPortFeature (
- UsbIo,
- StatusChangePort,
- EfiUsbPortEnable
- );
-
- gBS->Stall (50 * 1000);
-
- //
- // Wait for bit change
- //
- Number = 10;
- do {
- HubGetPortStatus (
- UsbIo,
- StatusChangePort,
- (UINT32 *) &HubPortStatus
- );
- gBS->Stall (10 * 1000);
- Number -= 1;
- } while ((HubPortStatus.PortStatus & USB_PORT_STAT_ENABLE) == 1 && Number > 0);
-
- if (Number == 0) {
- //
- // Cannot disable port, return error
- //
- DEBUG ((gUSBErrorLevel, "Disable Port Failed\n"));
- gBS->FreePool (NewDevice);
- return ;
- }
-
- HubSetPortFeature (
- UsbIo,
- StatusChangePort,
- EfiUsbPortReset
- );
-
- gBS->Stall (50 * 1000);
-
- //
- // Wait for port reset complete
- //
- Number = 10;
- do {
- HubGetPortStatus (
- UsbIo,
- StatusChangePort,
- (UINT32 *) &HubPortStatus
- );
- gBS->Stall (10 * 1000);
- Number -= 1;
- } while ((HubPortStatus.PortStatus & USB_PORT_STAT_RESET) == 1 && Number > 0);
-
- if (Number == 0) {
- //
- // Cannot reset port, return error
- //
- DEBUG ((gUSBErrorLevel, "Reset Port Failed\n"));
- gBS->FreePool (NewDevice);
- return ;
- }
- //
- // Check high speed or full speed device
- //
- if (HubPortStatus.PortStatus & USB_PORT_STAT_LOW_SPEED) {
- DEBUG ((gUSBDebugLevel, "Low Speed Device Attached to Hub\n"));
- NewDevice->DeviceSpeed = EFI_USB_SPEED_LOW;
- } else if (HubPortStatus.PortStatus & USB_PORT_STAT_HIGH_SPEED) {
- DEBUG ((gUSBDebugLevel, "High Speed Device Attached to Hub\n"));
- NewDevice->DeviceSpeed = EFI_USB_SPEED_HIGH;
- } else {
- DEBUG ((gUSBDebugLevel, "Full Speed Device Attached to Hub\n"));
- NewDevice->DeviceSpeed = EFI_USB_SPEED_FULL;
- }
- //
- // Configure that device
- //
- Status = UsbDeviceConfiguration (
- HubController,
- HostController,
- (UINT8) (StatusChangePort - 1),
- NewDevice
- );
-
- if (EFI_ERROR (Status)) {
- gBS->FreePool (NewDevice);
- return ;
- }
- //
- // Add this device to the usb bus tree
- // StatusChangePort is begin from 1,
- //
- HubController->Children[StatusChangePort - 1] = NewDevice;
-
- for (Index2 = 0; Index2 < NewDevice->NumOfControllers; Index2++) {
- //
- // If this device is hub, add to the hub index
- //
- NewController = NewDevice->UsbController[Index2];
-
- //
- // Connect the controller to the driver image
- //
- Status = gBS->ConnectController (
- NewController->Handle,
- NULL,
- NULL,
- TRUE
- );
- //
- // If connect success, we need to disconnect when
- // stop the controller, otherwise we need not call
- // gBS->DisconnectController ()
- // This is used by those usb devices we don't plan
- // to support. We can allocate
- // controller handles for them, but we don't have
- // device drivers to manage them.
- //
- NewController->IsManagedByDriver = (BOOLEAN) (!EFI_ERROR (Status));
-
- //
- // If this device is hub, add to the hub index
- //
- if (IsHub (NewController)) {
-
- NewController->IsUsbHub = TRUE;
-
- //
- // Configure Hub
- //
- Status = DoHubConfig (NewController);
-
- if (EFI_ERROR (Status)) {
- continue;
- }
- //
- // Create an event to do hub enumeration
- //
- gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- HubEnumeration,
- NewController,
- &NewController->HubNotify
- );
-
- //
- // Add request to do query hub status
- // change endpoint
- //
- UsbIo = &NewController->UsbIo;
- UsbIo->UsbAsyncInterruptTransfer (
- UsbIo,
- NewController->HubEndpointAddress, // Hub endpoint address
- TRUE,
- 100,
- 1, // Hub ports < 7
- OnHubInterruptComplete,
- NewController
- );
- }
- }
- } else {
- //
- // Something disconnected from USB hub
- //
- DEBUG ((gUSBDebugLevel, "Something Device Detached on Hub port\n"));
-
- OldUsbIoDevice = HubController->Children[StatusChangePort - 1];
-
- UsbDeviceDeConfiguration (OldUsbIoDevice);
-
- HubController->Children[StatusChangePort - 1] = NULL;
-
- }
-
- return ;
- }
-
- return ;
-}
-
-STATIC
-USB_IO_CONTROLLER_DEVICE *
-CreateUsbIoControllerDevice (
- VOID
- )
-/*++
-
- Routine Description:
- Allocate a structure for USB_IO_CONTROLLER_DEVICE
-
- Arguments:
- N/A
-
- Returns:
- A pointer to a USB_IO_CONTROLLER_DEVICE structure,
- Or NULL.
-
---*/
-{
- USB_IO_CONTROLLER_DEVICE *UsbIoControllerDev;
-
- //
- // Allocate USB_IO_CONTROLLER_DEVICE structure
- //
- UsbIoControllerDev = NULL;
- UsbIoControllerDev = AllocateZeroPool (sizeof (USB_IO_CONTROLLER_DEVICE));
-
- if (UsbIoControllerDev == NULL) {
- return NULL;
- }
-
- UsbIoControllerDev->Signature = USB_IO_CONTROLLER_SIGNATURE;
-
- return UsbIoControllerDev;
-}
-
-STATIC
-EFI_STATUS
-InitUsbIoController (
- IN USB_IO_CONTROLLER_DEVICE *UsbIoController
- )
-/*++
-
- Routine Description:
- Init and install EFI_USB_IO_PROTOCOL onto that controller.
-
- Arguments:
- UsbIoController - The Controller to be operated.
-
- Returns:
- EFI_SUCCESS
- Others
-
---*/
-{
- USB_DEVICE_PATH UsbNode;
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_USB_HC_PROTOCOL *UsbHcProtocol;
- EFI_USB2_HC_PROTOCOL *Usb2HcProtocol;
-
- //
- // Build the child device path for each new USB_IO device
- //
- ZeroMem (&UsbNode, sizeof (UsbNode));
- UsbNode.Header.Type = MESSAGING_DEVICE_PATH;
- UsbNode.Header.SubType = MSG_USB_DP;
- SetDevicePathNodeLength (&UsbNode.Header, sizeof (UsbNode));
- UsbNode.InterfaceNumber = UsbIoController->InterfaceNumber;
- UsbNode.ParentPortNumber = UsbIoController->ParentPort;
- ParentDevicePath = UsbIoController->Parent->DevicePath;
-
- UsbIoController->DevicePath =
- AppendDevicePathNode (ParentDevicePath, &UsbNode.Header);
- if (UsbIoController->DevicePath == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &UsbIoController->Handle,
- &gEfiDevicePathProtocolGuid,
- UsbIoController->DevicePath,
- &gEfiUsbIoProtocolGuid,
- &UsbIoController->UsbIo,
- NULL
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (UsbIoController->UsbDevice->BusController->Hc2ProtocolSupported) {
- Status = gBS->OpenProtocol (
- UsbIoController->HostController,
- &gEfiUsb2HcProtocolGuid,
- (VOID **)&Usb2HcProtocol,
- gUsbBusDriverBinding.DriverBindingHandle,
- UsbIoController->Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
- } else {
- Status = gBS->OpenProtocol (
- UsbIoController->HostController,
- &gEfiUsbHcProtocolGuid,
- (VOID **)&UsbHcProtocol,
- gUsbBusDriverBinding.DriverBindingHandle,
- UsbIoController->Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
- }
-
- return Status;
-}
-
-STATIC
-EFI_STATUS
-ParentPortReset (
- IN USB_IO_CONTROLLER_DEVICE *UsbIoController,
- IN BOOLEAN ReConfigure,
- IN UINT8 RetryTimes
- )
-/*++
-
- Routine Description:
- Reset parent hub port to which this device is connected.
-
- Arguments:
- UsbIoController - Indicating the Usb Controller Device.
- ReConfigure - Do we need to reconfigure it.
- RetryTimes - Retry Times when failed
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- USB_IO_DEVICE *ParentIoDev;
- USB_IO_DEVICE *UsbIoDev;
- USB_IO_CONTROLLER_DEVICE *ParentController;
- UINT8 HubPort;
- UINT32 Status;
- EFI_STATUS Result;
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT8 Address;
-
- ParentController = UsbIoController->Parent;
- ParentIoDev = ParentController->UsbDevice;
- UsbIoDev = UsbIoController->UsbDevice;
- HubPort = UsbIoController->ParentPort;
-
- gBS->Stall (100 * 1000);
-
- if (ParentIoDev->DeviceAddress == 1) {
- DEBUG ((gUSBDebugLevel, "Reset from Root Hub 0x%x\n", HubPort));
- ResetRootPort (ParentIoDev->BusController, HubPort, RetryTimes);
- } else {
- DEBUG ((gUSBDebugLevel, "Reset from Hub, Addr 0x%x\n", ParentIoDev->DeviceAddress));
- ResetHubPort (ParentController, (UINT8) (HubPort + 1));
- }
- //
- // If we only need port reset, just return
- //
- if (!ReConfigure) {
- return EFI_SUCCESS;
- }
- //
- // Re-config that USB device
- //
- UsbIo = &UsbIoController->UsbIo;
-
- //
- // Assign a unique address to this device
- //
- Address = UsbIoDev->DeviceAddress;
- UsbIoDev->DeviceAddress = 0;
-
- Result = UsbSetDeviceAddress (UsbIo, Address, &Status);
- UsbIoDev->DeviceAddress = Address;
-
- if (EFI_ERROR (Result)) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Set the device to the default configuration
- //
- Result = UsbSetDefaultConfiguration (UsbIoDev);
- if (EFI_ERROR (Result)) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-UsbPortReset (
- IN EFI_USB_IO_PROTOCOL *This
- )
-/*++
-
- Routine Description:
- Resets and reconfigures the USB controller. This function will
- work for all USB devices except USB Hub Controllers.
-
- Arguments:
- This - Indicates the calling context.
-
- Returns:
- EFI_SUCCESS
- EFI_INVALID_PARAMETER
- EFI_DEVICE_ERROR
-
---*/
-{
- USB_IO_CONTROLLER_DEVICE *UsbIoController;
-
- UsbIoController = USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This);
-
- if (IsHub (UsbIoController)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Since at this time, this device has already been configured,
- // it needs to be re-configured.
- //
- return ParentPortReset (UsbIoController, TRUE, 0);
-}
-
-STATIC
-EFI_STATUS
-ResetRootPort (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 PortNum,
- IN UINT8 RetryTimes
- )
-/*++
-
- Routine Description:
- Reset Root Hub port.
-
- Arguments:
- UsbBusDev - Bus controller of the device.
- PortNum - The given port to be reset.
- RetryTimes - RetryTimes when failed
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- EFI_STATUS Status;
- EFI_USB_PORT_STATUS PortStatus;
-
- //
- // reset root port
- //
- Status = UsbVirtualHcSetRootHubPortFeature (
- UsbBusDev,
- PortNum,
- EfiUsbPortReset
- );
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- gBS->Stall (50 * 1000);
-
- //
- // clear reset root port
- //
- Status = UsbVirtualHcClearRootHubPortFeature (
- UsbBusDev,
- PortNum,
- EfiUsbPortReset
- );
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- gBS->Stall (1000);
-
- Status = UsbVirtualHcClearRootHubPortFeature (
- UsbBusDev,
- PortNum,
- EfiUsbPortConnectChange
- );
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- UsbVirtualHcGetRootHubPortStatus (
- UsbBusDev,
- PortNum,
- &PortStatus
- );
- if (PortStatus.PortStatus & USB_PORT_STAT_OWNER) {
- //
- // Set port enable
- //
- Status = UsbVirtualHcSetRootHubPortFeature (
- UsbBusDev,
- PortNum,
- EfiUsbPortEnable
- );
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- Status = UsbVirtualHcClearRootHubPortFeature (
- UsbBusDev,
- PortNum,
- EfiUsbPortEnableChange
- );
- }
-
- gBS->Stall ((1 + RetryTimes) * 50 * 1000);
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-ResetHubPort (
- IN USB_IO_CONTROLLER_DEVICE *UsbIoController,
- IN UINT8 PortIndex
- )
-/*++
-
- Routine Description:
- Reset Hub port.
-
- Arguments:
- UsbIoController - The USB_IO_CONTROLLER_DEVICE instance.
- PortIndex - The given port to be reset.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_USB_PORT_STATUS HubPortStatus;
- UINT8 Number;
-
- ASSERT (UsbIoController->IsUsbHub == TRUE);
-
- UsbIo = &UsbIoController->UsbIo;
-
- HubSetPortFeature (
- UsbIo,
- PortIndex,
- EfiUsbPortReset
- );
-
- gBS->Stall (10 * 1000);
-
- //
- // Wait for port reset complete
- //
- Number = 10;
- do {
- HubGetPortStatus (
- UsbIo,
- PortIndex,
- (UINT32 *) &HubPortStatus
- );
- gBS->Stall (10 * 100);
- Number -= 1;
- } while ((HubPortStatus.PortChangeStatus & USB_PORT_STAT_C_RESET) == 0 && Number > 0);
-
- if (Number == 0) {
- //
- // Cannot reset port, return error
- //
- return EFI_DEVICE_ERROR;
- }
-
- gBS->Stall (1000);
-
- HubGetPortStatus (
- UsbIo,
- PortIndex,
- (UINT32 *) &HubPortStatus
- );
- //
- // reset port will cause some bits change, clear them
- //
- if (HubPortStatus.PortChangeStatus & USB_PORT_STAT_C_ENABLE) {
- DEBUG ((gUSBDebugLevel, "Port Enable Change\n"));
- HubClearPortFeature (
- UsbIo,
- PortIndex,
- EfiUsbPortEnableChange
- );
- }
-
- if (HubPortStatus.PortChangeStatus & USB_PORT_STAT_C_RESET) {
- DEBUG ((gUSBDebugLevel, "Port Reset Change\n"));
- HubClearPortFeature (
- UsbIo,
- PortIndex,
- EfiUsbPortResetChange
- );
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-ReportUsbStatusCode (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusController,
- IN EFI_STATUS_CODE_TYPE Type,
- IN EFI_STATUS_CODE_VALUE Code
- )
-/*++
-
-Routine Description:
-
- report a error Status code of USB bus driver controller
-
- Arguments:
- UsbBusController - USB_BUS_CONTROLLER_DEVICE
- Type - EFI_STATUS_CODE_TYPE
- Code - EFI_STATUS_CODE_VALUE
- Returns:
-
- None
-
---*/
-{
- return REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- Type,
- Code,
- UsbBusController->DevicePath
- );
-}
-
-EFI_STATUS
-IsDeviceDisconnected (
- IN USB_IO_CONTROLLER_DEVICE *UsbIoController,
- IN OUT BOOLEAN *Disconnected
- )
-/*++
-
- Routine Description:
- Reset if the device is disconencted or not
-
- Arguments:
- UsbIoController - Indicating the Usb Controller Device.
- Disconnected - Indicate whether the device is disconencted or not
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-{
- USB_IO_DEVICE *ParentIoDev;
- USB_IO_CONTROLLER_DEVICE *ParentController;
- UINT8 HubPort;
- EFI_STATUS Status;
- EFI_USB_PORT_STATUS PortStatus;
-
- ParentController = UsbIoController->Parent;
- ParentIoDev = ParentController->UsbDevice;
- HubPort = UsbIoController->ParentPort;
-
- if (ParentIoDev->DeviceAddress == 1) {
- //
- // Connected to the root hub
- //
- UsbVirtualHcGetRootHubPortStatus (
- ParentIoDev->BusController,
- HubPort,
- &PortStatus
- );
-
- } else {
- Status = HubGetPortStatus (
- &ParentController->UsbIo,
- (UINT8) (HubPort + 1),
- (UINT32 *) &PortStatus
- );
-
- if (EFI_ERROR (Status)) {
- return IsDeviceDisconnected (ParentController, Disconnected);
- }
- }
-
- *Disconnected = FALSE;
-
- if (!IsPortConnect (PortStatus.PortStatus)) {
- *Disconnected = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-UsbSetTransactionTranslator (
- IN USB_IO_CONTROLLER_DEVICE *ParentHubController,
- IN UINT8 ParentPort,
- IN OUT USB_IO_DEVICE *Device
- )
-/*++
-
- Routine Description:
-
- Set Transaction Translator parameter
-
- Arguments:
-
- ParentHubController - Controller structure of the parent Hub device
- ParentPort - Number of parent port
- Device - Structure of the device
-
- Returns:
-
- EFI_SUCCESS Success
- EFI_OUT_OF_RESOURCES Cannot allocate resources
-
---*/
-{
- USB_IO_CONTROLLER_DEVICE *AncestorHubController;
-
- AncestorHubController = ParentHubController;
- Device->Translator = NULL;
-
- if (EFI_USB_SPEED_HIGH == Device->DeviceSpeed) {
- return EFI_SUCCESS;
- }
-
- do {
- if (EFI_USB_SPEED_HIGH == AncestorHubController->UsbDevice->DeviceSpeed) {
- break;
- }
-
- if (NULL == AncestorHubController->Parent) {
- return EFI_SUCCESS;
- }
-
- AncestorHubController = AncestorHubController->Parent;
- } while (1);
-
- Device->Translator = AllocatePool (sizeof (EFI_USB2_HC_TRANSACTION_TRANSLATOR));
- if (NULL == Device->Translator) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Device->Translator->TranslatorHubAddress = AncestorHubController->UsbDevice->DeviceAddress;
- Device->Translator->TranslatorPortNumber = ParentPort;
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-UsbUnsetTransactionTranslator (
- USB_IO_DEVICE *Device
- )
-/*++
-
- Routine Description:
-
- Unset Transaction Translator parameter
-
- Arguments:
-
- Device - Structure of the device
-
- Returns:
-
- EFI_SUCCESS Success
-
---*/
-{
- if (Device->Translator) {
- gBS->FreePool (Device->Translator);
- Device->Translator = NULL;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-IdentifyDeviceSpeed (
- USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- USB_IO_DEVICE *NewDevice,
- UINT8 Index
- )
-/*++
-
- Routine Description:
-
- Identify speed of USB device
-
- Arguments:
-
- UsbBusDev - UsbBus controller structure of the device
- NewDevice - Devcie controller structure
- Index - Number of the port
-
- Returns:
-
- EFI_SUCCESS Success
- EFI_NOT_FOUND Device release to CHC or can't be found
-
---*/
-{
- EFI_STATUS Status;
- EFI_USB_PORT_STATUS HubPortStatus;
-
- UsbVirtualHcGetRootHubPortStatus (
- UsbBusDev,
- Index,
- (EFI_USB_PORT_STATUS *) &HubPortStatus
- );
-
- //
- // Check device device
- //
- if (!(HubPortStatus.PortStatus & USB_PORT_STAT_OWNER)) {
- //
- // EHC Port Owner
- //
- if (HubPortStatus.PortStatus & USB_PORT_STAT_HIGH_SPEED) {
- DEBUG ((gUSBDebugLevel, "High Speed Device attached to EHC\n"));
- NewDevice->DeviceSpeed = EFI_USB_SPEED_HIGH;
- } else {
- Status = ReleasePortToCHC (UsbBusDev, Index);
- if (EFI_ERROR (Status)) {
- DEBUG ((gUSBErrorLevel, "Fail to release port to CHC\n"));
- } else {
- DEBUG ((gUSBDebugLevel, "Success to release port to CHC\n"));
- }
- return EFI_DEVICE_ERROR;
- }
- } else {
- //
- // CHC Port Owner
- //
- if (HubPortStatus.PortStatus & USB_PORT_STAT_LOW_SPEED) {
- DEBUG ((gUSBDebugLevel, "Low Speed Device attached to CHC\n"));
- NewDevice->DeviceSpeed = EFI_USB_SPEED_LOW;
- } else {
- DEBUG ((gUSBDebugLevel, "FULL Speed Device attached to CHC\n"));
- NewDevice->DeviceSpeed = EFI_USB_SPEED_FULL;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-ReleasePortToCHC (
- USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- UINT8 PortNum
- )
-/*++
-
- Routine Description:
-
- Set bit to release the port owner to CHC
-
- Arguments:
-
- UsbBusDev - UsbBus controller structure of the device
- PortNum - Number of the port
-
- Returns:
-
- EFI_SUCCESS Success
- EFI_DEVICE_ERROR Fail
-
---*/
-{
- EFI_STATUS Status;
-
- Status = UsbVirtualHcSetRootHubPortFeature (
- UsbBusDev,
- PortNum,
- EfiUsbPortOwner
- );
-
- gBS->Stall (100 * 1000);
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcGetCapability (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- OUT UINT8 *MaxSpeed,
- OUT UINT8 *PortNumber,
- OUT UINT8 *Is64BitCapable
- )
-/*++
-
- Routine Description:
-
- Virtual interface to Retrieves the capablility of root hub ports
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- MaxSpeed - A pointer to the number of the host controller.
- PortNumber - A pointer to the number of the root hub ports.
- Is64BitCapable - A pointer to the flag for whether controller supports
- 64-bit memory addressing.
-
- Returns:
-
- EFI_SUCCESS
- The host controller capability were retrieved successfully.
- EFI_INVALID_PARAMETER
- MaxSpeed or PortNumber or Is64BitCapable is NULL.
- EFI_DEVICE_ERROR
- An error was encountered while attempting to retrieve the capabilities.
-
---*/
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- Status = UsbBusDev->Usb2HCInterface->GetCapability (
- UsbBusDev->Usb2HCInterface,
- MaxSpeed,
- PortNumber,
- Is64BitCapable
- );
- } else {
- Status = UsbBusDev->UsbHCInterface->GetRootHubPortNumber (
- UsbBusDev->UsbHCInterface,
- PortNumber
- );
- *MaxSpeed = EFI_USB_SPEED_FULL;
- *Is64BitCapable = (UINT8) FALSE;
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcReset (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT16 Attributes
- )
-/*++
-
- Routine Description:
-
- Virtual interface to provides software reset for the USB host controller
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- Attributes - A bit mask of the reset operation to perform.
- See below for a list of the supported bit mask values.
-
- #define EFI_USB_HC_RESET_GLOBAL 0x0001 // Hc2 and Hc
- #define EFI_USB_HC_RESET_HOST_CONTROLLER 0x0002 // Hc2 and Hc
- #define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG 0x0004 // Hc2
- #define EFI_USB_HC_RESET_HOST_WITH_DEBUG 0x0008 // Hc2
-
- EFI_USB_HC_RESET_GLOBAL
- If this bit is set, a global reset signal will be sent to the USB bus.
- This resets all of the USB bus logic, including the USB host
- controller hardware and all the devices attached on the USB bus.
- EFI_USB_HC_RESET_HOST_CONTROLLER
- If this bit is set, the USB host controller hardware will be reset.
- No reset signal will be sent to the USB bus.
- EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG
- If this bit is set, a global reset signal will be sent to the USB bus.
- This resets all of the USB bus logic, including the USB host
- controller hardware and all the devices attached on the USB bus.
- If this is an EHCI controller and the debug port has configured, then
- this is will still reset the host controller.
- EFI_USB_HC_RESET_HOST_WITH_DEBUG
- If this bit is set, the USB host controller hardware will be reset.
- If this is an EHCI controller and the debug port has been configured,
- then this will still reset the host controller.
-
- Returns:
-
- EFI_SUCCESS
- The reset operation succeeded.
- EFI_INVALID_PARAMETER
- Attributes is not valid.
- EFI_UNSUPPOURTED
- The type of reset specified by Attributes is not currently supported by
- the host controller hardware.
- EFI_ACCESS_DENIED
- Reset operation is rejected due to the debug port being configured and
- active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or
- EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Atrributes can be used to
- perform reset operation for this host controller.
- EFI_DEVICE_ERROR
- An error was encountered while attempting to perform
- the reset operation.
-
---*/
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- Status = UsbBusDev->Usb2HCInterface->Reset (
- UsbBusDev->Usb2HCInterface,
- EFI_USB_HC_RESET_GLOBAL
- );
- } else {
- Status = UsbBusDev->UsbHCInterface->Reset (
- UsbBusDev->UsbHCInterface,
- EFI_USB_HC_RESET_GLOBAL
- );
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcGetState (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- OUT EFI_USB_HC_STATE *State
- )
-/*++
-
- Routine Description:
-
- Virtual interface to retrieves current state of the USB host controller
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- State - A pointer to the EFI_USB_HC_STATE data structure that
- indicates current state of the USB host controller.
- Type EFI_USB_HC_STATE is defined below.
-
- typedef enum {
- EfiUsbHcStateHalt,
- EfiUsbHcStateOperational,
- EfiUsbHcStateSuspend,
- EfiUsbHcStateMaximum
- } EFI_USB_HC_STATE;
-
- Returns:
-
- EFI_SUCCESS
- The state information of the host controller was returned in State.
- EFI_INVALID_PARAMETER
- State is NULL.
- EFI_DEVICE_ERROR
- An error was encountered while attempting to retrieve the
- host controller's current state.
-
---*/
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- Status = UsbBusDev->Usb2HCInterface->GetState (
- UsbBusDev->Usb2HCInterface,
- State
- );
- } else {
- Status = UsbBusDev->UsbHCInterface->GetState (
- UsbBusDev->UsbHCInterface,
- State
- );
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcSetState (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN EFI_USB_HC_STATE State
- )
-/*++
-
- Routine Description:
-
- Virtual interface to sets the USB host controller to a specific state
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- State - Indicates the state of the host controller that will be set.
-
- Returns:
-
- EFI_SUCCESS
- The USB host controller was successfully placed in the state
- specified by State.
- EFI_INVALID_PARAMETER
- State is invalid.
- EFI_DEVICE_ERROR
- Failed to set the state specified by State due to device error.
-
---*/
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- Status = UsbBusDev->Usb2HCInterface->SetState (
- UsbBusDev->Usb2HCInterface,
- State
- );
- } else {
- Status = UsbBusDev->UsbHCInterface->SetState (
- UsbBusDev->UsbHCInterface,
- State
- );
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcGetRootHubPortStatus (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 PortNumber,
- OUT EFI_USB_PORT_STATUS *PortStatus
- )
-/*++
-
- Routine Description:
-
- Virtual interface to retrieves the current status of a USB root hub port
- both for Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- PortNumber - Specifies the root hub port from which the status
- is to be retrieved. This value is zero-based. For example,
- if a root hub has two ports, then the first port is numbered 0,
- and the second port is numbered 1.
- PortStatus - A pointer to the current port status bits and
- port status change bits.
-
- Returns:
-
- EFI_SUCCESS The status of the USB root hub port specified by PortNumber
- was returned in PortStatus.
- EFI_INVALID_PARAMETER PortNumber is invalid.
- EFI_DEVICE_ERROR Can't read register
-
---*/
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- Status = UsbBusDev->Usb2HCInterface->GetRootHubPortStatus (
- UsbBusDev->Usb2HCInterface,
- PortNumber,
- PortStatus
- );
- } else {
- Status = UsbBusDev->UsbHCInterface->GetRootHubPortStatus (
- UsbBusDev->UsbHCInterface,
- PortNumber,
- PortStatus
- );
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcSetRootHubPortFeature (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 PortNumber,
- IN EFI_USB_PORT_FEATURE PortFeature
- )
-/*++
-
- Routine Description:
- Virual interface to sets a feature for the specified root hub port
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- PortNumber - Specifies the root hub port whose feature
- is requested to be set.
- PortFeature - Indicates the feature selector associated
- with the feature set request.
-
- Returns:
-
- EFI_SUCCESS
- The feature specified by PortFeature was set for the
- USB root hub port specified by PortNumber.
- EFI_INVALID_PARAMETER
- PortNumber is invalid or PortFeature is invalid.
- EFI_DEVICE_ERROR
- Can't read register
-
---*/
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- Status = UsbBusDev->Usb2HCInterface->SetRootHubPortFeature (
- UsbBusDev->Usb2HCInterface,
- PortNumber,
- PortFeature
- );
- } else {
- Status = UsbBusDev->UsbHCInterface->SetRootHubPortFeature (
- UsbBusDev->UsbHCInterface,
- PortNumber,
- PortFeature
- );
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcClearRootHubPortFeature (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 PortNumber,
- IN EFI_USB_PORT_FEATURE PortFeature
- )
-/*++
-
- Routine Description:
-
- Virtual interface to clears a feature for the specified root hub port
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- PortNumber - Specifies the root hub port whose feature
- is requested to be cleared.
- PortFeature - Indicates the feature selector associated with the
- feature clear request.
-
- Returns:
-
- EFI_SUCCESS
- The feature specified by PortFeature was cleared for the
- USB root hub port specified by PortNumber.
- EFI_INVALID_PARAMETER
- PortNumber is invalid or PortFeature is invalid.
- EFI_DEVICE_ERROR
- Can't read register
-
---*/
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- Status = UsbBusDev->Usb2HCInterface->ClearRootHubPortFeature (
- UsbBusDev->Usb2HCInterface,
- PortNumber,
- PortFeature
- );
- } else {
- Status = UsbBusDev->UsbHCInterface->ClearRootHubPortFeature (
- UsbBusDev->UsbHCInterface,
- PortNumber,
- PortFeature
- );
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcControlTransfer (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN EFI_USB_DEVICE_REQUEST *Request,
- IN EFI_USB_DATA_DIRECTION TransferDirection,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN TimeOut,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-/*++
-
- Routine Description:
-
- Virtual interface to submits control transfer to a target USB device
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- DeviceSpeed - Indicates target device speed.
- MaximumPacketLength - Indicates the maximum packet size that the
- default control transfer endpoint is capable of
- sending or receiving.
- Request - A pointer to the USB device request that will be sent
- to the USB device.
- TransferDirection - Specifies the data direction for the transfer.
- There are three values available, DataIn, DataOut
- and NoData.
- Data - A pointer to the buffer of data that will be transmitted
- to USB device or received from USB device.
- DataLength - Indicates the size, in bytes, of the data buffer
- specified by Data.
- TimeOut - Indicates the maximum time, in microseconds,
- which the transfer is allowed to complete.
- Translator - A pointr to the transaction translator data.
- TransferResult - A pointer to the detailed result information generated
- by this control transfer.
-
- Returns:
-
- EFI_SUCCESS
- The control transfer was completed successfully.
- EFI_OUT_OF_RESOURCES
- The control transfer could not be completed due to a lack of resources.
- EFI_INVALID_PARAMETER
- Some parameters are invalid.
- EFI_TIMEOUT
- The control transfer failed due to timeout.
- EFI_DEVICE_ERROR
- The control transfer failed due to host controller or device error.
- Caller should check TranferResult for detailed error information.
-
---*/
-{
- EFI_STATUS Status;
- BOOLEAN IsSlowDevice;
-
- Status = EFI_SUCCESS;
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- Status = UsbBusDev->Usb2HCInterface->ControlTransfer (
- UsbBusDev->Usb2HCInterface,
- DeviceAddress,
- DeviceSpeed,
- MaximumPacketLength,
- Request,
- TransferDirection,
- Data,
- DataLength,
- TimeOut,
- Translator,
- TransferResult
- );
- } else {
- IsSlowDevice = (BOOLEAN) ((EFI_USB_SPEED_LOW == DeviceSpeed) ? TRUE : FALSE);
- Status = UsbBusDev->UsbHCInterface->ControlTransfer (
- UsbBusDev->UsbHCInterface,
- DeviceAddress,
- IsSlowDevice,
- (UINT8) MaximumPacketLength,
- Request,
- TransferDirection,
- Data,
- DataLength,
- TimeOut,
- TransferResult
- );
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcBulkTransfer (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN UINT8 DataBuffersNumber,
- IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
- IN OUT UINTN *DataLength,
- IN OUT UINT8 *DataToggle,
- IN UINTN TimeOut,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-/*++
-
- Routine Description:
-
- Virtual interface to submits bulk transfer to a bulk endpoint of a USB device
- both for Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - The combination of an endpoint number and an
- endpoint direction of the target USB device.
- Each endpoint address supports data transfer in
- one direction except the control endpoint
- (whose default endpoint address is 0).
- It is the caller's responsibility to make sure that
- the EndPointAddress represents a bulk endpoint.
- DeviceSpeed - Indicates device speed. The supported values are EFI_USB_SPEED_FULL
- and EFI_USB_SPEED_HIGH.
- MaximumPacketLength - Indicates the maximum packet size the target endpoint
- is capable of sending or receiving.
- DataBuffersNumber - Number of data buffers prepared for the transfer.
- Data - Array of pointers to the buffers of data that will be transmitted
- to USB device or received from USB device.
- DataLength - When input, indicates the size, in bytes, of the data buffer
- specified by Data. When output, indicates the actually
- transferred data size.
- DataToggle - A pointer to the data toggle value. On input, it indicates
- the initial data toggle value the bulk transfer should adopt;
- on output, it is updated to indicate the data toggle value
- of the subsequent bulk transfer.
- Translator - A pointr to the transaction translator data.
- TimeOut - Indicates the maximum time, in microseconds, which the
- transfer is allowed to complete.
- TransferResult - A pointer to the detailed result information of the
- bulk transfer.
-
- Returns:
-
- EFI_SUCCESS
- The bulk transfer was completed successfully.
- EFI_OUT_OF_RESOURCES
- The bulk transfer could not be submitted due to lack of resource.
- EFI_INVALID_PARAMETER
- Some parameters are invalid.
- EFI_TIMEOUT
- The bulk transfer failed due to timeout.
- EFI_DEVICE_ERROR
- The bulk transfer failed due to host controller or device error.
- Caller should check TranferResult for detailed error information.
-
---*/
-{
- EFI_STATUS Status;
-
- Status = EFI_SUCCESS;
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- Status = UsbBusDev->Usb2HCInterface->BulkTransfer (
- UsbBusDev->Usb2HCInterface,
- DeviceAddress,
- EndPointAddress,
- DeviceSpeed,
- MaximumPacketLength,
- DataBuffersNumber,
- Data,
- DataLength,
- DataToggle,
- TimeOut,
- Translator,
- TransferResult
- );
- } else {
- Status = UsbBusDev->UsbHCInterface->BulkTransfer (
- UsbBusDev->UsbHCInterface,
- DeviceAddress,
- EndPointAddress,
- (UINT8) MaximumPacketLength,
- *Data,
- DataLength,
- DataToggle,
- TimeOut,
- TransferResult
- );
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcAsyncInterruptTransfer (
- IN USB_BUS_CONTROLLER_DEVICE * UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN BOOLEAN IsNewTransfer,
- IN OUT UINT8 *DataToggle,
- IN UINTN PollingInterval,
- IN UINTN DataLength,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR * Translator,
- IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction,
- IN VOID *Context OPTIONAL
- )
-/*++
-
- Routine Description:
-
- Virtual interface to submits an asynchronous interrupt transfer to an
- interrupt endpoint of a USB device for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - The combination of an endpoint number and an endpoint
- direction of the target USB device. Each endpoint address
- supports data transfer in one direction except the
- control endpoint (whose default endpoint address is 0).
- It is the caller's responsibility to make sure that
- the EndPointAddress represents an interrupt endpoint.
- DeviceSpeed - Indicates device speed.
- MaximumPacketLength - Indicates the maximum packet size the target endpoint
- is capable of sending or receiving.
- IsNewTransfer - If TRUE, an asynchronous interrupt pipe is built between
- the host and the target interrupt endpoint.
- If FALSE, the specified asynchronous interrupt pipe
- is canceled.
- DataToggle - A pointer to the data toggle value. On input, it is valid
- when IsNewTransfer is TRUE, and it indicates the initial
- data toggle value the asynchronous interrupt transfer
- should adopt.
- On output, it is valid when IsNewTransfer is FALSE,
- and it is updated to indicate the data toggle value of
- the subsequent asynchronous interrupt transfer.
- PollingInterval - Indicates the interval, in milliseconds, that the
- asynchronous interrupt transfer is polled.
- This parameter is required when IsNewTransfer is TRUE.
- DataLength - Indicates the length of data to be received at the
- rate specified by PollingInterval from the target
- asynchronous interrupt endpoint. This parameter
- is only required when IsNewTransfer is TRUE.
- Translator - A pointr to the transaction translator data.
- CallBackFunction - The Callback function.This function is called at the
- rate specified by PollingInterval.This parameter is
- only required when IsNewTransfer is TRUE.
- Context - The context that is passed to the CallBackFunction.
- - This is an optional parameter and may be NULL.
-
- Returns:
-
- EFI_SUCCESS
- The asynchronous interrupt transfer request has been successfully
- submitted or canceled.
- EFI_INVALID_PARAMETER
- Some parameters are invalid.
- EFI_OUT_OF_RESOURCES
- The request could not be completed due to a lack of resources.
- EFI_DEVICE_ERROR
- Can't read register
-
---*/
-{
- EFI_STATUS Status;
- BOOLEAN IsSlowDevice;
-
- Status = EFI_SUCCESS;
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- Status = UsbBusDev->Usb2HCInterface->AsyncInterruptTransfer (
- UsbBusDev->Usb2HCInterface,
- DeviceAddress,
- EndPointAddress,
- DeviceSpeed,
- MaximumPacketLength,
- IsNewTransfer,
- DataToggle,
- PollingInterval,
- DataLength,
- Translator,
- CallBackFunction,
- Context
- );
- } else {
- IsSlowDevice = (BOOLEAN) ((EFI_USB_SPEED_LOW == DeviceSpeed) ? TRUE : FALSE);
- Status = UsbBusDev->UsbHCInterface->AsyncInterruptTransfer (
- UsbBusDev->UsbHCInterface,
- DeviceAddress,
- EndPointAddress,
- IsSlowDevice,
- (UINT8) MaximumPacketLength,
- IsNewTransfer,
- DataToggle,
- PollingInterval,
- DataLength,
- CallBackFunction,
- Context
- );
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcSyncInterruptTransfer (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN OUT UINT8 *DataToggle,
- IN UINTN TimeOut,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-/*++
-
- Routine Description:
-
- Vitual interface to submits synchronous interrupt transfer to an interrupt endpoint
- of a USB device for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - The combination of an endpoint number and an endpoint
- direction of the target USB device. Each endpoint
- address supports data transfer in one direction
- except the control endpoint (whose default
- endpoint address is 0). It is the caller's responsibility
- to make sure that the EndPointAddress represents
- an interrupt endpoint.
- DeviceSpeed - Indicates device speed.
- MaximumPacketLength - Indicates the maximum packet size the target endpoint
- is capable of sending or receiving.
- Data - A pointer to the buffer of data that will be transmitted
- to USB device or received from USB device.
- DataLength - On input, the size, in bytes, of the data buffer specified
- by Data. On output, the number of bytes transferred.
- DataToggle - A pointer to the data toggle value. On input, it indicates
- the initial data toggle value the synchronous interrupt
- transfer should adopt;
- on output, it is updated to indicate the data toggle value
- of the subsequent synchronous interrupt transfer.
- TimeOut - Indicates the maximum time, in microseconds, which the
- transfer is allowed to complete.
- Translator - A pointr to the transaction translator data.
- TransferResult - A pointer to the detailed result information from
- the synchronous interrupt transfer.
-
- Returns:
-
- EFI_SUCCESS
- The synchronous interrupt transfer was completed successfully.
- EFI_OUT_OF_RESOURCES
- The synchronous interrupt transfer could not be submitted due
- to lack of resource.
- EFI_INVALID_PARAMETER
- Some parameters are invalid.
- EFI_TIMEOUT
- The synchronous interrupt transfer failed due to timeout.
- EFI_DEVICE_ERROR
- The synchronous interrupt transfer failed due to host controller
- or device error. Caller should check TranferResult for detailed
- error information.
-
---*/
-{
- EFI_STATUS Status;
- BOOLEAN IsSlowDevice;
-
- Status = EFI_SUCCESS;
-
- if (UsbBusDev->Hc2ProtocolSupported) {
- Status = UsbBusDev->Usb2HCInterface->SyncInterruptTransfer (
- UsbBusDev->Usb2HCInterface,
- DeviceAddress,
- EndPointAddress,
- DeviceSpeed,
- MaximumPacketLength,
- Data,
- DataLength,
- DataToggle,
- TimeOut,
- Translator,
- TransferResult
- );
- } else {
- IsSlowDevice = (BOOLEAN) ((EFI_USB_SPEED_LOW == DeviceSpeed) ? TRUE : FALSE);
- Status = UsbBusDev->UsbHCInterface->SyncInterruptTransfer (
- UsbBusDev->UsbHCInterface,
- DeviceAddress,
- EndPointAddress,
- IsSlowDevice,
- (UINT8) MaximumPacketLength,
- Data,
- DataLength,
- DataToggle,
- TimeOut,
- TransferResult
- );
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcIsochronousTransfer (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN UINT8 DataBuffersNumber,
- IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
- IN UINTN DataLength,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-/*++
-
- Routine Description:
-
- Virtual interface to submits isochronous transfer to a target USB device
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - End point address
- DeviceSpeed - Indicates device speed.
- MaximumPacketLength - Indicates the maximum packet size that the
- default control transfer endpoint is capable of
- sending or receiving.
- DataBuffersNumber - Number of data buffers prepared for the transfer.
- Data - Array of pointers to the buffers of data that will be
- transmitted to USB device or received from USB device.
- DataLength - Indicates the size, in bytes, of the data buffer
- specified by Data.
- Translator - A pointr to the transaction translator data.
- TransferResult - A pointer to the detailed result information generated
- by this control transfer.
-
- Returns:
-
- EFI_UNSUPPORTED
-
---*/
-{
- return EFI_UNSUPPORTED;
-}
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcAsyncIsochronousTransfer (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN UINT8 DataBuffersNumber,
- IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
- IN UINTN DataLength,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
- IN VOID *Context
- )
-/*++
-
- Routine Description:
-
- Vitual interface to submits Async isochronous transfer to a target USB device
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - End point address
- DeviceSpeed - Indicates device speed.
- MaximumPacketLength - Indicates the maximum packet size that the
- default control transfer endpoint is capable of
- sending or receiving.
- DataBuffersNumber - Number of data buffers prepared for the transfer.
- Data - Array of pointers to the buffers of data that will be transmitted
- to USB device or received from USB device.
- DataLength - Indicates the size, in bytes, of the data buffer
- specified by Data.
- Translator - A pointr to the transaction translator data.
- IsochronousCallBack - When the transfer complete, the call back function will be called
- Context - Pass to the call back function as parameter
-
- Returns:
-
- EFI_UNSUPPORTED
-
---*/
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbbus.h b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbbus.h
deleted file mode 100644
index be60aedb76..0000000000
--- a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbbus.h
+++ /dev/null
@@ -1,1203 +0,0 @@
-/*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- Module Name:
-
- usbbus.h
-
- Abstract:
-
- Header file for USB bus driver Interface
-
- Revision History
-
-
-
---*/
-
-#ifndef _EFI_USB_BUS_H
-#define _EFI_USB_BUS_H
-
-
-#include <IndustryStandard/Usb.h>
-#include "hub.h"
-#include "usbutil.h"
-
-
-extern UINTN gUSBDebugLevel;
-extern UINTN gUSBErrorLevel;
-
-
-#define MICROSECOND 10000
-#define ONESECOND (1000 * MICROSECOND)
-#define BUSPOLLING_PERIOD ONESECOND
-//
-// We define some maximun value here
-//
-#define USB_MAXCONFIG 8
-#define USB_MAXALTSETTING 4
-#define USB_MAXINTERFACES 32
-#define USB_MAXENDPOINTS 16
-#define USB_MAXSTRINGS 16
-#define USB_MAXLANID 16
-#define USB_MAXCHILDREN 8
-#define USB_MAXCONTROLLERS 4
-
-#define USB_IO_CONTROLLER_SIGNATURE EFI_SIGNATURE_32 ('u', 's', 'b', 'd')
-
-typedef struct {
- LIST_ENTRY Link;
- UINT16 StringIndex;
- CHAR16 *String;
-} STR_LIST_ENTRY;
-
-typedef struct {
- LIST_ENTRY Link;
- UINT16 Toggle;
- EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
-} ENDPOINT_DESC_LIST_ENTRY;
-
-typedef struct {
- LIST_ENTRY Link;
- EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
- LIST_ENTRY EndpointDescListHead;
-} INTERFACE_DESC_LIST_ENTRY;
-
-typedef struct {
- LIST_ENTRY Link;
- EFI_USB_CONFIG_DESCRIPTOR CongfigDescriptor;
- LIST_ENTRY InterfaceDescListHead;
- UINTN ActiveInterface;
-} CONFIG_DESC_LIST_ENTRY;
-
-//
-// Forward declaring
-//
-struct usb_io_device;
-
-//
-// This is used to form the USB Controller Handle
-//
-typedef struct usb_io_controller_device {
- UINTN Signature;
- EFI_HANDLE Handle;
- EFI_USB_IO_PROTOCOL UsbIo;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_HANDLE HostController;
- UINT8 CurrentConfigValue;
- UINT8 InterfaceNumber;
- struct usb_io_device *UsbDevice;
-
- BOOLEAN IsUsbHub;
- BOOLEAN IsManagedByDriver;
-
- //
- // Fields specified for USB Hub
- //
- EFI_EVENT HubNotify;
- UINT8 HubEndpointAddress;
- UINT8 StatusChangePort;
- UINT8 DownstreamPorts;
-
- UINT8 ParentPort;
- struct usb_io_controller_device *Parent;
- struct usb_io_device *Children[USB_MAXCHILDREN];
-} USB_IO_CONTROLLER_DEVICE;
-
-#define USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS(a) \
- CR(a, USB_IO_CONTROLLER_DEVICE, UsbIo, USB_IO_CONTROLLER_SIGNATURE)
-
-//
-// This is used to keep the topology of USB bus
-//
-struct _usb_bus_controller_device;
-
-typedef struct usb_io_device {
- UINT8 DeviceAddress;
- BOOLEAN IsConfigured;
- BOOLEAN IsSlowDevice;
- UINT8 DeviceSpeed;
- EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator;
- EFI_USB_DEVICE_DESCRIPTOR DeviceDescriptor;
- LIST_ENTRY ConfigDescListHead;
- CONFIG_DESC_LIST_ENTRY *ActiveConfig;
- UINT16 LangID[USB_MAXLANID];
-
- struct _usb_bus_controller_device *BusController;
-
- //
- // Track the controller handle
- //
- UINT8 NumOfControllers;
- USB_IO_CONTROLLER_DEVICE *UsbController[USB_MAXCONTROLLERS];
-
-} USB_IO_DEVICE;
-
-//
-// Usb Bus Controller device strcuture
-//
-#define EFI_USB_BUS_PROTOCOL_GUID \
- { 0x2B2F68CC, 0x0CD2, 0x44cf, { 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } }
-
-typedef struct _EFI_USB_BUS_PROTOCOL {
- UINT64 Reserved;
-} EFI_USB_BUS_PROTOCOL;
-
-#define USB_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('u', 'b', 'u', 's')
-
-typedef struct _usb_bus_controller_device {
- UINTN Signature;
-
- EFI_USB_BUS_PROTOCOL BusIdentify;
- EFI_USB2_HC_PROTOCOL *Usb2HCInterface;
- EFI_USB_HC_PROTOCOL *UsbHCInterface;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINT8 AddressPool[16];
- USB_IO_DEVICE *Root;
- BOOLEAN Hc2ProtocolSupported;
-} USB_BUS_CONTROLLER_DEVICE;
-
-#define USB_BUS_CONTROLLER_DEVICE_FROM_THIS(a) \
- CR(a, USB_BUS_CONTROLLER_DEVICE, BusIdentify, USB_BUS_DEVICE_SIGNATURE)
-
-
-//
-// Global Variables
-//
-extern EFI_DRIVER_BINDING_PROTOCOL gUsbBusDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gUsbBusComponentName;
-
-//
-// EFI_DRIVER_BINDING_PROTOCOL Protocol Interface
-//
-EFI_STATUS
-EFIAPI
-UsbBusControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-EFI_STATUS
-EFIAPI
-UsbBusControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-EFI_STATUS
-EFIAPI
-UsbBusControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// EFI Component Name Functions
-//
-EFI_STATUS
-EFIAPI
-UsbBusComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-EFI_STATUS
-EFIAPI
-UsbBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle, OPTIONAL
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-//
-// Usb Device Configuration functions
-//
-BOOLEAN
-IsHub (
- IN USB_IO_CONTROLLER_DEVICE *Dev
- )
-/*++
-
- Routine Description:
- Tell if a usb controller is a hub controller.
-
- Arguments:
- Dev - UsbIoController device structure.
-
- Returns:
- TRUE/FALSE
---*/
-;
-
-EFI_STATUS
-UsbGetStringtable (
- IN USB_IO_DEVICE *UsbIoDevice
- )
-/*++
-
- Routine Description:
- Get the string table stored in a usb device.
-
- Arguments:
- Dev - UsbIoController device structure.
-
- Returns:
- EFI_SUCCESS
- EFI_UNSUPPORTED
- EFI_OUT_OF_RESOURCES
-
---*/
-;
-
-EFI_STATUS
-UsbGetAllConfigurations (
- IN USB_IO_DEVICE *UsbIoDevice
- )
-/*++
-
- Routine Description:
- This function is to parse all the configuration descriptor.
-
- Arguments:
- UsbIoDevice - USB_IO_DEVICE device structure.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
- EFI_OUT_OF_RESOURCES
-
---*/
-;
-
-EFI_STATUS
-UsbSetConfiguration (
- IN USB_IO_DEVICE *Dev,
- IN UINTN ConfigurationValue
- )
-/*++
-
- Routine Description:
- Set the device to a configuration value.
-
- Arguments:
- UsbIoDev - USB_IO_DEVICE to be set configuration
- ConfigrationValue - The configuration value to be set to that device
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-;
-
-EFI_STATUS
-UsbSetDefaultConfiguration (
- IN USB_IO_DEVICE *Dev
- )
-/*++
-
- Routine Description:
- Set the device to a default configuration value.
-
- Arguments:
- UsbIoDev - USB_IO_DEVICE to be set configuration
-
- Returns
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-;
-
-//
-// Device Deconfiguration functions
-//
-VOID
-UsbDestroyAllConfiguration (
- IN USB_IO_DEVICE *UsbIoDevice
- )
-/*++
-
- Routine Description:
- Delete all configuration data when device is not used.
-
- Arguments:
- UsbIoDevice - USB_IO_DEVICE to be set configuration
-
- Returns:
- VOID
-
---*/
-;
-
-EFI_STATUS
-DoHubConfig (
- IN USB_IO_CONTROLLER_DEVICE *HubIoDevice
- )
-/*++
-
- Routine Description:
- Configure the hub
-
- Arguments:
- HubController - Indicating the hub controller device that
- will be configured
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-
-;
-
-VOID
-GetDeviceEndPointMaxPacketLength (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 EndpointAddr,
- OUT UINTN *MaxPacketLength
- )
-/*++
-
- Routine Description:
- Get the Max Packet Length of the speified Endpoint.
-
- Arguments:
- UsbIo - Given Usb Controller device.
- EndpointAddr - Given Endpoint address.
- MaxPacketLength - The max packet length of that endpoint
-
- Returns:
- N/A
-
---*/
-;
-
-VOID
-GetDataToggleBit (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 EndpointAddr,
- OUT UINT8 *DataToggle
- )
-/*++
-
- Routine Description:
- Get the datatoggle of a specified endpoint.
-
- Arguments:
- UsbIo - Given Usb Controller device.
- EndpointAddr - Given Endpoint address.
- DataToggle - The current data toggle of that endpoint
-
- Returns:
- VOID
-
---*/
-;
-
-VOID
-SetDataToggleBit (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 EndpointAddr,
- IN UINT8 DataToggle
- )
-/*++
-
- Routine Description:
- Set the datatoggle of a specified endpoint
-
- Arguments:
- UsbIo - Given Usb Controller device.
- EndpointAddr - Given Endpoint address.
- DataToggle - The current data toggle of that endpoint to be set
-
- Returns:
- VOID
-
---*/
-;
-
-INTERFACE_DESC_LIST_ENTRY *
-FindInterfaceListEntry (
- IN EFI_USB_IO_PROTOCOL *This
- )
-/*++
-
- Routine Description:
- Find Interface ListEntry.
-
- Arguments:
- This - EFI_USB_IO_PROTOCOL
-
- Returns:
- INTERFACE_DESC_LIST_ENTRY pointer
-
---*/
-;
-
-ENDPOINT_DESC_LIST_ENTRY *
-FindEndPointListEntry (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 EndPointAddress
- )
-/*++
-
- Routine Description:
- Find EndPoint ListEntry.
-
- Arguments:
- This - EFI_USB_IO_PROTOCOL
- EndpointAddr - Endpoint address.
-
- Returns:
- ENDPOINT_DESC_LIST_ENTRY pointer
-
---*/
-;
-
-EFI_STATUS
-IsDeviceDisconnected (
- IN USB_IO_CONTROLLER_DEVICE *UsbIoController,
- IN OUT BOOLEAN *Disconnected
- )
-/*++
-
- Routine Description:
- Reset if the device is disconencted or not
-
- Arguments:
- UsbIoController - Indicating the Usb Controller Device.
- Disconnected - Indicate whether the device is disconencted or not
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-;
-
-EFI_STATUS
-UsbDeviceDeConfiguration (
- IN USB_IO_DEVICE *UsbIoDevice
- )
-/*++
-
- Routine Description:
- Remove Device, Device Handles, Uninstall Protocols.
-
- Arguments:
- UsbIoDevice - The device to be deconfigured.
-
- Returns:
- EFI_SUCCESS
- EFI_DEVICE_ERROR
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcGetCapability (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- OUT UINT8 *MaxSpeed,
- OUT UINT8 *PortNumber,
- OUT UINT8 *Is64BitCapable
- )
-/*++
-
- Routine Description:
-
- Virtual interface to Retrieves the capablility of root hub ports
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- MaxSpeed - A pointer to the number of the host controller.
- PortNumber - A pointer to the number of the root hub ports.
- Is64BitCapable - A pointer to the flag for whether controller supports
- 64-bit memory addressing.
-
- Returns:
-
- EFI_SUCCESS
- The host controller capability were retrieved successfully.
- EFI_INVALID_PARAMETER
- MaxSpeed or PortNumber or Is64BitCapable is NULL.
- EFI_DEVICE_ERROR
- An error was encountered while attempting to retrieve the capabilities.
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcReset (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT16 Attributes
- )
-/*++
-
- Routine Description:
-
- Virtual interface to provides software reset for the USB host controller
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- Attributes - A bit mask of the reset operation to perform.
- See below for a list of the supported bit mask values.
-
- #define EFI_USB_HC_RESET_GLOBAL 0x0001 // Hc2 and Hc
- #define EFI_USB_HC_RESET_HOST_CONTROLLER 0x0002 // Hc2 and Hc
- #define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG 0x0004 // Hc2
- #define EFI_USB_HC_RESET_HOST_WITH_DEBUG 0x0008 // Hc2
-
- EFI_USB_HC_RESET_GLOBAL
- If this bit is set, a global reset signal will be sent to the USB bus.
- This resets all of the USB bus logic, including the USB host
- controller hardware and all the devices attached on the USB bus.
- EFI_USB_HC_RESET_HOST_CONTROLLER
- If this bit is set, the USB host controller hardware will be reset.
- No reset signal will be sent to the USB bus.
- EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG
- If this bit is set, a global reset signal will be sent to the USB bus.
- This resets all of the USB bus logic, including the USB host
- controller hardware and all the devices attached on the USB bus.
- If this is an EHCI controller and the debug port has configured, then
- this is will still reset the host controller.
- EFI_USB_HC_RESET_HOST_WITH_DEBUG
- If this bit is set, the USB host controller hardware will be reset.
- If this is an EHCI controller and the debug port has been configured,
- then this will still reset the host controller.
-
- Returns:
-
- EFI_SUCCESS
- The reset operation succeeded.
- EFI_INVALID_PARAMETER
- Attributes is not valid.
- EFI_UNSUPPOURTED
- The type of reset specified by Attributes is not currently supported by
- the host controller hardware.
- EFI_ACCESS_DENIED
- Reset operation is rejected due to the debug port being configured and
- active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or
- EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Atrributes can be used to
- perform reset operation for this host controller.
- EFI_DEVICE_ERROR
- An error was encountered while attempting to perform
- the reset operation.
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcGetState (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- OUT EFI_USB_HC_STATE *State
- )
-/*++
-
- Routine Description:
-
- Virtual interface to retrieves current state of the USB host controller
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- State - A pointer to the EFI_USB_HC_STATE data structure that
- indicates current state of the USB host controller.
- Type EFI_USB_HC_STATE is defined below.
-
- typedef enum {
- EfiUsbHcStateHalt,
- EfiUsbHcStateOperational,
- EfiUsbHcStateSuspend,
- EfiUsbHcStateMaximum
- } EFI_USB_HC_STATE;
-
- Returns:
-
- EFI_SUCCESS
- The state information of the host controller was returned in State.
- EFI_INVALID_PARAMETER
- State is NULL.
- EFI_DEVICE_ERROR
- An error was encountered while attempting to retrieve the
- host controller's current state.
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcSetState (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN EFI_USB_HC_STATE State
- )
-/*++
-
- Routine Description:
-
- Virtual interface to sets the USB host controller to a specific state
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- State - Indicates the state of the host controller that will be set.
-
- Returns:
-
- EFI_SUCCESS
- The USB host controller was successfully placed in the state
- specified by State.
- EFI_INVALID_PARAMETER
- State is invalid.
- EFI_DEVICE_ERROR
- Failed to set the state specified by State due to device error.
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcGetRootHubPortStatus (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 PortNumber,
- OUT EFI_USB_PORT_STATUS *PortStatus
- )
-/*++
-
- Routine Description:
-
- Virtual interface to retrieves the current status of a USB root hub port
- both for Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- PortNumber - Specifies the root hub port from which the status
- is to be retrieved. This value is zero-based. For example,
- if a root hub has two ports, then the first port is numbered 0,
- and the second port is numbered 1.
- PortStatus - A pointer to the current port status bits and
- port status change bits.
-
- Returns:
-
- EFI_SUCCESS The status of the USB root hub port specified by PortNumber
- was returned in PortStatus.
- EFI_INVALID_PARAMETER PortNumber is invalid.
- EFI_DEVICE_ERROR Can't read register
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcSetRootHubPortFeature (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 PortNumber,
- IN EFI_USB_PORT_FEATURE PortFeature
- )
-/*++
-
- Routine Description:
- Virual interface to sets a feature for the specified root hub port
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- PortNumber - Specifies the root hub port whose feature
- is requested to be set.
- PortFeature - Indicates the feature selector associated
- with the feature set request.
-
- Returns:
-
- EFI_SUCCESS
- The feature specified by PortFeature was set for the
- USB root hub port specified by PortNumber.
- EFI_INVALID_PARAMETER
- PortNumber is invalid or PortFeature is invalid.
- EFI_DEVICE_ERROR
- Can't read register
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcClearRootHubPortFeature (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 PortNumber,
- IN EFI_USB_PORT_FEATURE PortFeature
- )
-/*++
-
- Routine Description:
-
- Virtual interface to clears a feature for the specified root hub port
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- PortNumber - Specifies the root hub port whose feature
- is requested to be cleared.
- PortFeature - Indicates the feature selector associated with the
- feature clear request.
-
- Returns:
-
- EFI_SUCCESS
- The feature specified by PortFeature was cleared for the
- USB root hub port specified by PortNumber.
- EFI_INVALID_PARAMETER
- PortNumber is invalid or PortFeature is invalid.
- EFI_DEVICE_ERROR
- Can't read register
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcControlTransfer (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN EFI_USB_DEVICE_REQUEST *Request,
- IN EFI_USB_DATA_DIRECTION TransferDirection,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN TimeOut,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-/*++
-
- Routine Description:
-
- Virtual interface to submits control transfer to a target USB device
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- DeviceSpeed - Indicates target device speed.
- MaximumPacketLength - Indicates the maximum packet size that the
- default control transfer endpoint is capable of
- sending or receiving.
- Request - A pointer to the USB device request that will be sent
- to the USB device.
- TransferDirection - Specifies the data direction for the transfer.
- There are three values available, DataIn, DataOut
- and NoData.
- Data - A pointer to the buffer of data that will be transmitted
- to USB device or received from USB device.
- DataLength - Indicates the size, in bytes, of the data buffer
- specified by Data.
- TimeOut - Indicates the maximum time, in microseconds,
- which the transfer is allowed to complete.
- Translator - A pointr to the transaction translator data.
- TransferResult - A pointer to the detailed result information generated
- by this control transfer.
-
- Returns:
-
- EFI_SUCCESS
- The control transfer was completed successfully.
- EFI_OUT_OF_RESOURCES
- The control transfer could not be completed due to a lack of resources.
- EFI_INVALID_PARAMETER
- Some parameters are invalid.
- EFI_TIMEOUT
- The control transfer failed due to timeout.
- EFI_DEVICE_ERROR
- The control transfer failed due to host controller or device error.
- Caller should check TranferResult for detailed error information.
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcBulkTransfer (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN UINT8 DataBuffersNumber,
- IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
- IN OUT UINTN *DataLength,
- IN OUT UINT8 *DataToggle,
- IN UINTN TimeOut,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-/*++
-
- Routine Description:
-
- Virtual interface to submits bulk transfer to a bulk endpoint of a USB device
- both for Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - The combination of an endpoint number and an
- endpoint direction of the target USB device.
- Each endpoint address supports data transfer in
- one direction except the control endpoint
- (whose default endpoint address is 0).
- It is the caller's responsibility to make sure that
- the EndPointAddress represents a bulk endpoint.
- DeviceSpeed - Indicates device speed. The supported values are EFI_USB_SPEED_FULL
- and EFI_USB_SPEED_HIGH.
- MaximumPacketLength - Indicates the maximum packet size the target endpoint
- is capable of sending or receiving.
- DataBuffersNumber - Number of data buffers prepared for the transfer.
- Data - Array of pointers to the buffers of data that will be transmitted
- to USB device or received from USB device.
- DataLength - When input, indicates the size, in bytes, of the data buffer
- specified by Data. When output, indicates the actually
- transferred data size.
- DataToggle - A pointer to the data toggle value. On input, it indicates
- the initial data toggle value the bulk transfer should adopt;
- on output, it is updated to indicate the data toggle value
- of the subsequent bulk transfer.
- Translator - A pointr to the transaction translator data.
- TimeOut - Indicates the maximum time, in microseconds, which the
- transfer is allowed to complete.
- TransferResult - A pointer to the detailed result information of the
- bulk transfer.
-
- Returns:
-
- EFI_SUCCESS
- The bulk transfer was completed successfully.
- EFI_OUT_OF_RESOURCES
- The bulk transfer could not be submitted due to lack of resource.
- EFI_INVALID_PARAMETER
- Some parameters are invalid.
- EFI_TIMEOUT
- The bulk transfer failed due to timeout.
- EFI_DEVICE_ERROR
- The bulk transfer failed due to host controller or device error.
- Caller should check TranferResult for detailed error information.
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcAsyncInterruptTransfer (
- IN USB_BUS_CONTROLLER_DEVICE * UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN BOOLEAN IsNewTransfer,
- IN OUT UINT8 *DataToggle,
- IN UINTN PollingInterval,
- IN UINTN DataLength,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR * Translator,
- IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction,
- IN VOID *Context OPTIONAL
- )
-/*++
-
- Routine Description:
-
- Virtual interface to submits an asynchronous interrupt transfer to an
- interrupt endpoint of a USB device for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - The combination of an endpoint number and an endpoint
- direction of the target USB device. Each endpoint address
- supports data transfer in one direction except the
- control endpoint (whose default endpoint address is 0).
- It is the caller's responsibility to make sure that
- the EndPointAddress represents an interrupt endpoint.
- DeviceSpeed - Indicates device speed.
- MaximumPacketLength - Indicates the maximum packet size the target endpoint
- is capable of sending or receiving.
- IsNewTransfer - If TRUE, an asynchronous interrupt pipe is built between
- the host and the target interrupt endpoint.
- If FALSE, the specified asynchronous interrupt pipe
- is canceled.
- DataToggle - A pointer to the data toggle value. On input, it is valid
- when IsNewTransfer is TRUE, and it indicates the initial
- data toggle value the asynchronous interrupt transfer
- should adopt.
- On output, it is valid when IsNewTransfer is FALSE,
- and it is updated to indicate the data toggle value of
- the subsequent asynchronous interrupt transfer.
- PollingInterval - Indicates the interval, in milliseconds, that the
- asynchronous interrupt transfer is polled.
- This parameter is required when IsNewTransfer is TRUE.
- DataLength - Indicates the length of data to be received at the
- rate specified by PollingInterval from the target
- asynchronous interrupt endpoint. This parameter
- is only required when IsNewTransfer is TRUE.
- Translator - A pointr to the transaction translator data.
- CallBackFunction - The Callback function.This function is called at the
- rate specified by PollingInterval.This parameter is
- only required when IsNewTransfer is TRUE.
- Context - The context that is passed to the CallBackFunction.
- - This is an optional parameter and may be NULL.
-
- Returns:
-
- EFI_SUCCESS
- The asynchronous interrupt transfer request has been successfully
- submitted or canceled.
- EFI_INVALID_PARAMETER
- Some parameters are invalid.
- EFI_OUT_OF_RESOURCES
- The request could not be completed due to a lack of resources.
- EFI_DEVICE_ERROR
- Can't read register
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcSyncInterruptTransfer (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN OUT UINT8 *DataToggle,
- IN UINTN TimeOut,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-/*++
-
- Routine Description:
-
- Vitual interface to submits synchronous interrupt transfer to an interrupt endpoint
- of a USB device for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - The combination of an endpoint number and an endpoint
- direction of the target USB device. Each endpoint
- address supports data transfer in one direction
- except the control endpoint (whose default
- endpoint address is 0). It is the caller's responsibility
- to make sure that the EndPointAddress represents
- an interrupt endpoint.
- DeviceSpeed - Indicates device speed.
- MaximumPacketLength - Indicates the maximum packet size the target endpoint
- is capable of sending or receiving.
- Data - A pointer to the buffer of data that will be transmitted
- to USB device or received from USB device.
- DataLength - On input, the size, in bytes, of the data buffer specified
- by Data. On output, the number of bytes transferred.
- DataToggle - A pointer to the data toggle value. On input, it indicates
- the initial data toggle value the synchronous interrupt
- transfer should adopt;
- on output, it is updated to indicate the data toggle value
- of the subsequent synchronous interrupt transfer.
- TimeOut - Indicates the maximum time, in microseconds, which the
- transfer is allowed to complete.
- Translator - A pointr to the transaction translator data.
- TransferResult - A pointer to the detailed result information from
- the synchronous interrupt transfer.
-
- Returns:
-
- EFI_SUCCESS
- The synchronous interrupt transfer was completed successfully.
- EFI_OUT_OF_RESOURCES
- The synchronous interrupt transfer could not be submitted due
- to lack of resource.
- EFI_INVALID_PARAMETER
- Some parameters are invalid.
- EFI_TIMEOUT
- The synchronous interrupt transfer failed due to timeout.
- EFI_DEVICE_ERROR
- The synchronous interrupt transfer failed due to host controller
- or device error. Caller should check TranferResult for detailed
- error information.
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcIsochronousTransfer (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN UINT8 DataBuffersNumber,
- IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
- IN UINTN DataLength,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-/*++
-
- Routine Description:
-
- Virtual interface to submits isochronous transfer to a target USB device
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - End point address
- DeviceSpeed - Indicates device speed.
- MaximumPacketLength - Indicates the maximum packet size that the
- default control transfer endpoint is capable of
- sending or receiving.
- DataBuffersNumber - Number of data buffers prepared for the transfer.
- Data - Array of pointers to the buffers of data that will be
- transmitted to USB device or received from USB device.
- DataLength - Indicates the size, in bytes, of the data buffer
- specified by Data.
- Translator - A pointr to the transaction translator data.
- TransferResult - A pointer to the detailed result information generated
- by this control transfer.
-
- Returns:
-
- EFI_UNSUPPORTED
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbVirtualHcAsyncIsochronousTransfer (
- IN USB_BUS_CONTROLLER_DEVICE *UsbBusDev,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN UINT8 DataBuffersNumber,
- IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
- IN UINTN DataLength,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
- IN VOID *Context
- )
-/*++
-
- Routine Description:
-
- Vitual interface to submits Async isochronous transfer to a target USB device
- for both Hc2 and Hc protocol.
-
- Arguments:
-
- UsbBusDev - A pointer to bus controller of the device.
- DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - End point address
- DeviceSpeed - Indicates device speed.
- MaximumPacketLength - Indicates the maximum packet size that the
- default control transfer endpoint is capable of
- sending or receiving.
- DataBuffersNumber - Number of data buffers prepared for the transfer.
- Data - Array of pointers to the buffers of data that will be transmitted
- to USB device or received from USB device.
- DataLength - Indicates the size, in bytes, of the data buffer
- specified by Data.
- Translator - A pointr to the transaction translator data.
- IsochronousCallBack - When the transfer complete, the call back function will be called
- Context - Pass to the call back function as parameter
-
- Returns:
-
- EFI_UNSUPPORTED
-
---*/
-;
-
-EFI_STATUS
-EFIAPI
-UsbPortReset (
- IN EFI_USB_IO_PROTOCOL *This
- )
-/*++
-
- Routine Description:
- Resets and reconfigures the USB controller. This function will
- work for all USB devices except USB Hub Controllers.
-
- Arguments:
- This - Indicates the calling context.
-
- Returns:
- EFI_SUCCESS
- EFI_INVALID_PARAMETER
- EFI_DEVICE_ERROR
-
---*/
-;
-
-VOID
-InitializeUsbIoInstance (
- IN USB_IO_CONTROLLER_DEVICE *UsbIoController
- )
-/*++
-
-Routine Description:
-
- Initialize the instance of UsbIo controller
-
-Arguments:
-
- UsbIoController - A pointer to controller structure of UsbIo
-
-Returns:
-
---*/
-;
-
-#endif
diff --git a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbio.c b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbio.c
deleted file mode 100644
index 4601767f64..0000000000
--- a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbio.c
+++ /dev/null
@@ -1,1183 +0,0 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- Module Name:
-
- UsbIo.c
-
- Abstract:
-
- USB I/O Abstraction Driver
-
- Revision History
-
---*/
-
-#include "usbbus.h"
-
-//
-// USB I/O Support Function Prototypes
-//
-STATIC
-EFI_STATUS
-EFIAPI
-UsbControlTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN EFI_USB_DEVICE_REQUEST *Request,
- IN EFI_USB_DATA_DIRECTION Direction,
- IN UINT32 Timeout,
- IN OUT VOID *Data, OPTIONAL
- IN UINTN DataLength, OPTIONAL
- OUT UINT32 *Status
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbBulkTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN Timeout,
- OUT UINT32 *Status
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbAsyncInterruptTransfer (
- IN EFI_USB_IO_PROTOCOL * This,
- IN UINT8 DeviceEndpoint,
- IN BOOLEAN IsNewTransfer,
- IN UINTN PollingInterval, OPTIONAL
- IN UINTN DataLength, OPTIONAL
- IN EFI_ASYNC_USB_TRANSFER_CALLBACK InterruptCallBack, OPTIONAL
- IN VOID *Context OPTIONAL
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbSyncInterruptTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN Timeout,
- OUT UINT32 *Status
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbIsochronousTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN UINTN DataLength,
- OUT UINT32 *Status
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbAsyncIsochronousTransfer (
- IN EFI_USB_IO_PROTOCOL * This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN UINTN DataLength,
- IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
- IN VOID *Context OPTIONAL
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetDeviceDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT EFI_USB_DEVICE_DESCRIPTOR *DeviceDescriptor
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetActiveConfigDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT EFI_USB_CONFIG_DESCRIPTOR *ConfigurationDescriptor
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetInterfaceDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDescriptor
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetEndpointDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 EndpointIndex,
- OUT EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetStringDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT16 LangID,
- IN UINT8 StringIndex,
- OUT CHAR16 **String
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetSupportedLanguages (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT UINT16 **LangIDTable,
- OUT UINT16 *TableSize
- );
-
-//
-// USB I/O Interface structure
-//
-STATIC EFI_USB_IO_PROTOCOL UsbIoInterface = {
- UsbControlTransfer,
- UsbBulkTransfer,
- UsbAsyncInterruptTransfer,
- UsbSyncInterruptTransfer,
- UsbIsochronousTransfer,
- UsbAsyncIsochronousTransfer,
- UsbGetDeviceDescriptor,
- UsbGetActiveConfigDescriptor,
- UsbGetInterfaceDescriptor,
- UsbGetEndpointDescriptor,
- UsbGetStringDescriptor,
- UsbGetSupportedLanguages,
- UsbPortReset
-};
-
-VOID
-InitializeUsbIoInstance (
- IN USB_IO_CONTROLLER_DEVICE *UsbIoController
- )
-/*++
-
-Routine Description:
-
- Initialize the instance of UsbIo controller
-
-Arguments:
-
- UsbIoController - A pointer to controller structure of UsbIo
-
-Returns:
-
---*/
-{
- //
- // Copy EFI_USB_IO protocol instance
- //
- CopyMem (
- &UsbIoController->UsbIo,
- &UsbIoInterface,
- sizeof (EFI_USB_IO_PROTOCOL)
- );
-}
-//
-// Implementation
-//
-STATIC
-EFI_STATUS
-EFIAPI
-UsbControlTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN EFI_USB_DEVICE_REQUEST *Request,
- IN EFI_USB_DATA_DIRECTION Direction,
- IN UINT32 Timeout,
- IN OUT VOID *Data, OPTIONAL
- IN UINTN DataLength, OPTIONAL
- OUT UINT32 *Status
- )
-/*++
-
- Routine Description:
- This function is used to manage a USB device with a control transfer pipe.
-
- Arguments:
- This - Indicates calling context.
- Request - A pointer to the USB device request that will be sent to
- the USB device.
- Direction - Indicates the data direction.
- Data - A pointer to the buffer of data that will be transmitted
- to USB device or received from USB device.
- Timeout - Indicates the transfer should be completed within this time
- frame.
- DataLength - The size, in bytes, of the data buffer specified by Data.
- Status - A pointer to the result of the USB transfer.
-
- Returns:
- EFI_SUCCESS
- EFI_INVALID_PARAMETER
- EFI_OUT_OF_RESOURCES
- EFI_TIMEOUT
- EFI_DEVICE_ERROR
-
---*/
-{
- USB_IO_CONTROLLER_DEVICE *UsbIoController;
-
- EFI_STATUS RetStatus;
- USB_IO_DEVICE *UsbIoDev;
- UINT8 MaxPacketLength;
- UINT32 TransferResult;
- BOOLEAN Disconnected;
- //
- // Parameters Checking
- //
- if (Status == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // leave the HostController's ControlTransfer
- // to perform other parameters checking
- //
- UsbIoController = USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This);
- UsbIoDev = UsbIoController->UsbDevice;
-
- MaxPacketLength = UsbIoDev->DeviceDescriptor.MaxPacketSize0;
-
-
- if (Request->Request == USB_DEV_CLEAR_FEATURE &&
- Request->RequestType == 0x02 &&
- Request->Value == EfiUsbEndpointHalt) {
- //
- //Reduce the remove delay time for system response
- //
- IsDeviceDisconnected (UsbIoController, &Disconnected);
- if (!EFI_ERROR (Status) && Disconnected == TRUE) {
- DEBUG ((gUSBErrorLevel, "Device is disconnected when trying reset\n"));
- return EFI_DEVICE_ERROR;
- }
- }
- //
- // using HostController's ControlTransfer to complete the request
- //
- RetStatus = UsbVirtualHcControlTransfer (
- UsbIoDev->BusController,
- UsbIoDev->DeviceAddress,
- UsbIoDev->DeviceSpeed,
- MaxPacketLength,
- Request,
- Direction,
- Data,
- &DataLength,
- (UINTN) Timeout,
- UsbIoDev->Translator,
- &TransferResult
- );
-
- *Status = TransferResult;
-
- if (Request->Request == USB_DEV_CLEAR_FEATURE &&
- Request->RequestType == 0x02 &&
- Request->Value == EfiUsbEndpointHalt) {
- //
- // This is a UsbClearEndpointHalt request
- // Need to clear data toggle
- // Request.Index == EndpointAddress
- //
- if (!EFI_ERROR (RetStatus) && TransferResult == EFI_USB_NOERROR) {
- SetDataToggleBit (
- This,
- (UINT8) Request->Index,
- 0
- );
- }
- }
- return RetStatus;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbBulkTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN Timeout,
- OUT UINT32 *Status
- )
-/*++
-
- Routine Description:
- This function is used to manage a USB device with the bulk transfer pipe.
-
- Arguments:
- This - Indicates calling context.
- DeviceEndpoint - The destination USB device endpoint to which the device
- request is being sent.
- Data - A pointer to the buffer of data that will be transmitted
- to USB device or received from USB device.
- DataLength - On input, the size, in bytes, of the data buffer
- specified by Data. On output, the number of bytes that
- were actually transferred.
- Timeout - Indicates the transfer should be completed within this
- time frame.
- Status - This parameter indicates the USB transfer status.
-
- Returns:
- EFI_SUCCESS
- EFI_INVALID_PARAMETER
- EFI_OUT_OF_RESOURCES
- EFI_TIMEOUT
- EFI_DEVICE_ERROR
-
---*/
-{
- USB_IO_DEVICE *UsbIoDev;
- UINTN MaxPacketLength;
- UINT8 DataToggle;
- UINT8 OldToggle;
- EFI_STATUS RetStatus;
- USB_IO_CONTROLLER_DEVICE *UsbIoController;
- ENDPOINT_DESC_LIST_ENTRY *EndPointListEntry;
- UINT8 DataBuffersNumber;
- UINT32 TransferResult;
-
- DataBuffersNumber = 1;
- UsbIoController = USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This);
- UsbIoDev = UsbIoController->UsbDevice;
-
- //
- // Parameters Checking
- //
- if ((DeviceEndpoint & 0x7F) == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((DeviceEndpoint & 0x7F) > 15) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Status == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- EndPointListEntry = FindEndPointListEntry (
- This,
- DeviceEndpoint
- );
-
- if (EndPointListEntry == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((EndPointListEntry->EndpointDescriptor.Attributes & 0x03) != 0x02) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // leave the HostController's BulkTransfer
- // to perform other parameters checking
- //
- GetDeviceEndPointMaxPacketLength (
- This,
- DeviceEndpoint,
- &MaxPacketLength
- );
-
- GetDataToggleBit (
- This,
- DeviceEndpoint,
- &DataToggle
- );
-
- OldToggle = DataToggle;
-
- //
- // using HostController's BulkTransfer to complete the request
- //
- RetStatus = UsbVirtualHcBulkTransfer (
- UsbIoDev->BusController,
- UsbIoDev->DeviceAddress,
- DeviceEndpoint,
- UsbIoDev->DeviceSpeed,
- MaxPacketLength,
- DataBuffersNumber,
- &Data,
- DataLength,
- &DataToggle,
- Timeout,
- UsbIoDev->Translator,
- &TransferResult
- );
-
- if (OldToggle != DataToggle) {
- //
- // Write the toggle back
- //
- SetDataToggleBit (
- This,
- DeviceEndpoint,
- DataToggle
- );
- }
-
- *Status = TransferResult;
-
- return RetStatus;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbSyncInterruptTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN Timeout,
- OUT UINT32 *Status
- )
-/*++
-
- Routine Description:
- Usb Sync Interrupt Transfer
-
- Arguments:
- This - Indicates calling context.
- DeviceEndpoint - The destination USB device endpoint to which the device
- request is being sent.
- Data - A pointer to the buffer of data that will be transmitted
- to USB device or received from USB device.
- DataLength - On input, the size, in bytes, of the data buffer
- specified by Data. On output, the number of bytes that
- were actually transferred.
- Timeout - Indicates the transfer should be completed within this
- time frame.
- Status - This parameter indicates the USB transfer status.
-
- Returns:
- EFI_SUCCESS
- EFI_INVALID_PARAMETER
- EFI_OUT_OF_RESOURCES
- EFI_TIMEOUT
- EFI_DEVICE_ERROR
-
---*/
-{
- USB_IO_DEVICE *UsbIoDev;
- UINTN MaxPacketLength;
- UINT8 DataToggle;
- UINT8 OldToggle;
- EFI_STATUS RetStatus;
- USB_IO_CONTROLLER_DEVICE *UsbIoController;
- ENDPOINT_DESC_LIST_ENTRY *EndPointListEntry;
-
- //
- // Parameters Checking
- //
- if ((DeviceEndpoint & 0x7F) == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((DeviceEndpoint & 0x7F) > 15) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Status == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- EndPointListEntry = FindEndPointListEntry (
- This,
- DeviceEndpoint
- );
-
- if (EndPointListEntry == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((EndPointListEntry->EndpointDescriptor.Attributes & 0x03) != 0x03) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // leave the HostController's SyncInterruptTransfer
- // to perform other parameters checking
- //
- UsbIoController = USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This);
- UsbIoDev = UsbIoController->UsbDevice;
- GetDeviceEndPointMaxPacketLength (
- This,
- DeviceEndpoint,
- &MaxPacketLength
- );
-
- GetDataToggleBit (
- This,
- DeviceEndpoint,
- &DataToggle
- );
-
- OldToggle = DataToggle;
- //
- // using HostController's SyncInterruptTransfer to complete the request
- //
- RetStatus = UsbVirtualHcSyncInterruptTransfer (
- UsbIoDev->BusController,
- UsbIoDev->DeviceAddress,
- DeviceEndpoint,
- UsbIoDev->DeviceSpeed,
- MaxPacketLength,
- Data,
- DataLength,
- &DataToggle,
- Timeout,
- UsbIoDev->Translator,
- Status
- );
-
- if (OldToggle != DataToggle) {
- //
- // Write the toggle back
- //
- SetDataToggleBit (
- This,
- DeviceEndpoint,
- DataToggle
- );
- }
-
- return RetStatus;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbAsyncInterruptTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 DeviceEndpoint,
- IN BOOLEAN IsNewTransfer,
- IN UINTN PollingInterval, OPTIONAL
- IN UINTN DataLength, OPTIONAL
- IN EFI_ASYNC_USB_TRANSFER_CALLBACK InterruptCallBack, OPTIONAL
- IN VOID *Context OPTIONAL
- )
-/*++
-
- Routine Description:
- Usb Async Interrput Transfer
-
- Arguments:
- This - Indicates calling context.
- DeviceEndpoint - The destination USB device endpoint to which the
- device request is being sent.
- IsNewTransfer - If TRUE, a new transfer will be submitted to USB
- controller. If FALSE, the interrupt transfer is
- deleted from the device's interrupt transfer queue.
- PollingInterval - Indicates the periodic rate, in milliseconds, that
- the transfer is to be executed.
- DataLength - Specifies the length, in bytes, of the data to be
- received from the USB device.
- InterruptCallBack - The Callback function. This function is called if
- the asynchronous interrupt transfer is completed.
- Context - Passed to InterruptCallback
- Returns:
- EFI_SUCCESS
- EFI_INVALID_PARAMETER
- EFI_OUT_OF_RESOURCES
-
---*/
-{
- USB_IO_DEVICE *UsbIoDev;
- UINTN MaxPacketLength;
- UINT8 DataToggle;
- EFI_STATUS RetStatus;
- USB_IO_CONTROLLER_DEVICE *UsbIoController;
- ENDPOINT_DESC_LIST_ENTRY *EndpointListEntry;
-
- //
- // Check endpoint
- //
- if ((DeviceEndpoint & 0x7F) == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((DeviceEndpoint & 0x7F) > 15) {
- return EFI_INVALID_PARAMETER;
- }
-
- EndpointListEntry = FindEndPointListEntry (
- This,
- DeviceEndpoint
- );
-
- if (EndpointListEntry == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((EndpointListEntry->EndpointDescriptor.Attributes & 0x03) != 0x03) {
- return EFI_INVALID_PARAMETER;
- }
-
- UsbIoController = USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This);
- UsbIoDev = UsbIoController->UsbDevice;
-
- if (!IsNewTransfer) {
- //
- // Delete this transfer
- //
- UsbVirtualHcAsyncInterruptTransfer (
- UsbIoDev->BusController,
- UsbIoDev->DeviceAddress,
- DeviceEndpoint,
- UsbIoDev->DeviceSpeed,
- 0,
- FALSE,
- &DataToggle,
- PollingInterval,
- DataLength,
- UsbIoDev->Translator,
- NULL,
- NULL
- );
-
- //
- // We need to store the toggle value
- //
- SetDataToggleBit (
- This,
- DeviceEndpoint,
- DataToggle
- );
-
- return EFI_SUCCESS;
- }
-
- GetDeviceEndPointMaxPacketLength (
- This,
- DeviceEndpoint,
- &MaxPacketLength
- );
-
- GetDataToggleBit (
- This,
- DeviceEndpoint,
- &DataToggle
- );
-
- RetStatus = UsbVirtualHcAsyncInterruptTransfer (
- UsbIoDev->BusController,
- UsbIoDev->DeviceAddress,
- DeviceEndpoint,
- UsbIoDev->DeviceSpeed,
- MaxPacketLength,
- TRUE,
- &DataToggle,
- PollingInterval,
- DataLength,
- UsbIoDev->Translator,
- InterruptCallBack,
- Context
- );
-
- return RetStatus;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbIsochronousTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN UINTN DataLength,
- OUT UINT32 *Status
- )
-/*++
-
- Routine Description:
- Usb Isochronous Transfer
-
- Arguments:
- This - Indicates calling context.
- DeviceEndpoint - The destination USB device endpoint to which the
- device request is being sent.
- Data - A pointer to the buffer of data that will be
- transmitted to USB device or received from USB device.
- DataLength - The size, in bytes, of the data buffer specified by
- Data.
- Status - This parameter indicates the USB transfer status.
-
- Returns:
- EFI_SUCCESS
- EFI_INVALID_PARAMETER
- EFI_OUT_OF_RESOURCES
- EFI_TIMEOUT
- EFI_DEVICE_ERROR
- EFI_UNSUPPORTED
---*/
-{
- //
- // Currently we don't support this transfer
- //
- return EFI_UNSUPPORTED;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbAsyncIsochronousTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN UINTN DataLength,
- IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
- IN VOID *Context OPTIONAL
- )
-/*++
-
-Routine Description:
-
- Usb Async Isochronous Transfer
-
-Arguments:
-
- This - EFI_USB_IO_PROTOCOL
- DeviceEndpoint - DeviceEndpoint number
- Data - Data to transfer
- DataLength - DataLength
- IsochronousCallBack - Isochronous CallBack function
- Context - Passed to IsochronousCallBack function
-Returns:
-
- EFI_UNSUPPORTED - Unsupported now
-
---*/
-{
- //
- // Currently we don't support this transfer
- //
- return EFI_UNSUPPORTED;
-}
-//
-// Here is new definitions
-//
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetDeviceDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT EFI_USB_DEVICE_DESCRIPTOR *DeviceDescriptor
- )
-/*++
-
- Routine Description:
- Retrieves the USB Device Descriptor.
-
- Arguments:
- This - Indicates the calling context.
- DeviceDescriptor - A pointer to the caller allocated USB Device
- Descriptor.
-
- Returns:
- EFI_SUCCESS
- EFI_INVALID_PARAMETER
- EFI_NOT_FOUND
-
---*/
-{
- USB_IO_CONTROLLER_DEVICE *UsbIoController;
- USB_IO_DEVICE *UsbIoDev;
-
- //
- // This function just wrapps UsbGetDeviceDescriptor.
- //
-
- if (DeviceDescriptor == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- UsbIoController = USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This);
- UsbIoDev = UsbIoController->UsbDevice;
-
- if (!UsbIoDev->IsConfigured) {
- return EFI_NOT_FOUND;
- }
-
- CopyMem (
- DeviceDescriptor,
- &UsbIoDev->DeviceDescriptor,
- sizeof (EFI_USB_DEVICE_DESCRIPTOR)
- );
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetActiveConfigDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT EFI_USB_CONFIG_DESCRIPTOR *ConfigurationDescriptor
- )
-/*++
-
- Routine Description:
- Retrieves the current USB configuration Descriptor.
-
- Arguments:
- This - Indicates the calling context.
- ConfigurationDescriptor - A pointer to the caller allocated USB active
- Configuration Descriptor.
-
- Returns:
- EFI_SUCCESS
- EFI_INVALID_PARAMETER
- EFI_NOT_FOUND
-
---*/
-{
- USB_IO_DEVICE *UsbIoDev;
- USB_IO_CONTROLLER_DEVICE *UsbIoController;
-
- //
- // This function just wrapps UsbGetActiveConfigDescriptor.
- //
- if (ConfigurationDescriptor == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- UsbIoController = USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This);
- UsbIoDev = UsbIoController->UsbDevice;
-
- if (!UsbIoDev->IsConfigured) {
- return EFI_NOT_FOUND;
- }
-
- CopyMem (
- ConfigurationDescriptor,
- &(UsbIoDev->ActiveConfig->CongfigDescriptor),
- sizeof (EFI_USB_CONFIG_DESCRIPTOR)
- );
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetInterfaceDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDescriptor
- )
-/*++
-
- Routine Description:
- Retrieves the interface Descriptor for that controller.
-
- Arguments:
- This - Indicates the calling context.
- InterfaceDescriptor - A pointer to the caller allocated USB interface
- Descriptor.
-
- Returns:
- EFI_SUCCESS
- EFI_INVALID_PARAMETER
- EFI_NOT_FOUND
-
---*/
-{
- INTERFACE_DESC_LIST_ENTRY *InterfaceListEntry;
-
- if (InterfaceDescriptor == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- InterfaceListEntry = FindInterfaceListEntry (This);
-
- if (InterfaceListEntry == NULL) {
- return EFI_NOT_FOUND;
- }
-
- CopyMem (
- InterfaceDescriptor,
- &(InterfaceListEntry->InterfaceDescriptor),
- sizeof (EFI_USB_INTERFACE_DESCRIPTOR)
- );
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetEndpointDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 EndpointIndex,
- OUT EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor
- )
-/*++
-
- Routine Description:
- Retrieves the endpoint Descriptor for a given endpoint.
-
- Arguments:
- This - Indicates the calling context.
- EndpointIndex - Indicates which endpoint descriptor to retrieve.
- The valid range is 0..15.
- EndpointDescriptor - A pointer to the caller allocated USB Endpoint
- Descriptor of a USB controller.
-
- Returns:
- EFI_SUCCESS - The endpoint descriptor was retrieved successfully.
- EFI_INVALID_PARAMETER - EndpointIndex is not valid.
- - EndpointDescriptor is NULL.
- EFI_NOT_FOUND - The endpoint descriptor cannot be found.
- The device may not be correctly configured.
-
---*/
-{
- INTERFACE_DESC_LIST_ENTRY *InterfaceListEntry;
- LIST_ENTRY *EndpointListHead;
- ENDPOINT_DESC_LIST_ENTRY *EndpointListEntry;
-
- if (EndpointDescriptor == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (EndpointIndex > 15) {
- return EFI_INVALID_PARAMETER;
- }
-
- InterfaceListEntry = FindInterfaceListEntry (This);
-
- if (InterfaceListEntry == NULL) {
- return EFI_NOT_FOUND;
- }
-
- EndpointListHead = (LIST_ENTRY *) (&InterfaceListEntry->EndpointDescListHead);
- EndpointListEntry = (ENDPOINT_DESC_LIST_ENTRY *) (EndpointListHead->ForwardLink);
-
- if (EndpointIndex >= InterfaceListEntry->InterfaceDescriptor.NumEndpoints) {
- return EFI_NOT_FOUND;
- }
- //
- // Loop all endpoint descriptor to get match one.
- //
- while (EndpointIndex != 0) {
- EndpointListEntry = (ENDPOINT_DESC_LIST_ENTRY *) (EndpointListEntry->Link.ForwardLink);
- EndpointIndex--;
- }
-
- CopyMem (
- EndpointDescriptor,
- &EndpointListEntry->EndpointDescriptor,
- sizeof (EFI_USB_ENDPOINT_DESCRIPTOR)
- );
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetSupportedLanguages (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT UINT16 **LangIDTable,
- OUT UINT16 *TableSize
- )
-/*++
-
- Routine Description:
- Get all the languages that the USB device supports
-
- Arguments:
- This - Indicates the calling context.
- LangIDTable - Language ID for the string the caller wants to get.
- TableSize - The size, in bytes, of the table LangIDTable.
-
- Returns:
- EFI_SUCCESS
- EFI_NOT_FOUND
-
---*/
-{
- USB_IO_DEVICE *UsbIoDev;
- USB_IO_CONTROLLER_DEVICE *UsbIoController;
- UINTN Index;
- BOOLEAN Found;
-
- UsbIoController = USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This);
- UsbIoDev = UsbIoController->UsbDevice;
-
- Found = FALSE;
- Index = 0;
- //
- // Loop language table
- //
- while (UsbIoDev->LangID[Index]) {
- Found = TRUE;
- Index++;
- }
-
- if (!Found) {
- return EFI_NOT_FOUND;
- }
-
- *LangIDTable = UsbIoDev->LangID;
- *TableSize = (UINT16) Index;
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-UsbGetStringDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT16 LangID,
- IN UINT8 StringIndex,
- OUT CHAR16 **String
- )
-/*++
-
- Routine Description:
- Get a given string descriptor
-
- Arguments:
- This - Indicates the calling context.
- LangID - The Language ID for the string being retrieved.
- StringIndex - The ID of the string being retrieved.
- String - A pointer to a buffer allocated by this function
- with AllocatePool() to store the string. If this
- function returns EFI_SUCCESS, it stores the string
- the caller wants to get. The caller should release
- the string buffer with FreePool() after the string
- is not used any more.
- Returns:
- EFI_SUCCESS
- EFI_NOT_FOUND
- EFI_OUT_OF_RESOURCES
- EFI_UNSUPPORTED
-
---*/
-{
- UINT32 Status;
- EFI_STATUS Result;
- EFI_USB_STRING_DESCRIPTOR *StrDescriptor;
- UINT8 *Buffer;
- CHAR16 *UsbString;
- UINT16 TempBuffer;
- USB_IO_DEVICE *UsbIoDev;
- UINT8 Index;
- BOOLEAN Found;
- USB_IO_CONTROLLER_DEVICE *UsbIoController;
-
- if (StringIndex == 0) {
- return EFI_NOT_FOUND;
- }
- //
- // Search LanguageID, check if it is supported by this device
- //
- if (LangID == 0) {
- return EFI_NOT_FOUND;
- }
-
- UsbIoController = USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This);
- UsbIoDev = UsbIoController->UsbDevice;
-
- Found = FALSE;
- Index = 0;
- while (UsbIoDev->LangID[Index]) {
- if (UsbIoDev->LangID[Index] == LangID) {
- Found = TRUE;
- break;
- }
-
- Index++;
- }
-
- if (!Found) {
- return EFI_NOT_FOUND;
- }
- //
- // Get String Length
- //
- Result = UsbGetString (
- This,
- LangID,
- StringIndex,
- &TempBuffer,
- 2,
- &Status
- );
- if (EFI_ERROR (Result)) {
- return EFI_NOT_FOUND;
- }
-
- StrDescriptor = (EFI_USB_STRING_DESCRIPTOR *) &TempBuffer;
-
- if (StrDescriptor->Length == 0) {
- return EFI_UNSUPPORTED;
- }
-
- Buffer = AllocateZeroPool (StrDescriptor->Length);
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Result = UsbGetString (
- This,
- LangID,
- StringIndex,
- Buffer,
- StrDescriptor->Length,
- &Status
- );
-
- if (EFI_ERROR (Result)) {
- gBS->FreePool (Buffer);
- return EFI_NOT_FOUND;
- }
-
- StrDescriptor = (EFI_USB_STRING_DESCRIPTOR *) Buffer;
-
- //
- // UsbString is a UNICODE string
- //
- UsbString = AllocateZeroPool (StrDescriptor->Length);
- if (UsbString == NULL) {
- gBS->FreePool (Buffer);
- return EFI_OUT_OF_RESOURCES;
- }
-
- CopyMem (
- (VOID *) UsbString,
- Buffer + 2,
- StrDescriptor->Length - 2
- );
-
- *String = UsbString;
-
- gBS->FreePool (Buffer);
-
- return EFI_SUCCESS;
-}
diff --git a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbutil.c b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbutil.c
deleted file mode 100644
index e3380856bf..0000000000
--- a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbutil.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- Module Name:
- usbutil.c
-
- Abstract:
-
- Helper functions for USB
-
- Revision History
-
---*/
-
-#include "usbbus.h"
-
-//
-// Following APIs are used to query Port Status
-//
-BOOLEAN
-IsPortConnect (
- IN UINT16 PortStatus
- )
-/*++
-
- Routine Description:
- Tell if there is a device connected to that port according to
- the Port Status.
-
- Arguments:
- PortStatus - The status value of that port.
-
- Returns:
- TRUE
- FALSE
-
---*/
-{
- //
- // return the bit 0 value of PortStatus
- //
- if ((PortStatus & USB_PORT_STAT_CONNECTION) != 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-BOOLEAN
-IsPortEnable (
- IN UINT16 PortStatus
- )
-/*++
-
- Routine Description:
- Tell if Port is enabled.
-
- Arguments:
- PortStatus - The status value of that port.
-
- Returns:
- TRUE - Port is enable
- FALSE - Port is disable
-
---*/
-{
- //
- // return the bit 1 value of PortStatus
- //
- if ((PortStatus & USB_PORT_STAT_ENABLE) != 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-BOOLEAN
-IsPortInReset (
- IN UINT16 PortStatus
- )
-/*++
-
- Routine Description:
- Tell if the port is being reset.
-
- Arguments:
- PortStatus - The status value of that port.
-
- Returns:
- TRUE
- FALSE
-
---*/
-{
- //
- // return the bit 4 value of PortStatus
- //
- if ((PortStatus & USB_PORT_STAT_RESET) != 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-BOOLEAN
-IsPortPowerApplied (
- IN UINT16 PortStatus
- )
-/*++
-
- Routine Description:
- Tell if there is power applied to that port.
-
- Arguments:
- PortStatus - The status value of that port.
-
- Returns:
- TRUE
- FALSE
-
---*/
-{
- //
- // return the bit 8 value of PortStatus
- //
- if ((PortStatus & USB_PORT_STAT_POWER) != 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-BOOLEAN
-IsPortLowSpeedDeviceAttached (
- IN UINT16 PortStatus
- )
-/*++
-
- Routine Description:
- Tell if the connected device is a low device.
-
- Arguments:
- PortStatus - The status value of that port.
-
- Returns:
- TRUE
- FALSE
-
---*/
-{
- //
- // return the bit 9 value of PortStatus
- //
- if ((PortStatus & USB_PORT_STAT_LOW_SPEED) != 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-BOOLEAN
-IsPortSuspend (
- IN UINT16 PortStatus
- )
-/*++
-
- Routine Description:
- Tell if the port is suspend.
-
- Arguments:
- PortStatus - The status value of that port.
-
- Returns:
- TRUE
- FALSE
-
---*/
-{
- //
- // return the bit 2 value of PortStatus
- //
- if ((PortStatus & USB_PORT_STAT_SUSPEND) != 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-//
-// Following APIs are used to query Port Change Status
-//
-BOOLEAN
-IsPortConnectChange (
- IN UINT16 PortChangeStatus
- )
-/*++
-
- Routine Description:
- Tell if there is a Connect Change status in that port.
-
- Arguments:
- PortChangeStatus - The status value of that port.
-
- Returns:
- TRUE
- FALSE
-
---*/
-{
- //
- // return the bit 0 value of PortChangeStatus
- //
- if ((PortChangeStatus & USB_PORT_STAT_C_CONNECTION) != 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-BOOLEAN
-IsPortEnableDisableChange (
- IN UINT16 PortChangeStatus
- )
-/*++
-
- Routine Description:
- Tell if there is a Enable/Disable change in that port.
-
- Arguments:
- PortChangeStatus - The status value of that port.
-
- Returns:
- TRUE
- FALSE
-
---*/
-{
- //
- // return the bit 1 value of PortChangeStatus
- //
- if ((PortChangeStatus & USB_PORT_STAT_C_ENABLE) != 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-BOOLEAN
-IsPortResetChange (
- IN UINT16 PortChangeStatus
- )
-/*++
-
- Routine Description:
- Tell if there is a Port Reset Change status in that port.
-
- Arguments:
- PortChangeStatus - The status value of that port.
-
- Returns:
- TRUE
- FALSE
-
---*/
-{
- //
- // return the bit 4 value of PortChangeStatus
- //
- if ((PortChangeStatus & USB_PORT_STAT_C_RESET) != 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-BOOLEAN
-IsPortSuspendChange (
- IN UINT16 PortChangeStatus
- )
-/*++
-
- Routine Description:
- Tell if there is a Suspend Change Status in that port.
-
- Arguments:
- PortChangeStatus - The status value of that port.
-
- Returns:
- TRUE
- FALSE
-
---*/
-{
- //
- // return the bit 2 value of PortChangeStatus
- //
- if ((PortChangeStatus & USB_PORT_STAT_C_SUSPEND) != 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-INTERFACE_DESC_LIST_ENTRY *
-FindInterfaceListEntry (
- IN EFI_USB_IO_PROTOCOL *This
- )
-/*++
-
- Routine Description:
- Find Interface ListEntry.
-
- Arguments:
- This - EFI_USB_IO_PROTOCOL
-
- Returns:
- INTERFACE_DESC_LIST_ENTRY pointer
-
---*/
-{
- USB_IO_CONTROLLER_DEVICE *UsbIoController;
- USB_IO_DEVICE *UsbIoDev;
- LIST_ENTRY *InterfaceListHead;
- INTERFACE_DESC_LIST_ENTRY *InterfaceListEntry;
-
- UsbIoController = USB_IO_CONTROLLER_DEVICE_FROM_USB_IO_THIS (This);
- UsbIoDev = UsbIoController->UsbDevice;
-
- if (!UsbIoDev->IsConfigured) {
- return NULL;
- }
-
- InterfaceListHead = &UsbIoDev->ActiveConfig->InterfaceDescListHead;
- InterfaceListEntry = (INTERFACE_DESC_LIST_ENTRY *) (InterfaceListHead->ForwardLink);
-
- //
- // Loop all interface descriptor to get match one.
- //
- while (InterfaceListEntry != (INTERFACE_DESC_LIST_ENTRY *) InterfaceListHead) {
- if (InterfaceListEntry->InterfaceDescriptor.InterfaceNumber == UsbIoController->InterfaceNumber) {
- return InterfaceListEntry;
- }
-
- InterfaceListEntry = (INTERFACE_DESC_LIST_ENTRY *) InterfaceListEntry->Link.ForwardLink;
- }
-
- return NULL;
-}
-
-ENDPOINT_DESC_LIST_ENTRY*
-FindEndPointListEntry (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 EndPointAddress
- )
-/*++
-
- Routine Description:
- Find EndPoint ListEntry.
-
- Arguments:
- This - EFI_USB_IO_PROTOCOL
- EndPointAddress - Endpoint address.
-
- Returns:
- ENDPOINT_DESC_LIST_ENTRY pointer
-
---*/
-{
- INTERFACE_DESC_LIST_ENTRY *InterfaceListEntry;
- LIST_ENTRY *EndpointDescListHead;
- ENDPOINT_DESC_LIST_ENTRY *EndPointListEntry;
-
- InterfaceListEntry = FindInterfaceListEntry (This);
- if (InterfaceListEntry != NULL) {
- EndpointDescListHead = &InterfaceListEntry->EndpointDescListHead;
- EndPointListEntry = (ENDPOINT_DESC_LIST_ENTRY *) (EndpointDescListHead->ForwardLink);
-
- //
- // Loop all interface descriptor to get match one.
- //
- while (EndPointListEntry != (ENDPOINT_DESC_LIST_ENTRY *) EndpointDescListHead) {
- if (EndPointListEntry->EndpointDescriptor.EndpointAddress == EndPointAddress) {
- return EndPointListEntry;
- }
-
- EndPointListEntry = (ENDPOINT_DESC_LIST_ENTRY *) EndPointListEntry->Link.ForwardLink;
- }
- }
-
- return NULL;
-}
-
-VOID
-GetDataToggleBit (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 EndpointAddr,
- OUT UINT8 *DataToggle
- )
-/*++
-
- Routine Description:
- Get the datatoggle of a specified endpoint.
-
- Arguments:
- UsbIo - Given Usb Controller device.
- EndpointAddr - Given Endpoint address.
- DataToggle - The current data toggle of that endpoint
-
- Returns:
- N/A
-
---*/
-{
-
- ENDPOINT_DESC_LIST_ENTRY *EndpointListEntry;
-
- *DataToggle = 0;
-
- EndpointListEntry = FindEndPointListEntry (UsbIo, EndpointAddr);
- if (EndpointListEntry == NULL) {
- return ;
- }
-
- *DataToggle = (UINT8) (EndpointListEntry->Toggle);
- return ;
-}
-
-VOID
-SetDataToggleBit (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 EndpointAddr,
- IN UINT8 DataToggle
- )
-/*++
-
- Routine Description:
- Set the datatoggle of a specified endpoint
-
- Arguments:
- UsbIo - Given Usb Controller device.
- EndpointAddr - Given Endpoint address.
- DataToggle - The current data toggle of that endpoint to be set
-
- Returns:
- N/A
-
---*/
-{
-
- ENDPOINT_DESC_LIST_ENTRY *EndpointListEntry;
-
- EndpointListEntry = FindEndPointListEntry (UsbIo, EndpointAddr);
- if (EndpointListEntry == NULL) {
- return ;
- }
-
- EndpointListEntry->Toggle = DataToggle;
- return ;
-}
-
-VOID
-GetDeviceEndPointMaxPacketLength (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 EndpointAddr,
- OUT UINTN *MaxPacketLength
- )
-/*++
-
- Routine Description:
- Get the Max Packet Length of the speified Endpoint.
-
- Arguments:
- UsbIo - Given Usb Controller device.
- EndpointAddr - Given Endpoint address.
- MaxPacketLength - The max packet length of that endpoint
-
- Returns:
- N/A
-
---*/
-{
-
- ENDPOINT_DESC_LIST_ENTRY *EndpointListEntry;
-
- *MaxPacketLength = 0;
-
- EndpointListEntry = FindEndPointListEntry (UsbIo, EndpointAddr);
- if (EndpointListEntry == NULL) {
- return ;
- }
-
- *MaxPacketLength = (UINTN) (EndpointListEntry->EndpointDescriptor.MaxPacketSize);
-
- return ;
-}
-
-
-EFI_STATUS
-UsbSetDeviceAddress (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT16 AddressValue,
- OUT UINT32 *Status
- )
-/*++
-
-Routine Description:
-
- Usb Set Device Address
-
-Arguments:
-
- UsbIo - EFI_USB_IO_PROTOCOL
- AddressValue - Device address
- Status - Transfer status
-
-Returns:
-
- EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
- EFI_TIMEOUT - Device has no response
-
-
---*/
-{
- EFI_USB_DEVICE_REQUEST DevReq;
-
- if (UsbIo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
-
- DevReq.RequestType = USB_DEV_SET_ADDRESS_REQ_TYPE;
- DevReq.Request = USB_DEV_SET_ADDRESS;
- DevReq.Value = AddressValue;
-
- return UsbIo->UsbControlTransfer (
- UsbIo,
- &DevReq,
- EfiUsbNoData,
- TIMEOUT_VALUE,
- NULL,
- 0,
- Status
- );
-}
-
diff --git a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbutil.h b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbutil.h
deleted file mode 100644
index 259276cbaf..0000000000
--- a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/usbutil.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- Module Name:
- usbutil.h
-
- Abstract:
-
- Helper functions for USB
-
- Revision History
-
-
---*/
-
-#ifndef _USB_UTIL_H
-#define _USB_UTIL_H
-
-//
-// Following APIs are used to query Port Status
-//
-BOOLEAN
-IsPortConnect (
- IN UINT16 PortStatus
- );
-
-BOOLEAN
-IsPortEnable (
- IN UINT16 PortStatus
- );
-
-BOOLEAN
-IsPortInReset (
- IN UINT16 PortStatus
- );
-
-BOOLEAN
-IsPortPowerApplied (
- IN UINT16 PortStatus
- );
-
-BOOLEAN
-IsPortLowSpeedDeviceAttached (
- IN UINT16 PortStatus
- );
-
-BOOLEAN
-IsPortSuspend (
- IN UINT16 PortStatus
- );
-
-//
-// Following APIs are used to query Port Change Status
-//
-BOOLEAN
-IsPortConnectChange (
- IN UINT16 PortChangeStatus
- );
-
-BOOLEAN
-IsPortEnableDisableChange (
- IN UINT16 PortChangeStatus
- );
-
-BOOLEAN
-IsPortResetChange (
- IN UINT16 PortChangeStatus
- );
-
-BOOLEAN
-IsPortSuspendChange (
- IN UINT16 PortChangeStatus
- );
-
-//
-// Set device address;
-//
-EFI_STATUS
-UsbSetDeviceAddress (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT16 AddressValue,
- OUT UINT32 *Status
- );
-
-
-#endif