MdeModulePkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the MdeModulePkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
committed by
mergify[bot]
parent
7c7184e201
commit
1436aea4d5
@@ -7,13 +7,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
|
||||
#include <Library/UefiLib.h>
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@@ -61,7 +58,6 @@ UsbBusComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@@ -133,14 +129,13 @@ UsbBusComponentNameGetDriverName (
|
||||
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
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
@@ -153,16 +148,15 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL mUsbBusComponentName
|
||||
//
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL mUsbBusComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UsbBusComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UsbBusComponentNameGetControllerName,
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL mUsbBusComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)UsbBusComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)UsbBusComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbBusDriverNameTable[] = {
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbBusDriverNameTable[] = {
|
||||
{ "eng;en", L"Usb Bus Driver" },
|
||||
{ NULL , NULL }
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -292,11 +286,11 @@ UsbBusComponentNameGetDriverName (
|
||||
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
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _EFI_USB_BUS_H_
|
||||
#define _EFI_USB_BUS_H_
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/Usb2HostController.h>
|
||||
@@ -28,7 +27,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
|
||||
|
||||
#include <IndustryStandard/Usb.h>
|
||||
|
||||
typedef struct _USB_DEVICE USB_DEVICE;
|
||||
@@ -36,7 +34,6 @@ typedef struct _USB_INTERFACE USB_INTERFACE;
|
||||
typedef struct _USB_BUS USB_BUS;
|
||||
typedef struct _USB_HUB_API USB_HUB_API;
|
||||
|
||||
|
||||
#include "UsbUtility.h"
|
||||
#include "UsbDesc.h"
|
||||
#include "UsbHub.h"
|
||||
@@ -46,19 +43,19 @@ typedef struct _USB_HUB_API USB_HUB_API;
|
||||
// USB bus timeout experience values
|
||||
//
|
||||
|
||||
#define USB_MAX_LANG_ID 16
|
||||
#define USB_MAX_INTERFACE 16
|
||||
#define USB_MAX_DEVICES 128
|
||||
#define USB_MAX_LANG_ID 16
|
||||
#define USB_MAX_INTERFACE 16
|
||||
#define USB_MAX_DEVICES 128
|
||||
|
||||
#define USB_BUS_1_MILLISECOND 1000
|
||||
#define USB_BUS_1_MILLISECOND 1000
|
||||
|
||||
//
|
||||
// Roothub and hub's polling interval, set by experience,
|
||||
// The unit of roothub is 100us, means 100ms as interval, and
|
||||
// the unit of hub is 1ms, means 64ms as interval.
|
||||
//
|
||||
#define USB_ROOTHUB_POLL_INTERVAL (100 * 10000U)
|
||||
#define USB_HUB_POLL_INTERVAL 64
|
||||
#define USB_ROOTHUB_POLL_INTERVAL (100 * 10000U)
|
||||
#define USB_HUB_POLL_INTERVAL 64
|
||||
|
||||
//
|
||||
// Wait for port stable to work, refers to specification
|
||||
@@ -69,13 +66,13 @@ typedef struct _USB_HUB_API USB_HUB_API;
|
||||
//
|
||||
// Wait for port statue reg change, set by experience
|
||||
//
|
||||
#define USB_WAIT_PORT_STS_CHANGE_STALL (100)
|
||||
#define USB_WAIT_PORT_STS_CHANGE_STALL (100)
|
||||
|
||||
//
|
||||
// Wait for set device address, refers to specification
|
||||
// [USB20-9.2.6.3, it says 2ms]
|
||||
//
|
||||
#define USB_SET_DEVICE_ADDRESS_STALL (2 * USB_BUS_1_MILLISECOND)
|
||||
#define USB_SET_DEVICE_ADDRESS_STALL (2 * USB_BUS_1_MILLISECOND)
|
||||
|
||||
//
|
||||
// Wait for retry max packet size, set by experience
|
||||
@@ -86,7 +83,7 @@ typedef struct _USB_HUB_API USB_HUB_API;
|
||||
// Wait for hub port power-on, refers to specification
|
||||
// [USB20-11.23.2]
|
||||
//
|
||||
#define USB_SET_PORT_POWER_STALL (2 * USB_BUS_1_MILLISECOND)
|
||||
#define USB_SET_PORT_POWER_STALL (2 * USB_BUS_1_MILLISECOND)
|
||||
|
||||
//
|
||||
// Wait for port reset, refers to specification
|
||||
@@ -103,7 +100,7 @@ typedef struct _USB_HUB_API USB_HUB_API;
|
||||
// Wait for port recovery to accept SetAddress, refers to specification
|
||||
// [USB20-7.1.7.5, it says 10 ms for TRSTRCY]
|
||||
//
|
||||
#define USB_SET_PORT_RECOVERY_STALL (10 * USB_BUS_1_MILLISECOND)
|
||||
#define USB_SET_PORT_RECOVERY_STALL (10 * USB_BUS_1_MILLISECOND)
|
||||
|
||||
//
|
||||
// Wait for clear roothub port reset, set by experience
|
||||
@@ -113,7 +110,7 @@ typedef struct _USB_HUB_API USB_HUB_API;
|
||||
//
|
||||
// Wait for set roothub port enable, set by experience
|
||||
//
|
||||
#define USB_SET_ROOT_PORT_ENABLE_STALL (20 * USB_BUS_1_MILLISECOND)
|
||||
#define USB_SET_ROOT_PORT_ENABLE_STALL (20 * USB_BUS_1_MILLISECOND)
|
||||
|
||||
//
|
||||
// Send general device request timeout.
|
||||
@@ -122,7 +119,7 @@ typedef struct _USB_HUB_API USB_HUB_API;
|
||||
// 50 milliseconds. We use a value of 500 milliseconds to work
|
||||
// around slower hubs and devices.
|
||||
//
|
||||
#define USB_GENERAL_DEVICE_REQUEST_TIMEOUT 500
|
||||
#define USB_GENERAL_DEVICE_REQUEST_TIMEOUT 500
|
||||
|
||||
//
|
||||
// Send clear feature request timeout, set by experience
|
||||
@@ -133,13 +130,13 @@ typedef struct _USB_HUB_API USB_HUB_API;
|
||||
// Bus raises TPL to TPL_NOTIFY to serialize all its operations
|
||||
// to protect shared data structures.
|
||||
//
|
||||
#define USB_BUS_TPL TPL_NOTIFY
|
||||
#define USB_BUS_TPL TPL_NOTIFY
|
||||
|
||||
#define USB_INTERFACE_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'I')
|
||||
#define USB_BUS_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'B')
|
||||
#define USB_INTERFACE_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'I')
|
||||
#define USB_BUS_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'B')
|
||||
|
||||
#define USB_BIT(a) ((UINTN)(1 << (a)))
|
||||
#define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
|
||||
#define USB_BIT(a) ((UINTN)(1 << (a)))
|
||||
#define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
|
||||
|
||||
#define USB_INTERFACE_FROM_USBIO(a) \
|
||||
CR(a, USB_INTERFACE, UsbIo, USB_INTERFACE_SIGNATURE)
|
||||
@@ -153,113 +150,112 @@ typedef struct _USB_HUB_API USB_HUB_API;
|
||||
// gEfiCallerIdGuid will be used as its protocol guid.
|
||||
//
|
||||
typedef struct _EFI_USB_BUS_PROTOCOL {
|
||||
UINT64 Reserved;
|
||||
UINT64 Reserved;
|
||||
} EFI_USB_BUS_PROTOCOL;
|
||||
|
||||
|
||||
//
|
||||
// Stands for the real USB device. Each device may
|
||||
// has several separately working interfaces.
|
||||
//
|
||||
struct _USB_DEVICE {
|
||||
USB_BUS *Bus;
|
||||
USB_BUS *Bus;
|
||||
|
||||
//
|
||||
// Configuration information
|
||||
//
|
||||
UINT8 Speed;
|
||||
UINT8 Address;
|
||||
UINT32 MaxPacket0;
|
||||
UINT8 Speed;
|
||||
UINT8 Address;
|
||||
UINT32 MaxPacket0;
|
||||
|
||||
//
|
||||
// The device's descriptors and its configuration
|
||||
//
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
USB_CONFIG_DESC *ActiveConfig;
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
USB_CONFIG_DESC *ActiveConfig;
|
||||
|
||||
UINT16 LangId [USB_MAX_LANG_ID];
|
||||
UINT16 TotalLangId;
|
||||
UINT16 LangId[USB_MAX_LANG_ID];
|
||||
UINT16 TotalLangId;
|
||||
|
||||
UINT8 NumOfInterface;
|
||||
USB_INTERFACE *Interfaces [USB_MAX_INTERFACE];
|
||||
UINT8 NumOfInterface;
|
||||
USB_INTERFACE *Interfaces[USB_MAX_INTERFACE];
|
||||
|
||||
//
|
||||
// Parent child relationship
|
||||
//
|
||||
EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;
|
||||
EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;
|
||||
|
||||
UINT8 ParentAddr;
|
||||
USB_INTERFACE *ParentIf;
|
||||
UINT8 ParentPort; // Start at 0
|
||||
UINT8 Tier;
|
||||
BOOLEAN DisconnectFail;
|
||||
UINT8 ParentAddr;
|
||||
USB_INTERFACE *ParentIf;
|
||||
UINT8 ParentPort; // Start at 0
|
||||
UINT8 Tier;
|
||||
BOOLEAN DisconnectFail;
|
||||
};
|
||||
|
||||
//
|
||||
// Stands for different functions of USB device
|
||||
//
|
||||
struct _USB_INTERFACE {
|
||||
UINTN Signature;
|
||||
USB_DEVICE *Device;
|
||||
USB_INTERFACE_DESC *IfDesc;
|
||||
USB_INTERFACE_SETTING *IfSetting;
|
||||
UINTN Signature;
|
||||
USB_DEVICE *Device;
|
||||
USB_INTERFACE_DESC *IfDesc;
|
||||
USB_INTERFACE_SETTING *IfSetting;
|
||||
|
||||
//
|
||||
// Handles and protocols
|
||||
//
|
||||
EFI_HANDLE Handle;
|
||||
EFI_USB_IO_PROTOCOL UsbIo;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
BOOLEAN IsManaged;
|
||||
EFI_HANDLE Handle;
|
||||
EFI_USB_IO_PROTOCOL UsbIo;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
BOOLEAN IsManaged;
|
||||
|
||||
//
|
||||
// Hub device special data
|
||||
//
|
||||
BOOLEAN IsHub;
|
||||
USB_HUB_API *HubApi;
|
||||
UINT8 NumOfPort;
|
||||
EFI_EVENT HubNotify;
|
||||
BOOLEAN IsHub;
|
||||
USB_HUB_API *HubApi;
|
||||
UINT8 NumOfPort;
|
||||
EFI_EVENT HubNotify;
|
||||
|
||||
//
|
||||
// Data used only by normal hub devices
|
||||
//
|
||||
USB_ENDPOINT_DESC *HubEp;
|
||||
UINT8 *ChangeMap;
|
||||
USB_ENDPOINT_DESC *HubEp;
|
||||
UINT8 *ChangeMap;
|
||||
|
||||
//
|
||||
// Data used only by root hub to hand over device to
|
||||
// companion UHCI driver if low/full speed devices are
|
||||
// connected to EHCI.
|
||||
//
|
||||
UINT8 MaxSpeed;
|
||||
UINT8 MaxSpeed;
|
||||
};
|
||||
|
||||
//
|
||||
// Stands for the current USB Bus
|
||||
//
|
||||
struct _USB_BUS {
|
||||
UINTN Signature;
|
||||
EFI_USB_BUS_PROTOCOL BusId;
|
||||
UINTN Signature;
|
||||
EFI_USB_BUS_PROTOCOL BusId;
|
||||
|
||||
//
|
||||
// Managed USB host controller
|
||||
//
|
||||
EFI_HANDLE HostHandle;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
EFI_USB2_HC_PROTOCOL *Usb2Hc;
|
||||
EFI_USB_HC_PROTOCOL *UsbHc;
|
||||
EFI_HANDLE HostHandle;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
EFI_USB2_HC_PROTOCOL *Usb2Hc;
|
||||
EFI_USB_HC_PROTOCOL *UsbHc;
|
||||
|
||||
//
|
||||
// Recorded the max supported usb devices.
|
||||
// XHCI can support up to 255 devices.
|
||||
// EHCI/UHCI/OHCI supports up to 127 devices.
|
||||
//
|
||||
UINT32 MaxDevices;
|
||||
UINT32 MaxDevices;
|
||||
//
|
||||
// An array of device that is on the bus. Devices[0] is
|
||||
// for root hub. Device with address i is at Devices[i].
|
||||
//
|
||||
USB_DEVICE *Devices[256];
|
||||
USB_DEVICE *Devices[256];
|
||||
|
||||
//
|
||||
// USB Bus driver need to control the recursive connect policy of the bus, only those wanted
|
||||
@@ -269,35 +265,34 @@ struct _USB_BUS {
|
||||
// every wanted child device is stored in a item of the WantedUsbIoDPList, whose structure is
|
||||
// DEVICE_PATH_LIST_ITEM
|
||||
//
|
||||
LIST_ENTRY WantedUsbIoDPList;
|
||||
|
||||
LIST_ENTRY WantedUsbIoDPList;
|
||||
};
|
||||
|
||||
//
|
||||
// USB Hub Api
|
||||
//
|
||||
struct _USB_HUB_API{
|
||||
USB_HUB_INIT Init;
|
||||
USB_HUB_GET_PORT_STATUS GetPortStatus;
|
||||
USB_HUB_CLEAR_PORT_CHANGE ClearPortChange;
|
||||
USB_HUB_SET_PORT_FEATURE SetPortFeature;
|
||||
USB_HUB_CLEAR_PORT_FEATURE ClearPortFeature;
|
||||
USB_HUB_RESET_PORT ResetPort;
|
||||
USB_HUB_RELEASE Release;
|
||||
struct _USB_HUB_API {
|
||||
USB_HUB_INIT Init;
|
||||
USB_HUB_GET_PORT_STATUS GetPortStatus;
|
||||
USB_HUB_CLEAR_PORT_CHANGE ClearPortChange;
|
||||
USB_HUB_SET_PORT_FEATURE SetPortFeature;
|
||||
USB_HUB_CLEAR_PORT_FEATURE ClearPortFeature;
|
||||
USB_HUB_RESET_PORT ResetPort;
|
||||
USB_HUB_RELEASE Release;
|
||||
};
|
||||
|
||||
#define USB_US_LAND_ID 0x0409
|
||||
#define USB_US_LAND_ID 0x0409
|
||||
|
||||
#define DEVICE_PATH_LIST_ITEM_SIGNATURE SIGNATURE_32('d','p','l','i')
|
||||
typedef struct _DEVICE_PATH_LIST_ITEM{
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
#define DEVICE_PATH_LIST_ITEM_SIGNATURE SIGNATURE_32('d','p','l','i')
|
||||
typedef struct _DEVICE_PATH_LIST_ITEM {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
} DEVICE_PATH_LIST_ITEM;
|
||||
|
||||
typedef struct {
|
||||
USB_CLASS_DEVICE_PATH UsbClass;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
USB_CLASS_DEVICE_PATH UsbClass;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} USB_CLASS_FORMAT_DEVICE_PATH;
|
||||
|
||||
/**
|
||||
@@ -312,7 +307,7 @@ typedef struct {
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbBusFreeUsbDPList (
|
||||
IN LIST_ENTRY *UsbIoDPList
|
||||
IN LIST_ENTRY *UsbIoDPList
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -329,8 +324,8 @@ UsbBusFreeUsbDPList (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbBusAddWantedUsbIoDP (
|
||||
IN EFI_USB_BUS_PROTOCOL *UsbBusId,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
IN EFI_USB_BUS_PROTOCOL *UsbBusId,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -346,8 +341,8 @@ UsbBusAddWantedUsbIoDP (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
UsbBusIsWantedUsbIO (
|
||||
IN USB_BUS *Bus,
|
||||
IN USB_INTERFACE *UsbIf
|
||||
IN USB_BUS *Bus,
|
||||
IN USB_INTERFACE *UsbIf
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -363,7 +358,7 @@ UsbBusIsWantedUsbIO (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbBusRecursivelyConnectWantedUsbIo (
|
||||
IN EFI_USB_BUS_PROTOCOL *UsbBusId
|
||||
IN EFI_USB_BUS_PROTOCOL *UsbBusId
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -416,12 +411,12 @@ UsbIoControlTransfer (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbIoBulkTransfer (
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
IN UINT8 Endpoint,
|
||||
IN OUT VOID *Data,
|
||||
IN OUT UINTN *DataLength,
|
||||
IN UINTN Timeout,
|
||||
OUT UINT32 *UsbStatus
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
IN UINT8 Endpoint,
|
||||
IN OUT VOID *Data,
|
||||
IN OUT UINTN *DataLength,
|
||||
IN UINTN Timeout,
|
||||
OUT UINT32 *UsbStatus
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -443,12 +438,12 @@ UsbIoBulkTransfer (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbIoSyncInterruptTransfer (
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
IN UINT8 Endpoint,
|
||||
IN OUT VOID *Data,
|
||||
IN OUT UINTN *DataLength,
|
||||
IN UINTN Timeout,
|
||||
OUT UINT32 *UsbStatus
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
IN UINT8 Endpoint,
|
||||
IN OUT VOID *Data,
|
||||
IN OUT UINTN *DataLength,
|
||||
IN UINTN Timeout,
|
||||
OUT UINT32 *UsbStatus
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -498,11 +493,11 @@ UsbIoAsyncInterruptTransfer (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbIoIsochronousTransfer (
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
IN UINT8 DeviceEndpoint,
|
||||
IN OUT VOID *Data,
|
||||
IN UINTN DataLength,
|
||||
OUT UINT32 *Status
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
IN UINT8 DeviceEndpoint,
|
||||
IN OUT VOID *Data,
|
||||
IN UINTN DataLength,
|
||||
OUT UINT32 *Status
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -543,8 +538,8 @@ UsbIoAsyncIsochronousTransfer (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbIoGetDeviceDescriptor (
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
OUT EFI_USB_DEVICE_DESCRIPTOR *Descriptor
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
OUT EFI_USB_DEVICE_DESCRIPTOR *Descriptor
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -561,8 +556,8 @@ UsbIoGetDeviceDescriptor (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbIoGetActiveConfigDescriptor (
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -597,9 +592,9 @@ UsbIoGetInterfaceDescriptor (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbIoGetEndpointDescriptor (
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
IN UINT8 Index,
|
||||
OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
IN UINT8 Index,
|
||||
OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -615,9 +610,9 @@ UsbIoGetEndpointDescriptor (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbIoGetSupportedLanguages (
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
OUT UINT16 **LangIDTable,
|
||||
OUT UINT16 *TableSize
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
OUT UINT16 **LangIDTable,
|
||||
OUT UINT16 *TableSize
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -635,10 +630,10 @@ UsbIoGetSupportedLanguages (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbIoGetStringDescriptor (
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
IN UINT16 LangID,
|
||||
IN UINT8 StringIndex,
|
||||
OUT CHAR16 **String
|
||||
IN EFI_USB_IO_PROTOCOL *This,
|
||||
IN UINT16 LangID,
|
||||
IN UINT8 StringIndex,
|
||||
OUT CHAR16 **String
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -690,8 +685,8 @@ UsbBusBuildProtocol (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbBusDriverEntryPoint (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -756,9 +751,9 @@ UsbBusControllerDriverStop (
|
||||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
);
|
||||
|
||||
extern EFI_USB_IO_PROTOCOL mUsbIoProtocol;
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL mUsbBusComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL mUsbBusComponentName2;
|
||||
extern EFI_USB_IO_PROTOCOL mUsbIoProtocol;
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL mUsbBusComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL mUsbBusComponentName2;
|
||||
|
||||
#endif
|
||||
|
@@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "UsbBus.h"
|
||||
|
||||
|
||||
/**
|
||||
Free the interface setting descriptor.
|
||||
|
||||
@@ -21,8 +20,8 @@ UsbFreeInterfaceDesc (
|
||||
IN USB_INTERFACE_SETTING *Setting
|
||||
)
|
||||
{
|
||||
USB_ENDPOINT_DESC *Ep;
|
||||
UINTN Index;
|
||||
USB_ENDPOINT_DESC *Ep;
|
||||
UINTN Index;
|
||||
|
||||
if (Setting->Endpoints != NULL) {
|
||||
//
|
||||
@@ -47,7 +46,6 @@ UsbFreeInterfaceDesc (
|
||||
FreePool (Setting);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free a configuration descriptor with its interface
|
||||
descriptors. It may be initialized partially.
|
||||
@@ -57,12 +55,12 @@ UsbFreeInterfaceDesc (
|
||||
**/
|
||||
VOID
|
||||
UsbFreeConfigDesc (
|
||||
IN USB_CONFIG_DESC *Config
|
||||
IN USB_CONFIG_DESC *Config
|
||||
)
|
||||
{
|
||||
USB_INTERFACE_DESC *Interface;
|
||||
UINTN Index;
|
||||
UINTN SetIndex;
|
||||
USB_INTERFACE_DESC *Interface;
|
||||
UINTN Index;
|
||||
UINTN SetIndex;
|
||||
|
||||
if (Config->Interfaces != NULL) {
|
||||
//
|
||||
@@ -91,10 +89,8 @@ UsbFreeConfigDesc (
|
||||
}
|
||||
|
||||
FreePool (Config);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free a device descriptor with its configurations.
|
||||
|
||||
@@ -103,10 +99,10 @@ UsbFreeConfigDesc (
|
||||
**/
|
||||
VOID
|
||||
UsbFreeDevDesc (
|
||||
IN USB_DEVICE_DESC *DevDesc
|
||||
IN USB_DEVICE_DESC *DevDesc
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
if (DevDesc->Configs != NULL) {
|
||||
for (Index = 0; Index < DevDesc->Desc.NumConfigurations; Index++) {
|
||||
@@ -121,7 +117,6 @@ UsbFreeDevDesc (
|
||||
FreePool (DevDesc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a descriptor.
|
||||
|
||||
@@ -135,46 +130,46 @@ UsbFreeDevDesc (
|
||||
**/
|
||||
VOID *
|
||||
UsbCreateDesc (
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len,
|
||||
IN UINT8 Type,
|
||||
OUT UINTN *Consumed
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len,
|
||||
IN UINT8 Type,
|
||||
OUT UINTN *Consumed
|
||||
)
|
||||
{
|
||||
USB_DESC_HEAD *Head;
|
||||
UINTN DescLen;
|
||||
UINTN CtrlLen;
|
||||
UINTN Offset;
|
||||
VOID *Desc;
|
||||
USB_DESC_HEAD *Head;
|
||||
UINTN DescLen;
|
||||
UINTN CtrlLen;
|
||||
UINTN Offset;
|
||||
VOID *Desc;
|
||||
|
||||
DescLen = 0;
|
||||
CtrlLen = 0;
|
||||
*Consumed = 0;
|
||||
|
||||
switch (Type) {
|
||||
case USB_DESC_TYPE_DEVICE:
|
||||
DescLen = sizeof (EFI_USB_DEVICE_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_DEVICE_DESC);
|
||||
break;
|
||||
case USB_DESC_TYPE_DEVICE:
|
||||
DescLen = sizeof (EFI_USB_DEVICE_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_DEVICE_DESC);
|
||||
break;
|
||||
|
||||
case USB_DESC_TYPE_CONFIG:
|
||||
DescLen = sizeof (EFI_USB_CONFIG_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_CONFIG_DESC);
|
||||
break;
|
||||
case USB_DESC_TYPE_CONFIG:
|
||||
DescLen = sizeof (EFI_USB_CONFIG_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_CONFIG_DESC);
|
||||
break;
|
||||
|
||||
case USB_DESC_TYPE_INTERFACE:
|
||||
DescLen = sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_INTERFACE_SETTING);
|
||||
break;
|
||||
case USB_DESC_TYPE_INTERFACE:
|
||||
DescLen = sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_INTERFACE_SETTING);
|
||||
break;
|
||||
|
||||
case USB_DESC_TYPE_ENDPOINT:
|
||||
DescLen = sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_ENDPOINT_DESC);
|
||||
break;
|
||||
case USB_DESC_TYPE_ENDPOINT:
|
||||
DescLen = sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_ENDPOINT_DESC);
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
return NULL;
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -231,19 +226,18 @@ UsbCreateDesc (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Desc = AllocateZeroPool ((UINTN) CtrlLen);
|
||||
Desc = AllocateZeroPool ((UINTN)CtrlLen);
|
||||
if (Desc == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CopyMem (Desc, Head, (UINTN) DescLen);
|
||||
CopyMem (Desc, Head, (UINTN)DescLen);
|
||||
|
||||
*Consumed = Offset;
|
||||
|
||||
return Desc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parse an interface descriptor and its endpoints.
|
||||
|
||||
@@ -256,23 +250,23 @@ UsbCreateDesc (
|
||||
**/
|
||||
USB_INTERFACE_SETTING *
|
||||
UsbParseInterfaceDesc (
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len,
|
||||
OUT UINTN *Consumed
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len,
|
||||
OUT UINTN *Consumed
|
||||
)
|
||||
{
|
||||
USB_INTERFACE_SETTING *Setting;
|
||||
USB_ENDPOINT_DESC *Ep;
|
||||
UINTN Index;
|
||||
UINTN NumEp;
|
||||
UINTN Used;
|
||||
UINTN Offset;
|
||||
USB_INTERFACE_SETTING *Setting;
|
||||
USB_ENDPOINT_DESC *Ep;
|
||||
UINTN Index;
|
||||
UINTN NumEp;
|
||||
UINTN Used;
|
||||
UINTN Offset;
|
||||
|
||||
*Consumed = 0;
|
||||
Setting = UsbCreateDesc (DescBuf, Len, USB_DESC_TYPE_INTERFACE, &Used);
|
||||
|
||||
if (Setting == NULL) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create interface descriptor\n"));
|
||||
DEBUG ((DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create interface descriptor\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -281,16 +275,21 @@ UsbParseInterfaceDesc (
|
||||
//
|
||||
// Create an array to hold the interface's endpoints
|
||||
//
|
||||
NumEp = Setting->Desc.NumEndpoints;
|
||||
NumEp = Setting->Desc.NumEndpoints;
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbParseInterfaceDesc: interface %d(setting %d) has %d endpoints\n",
|
||||
Setting->Desc.InterfaceNumber, Setting->Desc.AlternateSetting, (UINT32)NumEp));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"UsbParseInterfaceDesc: interface %d(setting %d) has %d endpoints\n",
|
||||
Setting->Desc.InterfaceNumber,
|
||||
Setting->Desc.AlternateSetting,
|
||||
(UINT32)NumEp
|
||||
));
|
||||
|
||||
if (NumEp == 0) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Setting->Endpoints = AllocateZeroPool (sizeof (USB_ENDPOINT_DESC *) * NumEp);
|
||||
Setting->Endpoints = AllocateZeroPool (sizeof (USB_ENDPOINT_DESC *) * NumEp);
|
||||
|
||||
if (Setting->Endpoints == NULL) {
|
||||
goto ON_ERROR;
|
||||
@@ -303,15 +302,14 @@ UsbParseInterfaceDesc (
|
||||
Ep = UsbCreateDesc (DescBuf + Offset, Len - Offset, USB_DESC_TYPE_ENDPOINT, &Used);
|
||||
|
||||
if (Ep == NULL) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create endpoint(index %d)\n", (UINT32)Index));
|
||||
DEBUG ((DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create endpoint(index %d)\n", (UINT32)Index));
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Setting->Endpoints[Index] = Ep;
|
||||
Offset += Used;
|
||||
Setting->Endpoints[Index] = Ep;
|
||||
Offset += Used;
|
||||
}
|
||||
|
||||
|
||||
ON_EXIT:
|
||||
*Consumed = Offset;
|
||||
return Setting;
|
||||
@@ -321,7 +319,6 @@ ON_ERROR:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parse the configuration descriptor and its interfaces.
|
||||
|
||||
@@ -333,16 +330,16 @@ ON_ERROR:
|
||||
**/
|
||||
USB_CONFIG_DESC *
|
||||
UsbParseConfigDesc (
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len
|
||||
)
|
||||
{
|
||||
USB_CONFIG_DESC *Config;
|
||||
USB_INTERFACE_SETTING *Setting;
|
||||
USB_INTERFACE_DESC *Interface;
|
||||
UINTN Index;
|
||||
UINTN NumIf;
|
||||
UINTN Consumed;
|
||||
USB_CONFIG_DESC *Config;
|
||||
USB_INTERFACE_SETTING *Setting;
|
||||
USB_INTERFACE_DESC *Interface;
|
||||
UINTN Index;
|
||||
UINTN NumIf;
|
||||
UINTN Consumed;
|
||||
|
||||
ASSERT (DescBuf != NULL);
|
||||
|
||||
@@ -355,15 +352,19 @@ UsbParseConfigDesc (
|
||||
//
|
||||
// Initialize an array of setting for the configuration's interfaces.
|
||||
//
|
||||
NumIf = Config->Desc.NumInterfaces;
|
||||
Config->Interfaces = AllocateZeroPool (sizeof (USB_INTERFACE_DESC *) * NumIf);
|
||||
NumIf = Config->Desc.NumInterfaces;
|
||||
Config->Interfaces = AllocateZeroPool (sizeof (USB_INTERFACE_DESC *) * NumIf);
|
||||
|
||||
if (Config->Interfaces == NULL) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbParseConfigDesc: config %d has %d interfaces\n",
|
||||
Config->Desc.ConfigurationValue, (UINT32)NumIf));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"UsbParseConfigDesc: config %d has %d interfaces\n",
|
||||
Config->Desc.ConfigurationValue,
|
||||
(UINT32)NumIf
|
||||
));
|
||||
|
||||
for (Index = 0; Index < NumIf; Index++) {
|
||||
Interface = AllocateZeroPool (sizeof (USB_INTERFACE_DESC));
|
||||
@@ -394,11 +395,10 @@ UsbParseConfigDesc (
|
||||
Setting = UsbParseInterfaceDesc (DescBuf, Len, &Consumed);
|
||||
|
||||
if (Setting == NULL) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbParseConfigDesc: warning: failed to get interface setting, stop parsing now.\n"));
|
||||
DEBUG ((DEBUG_ERROR, "UsbParseConfigDesc: warning: failed to get interface setting, stop parsing now.\n"));
|
||||
break;
|
||||
|
||||
} else if (Setting->Desc.InterfaceNumber >= NumIf) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbParseConfigDesc: malformatted interface descriptor\n"));
|
||||
DEBUG ((DEBUG_ERROR, "UsbParseConfigDesc: malformatted interface descriptor\n"));
|
||||
|
||||
UsbFreeInterfaceDesc (Setting);
|
||||
goto ON_ERROR;
|
||||
@@ -427,7 +427,6 @@ ON_ERROR:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
USB standard control transfer support routine. This
|
||||
function is used by USB device. It is possible that
|
||||
@@ -450,15 +449,15 @@ ON_ERROR:
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbCtrlRequest (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN EFI_USB_DATA_DIRECTION Direction,
|
||||
IN UINTN Type,
|
||||
IN UINTN Target,
|
||||
IN UINTN Request,
|
||||
IN UINT16 Value,
|
||||
IN UINT16 Index,
|
||||
IN OUT VOID *Buf,
|
||||
IN UINTN Length
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN EFI_USB_DATA_DIRECTION Direction,
|
||||
IN UINTN Type,
|
||||
IN UINTN Target,
|
||||
IN UINTN Request,
|
||||
IN UINT16 Value,
|
||||
IN UINT16 Index,
|
||||
IN OUT VOID *Buf,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
EFI_USB_DEVICE_REQUEST DevReq;
|
||||
@@ -468,13 +467,13 @@ UsbCtrlRequest (
|
||||
|
||||
ASSERT ((UsbDev != NULL) && (UsbDev->Bus != NULL));
|
||||
|
||||
DevReq.RequestType = USB_REQUEST_TYPE (Direction, Type, Target);
|
||||
DevReq.Request = (UINT8) Request;
|
||||
DevReq.Value = Value;
|
||||
DevReq.Index = Index;
|
||||
DevReq.Length = (UINT16) Length;
|
||||
DevReq.RequestType = USB_REQUEST_TYPE (Direction, Type, Target);
|
||||
DevReq.Request = (UINT8)Request;
|
||||
DevReq.Value = Value;
|
||||
DevReq.Index = Index;
|
||||
DevReq.Length = (UINT16)Length;
|
||||
|
||||
Len = Length;
|
||||
Len = Length;
|
||||
Status = UsbHcControlTransfer (
|
||||
UsbDev->Bus,
|
||||
UsbDev->Address,
|
||||
@@ -492,7 +491,6 @@ UsbCtrlRequest (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the standard descriptors.
|
||||
|
||||
@@ -510,15 +508,15 @@ UsbCtrlRequest (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbCtrlGetDesc (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINTN DescType,
|
||||
IN UINTN DescIndex,
|
||||
IN UINT16 LangId,
|
||||
OUT VOID *Buf,
|
||||
IN UINTN Length
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINTN DescType,
|
||||
IN UINTN DescIndex,
|
||||
IN UINT16 LangId,
|
||||
OUT VOID *Buf,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbCtrlRequest (
|
||||
UsbDev,
|
||||
@@ -526,7 +524,7 @@ UsbCtrlGetDesc (
|
||||
USB_REQ_TYPE_STANDARD,
|
||||
USB_TARGET_DEVICE,
|
||||
USB_REQ_GET_DESCRIPTOR,
|
||||
(UINT16) ((DescType << 8) | DescIndex),
|
||||
(UINT16)((DescType << 8) | DescIndex),
|
||||
LangId,
|
||||
Buf,
|
||||
Length
|
||||
@@ -535,7 +533,6 @@ UsbCtrlGetDesc (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Return the max packet size for endpoint zero. This function
|
||||
is the first function called to get descriptors during bus
|
||||
@@ -549,13 +546,12 @@ UsbCtrlGetDesc (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbGetMaxPacketSize0 (
|
||||
IN USB_DEVICE *UsbDev
|
||||
IN USB_DEVICE *UsbDev
|
||||
)
|
||||
{
|
||||
EFI_USB_DEVICE_DESCRIPTOR DevDesc;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
|
||||
EFI_USB_DEVICE_DESCRIPTOR DevDesc;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Get the first 8 bytes of the device descriptor which contains
|
||||
@@ -569,6 +565,7 @@ UsbGetMaxPacketSize0 (
|
||||
UsbDev->MaxPacket0 = 1 << 9;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
UsbDev->MaxPacket0 = DevDesc.MaxPacketSize0;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -579,7 +576,6 @@ UsbGetMaxPacketSize0 (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the device descriptor for the device.
|
||||
|
||||
@@ -591,11 +587,11 @@ UsbGetMaxPacketSize0 (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbGetDevDesc (
|
||||
IN USB_DEVICE *UsbDev
|
||||
IN USB_DEVICE *UsbDev
|
||||
)
|
||||
{
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
EFI_STATUS Status;
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DevDesc = AllocateZeroPool (sizeof (USB_DEVICE_DESC));
|
||||
|
||||
@@ -603,14 +599,14 @@ UsbGetDevDesc (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = UsbCtrlGetDesc (
|
||||
UsbDev,
|
||||
USB_DESC_TYPE_DEVICE,
|
||||
0,
|
||||
0,
|
||||
DevDesc,
|
||||
sizeof (EFI_USB_DEVICE_DESCRIPTOR)
|
||||
);
|
||||
Status = UsbCtrlGetDesc (
|
||||
UsbDev,
|
||||
USB_DESC_TYPE_DEVICE,
|
||||
0,
|
||||
0,
|
||||
DevDesc,
|
||||
sizeof (EFI_USB_DEVICE_DESCRIPTOR)
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
gBS->FreePool (DevDesc);
|
||||
@@ -621,7 +617,6 @@ UsbGetDevDesc (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieve the indexed string for the language. It requires two
|
||||
steps to get a string, first to get the string's length. Then
|
||||
@@ -636,14 +631,14 @@ UsbGetDevDesc (
|
||||
**/
|
||||
EFI_USB_STRING_DESCRIPTOR *
|
||||
UsbGetOneString (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Index,
|
||||
IN UINT16 LangId
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Index,
|
||||
IN UINT16 LangId
|
||||
)
|
||||
{
|
||||
EFI_USB_STRING_DESCRIPTOR Desc;
|
||||
EFI_STATUS Status;
|
||||
UINT8 *Buf;
|
||||
EFI_USB_STRING_DESCRIPTOR Desc;
|
||||
EFI_STATUS Status;
|
||||
UINT8 *Buf;
|
||||
|
||||
//
|
||||
// First get two bytes which contains the string length.
|
||||
@@ -656,7 +651,8 @@ UsbGetOneString (
|
||||
if (EFI_ERROR (Status) ||
|
||||
(Desc.Length < OFFSET_OF (EFI_USB_STRING_DESCRIPTOR, Length) + sizeof (Desc.Length)) ||
|
||||
(Desc.Length % 2 != 0)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -680,10 +676,9 @@ UsbGetOneString (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (EFI_USB_STRING_DESCRIPTOR *) Buf;
|
||||
return (EFI_USB_STRING_DESCRIPTOR *)Buf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Build the language ID table for string descriptors.
|
||||
|
||||
@@ -694,14 +689,14 @@ UsbGetOneString (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbBuildLangTable (
|
||||
IN USB_DEVICE *UsbDev
|
||||
IN USB_DEVICE *UsbDev
|
||||
)
|
||||
{
|
||||
EFI_USB_STRING_DESCRIPTOR *Desc;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
UINTN Max;
|
||||
UINT16 *Point;
|
||||
EFI_USB_STRING_DESCRIPTOR *Desc;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
UINTN Max;
|
||||
UINT16 *Point;
|
||||
|
||||
//
|
||||
// The string of language ID zero returns the supported languages
|
||||
@@ -719,8 +714,8 @@ UsbBuildLangTable (
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
Max = (Desc->Length - 2) / 2;
|
||||
Max = MIN(Max, USB_MAX_LANG_ID);
|
||||
Max = (Desc->Length - 2) / 2;
|
||||
Max = MIN (Max, USB_MAX_LANG_ID);
|
||||
|
||||
Point = Desc->String;
|
||||
for (Index = 0; Index < Max; Index++) {
|
||||
@@ -735,7 +730,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieve the indexed configure for the device. USB device
|
||||
returns the configuration together with the interfaces for
|
||||
@@ -750,13 +744,13 @@ ON_EXIT:
|
||||
**/
|
||||
EFI_USB_CONFIG_DESCRIPTOR *
|
||||
UsbGetOneConfig (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Index
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Index
|
||||
)
|
||||
{
|
||||
EFI_USB_CONFIG_DESCRIPTOR Desc;
|
||||
EFI_STATUS Status;
|
||||
VOID *Buf;
|
||||
EFI_USB_CONFIG_DESCRIPTOR Desc;
|
||||
EFI_STATUS Status;
|
||||
VOID *Buf;
|
||||
|
||||
//
|
||||
// First get four bytes which contains the total length
|
||||
@@ -765,13 +759,17 @@ UsbGetOneConfig (
|
||||
Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_CONFIG, Index, 0, &Desc, 8);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbGetOneConfig: failed to get descript length(%d) %r\n",
|
||||
Desc.TotalLength, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"UsbGetOneConfig: failed to get descript length(%d) %r\n",
|
||||
Desc.TotalLength,
|
||||
Status
|
||||
));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbGetOneConfig: total length is %d\n", Desc.TotalLength));
|
||||
DEBUG ((DEBUG_INFO, "UsbGetOneConfig: total length is %d\n", Desc.TotalLength));
|
||||
|
||||
//
|
||||
// Reject if TotalLength even cannot cover itself.
|
||||
@@ -789,7 +787,7 @@ UsbGetOneConfig (
|
||||
Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_CONFIG, Index, 0, Buf, Desc.TotalLength);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbGetOneConfig: failed to get full descript %r\n", Status));
|
||||
DEBUG ((DEBUG_ERROR, "UsbGetOneConfig: failed to get full descript %r\n", Status));
|
||||
|
||||
FreePool (Buf);
|
||||
return NULL;
|
||||
@@ -798,7 +796,6 @@ UsbGetOneConfig (
|
||||
return Buf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Build the whole array of descriptors. This function must
|
||||
be called after UsbGetMaxPacketSize0 returns the max packet
|
||||
@@ -812,15 +809,15 @@ UsbGetOneConfig (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbBuildDescTable (
|
||||
IN USB_DEVICE *UsbDev
|
||||
IN USB_DEVICE *UsbDev
|
||||
)
|
||||
{
|
||||
EFI_USB_CONFIG_DESCRIPTOR *Config;
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
USB_CONFIG_DESC *ConfigDesc;
|
||||
UINT8 NumConfig;
|
||||
EFI_STATUS Status;
|
||||
UINT8 Index;
|
||||
EFI_USB_CONFIG_DESCRIPTOR *Config;
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
USB_CONFIG_DESC *ConfigDesc;
|
||||
UINT8 NumConfig;
|
||||
EFI_STATUS Status;
|
||||
UINT8 Index;
|
||||
|
||||
//
|
||||
// Get the device descriptor, then allocate the configure
|
||||
@@ -829,7 +826,7 @@ UsbBuildDescTable (
|
||||
Status = UsbGetDevDesc (UsbDev);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to get device descriptor - %r\n", Status));
|
||||
DEBUG ((DEBUG_ERROR, "UsbBuildDescTable: failed to get device descriptor - %r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -844,7 +841,7 @@ UsbBuildDescTable (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbBuildDescTable: device has %d configures\n", NumConfig));
|
||||
DEBUG ((DEBUG_INFO, "UsbBuildDescTable: device has %d configures\n", NumConfig));
|
||||
|
||||
//
|
||||
// Read each configurations, then parse them
|
||||
@@ -853,7 +850,7 @@ UsbBuildDescTable (
|
||||
Config = UsbGetOneConfig (UsbDev, Index);
|
||||
|
||||
if (Config == NULL) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to get configure (index %d)\n", Index));
|
||||
DEBUG ((DEBUG_ERROR, "UsbBuildDescTable: failed to get configure (index %d)\n", Index));
|
||||
|
||||
//
|
||||
// If we can get the default descriptor, it is likely that the
|
||||
@@ -866,12 +863,12 @@ UsbBuildDescTable (
|
||||
break;
|
||||
}
|
||||
|
||||
ConfigDesc = UsbParseConfigDesc ((UINT8 *) Config, Config->TotalLength);
|
||||
ConfigDesc = UsbParseConfigDesc ((UINT8 *)Config, Config->TotalLength);
|
||||
|
||||
FreePool (Config);
|
||||
|
||||
if (ConfigDesc == NULL) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to parse configure (index %d)\n", Index));
|
||||
DEBUG ((DEBUG_ERROR, "UsbBuildDescTable: failed to parse configure (index %d)\n", Index));
|
||||
|
||||
//
|
||||
// If we can get the default descriptor, it is likely that the
|
||||
@@ -894,13 +891,12 @@ UsbBuildDescTable (
|
||||
Status = UsbBuildLangTable (UsbDev);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_INFO, "UsbBuildDescTable: get language ID table %r\n", Status));
|
||||
DEBUG ((DEBUG_INFO, "UsbBuildDescTable: get language ID table %r\n", Status));
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the device's address.
|
||||
|
||||
@@ -913,11 +909,11 @@ UsbBuildDescTable (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbSetAddress (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Address
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Address
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbCtrlRequest (
|
||||
UsbDev,
|
||||
@@ -934,7 +930,6 @@ UsbSetAddress (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the device's configuration. This function changes
|
||||
the device's internal state. UsbSelectConfig changes
|
||||
@@ -949,11 +944,11 @@ UsbSetAddress (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbSetConfig (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 ConfigIndex
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 ConfigIndex
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbCtrlRequest (
|
||||
UsbDev,
|
||||
@@ -965,12 +960,11 @@ UsbSetConfig (
|
||||
0,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Usb UsbIo interface to clear the feature. This is should
|
||||
only be used by HUB which is considered a device driver
|
||||
@@ -987,21 +981,21 @@ UsbSetConfig (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbIoClearFeature (
|
||||
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
||||
IN UINTN Target,
|
||||
IN UINT16 Feature,
|
||||
IN UINT16 Index
|
||||
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
||||
IN UINTN Target,
|
||||
IN UINT16 Feature,
|
||||
IN UINT16 Index
|
||||
)
|
||||
{
|
||||
EFI_USB_DEVICE_REQUEST DevReq;
|
||||
UINT32 UsbResult;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DevReq.RequestType = USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD, Target);
|
||||
DevReq.Request = USB_REQ_CLEAR_FEATURE;
|
||||
DevReq.Value = Feature;
|
||||
DevReq.Index = Index;
|
||||
DevReq.Length = 0;
|
||||
DevReq.RequestType = USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD, Target);
|
||||
DevReq.Request = USB_REQ_CLEAR_FEATURE;
|
||||
DevReq.Value = Feature;
|
||||
DevReq.Index = Index;
|
||||
DevReq.Length = 0;
|
||||
|
||||
Status = UsbIo->UsbControlTransfer (
|
||||
UsbIo,
|
||||
|
@@ -26,12 +26,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UINT8 Len;
|
||||
UINT8 Type;
|
||||
UINT8 Len;
|
||||
UINT8 Type;
|
||||
} USB_DESC_HEAD;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
//
|
||||
// Each USB device has a device descriptor. Each device may
|
||||
// have several configures. Each configure contains several
|
||||
@@ -42,13 +41,13 @@ typedef struct {
|
||||
// structure.
|
||||
//
|
||||
typedef struct {
|
||||
EFI_USB_ENDPOINT_DESCRIPTOR Desc;
|
||||
UINT8 Toggle;
|
||||
EFI_USB_ENDPOINT_DESCRIPTOR Desc;
|
||||
UINT8 Toggle;
|
||||
} USB_ENDPOINT_DESC;
|
||||
|
||||
typedef struct {
|
||||
EFI_USB_INTERFACE_DESCRIPTOR Desc;
|
||||
USB_ENDPOINT_DESC **Endpoints;
|
||||
EFI_USB_INTERFACE_DESCRIPTOR Desc;
|
||||
USB_ENDPOINT_DESC **Endpoints;
|
||||
} USB_INTERFACE_SETTING;
|
||||
|
||||
//
|
||||
@@ -57,19 +56,19 @@ typedef struct {
|
||||
// It should sufice in most environments.
|
||||
//
|
||||
typedef struct {
|
||||
USB_INTERFACE_SETTING* Settings[USB_MAX_INTERFACE_SETTING];
|
||||
UINTN NumOfSetting;
|
||||
UINTN ActiveIndex; // Index of active setting
|
||||
USB_INTERFACE_SETTING *Settings[USB_MAX_INTERFACE_SETTING];
|
||||
UINTN NumOfSetting;
|
||||
UINTN ActiveIndex; // Index of active setting
|
||||
} USB_INTERFACE_DESC;
|
||||
|
||||
typedef struct {
|
||||
EFI_USB_CONFIG_DESCRIPTOR Desc;
|
||||
USB_INTERFACE_DESC **Interfaces;
|
||||
EFI_USB_CONFIG_DESCRIPTOR Desc;
|
||||
USB_INTERFACE_DESC **Interfaces;
|
||||
} USB_CONFIG_DESC;
|
||||
|
||||
typedef struct {
|
||||
EFI_USB_DEVICE_DESCRIPTOR Desc;
|
||||
USB_CONFIG_DESC **Configs;
|
||||
EFI_USB_DEVICE_DESCRIPTOR Desc;
|
||||
USB_CONFIG_DESC **Configs;
|
||||
} USB_DEVICE_DESC;
|
||||
|
||||
/**
|
||||
@@ -94,15 +93,15 @@ typedef struct {
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbCtrlRequest (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN EFI_USB_DATA_DIRECTION Direction,
|
||||
IN UINTN Type,
|
||||
IN UINTN Target,
|
||||
IN UINTN Request,
|
||||
IN UINT16 Value,
|
||||
IN UINT16 Index,
|
||||
IN OUT VOID *Buf,
|
||||
IN UINTN Length
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN EFI_USB_DATA_DIRECTION Direction,
|
||||
IN UINTN Type,
|
||||
IN UINTN Target,
|
||||
IN UINTN Request,
|
||||
IN UINT16 Value,
|
||||
IN UINT16 Index,
|
||||
IN OUT VOID *Buf,
|
||||
IN UINTN Length
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -118,7 +117,7 @@ UsbCtrlRequest (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbGetMaxPacketSize0 (
|
||||
IN USB_DEVICE *UsbDev
|
||||
IN USB_DEVICE *UsbDev
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -131,7 +130,7 @@ UsbGetMaxPacketSize0 (
|
||||
**/
|
||||
VOID
|
||||
UsbFreeDevDesc (
|
||||
IN USB_DEVICE_DESC *DevDesc
|
||||
IN USB_DEVICE_DESC *DevDesc
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -146,11 +145,11 @@ UsbFreeDevDesc (
|
||||
@return The created string descriptor or NULL.
|
||||
|
||||
**/
|
||||
EFI_USB_STRING_DESCRIPTOR*
|
||||
EFI_USB_STRING_DESCRIPTOR *
|
||||
UsbGetOneString (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 StringIndex,
|
||||
IN UINT16 LangId
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 StringIndex,
|
||||
IN UINT16 LangId
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -166,7 +165,7 @@ UsbGetOneString (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbBuildDescTable (
|
||||
IN USB_DEVICE *UsbDev
|
||||
IN USB_DEVICE *UsbDev
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -181,8 +180,8 @@ UsbBuildDescTable (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbSetAddress (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Address
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Address
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -199,8 +198,8 @@ UsbSetAddress (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbSetConfig (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 ConfigIndex
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 ConfigIndex
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -219,9 +218,10 @@ UsbSetConfig (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbIoClearFeature (
|
||||
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
||||
IN UINTN Target,
|
||||
IN UINT16 Feature,
|
||||
IN UINT16 Index
|
||||
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
||||
IN UINTN Target,
|
||||
IN UINT16 Feature,
|
||||
IN UINT16 Index
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -20,13 +20,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
USB_ENDPOINT_DESC *
|
||||
UsbGetEndpointDesc (
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 EpAddr
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 EpAddr
|
||||
)
|
||||
{
|
||||
USB_ENDPOINT_DESC *EpDesc;
|
||||
UINT8 Index;
|
||||
UINT8 NumEndpoints;
|
||||
USB_ENDPOINT_DESC *EpDesc;
|
||||
UINT8 Index;
|
||||
UINT8 NumEndpoints;
|
||||
|
||||
NumEndpoints = UsbIf->IfSetting->Desc.NumEndpoints;
|
||||
|
||||
@@ -41,7 +41,6 @@ UsbGetEndpointDesc (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the resource used by USB interface.
|
||||
|
||||
@@ -52,31 +51,34 @@ UsbGetEndpointDesc (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbFreeInterface (
|
||||
IN USB_INTERFACE *UsbIf
|
||||
IN USB_INTERFACE *UsbIf
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
UsbCloseHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);
|
||||
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
UsbIf->Handle,
|
||||
&gEfiDevicePathProtocolGuid, UsbIf->DevicePath,
|
||||
&gEfiUsbIoProtocolGuid, &UsbIf->UsbIo,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
UsbIf->DevicePath,
|
||||
&gEfiUsbIoProtocolGuid,
|
||||
&UsbIf->UsbIo,
|
||||
NULL
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (UsbIf->DevicePath != NULL) {
|
||||
FreePool (UsbIf->DevicePath);
|
||||
}
|
||||
|
||||
FreePool (UsbIf);
|
||||
} else {
|
||||
UsbOpenHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create an interface for the descriptor IfDesc. Each
|
||||
device's configuration can have several interfaces.
|
||||
@@ -89,14 +91,14 @@ UsbFreeInterface (
|
||||
**/
|
||||
USB_INTERFACE *
|
||||
UsbCreateInterface (
|
||||
IN USB_DEVICE *Device,
|
||||
IN USB_INTERFACE_DESC *IfDesc
|
||||
IN USB_DEVICE *Device,
|
||||
IN USB_INTERFACE_DESC *IfDesc
|
||||
)
|
||||
{
|
||||
USB_DEVICE_PATH UsbNode;
|
||||
USB_INTERFACE *UsbIf;
|
||||
USB_INTERFACE *HubIf;
|
||||
EFI_STATUS Status;
|
||||
USB_DEVICE_PATH UsbNode;
|
||||
USB_INTERFACE *UsbIf;
|
||||
USB_INTERFACE *HubIf;
|
||||
EFI_STATUS Status;
|
||||
|
||||
UsbIf = AllocateZeroPool (sizeof (USB_INTERFACE));
|
||||
|
||||
@@ -104,11 +106,11 @@ UsbCreateInterface (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UsbIf->Signature = USB_INTERFACE_SIGNATURE;
|
||||
UsbIf->Device = Device;
|
||||
UsbIf->IfDesc = IfDesc;
|
||||
UsbIf->Signature = USB_INTERFACE_SIGNATURE;
|
||||
UsbIf->Device = Device;
|
||||
UsbIf->IfDesc = IfDesc;
|
||||
ASSERT (IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
|
||||
UsbIf->IfSetting = IfDesc->Settings[IfDesc->ActiveIndex];
|
||||
UsbIf->IfSetting = IfDesc->Settings[IfDesc->ActiveIndex];
|
||||
|
||||
CopyMem (
|
||||
&(UsbIf->UsbIo),
|
||||
@@ -119,10 +121,10 @@ UsbCreateInterface (
|
||||
//
|
||||
// Install protocols for USBIO and device path
|
||||
//
|
||||
UsbNode.Header.Type = MESSAGING_DEVICE_PATH;
|
||||
UsbNode.Header.SubType = MSG_USB_DP;
|
||||
UsbNode.ParentPortNumber = Device->ParentPort;
|
||||
UsbNode.InterfaceNumber = UsbIf->IfSetting->Desc.InterfaceNumber;
|
||||
UsbNode.Header.Type = MESSAGING_DEVICE_PATH;
|
||||
UsbNode.Header.SubType = MSG_USB_DP;
|
||||
UsbNode.ParentPortNumber = Device->ParentPort;
|
||||
UsbNode.InterfaceNumber = UsbIf->IfSetting->Desc.InterfaceNumber;
|
||||
|
||||
SetDevicePathNodeLength (&UsbNode.Header, sizeof (UsbNode));
|
||||
|
||||
@@ -182,7 +184,6 @@ ON_ERROR:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the resource used by this USB device.
|
||||
|
||||
@@ -191,7 +192,7 @@ ON_ERROR:
|
||||
**/
|
||||
VOID
|
||||
UsbFreeDevice (
|
||||
IN USB_DEVICE *Device
|
||||
IN USB_DEVICE *Device
|
||||
)
|
||||
{
|
||||
if (Device->DevDesc != NULL) {
|
||||
@@ -201,7 +202,6 @@ UsbFreeDevice (
|
||||
gBS->FreePool (Device);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a device which is on the parent's ParentPort port.
|
||||
|
||||
@@ -213,11 +213,11 @@ UsbFreeDevice (
|
||||
**/
|
||||
USB_DEVICE *
|
||||
UsbCreateDevice (
|
||||
IN USB_INTERFACE *ParentIf,
|
||||
IN UINT8 ParentPort
|
||||
IN USB_INTERFACE *ParentIf,
|
||||
IN UINT8 ParentPort
|
||||
)
|
||||
{
|
||||
USB_DEVICE *Device;
|
||||
USB_DEVICE *Device;
|
||||
|
||||
ASSERT (ParentIf != NULL);
|
||||
|
||||
@@ -227,16 +227,15 @@ UsbCreateDevice (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Device->Bus = ParentIf->Device->Bus;
|
||||
Device->MaxPacket0 = 8;
|
||||
Device->ParentAddr = ParentIf->Device->Address;
|
||||
Device->ParentIf = ParentIf;
|
||||
Device->ParentPort = ParentPort;
|
||||
Device->Tier = (UINT8)(ParentIf->Device->Tier + 1);
|
||||
Device->Bus = ParentIf->Device->Bus;
|
||||
Device->MaxPacket0 = 8;
|
||||
Device->ParentAddr = ParentIf->Device->Address;
|
||||
Device->ParentIf = ParentIf;
|
||||
Device->ParentPort = ParentPort;
|
||||
Device->Tier = (UINT8)(ParentIf->Device->Tier + 1);
|
||||
return Device;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Connect the USB interface with its driver. EFI USB bus will
|
||||
create a USB interface for each separate interface descriptor.
|
||||
@@ -249,11 +248,11 @@ UsbCreateDevice (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbConnectDriver (
|
||||
IN USB_INTERFACE *UsbIf
|
||||
IN USB_INTERFACE *UsbIf
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL OldTpl;
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
@@ -264,7 +263,6 @@ UsbConnectDriver (
|
||||
if (UsbIsHubInterface (UsbIf)) {
|
||||
DEBUG ((DEBUG_INFO, "UsbConnectDriver: found a hub device\n"));
|
||||
Status = mUsbHubApi.Init (UsbIf);
|
||||
|
||||
} else {
|
||||
//
|
||||
// This function is called in both UsbIoControlTransfer and
|
||||
@@ -278,15 +276,15 @@ UsbConnectDriver (
|
||||
// Only recursively wanted usb child device
|
||||
//
|
||||
if (UsbBusIsWantedUsbIO (UsbIf->Device->Bus, UsbIf)) {
|
||||
OldTpl = UsbGetCurrentTpl ();
|
||||
OldTpl = UsbGetCurrentTpl ();
|
||||
DEBUG ((DEBUG_INFO, "UsbConnectDriver: TPL before connect is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle));
|
||||
|
||||
gBS->RestoreTPL (TPL_CALLBACK);
|
||||
|
||||
Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);
|
||||
UsbIf->IsManaged = (BOOLEAN)!EFI_ERROR (Status);
|
||||
Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);
|
||||
UsbIf->IsManaged = (BOOLEAN) !EFI_ERROR (Status);
|
||||
|
||||
DEBUG ((DEBUG_INFO, "UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl()));
|
||||
DEBUG ((DEBUG_INFO, "UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl ()));
|
||||
ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK);
|
||||
|
||||
gBS->RaiseTPL (OldTpl);
|
||||
@@ -296,7 +294,6 @@ UsbConnectDriver (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Select an alternate setting for the interface.
|
||||
Each interface can have several mutually exclusive
|
||||
@@ -312,12 +309,12 @@ UsbConnectDriver (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbSelectSetting (
|
||||
IN USB_INTERFACE_DESC *IfDesc,
|
||||
IN UINT8 Alternate
|
||||
IN USB_INTERFACE_DESC *IfDesc,
|
||||
IN UINT8 Alternate
|
||||
)
|
||||
{
|
||||
USB_INTERFACE_SETTING *Setting;
|
||||
UINTN Index;
|
||||
USB_INTERFACE_SETTING *Setting;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Locate the active alternate setting
|
||||
@@ -340,8 +337,12 @@ UsbSelectSetting (
|
||||
IfDesc->ActiveIndex = Index;
|
||||
|
||||
ASSERT (Setting != NULL);
|
||||
DEBUG ((DEBUG_INFO, "UsbSelectSetting: setting %d selected for interface %d\n",
|
||||
Alternate, Setting->Desc.InterfaceNumber));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"UsbSelectSetting: setting %d selected for interface %d\n",
|
||||
Alternate,
|
||||
Setting->Desc.InterfaceNumber
|
||||
));
|
||||
|
||||
//
|
||||
// Reset the endpoint toggle to zero
|
||||
@@ -353,7 +354,6 @@ UsbSelectSetting (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Select a new configuration for the device. Each
|
||||
device may support several configurations.
|
||||
@@ -368,22 +368,22 @@ UsbSelectSetting (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbSelectConfig (
|
||||
IN USB_DEVICE *Device,
|
||||
IN UINT8 ConfigValue
|
||||
IN USB_DEVICE *Device,
|
||||
IN UINT8 ConfigValue
|
||||
)
|
||||
{
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
USB_CONFIG_DESC *ConfigDesc;
|
||||
USB_INTERFACE_DESC *IfDesc;
|
||||
USB_INTERFACE *UsbIf;
|
||||
EFI_STATUS Status;
|
||||
UINT8 Index;
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
USB_CONFIG_DESC *ConfigDesc;
|
||||
USB_INTERFACE_DESC *IfDesc;
|
||||
USB_INTERFACE *UsbIf;
|
||||
EFI_STATUS Status;
|
||||
UINT8 Index;
|
||||
|
||||
//
|
||||
// Locate the active config, then set the device's pointer
|
||||
//
|
||||
DevDesc = Device->DevDesc;
|
||||
ConfigDesc = NULL;
|
||||
DevDesc = Device->DevDesc;
|
||||
ConfigDesc = NULL;
|
||||
|
||||
for (Index = 0; Index < DevDesc->Desc.NumConfigurations; Index++) {
|
||||
ConfigDesc = DevDesc->Configs[Index];
|
||||
@@ -399,8 +399,12 @@ UsbSelectConfig (
|
||||
|
||||
Device->ActiveConfig = ConfigDesc;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "UsbSelectConfig: config %d selected for device %d\n",
|
||||
ConfigValue, Device->Address));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"UsbSelectConfig: config %d selected for device %d\n",
|
||||
ConfigValue,
|
||||
Device->Address
|
||||
));
|
||||
|
||||
//
|
||||
// Create interfaces for each USB interface descriptor.
|
||||
@@ -447,7 +451,6 @@ UsbSelectConfig (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Disconnect the USB interface with its driver.
|
||||
|
||||
@@ -456,11 +459,11 @@ UsbSelectConfig (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbDisconnectDriver (
|
||||
IN USB_INTERFACE *UsbIf
|
||||
IN USB_INTERFACE *UsbIf
|
||||
)
|
||||
{
|
||||
EFI_TPL OldTpl;
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL OldTpl;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Release the hub if it's a hub controller, otherwise
|
||||
@@ -469,7 +472,6 @@ UsbDisconnectDriver (
|
||||
Status = EFI_SUCCESS;
|
||||
if (UsbIf->IsHub) {
|
||||
Status = UsbIf->HubApi->Release (UsbIf);
|
||||
|
||||
} else if (UsbIf->IsManaged) {
|
||||
//
|
||||
// This function is called in both UsbIoControlTransfer and
|
||||
@@ -478,7 +480,7 @@ UsbDisconnectDriver (
|
||||
// twisted TPL used. It should be no problem for us to connect
|
||||
// or disconnect at CALLBACK.
|
||||
//
|
||||
OldTpl = UsbGetCurrentTpl ();
|
||||
OldTpl = UsbGetCurrentTpl ();
|
||||
DEBUG ((DEBUG_INFO, "UsbDisconnectDriver: old TPL is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle));
|
||||
|
||||
gBS->RestoreTPL (TPL_CALLBACK);
|
||||
@@ -488,7 +490,7 @@ UsbDisconnectDriver (
|
||||
UsbIf->IsManaged = FALSE;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbDisconnectDriver: TPL after disconnect is %d, %d\n", (UINT32)UsbGetCurrentTpl(), Status));
|
||||
DEBUG ((DEBUG_INFO, "UsbDisconnectDriver: TPL after disconnect is %d, %d\n", (UINT32)UsbGetCurrentTpl (), Status));
|
||||
ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK);
|
||||
|
||||
gBS->RaiseTPL (OldTpl);
|
||||
@@ -497,7 +499,6 @@ UsbDisconnectDriver (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove the current device configuration.
|
||||
|
||||
@@ -506,13 +507,13 @@ UsbDisconnectDriver (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbRemoveConfig (
|
||||
IN USB_DEVICE *Device
|
||||
IN USB_DEVICE *Device
|
||||
)
|
||||
{
|
||||
USB_INTERFACE *UsbIf;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS ReturnStatus;
|
||||
USB_INTERFACE *UsbIf;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS ReturnStatus;
|
||||
|
||||
//
|
||||
// Remove each interface of the device
|
||||
@@ -541,11 +542,10 @@ UsbRemoveConfig (
|
||||
}
|
||||
}
|
||||
|
||||
Device->ActiveConfig = NULL;
|
||||
Device->ActiveConfig = NULL;
|
||||
return ReturnStatus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove the device and all its children from the bus.
|
||||
|
||||
@@ -556,14 +556,14 @@ UsbRemoveConfig (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbRemoveDevice (
|
||||
IN USB_DEVICE *Device
|
||||
IN USB_DEVICE *Device
|
||||
)
|
||||
{
|
||||
USB_BUS *Bus;
|
||||
USB_DEVICE *Child;
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS ReturnStatus;
|
||||
UINTN Index;
|
||||
USB_BUS *Bus;
|
||||
USB_DEVICE *Child;
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS ReturnStatus;
|
||||
UINTN Index;
|
||||
|
||||
Bus = Device->Bus;
|
||||
|
||||
@@ -585,7 +585,7 @@ UsbRemoveDevice (
|
||||
Bus->Devices[Index] = NULL;
|
||||
} else {
|
||||
Bus->Devices[Index]->DisconnectFail = TRUE;
|
||||
ReturnStatus = Status;
|
||||
ReturnStatus = Status;
|
||||
DEBUG ((DEBUG_INFO, "UsbRemoveDevice: failed to remove child %p at parent %p\n", Child, Device));
|
||||
}
|
||||
}
|
||||
@@ -597,7 +597,7 @@ UsbRemoveDevice (
|
||||
Status = UsbRemoveConfig (Device);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_INFO, "UsbRemoveDevice: device %d removed\n", Device->Address));
|
||||
DEBUG ((DEBUG_INFO, "UsbRemoveDevice: device %d removed\n", Device->Address));
|
||||
|
||||
ASSERT (Device->Address < Bus->MaxDevices);
|
||||
Bus->Devices[Device->Address] = NULL;
|
||||
@@ -605,10 +605,10 @@ UsbRemoveDevice (
|
||||
} else {
|
||||
Bus->Devices[Device->Address]->DisconnectFail = TRUE;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find the child device on the hub's port.
|
||||
|
||||
@@ -620,13 +620,13 @@ UsbRemoveDevice (
|
||||
**/
|
||||
USB_DEVICE *
|
||||
UsbFindChild (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
)
|
||||
{
|
||||
USB_DEVICE *Device;
|
||||
USB_BUS *Bus;
|
||||
UINTN Index;
|
||||
USB_DEVICE *Device;
|
||||
USB_BUS *Bus;
|
||||
UINTN Index;
|
||||
|
||||
Bus = HubIf->Device->Bus;
|
||||
|
||||
@@ -637,8 +637,8 @@ UsbFindChild (
|
||||
Device = Bus->Devices[Index];
|
||||
|
||||
if ((Device != NULL) && (Device->ParentAddr == HubIf->Device->Address) &&
|
||||
(Device->ParentPort == Port)) {
|
||||
|
||||
(Device->ParentPort == Port))
|
||||
{
|
||||
return Device;
|
||||
}
|
||||
}
|
||||
@@ -646,7 +646,6 @@ UsbFindChild (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enumerate and configure the new device on the port of this HUB interface.
|
||||
|
||||
@@ -661,19 +660,19 @@ UsbFindChild (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbEnumerateNewDev (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
IN BOOLEAN ResetIsNeeded
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
IN BOOLEAN ResetIsNeeded
|
||||
)
|
||||
{
|
||||
USB_BUS *Bus;
|
||||
USB_HUB_API *HubApi;
|
||||
USB_DEVICE *Child;
|
||||
USB_DEVICE *Parent;
|
||||
EFI_USB_PORT_STATUS PortState;
|
||||
UINTN Address;
|
||||
UINT8 Config;
|
||||
EFI_STATUS Status;
|
||||
USB_BUS *Bus;
|
||||
USB_HUB_API *HubApi;
|
||||
USB_DEVICE *Child;
|
||||
USB_DEVICE *Parent;
|
||||
EFI_USB_PORT_STATUS PortState;
|
||||
UINTN Address;
|
||||
UINT8 Config;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Parent = HubIf->Device;
|
||||
Bus = Parent->Bus;
|
||||
@@ -695,9 +694,10 @@ UsbEnumerateNewDev (
|
||||
|
||||
return Status;
|
||||
}
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: hub port %d is reset\n", Port));
|
||||
|
||||
DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: hub port %d is reset\n", Port));
|
||||
} else {
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: hub port %d reset is skipped\n", Port));
|
||||
DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: hub port %d reset is skipped\n", Port));
|
||||
}
|
||||
|
||||
Child = UsbCreateDevice (HubIf, Port);
|
||||
@@ -721,7 +721,7 @@ UsbEnumerateNewDev (
|
||||
DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: No device present at port %d\n", Port));
|
||||
Status = EFI_NOT_FOUND;
|
||||
goto ON_ERROR;
|
||||
} else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_SUPER_SPEED)){
|
||||
} else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_SUPER_SPEED)) {
|
||||
Child->Speed = EFI_USB_SPEED_SUPER;
|
||||
Child->MaxPacket0 = 512;
|
||||
} else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_HIGH_SPEED)) {
|
||||
@@ -735,10 +735,11 @@ UsbEnumerateNewDev (
|
||||
Child->MaxPacket0 = 8;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device is of %d speed\n", Child->Speed));
|
||||
DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: device is of %d speed\n", Child->Speed));
|
||||
|
||||
if (((Child->Speed == EFI_USB_SPEED_LOW) || (Child->Speed == EFI_USB_SPEED_FULL)) &&
|
||||
(Parent->Speed == EFI_USB_SPEED_HIGH)) {
|
||||
(Parent->Speed == EFI_USB_SPEED_HIGH))
|
||||
{
|
||||
//
|
||||
// If the child is a low or full speed device, it is necessary to
|
||||
// set the transaction translator. Port TT is 1-based.
|
||||
@@ -746,14 +747,18 @@ UsbEnumerateNewDev (
|
||||
// 1. if parent is of high speed, then parent is our translator
|
||||
// 2. otherwise use parent's translator.
|
||||
//
|
||||
Child->Translator.TranslatorHubAddress = Parent->Address;
|
||||
Child->Translator.TranslatorPortNumber = (UINT8) (Port + 1);
|
||||
Child->Translator.TranslatorHubAddress = Parent->Address;
|
||||
Child->Translator.TranslatorPortNumber = (UINT8)(Port + 1);
|
||||
} else {
|
||||
Child->Translator = Parent->Translator;
|
||||
}
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device uses translator (%d, %d)\n",
|
||||
Child->Translator.TranslatorHubAddress,
|
||||
Child->Translator.TranslatorPortNumber));
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"UsbEnumerateNewDev: device uses translator (%d, %d)\n",
|
||||
Child->Translator.TranslatorHubAddress,
|
||||
Child->Translator.TranslatorPortNumber
|
||||
));
|
||||
|
||||
//
|
||||
// After port is reset, hub establishes a signal path between
|
||||
@@ -805,7 +810,7 @@ UsbEnumerateNewDev (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child->MaxPacket0));
|
||||
DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child->MaxPacket0));
|
||||
|
||||
//
|
||||
// Host learns about the device's abilities by requesting device's
|
||||
@@ -830,7 +835,7 @@ UsbEnumerateNewDev (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device %d is now in CONFIGED state\n", Address));
|
||||
DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: device %d is now in CONFIGED state\n", Address));
|
||||
|
||||
//
|
||||
// Host assigns and loads a device driver.
|
||||
@@ -870,7 +875,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process the events on the port.
|
||||
|
||||
@@ -884,17 +888,17 @@ ON_ERROR:
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbEnumeratePort (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
)
|
||||
{
|
||||
USB_HUB_API *HubApi;
|
||||
USB_DEVICE *Child;
|
||||
EFI_USB_PORT_STATUS PortState;
|
||||
EFI_STATUS Status;
|
||||
USB_HUB_API *HubApi;
|
||||
USB_DEVICE *Child;
|
||||
EFI_USB_PORT_STATUS PortState;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Child = NULL;
|
||||
HubApi = HubIf->HubApi;
|
||||
Child = NULL;
|
||||
HubApi = HubIf->HubApi;
|
||||
|
||||
//
|
||||
// Host learns of the new device by polling the hub for port changes.
|
||||
@@ -914,8 +918,14 @@ UsbEnumeratePort (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumeratePort: port %d state - %02x, change - %02x on %p\n",
|
||||
Port, PortState.PortStatus, PortState.PortChangeStatus, HubIf));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"UsbEnumeratePort: port %d state - %02x, change - %02x on %p\n",
|
||||
Port,
|
||||
PortState.PortStatus,
|
||||
PortState.PortChangeStatus,
|
||||
HubIf
|
||||
));
|
||||
|
||||
//
|
||||
// This driver only process two kinds of events now: over current and
|
||||
@@ -924,7 +934,6 @@ UsbEnumeratePort (
|
||||
//
|
||||
|
||||
if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_OVERCURRENT)) {
|
||||
|
||||
if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_OVERCURRENT)) {
|
||||
//
|
||||
// Case1:
|
||||
@@ -932,17 +941,17 @@ UsbEnumeratePort (
|
||||
// which probably is caused by short circuit. It has to wait system hardware
|
||||
// to perform recovery.
|
||||
//
|
||||
DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: Critical Over Current\n", Port));
|
||||
DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: Critical Over Current\n", Port));
|
||||
return EFI_DEVICE_ERROR;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Case2:
|
||||
// Only OverCurrentChange set, means system has been recoveried from
|
||||
// over current. As a result, all ports are nearly power-off, so
|
||||
// it's necessary to detach and enumerate all ports again.
|
||||
//
|
||||
DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port));
|
||||
DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port));
|
||||
}
|
||||
|
||||
if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_ENABLE)) {
|
||||
@@ -952,7 +961,7 @@ UsbEnumeratePort (
|
||||
// on 2.0 roothub does. When over-current has influence on 1.1 device, the port
|
||||
// would be disabled, so it's also necessary to detach and enumerate again.
|
||||
//
|
||||
DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port));
|
||||
DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port));
|
||||
}
|
||||
|
||||
if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_CONNECTION)) {
|
||||
@@ -969,7 +978,7 @@ UsbEnumeratePort (
|
||||
Child = UsbFindChild (HubIf, Port);
|
||||
|
||||
if (Child != NULL) {
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumeratePort: device at port %d removed from root hub %p\n", Port, HubIf));
|
||||
DEBUG ((DEBUG_INFO, "UsbEnumeratePort: device at port %d removed from root hub %p\n", Port, HubIf));
|
||||
UsbRemoveDevice (Child);
|
||||
}
|
||||
|
||||
@@ -977,22 +986,20 @@ UsbEnumeratePort (
|
||||
//
|
||||
// Now, new device connected, enumerate and configure the device
|
||||
//
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumeratePort: new device connected at port %d\n", Port));
|
||||
DEBUG ((DEBUG_INFO, "UsbEnumeratePort: new device connected at port %d\n", Port));
|
||||
if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET)) {
|
||||
Status = UsbEnumerateNewDev (HubIf, Port, FALSE);
|
||||
} else {
|
||||
Status = UsbEnumerateNewDev (HubIf, Port, TRUE);
|
||||
}
|
||||
|
||||
} else {
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumeratePort: device disconnected event on port %d\n", Port));
|
||||
DEBUG ((DEBUG_INFO, "UsbEnumeratePort: device disconnected event on port %d\n", Port));
|
||||
}
|
||||
|
||||
HubApi->ClearPortChange (HubIf, Port);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enumerate all the changed hub ports.
|
||||
|
||||
@@ -1003,37 +1010,37 @@ UsbEnumeratePort (
|
||||
VOID
|
||||
EFIAPI
|
||||
UsbHubEnumeration (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
USB_INTERFACE *HubIf;
|
||||
UINT8 Byte;
|
||||
UINT8 Bit;
|
||||
UINT8 Index;
|
||||
USB_DEVICE *Child;
|
||||
USB_INTERFACE *HubIf;
|
||||
UINT8 Byte;
|
||||
UINT8 Bit;
|
||||
UINT8 Index;
|
||||
USB_DEVICE *Child;
|
||||
|
||||
ASSERT (Context != NULL);
|
||||
|
||||
HubIf = (USB_INTERFACE *) Context;
|
||||
HubIf = (USB_INTERFACE *)Context;
|
||||
|
||||
for (Index = 0; Index < HubIf->NumOfPort; Index++) {
|
||||
Child = UsbFindChild (HubIf, Index);
|
||||
if ((Child != NULL) && (Child->DisconnectFail == TRUE)) {
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from hub %p, try again\n", Index, HubIf));
|
||||
DEBUG ((DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from hub %p, try again\n", Index, HubIf));
|
||||
UsbRemoveDevice (Child);
|
||||
}
|
||||
}
|
||||
|
||||
if (HubIf->ChangeMap == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// HUB starts its port index with 1.
|
||||
//
|
||||
Byte = 0;
|
||||
Bit = 1;
|
||||
Byte = 0;
|
||||
Bit = 1;
|
||||
|
||||
for (Index = 0; Index < HubIf->NumOfPort; Index++) {
|
||||
if (USB_BIT_IS_SET (HubIf->ChangeMap[Byte], USB_BIT (Bit))) {
|
||||
@@ -1047,10 +1054,9 @@ UsbHubEnumeration (
|
||||
|
||||
gBS->FreePool (HubIf->ChangeMap);
|
||||
HubIf->ChangeMap = NULL;
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enumerate all the changed hub ports.
|
||||
|
||||
@@ -1061,20 +1067,20 @@ UsbHubEnumeration (
|
||||
VOID
|
||||
EFIAPI
|
||||
UsbRootHubEnumeration (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
USB_INTERFACE *RootHub;
|
||||
UINT8 Index;
|
||||
USB_DEVICE *Child;
|
||||
USB_INTERFACE *RootHub;
|
||||
UINT8 Index;
|
||||
USB_DEVICE *Child;
|
||||
|
||||
RootHub = (USB_INTERFACE *) Context;
|
||||
RootHub = (USB_INTERFACE *)Context;
|
||||
|
||||
for (Index = 0; Index < RootHub->NumOfPort; Index++) {
|
||||
Child = UsbFindChild (RootHub, Index);
|
||||
if ((Child != NULL) && (Child->DisconnectFail == TRUE)) {
|
||||
DEBUG (( DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from root hub %p, try again\n", Index, RootHub));
|
||||
DEBUG ((DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from root hub %p, try again\n", Index, RootHub));
|
||||
UsbRemoveDevice (Child);
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
//
|
||||
// Common interface used by usb bus enumeration process.
|
||||
// This interface is defined to mask the difference between
|
||||
@@ -32,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(*USB_HUB_INIT) (
|
||||
IN USB_INTERFACE *UsbIf
|
||||
IN USB_INTERFACE *UsbIf
|
||||
);
|
||||
|
||||
//
|
||||
@@ -44,45 +43,45 @@ EFI_STATUS
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(*USB_HUB_GET_PORT_STATUS) (
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 Port,
|
||||
OUT EFI_USB_PORT_STATUS *PortState
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 Port,
|
||||
OUT EFI_USB_PORT_STATUS *PortState
|
||||
);
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(*USB_HUB_CLEAR_PORT_CHANGE) (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(*USB_HUB_SET_PORT_FEATURE) (
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(*USB_HUB_CLEAR_PORT_FEATURE) (
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(*USB_HUB_RESET_PORT) (
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 Port
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 Port
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(*USB_HUB_RELEASE) (
|
||||
IN USB_INTERFACE *UsbIf
|
||||
IN USB_INTERFACE *UsbIf
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -94,10 +93,10 @@ EFI_STATUS
|
||||
@return The endpoint descriptor or NULL.
|
||||
|
||||
**/
|
||||
USB_ENDPOINT_DESC*
|
||||
USB_ENDPOINT_DESC *
|
||||
UsbGetEndpointDesc (
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 EpAddr
|
||||
IN USB_INTERFACE *UsbIf,
|
||||
IN UINT8 EpAddr
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -115,8 +114,8 @@ UsbGetEndpointDesc (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbSelectSetting (
|
||||
IN USB_INTERFACE_DESC *IfDesc,
|
||||
IN UINT8 Alternate
|
||||
IN USB_INTERFACE_DESC *IfDesc,
|
||||
IN UINT8 Alternate
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -133,8 +132,8 @@ UsbSelectSetting (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbSelectConfig (
|
||||
IN USB_DEVICE *Device,
|
||||
IN UINT8 ConfigIndex
|
||||
IN USB_DEVICE *Device,
|
||||
IN UINT8 ConfigIndex
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -147,7 +146,7 @@ UsbSelectConfig (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbRemoveConfig (
|
||||
IN USB_DEVICE *Device
|
||||
IN USB_DEVICE *Device
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -160,7 +159,7 @@ UsbRemoveConfig (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbRemoveDevice (
|
||||
IN USB_DEVICE *Device
|
||||
IN USB_DEVICE *Device
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -175,8 +174,8 @@ UsbRemoveDevice (
|
||||
VOID
|
||||
EFIAPI
|
||||
UsbHubEnumeration (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -191,7 +190,8 @@ UsbHubEnumeration (
|
||||
VOID
|
||||
EFIAPI
|
||||
UsbRootHubEnumeration (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -17,19 +17,19 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
// bit maps.
|
||||
//
|
||||
USB_CHANGE_FEATURE_MAP mHubFeatureMap[] = {
|
||||
{USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange},
|
||||
{USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange},
|
||||
{USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange},
|
||||
{USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange},
|
||||
{USB_PORT_STAT_C_RESET, EfiUsbPortResetChange}
|
||||
{ USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange },
|
||||
{ USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange },
|
||||
{ USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange },
|
||||
{ USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange },
|
||||
{ USB_PORT_STAT_C_RESET, EfiUsbPortResetChange }
|
||||
};
|
||||
|
||||
USB_CHANGE_FEATURE_MAP mRootHubFeatureMap[] = {
|
||||
{USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange},
|
||||
{USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange},
|
||||
{USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange},
|
||||
{USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange},
|
||||
{USB_PORT_STAT_C_RESET, EfiUsbPortResetChange},
|
||||
{ USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange },
|
||||
{ USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange },
|
||||
{ USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange },
|
||||
{ USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange },
|
||||
{ USB_PORT_STAT_C_RESET, EfiUsbPortResetChange },
|
||||
};
|
||||
|
||||
//
|
||||
@@ -37,6 +37,7 @@ USB_CHANGE_FEATURE_MAP mRootHubFeatureMap[] = {
|
||||
// is related to an interface, these requests are sent
|
||||
// to the control endpoint of the device.
|
||||
//
|
||||
|
||||
/**
|
||||
USB hub control transfer to set the hub depth.
|
||||
|
||||
@@ -49,11 +50,11 @@ USB_CHANGE_FEATURE_MAP mRootHubFeatureMap[] = {
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubCtrlSetHubDepth (
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT16 Depth
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT16 Depth
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbCtrlRequest (
|
||||
HubDev,
|
||||
@@ -82,11 +83,11 @@ UsbHubCtrlSetHubDepth (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubCtrlClearHubFeature (
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT16 Feature
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT16 Feature
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbCtrlRequest (
|
||||
HubDev,
|
||||
@@ -103,7 +104,6 @@ UsbHubCtrlClearHubFeature (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clear the feature of the device's port.
|
||||
|
||||
@@ -117,12 +117,12 @@ UsbHubCtrlClearHubFeature (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubCtrlClearPortFeature (
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT8 Port,
|
||||
IN UINT16 Feature
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT8 Port,
|
||||
IN UINT16 Feature
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// In USB bus, all the port index starts from 0. But HUB
|
||||
@@ -135,7 +135,7 @@ UsbHubCtrlClearPortFeature (
|
||||
USB_HUB_TARGET_PORT,
|
||||
USB_HUB_REQ_CLEAR_FEATURE,
|
||||
Feature,
|
||||
(UINT16) (Port + 1),
|
||||
(UINT16)(Port + 1),
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
@@ -143,7 +143,6 @@ UsbHubCtrlClearPortFeature (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clear the transaction translate buffer if full/low
|
||||
speed control/bulk transfer failed and the transfer
|
||||
@@ -163,21 +162,21 @@ UsbHubCtrlClearPortFeature (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubCtrlClearTTBuffer (
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT8 Port,
|
||||
IN UINT16 DevAddr,
|
||||
IN UINT16 EpNum,
|
||||
IN UINT16 EpType
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT8 Port,
|
||||
IN UINT16 DevAddr,
|
||||
IN UINT16 EpNum,
|
||||
IN UINT16 EpType
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT16 Value;
|
||||
EFI_STATUS Status;
|
||||
UINT16 Value;
|
||||
|
||||
//
|
||||
// Check USB2.0 spec page 424 for wValue's encoding
|
||||
//
|
||||
Value = (UINT16) ((EpNum & 0x0F) | (DevAddr << 4) |
|
||||
((EpType & 0x03) << 11) | ((EpNum & 0x80) << 15));
|
||||
Value = (UINT16)((EpNum & 0x0F) | (DevAddr << 4) |
|
||||
((EpType & 0x03) << 11) | ((EpNum & 0x80) << 15));
|
||||
|
||||
Status = UsbCtrlRequest (
|
||||
HubDev,
|
||||
@@ -186,7 +185,7 @@ UsbHubCtrlClearTTBuffer (
|
||||
USB_HUB_TARGET_PORT,
|
||||
USB_HUB_REQ_CLEAR_TT,
|
||||
Value,
|
||||
(UINT16) (Port + 1),
|
||||
(UINT16)(Port + 1),
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
@@ -207,13 +206,13 @@ UsbHubCtrlClearTTBuffer (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubCtrlGetHubDesc (
|
||||
IN USB_DEVICE *HubDev,
|
||||
OUT VOID *Buf,
|
||||
IN UINTN Len
|
||||
IN USB_DEVICE *HubDev,
|
||||
OUT VOID *Buf,
|
||||
IN UINTN Len
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 DescType;
|
||||
EFI_STATUS Status;
|
||||
UINT8 DescType;
|
||||
|
||||
DescType = (HubDev->Speed == EFI_USB_SPEED_SUPER) ?
|
||||
USB_DESC_TYPE_HUB_SUPER_SPEED :
|
||||
@@ -225,7 +224,7 @@ UsbHubCtrlGetHubDesc (
|
||||
USB_REQ_TYPE_CLASS,
|
||||
USB_HUB_TARGET_HUB,
|
||||
USB_HUB_REQ_GET_DESC,
|
||||
(UINT16) (DescType << 8),
|
||||
(UINT16)(DescType << 8),
|
||||
0,
|
||||
Buf,
|
||||
Len
|
||||
@@ -234,7 +233,6 @@ UsbHubCtrlGetHubDesc (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Usb hub control transfer to get the hub status.
|
||||
|
||||
@@ -247,11 +245,11 @@ UsbHubCtrlGetHubDesc (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubCtrlGetHubStatus (
|
||||
IN USB_DEVICE *HubDev,
|
||||
OUT UINT32 *State
|
||||
IN USB_DEVICE *HubDev,
|
||||
OUT UINT32 *State
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbCtrlRequest (
|
||||
HubDev,
|
||||
@@ -268,7 +266,6 @@ UsbHubCtrlGetHubStatus (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Usb hub control transfer to get the port status.
|
||||
|
||||
@@ -282,12 +279,12 @@ UsbHubCtrlGetHubStatus (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubCtrlGetPortStatus (
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT8 Port,
|
||||
OUT VOID *State
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT8 Port,
|
||||
OUT VOID *State
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// In USB bus, all the port index starts from 0. But HUB
|
||||
@@ -302,7 +299,7 @@ UsbHubCtrlGetPortStatus (
|
||||
USB_HUB_TARGET_PORT,
|
||||
USB_HUB_REQ_GET_STATUS,
|
||||
0,
|
||||
(UINT16) (Port + 1),
|
||||
(UINT16)(Port + 1),
|
||||
State,
|
||||
4
|
||||
);
|
||||
@@ -310,7 +307,6 @@ UsbHubCtrlGetPortStatus (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Usb hub control transfer to set the port feature.
|
||||
|
||||
@@ -324,12 +320,12 @@ UsbHubCtrlGetPortStatus (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubCtrlSetPortFeature (
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT8 Port,
|
||||
IN UINT8 Feature
|
||||
IN USB_DEVICE *HubDev,
|
||||
IN UINT8 Port,
|
||||
IN UINT8 Feature
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// In USB bus, all the port index starts from 0. But HUB
|
||||
@@ -342,7 +338,7 @@ UsbHubCtrlSetPortFeature (
|
||||
USB_HUB_TARGET_PORT,
|
||||
USB_HUB_REQ_SET_FEATURE,
|
||||
Feature,
|
||||
(UINT16) (Port + 1),
|
||||
(UINT16)(Port + 1),
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
@@ -350,7 +346,6 @@ UsbHubCtrlSetPortFeature (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read the whole usb hub descriptor. It is necessary
|
||||
to do it in two steps because hub descriptor is of
|
||||
@@ -369,7 +364,7 @@ UsbHubReadDesc (
|
||||
OUT EFI_USB_HUB_DESCRIPTOR *HubDesc
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// First get the hub descriptor length
|
||||
@@ -386,8 +381,6 @@ UsbHubReadDesc (
|
||||
return UsbHubCtrlGetHubDesc (HubDev, HubDesc, HubDesc->Length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Ack the hub change bits. If these bits are not ACKed, Hub will
|
||||
always return changed bit map from its interrupt endpoint.
|
||||
@@ -400,13 +393,13 @@ UsbHubReadDesc (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubAckHubStatus (
|
||||
IN USB_DEVICE *HubDev
|
||||
IN USB_DEVICE *HubDev
|
||||
)
|
||||
{
|
||||
EFI_USB_PORT_STATUS HubState;
|
||||
EFI_STATUS Status;
|
||||
EFI_USB_PORT_STATUS HubState;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbHubCtrlGetHubStatus (HubDev, (UINT32 *) &HubState);
|
||||
Status = UsbHubCtrlGetHubStatus (HubDev, (UINT32 *)&HubState);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@@ -423,7 +416,6 @@ UsbHubAckHubStatus (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Test whether the interface is a hub interface.
|
||||
|
||||
@@ -435,7 +427,7 @@ UsbHubAckHubStatus (
|
||||
**/
|
||||
BOOLEAN
|
||||
UsbIsHubInterface (
|
||||
IN USB_INTERFACE *UsbIf
|
||||
IN USB_INTERFACE *UsbIf
|
||||
)
|
||||
{
|
||||
EFI_USB_INTERFACE_DESCRIPTOR *Setting;
|
||||
@@ -447,15 +439,14 @@ UsbIsHubInterface (
|
||||
Setting = &UsbIf->IfSetting->Desc;
|
||||
|
||||
if ((Setting->InterfaceClass == USB_HUB_CLASS_CODE) &&
|
||||
(Setting->InterfaceSubClass == USB_HUB_SUBCLASS_CODE)) {
|
||||
|
||||
(Setting->InterfaceSubClass == USB_HUB_SUBCLASS_CODE))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The callback function to the USB hub status change
|
||||
interrupt endpoint. It is called periodically by
|
||||
@@ -473,20 +464,20 @@ UsbIsHubInterface (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbOnHubInterrupt (
|
||||
IN VOID *Data,
|
||||
IN UINTN DataLength,
|
||||
IN VOID *Context,
|
||||
IN UINT32 Result
|
||||
IN VOID *Data,
|
||||
IN UINTN DataLength,
|
||||
IN VOID *Context,
|
||||
IN UINT32 Result
|
||||
)
|
||||
{
|
||||
USB_INTERFACE *HubIf;
|
||||
EFI_USB_IO_PROTOCOL *UsbIo;
|
||||
EFI_USB_ENDPOINT_DESCRIPTOR *EpDesc;
|
||||
EFI_STATUS Status;
|
||||
USB_INTERFACE *HubIf;
|
||||
EFI_USB_IO_PROTOCOL *UsbIo;
|
||||
EFI_USB_ENDPOINT_DESCRIPTOR *EpDesc;
|
||||
EFI_STATUS Status;
|
||||
|
||||
HubIf = (USB_INTERFACE *) Context;
|
||||
UsbIo = &(HubIf->UsbIo);
|
||||
EpDesc = &(HubIf->HubEp->Desc);
|
||||
HubIf = (USB_INTERFACE *)Context;
|
||||
UsbIo = &(HubIf->UsbIo);
|
||||
EpDesc = &(HubIf->HubEp->Desc);
|
||||
|
||||
if (Result != EFI_USB_NOERROR) {
|
||||
//
|
||||
@@ -516,7 +507,7 @@ UsbOnHubInterrupt (
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbOnHubInterrupt: failed to remove async transfer - %r\n", Status));
|
||||
DEBUG ((DEBUG_ERROR, "UsbOnHubInterrupt: failed to remove async transfer - %r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -531,7 +522,7 @@ UsbOnHubInterrupt (
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbOnHubInterrupt: failed to submit new async transfer - %r\n", Status));
|
||||
DEBUG ((DEBUG_ERROR, "UsbOnHubInterrupt: failed to submit new async transfer - %r\n", Status));
|
||||
}
|
||||
|
||||
return Status;
|
||||
@@ -559,9 +550,6 @@ UsbOnHubInterrupt (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the device for a non-root hub.
|
||||
|
||||
@@ -573,7 +561,7 @@ UsbOnHubInterrupt (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubInit (
|
||||
IN USB_INTERFACE *HubIf
|
||||
IN USB_INTERFACE *HubIf
|
||||
)
|
||||
{
|
||||
UINT8 HubDescBuffer[256];
|
||||
@@ -590,11 +578,11 @@ UsbHubInit (
|
||||
//
|
||||
// Locate the interrupt endpoint for port change map
|
||||
//
|
||||
HubIf->IsHub = FALSE;
|
||||
Setting = HubIf->IfSetting;
|
||||
HubDev = HubIf->Device;
|
||||
EpDesc = NULL;
|
||||
NumEndpoints = Setting->Desc.NumEndpoints;
|
||||
HubIf->IsHub = FALSE;
|
||||
Setting = HubIf->IfSetting;
|
||||
HubDev = HubIf->Device;
|
||||
EpDesc = NULL;
|
||||
NumEndpoints = Setting->Desc.NumEndpoints;
|
||||
|
||||
for (Index = 0; Index < NumEndpoints; Index++) {
|
||||
ASSERT ((Setting->Endpoints != NULL) && (Setting->Endpoints[Index] != NULL));
|
||||
@@ -602,13 +590,14 @@ UsbHubInit (
|
||||
EpDesc = Setting->Endpoints[Index];
|
||||
|
||||
if (USB_BIT_IS_SET (EpDesc->Desc.EndpointAddress, USB_ENDPOINT_DIR_IN) &&
|
||||
(USB_ENDPOINT_TYPE (&EpDesc->Desc) == USB_ENDPOINT_INTERRUPT)) {
|
||||
(USB_ENDPOINT_TYPE (&EpDesc->Desc) == USB_ENDPOINT_INTERRUPT))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index == NumEndpoints) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbHubInit: no interrupt endpoint found for hub %d\n", HubDev->Address));
|
||||
DEBUG ((DEBUG_ERROR, "UsbHubInit: no interrupt endpoint found for hub %d\n", HubDev->Address));
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@@ -616,17 +605,17 @@ UsbHubInit (
|
||||
// The length field of descriptor is UINT8 type, so the buffer
|
||||
// with 256 bytes is enough to hold the descriptor data.
|
||||
//
|
||||
HubDesc = (EFI_USB_HUB_DESCRIPTOR *) HubDescBuffer;
|
||||
Status = UsbHubReadDesc (HubDev, HubDesc);
|
||||
HubDesc = (EFI_USB_HUB_DESCRIPTOR *)HubDescBuffer;
|
||||
Status = UsbHubReadDesc (HubDev, HubDesc);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbHubInit: failed to read HUB descriptor %r\n", Status));
|
||||
DEBUG ((DEBUG_ERROR, "UsbHubInit: failed to read HUB descriptor %r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
HubIf->NumOfPort = HubDesc->NumPorts;
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbHubInit: hub %d has %d ports\n", HubDev->Address,HubIf->NumOfPort));
|
||||
DEBUG ((DEBUG_INFO, "UsbHubInit: hub %d has %d ports\n", HubDev->Address, HubIf->NumOfPort));
|
||||
|
||||
//
|
||||
// OK, set IsHub to TRUE. Now usb bus can handle this device
|
||||
@@ -652,7 +641,7 @@ UsbHubInit (
|
||||
// for both gang/individual powered hubs.
|
||||
//
|
||||
for (Index = 0; Index < HubDesc->NumPorts; Index++) {
|
||||
UsbHubCtrlSetPortFeature (HubIf->Device, Index, (EFI_USB_PORT_FEATURE) USB_HUB_PORT_POWER);
|
||||
UsbHubCtrlSetPortFeature (HubIf->Device, Index, (EFI_USB_PORT_FEATURE)USB_HUB_PORT_POWER);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -661,6 +650,7 @@ UsbHubInit (
|
||||
if (HubDesc->PwrOn2PwrGood > 0) {
|
||||
gBS->Stall (HubDesc->PwrOn2PwrGood * USB_SET_PORT_POWER_STALL);
|
||||
}
|
||||
|
||||
UsbHubAckHubStatus (HubIf->Device);
|
||||
}
|
||||
|
||||
@@ -676,8 +666,12 @@ UsbHubInit (
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbHubInit: failed to create signal for hub %d - %r\n",
|
||||
HubDev->Address, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"UsbHubInit: failed to create signal for hub %d - %r\n",
|
||||
HubDev->Address,
|
||||
Status
|
||||
));
|
||||
|
||||
return Status;
|
||||
}
|
||||
@@ -701,8 +695,12 @@ UsbHubInit (
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbHubInit: failed to queue interrupt transfer for hub %d - %r\n",
|
||||
HubDev->Address, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"UsbHubInit: failed to queue interrupt transfer for hub %d - %r\n",
|
||||
HubDev->Address,
|
||||
Status
|
||||
));
|
||||
|
||||
gBS->CloseEvent (HubIf->HubNotify);
|
||||
HubIf->HubNotify = NULL;
|
||||
@@ -710,12 +708,10 @@ UsbHubInit (
|
||||
return Status;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbHubInit: hub %d initialized\n", HubDev->Address));
|
||||
DEBUG ((DEBUG_INFO, "UsbHubInit: hub %d initialized\n", HubDev->Address));
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Get the port status. This function is required to
|
||||
ACK the port change bits although it will return
|
||||
@@ -732,20 +728,18 @@ UsbHubInit (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubGetPortStatus (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
OUT EFI_USB_PORT_STATUS *PortState
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
OUT EFI_USB_PORT_STATUS *PortState
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbHubCtrlGetPortStatus (HubIf->Device, Port, PortState);
|
||||
Status = UsbHubCtrlGetPortStatus (HubIf->Device, Port, PortState);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Clear the port change status.
|
||||
|
||||
@@ -755,8 +749,8 @@ UsbHubGetPortStatus (
|
||||
**/
|
||||
VOID
|
||||
UsbHubClearPortChange (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
)
|
||||
{
|
||||
EFI_USB_PORT_STATUS PortState;
|
||||
@@ -780,13 +774,11 @@ UsbHubClearPortChange (
|
||||
Map = &mHubFeatureMap[Index];
|
||||
|
||||
if (USB_BIT_IS_SET (PortState.PortChangeStatus, Map->ChangedBit)) {
|
||||
UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT16) Map->Feature);
|
||||
UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT16)Map->Feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Function to set the port feature for non-root hub.
|
||||
|
||||
@@ -800,19 +792,18 @@ UsbHubClearPortChange (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubSetPortFeature (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbHubCtrlSetPortFeature (HubIf->Device, Port, (UINT8) Feature);
|
||||
Status = UsbHubCtrlSetPortFeature (HubIf->Device, Port, (UINT8)Feature);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Interface function to clear the port feature for non-root hub.
|
||||
|
||||
@@ -826,19 +817,18 @@ UsbHubSetPortFeature (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubClearPortFeature (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT8) Feature);
|
||||
Status = UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT8)Feature);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Interface function to reset the port.
|
||||
|
||||
@@ -852,15 +842,15 @@ UsbHubClearPortFeature (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubResetPort (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
)
|
||||
{
|
||||
EFI_USB_PORT_STATUS PortState;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
EFI_USB_PORT_STATUS PortState;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbHubSetPortFeature (HubIf, Port, (EFI_USB_PORT_FEATURE) USB_HUB_PORT_RESET);
|
||||
Status = UsbHubSetPortFeature (HubIf, Port, (EFI_USB_PORT_FEATURE)USB_HUB_PORT_RESET);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@@ -885,7 +875,8 @@ UsbHubResetPort (
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status) &&
|
||||
USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET)) {
|
||||
USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET))
|
||||
{
|
||||
gBS->Stall (USB_SET_PORT_RECOVERY_STALL);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -896,7 +887,6 @@ UsbHubResetPort (
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release the hub's control of the interface.
|
||||
|
||||
@@ -907,11 +897,11 @@ UsbHubResetPort (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubRelease (
|
||||
IN USB_INTERFACE *HubIf
|
||||
IN USB_INTERFACE *HubIf
|
||||
)
|
||||
{
|
||||
EFI_USB_IO_PROTOCOL *UsbIo;
|
||||
EFI_STATUS Status;
|
||||
EFI_USB_IO_PROTOCOL *UsbIo;
|
||||
EFI_STATUS Status;
|
||||
|
||||
UsbIo = &HubIf->UsbIo;
|
||||
Status = UsbIo->UsbAsyncInterruptTransfer (
|
||||
@@ -930,17 +920,15 @@ UsbHubRelease (
|
||||
|
||||
gBS->CloseEvent (HubIf->HubNotify);
|
||||
|
||||
HubIf->IsHub = FALSE;
|
||||
HubIf->HubApi = NULL;
|
||||
HubIf->HubEp = NULL;
|
||||
HubIf->HubNotify = NULL;
|
||||
HubIf->IsHub = FALSE;
|
||||
HubIf->HubApi = NULL;
|
||||
HubIf->HubEp = NULL;
|
||||
HubIf->HubNotify = NULL;
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbHubRelease: hub device %d released\n", HubIf->Device->Address));
|
||||
DEBUG ((DEBUG_INFO, "UsbHubRelease: hub device %d released\n", HubIf->Device->Address));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the interface for root hub.
|
||||
|
||||
@@ -952,13 +940,13 @@ UsbHubRelease (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbRootHubInit (
|
||||
IN USB_INTERFACE *HubIf
|
||||
IN USB_INTERFACE *HubIf
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 MaxSpeed;
|
||||
UINT8 NumOfPort;
|
||||
UINT8 Support64;
|
||||
EFI_STATUS Status;
|
||||
UINT8 MaxSpeed;
|
||||
UINT8 NumOfPort;
|
||||
UINT8 Support64;
|
||||
|
||||
Status = UsbHcGetCapability (HubIf->Device->Bus, &MaxSpeed, &NumOfPort, &Support64);
|
||||
|
||||
@@ -966,15 +954,20 @@ UsbRootHubInit (
|
||||
return Status;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbRootHubInit: root hub %p - max speed %d, %d ports\n",
|
||||
HubIf, MaxSpeed, NumOfPort));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"UsbRootHubInit: root hub %p - max speed %d, %d ports\n",
|
||||
HubIf,
|
||||
MaxSpeed,
|
||||
NumOfPort
|
||||
));
|
||||
|
||||
HubIf->IsHub = TRUE;
|
||||
HubIf->HubApi = &mUsbRootHubApi;
|
||||
HubIf->HubEp = NULL;
|
||||
HubIf->MaxSpeed = MaxSpeed;
|
||||
HubIf->NumOfPort = NumOfPort;
|
||||
HubIf->HubNotify = NULL;
|
||||
HubIf->IsHub = TRUE;
|
||||
HubIf->HubApi = &mUsbRootHubApi;
|
||||
HubIf->HubEp = NULL;
|
||||
HubIf->MaxSpeed = MaxSpeed;
|
||||
HubIf->NumOfPort = NumOfPort;
|
||||
HubIf->HubNotify = NULL;
|
||||
|
||||
//
|
||||
// Create a timer to poll root hub ports periodically
|
||||
@@ -1010,7 +1003,6 @@ UsbRootHubInit (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the port status. This function is required to
|
||||
ACK the port change bits although it will return
|
||||
@@ -1027,21 +1019,20 @@ UsbRootHubInit (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbRootHubGetPortStatus (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
OUT EFI_USB_PORT_STATUS *PortState
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
OUT EFI_USB_PORT_STATUS *PortState
|
||||
)
|
||||
{
|
||||
USB_BUS *Bus;
|
||||
EFI_STATUS Status;
|
||||
USB_BUS *Bus;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Bus = HubIf->Device->Bus;
|
||||
Status = UsbHcGetRootHubPortStatus (Bus, Port, PortState);
|
||||
Bus = HubIf->Device->Bus;
|
||||
Status = UsbHcGetRootHubPortStatus (Bus, Port, PortState);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clear the port change status.
|
||||
|
||||
@@ -1051,8 +1042,8 @@ UsbRootHubGetPortStatus (
|
||||
**/
|
||||
VOID
|
||||
UsbRootHubClearPortChange (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port
|
||||
)
|
||||
{
|
||||
EFI_USB_PORT_STATUS PortState;
|
||||
@@ -1076,12 +1067,11 @@ UsbRootHubClearPortChange (
|
||||
Map = &mRootHubFeatureMap[Index];
|
||||
|
||||
if (USB_BIT_IS_SET (PortState.PortChangeStatus, Map->ChangedBit)) {
|
||||
UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, (EFI_USB_PORT_FEATURE) Map->Feature);
|
||||
UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, (EFI_USB_PORT_FEATURE)Map->Feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the root hub port feature.
|
||||
|
||||
@@ -1095,19 +1085,18 @@ UsbRootHubClearPortChange (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbRootHubSetPortFeature (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbHcSetRootHubPortFeature (HubIf->Device->Bus, Port, Feature);
|
||||
Status = UsbHcSetRootHubPortFeature (HubIf->Device->Bus, Port, Feature);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clear the root hub port feature.
|
||||
|
||||
@@ -1121,19 +1110,18 @@ UsbRootHubSetPortFeature (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbRootHubClearPortFeature (
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
IN USB_INTERFACE *HubIf,
|
||||
IN UINT8 Port,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, Feature);
|
||||
Status = UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, Feature);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Interface function to reset the root hub port.
|
||||
|
||||
@@ -1149,26 +1137,26 @@ UsbRootHubClearPortFeature (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbRootHubResetPort (
|
||||
IN USB_INTERFACE *RootIf,
|
||||
IN UINT8 Port
|
||||
IN USB_INTERFACE *RootIf,
|
||||
IN UINT8 Port
|
||||
)
|
||||
{
|
||||
USB_BUS *Bus;
|
||||
EFI_STATUS Status;
|
||||
EFI_USB_PORT_STATUS PortState;
|
||||
UINTN Index;
|
||||
USB_BUS *Bus;
|
||||
EFI_STATUS Status;
|
||||
EFI_USB_PORT_STATUS PortState;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Notice: although EHCI requires that ENABLED bit be cleared
|
||||
// when reset the port, we don't need to care that here. It
|
||||
// should be handled in the EHCI driver.
|
||||
//
|
||||
Bus = RootIf->Device->Bus;
|
||||
Bus = RootIf->Device->Bus;
|
||||
|
||||
Status = UsbHcSetRootHubPortFeature (Bus, Port, EfiUsbPortReset);
|
||||
Status = UsbHcSetRootHubPortFeature (Bus, Port, EfiUsbPortReset);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: failed to start reset on port %d\n", Port));
|
||||
DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: failed to start reset on port %d\n", Port));
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -1181,7 +1169,7 @@ UsbRootHubResetPort (
|
||||
Status = UsbHcClearRootHubPortFeature (Bus, Port, EfiUsbPortReset);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: failed to clear reset on port %d\n", Port));
|
||||
DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: failed to clear reset on port %d\n", Port));
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -1220,17 +1208,15 @@ UsbRootHubResetPort (
|
||||
// automatically enable the port, we need to enable it manually.
|
||||
//
|
||||
if (RootIf->MaxSpeed == EFI_USB_SPEED_HIGH) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: release low/full speed device (%d) to UHCI\n", Port));
|
||||
DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: release low/full speed device (%d) to UHCI\n", Port));
|
||||
|
||||
UsbRootHubSetPortFeature (RootIf, Port, EfiUsbPortOwner);
|
||||
return EFI_NOT_FOUND;
|
||||
|
||||
} else {
|
||||
|
||||
Status = UsbRootHubSetPortFeature (RootIf, Port, EfiUsbPortEnable);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: failed to enable port %d for UHCI\n", Port));
|
||||
DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: failed to enable port %d for UHCI\n", Port));
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -1241,7 +1227,6 @@ UsbRootHubResetPort (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release the root hub's control of the interface.
|
||||
|
||||
@@ -1253,10 +1238,10 @@ UsbRootHubResetPort (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbRootHubRelease (
|
||||
IN USB_INTERFACE *HubIf
|
||||
IN USB_INTERFACE *HubIf
|
||||
)
|
||||
{
|
||||
DEBUG (( DEBUG_INFO, "UsbRootHubRelease: root hub released for hub %p\n", HubIf));
|
||||
DEBUG ((DEBUG_INFO, "UsbRootHubRelease: root hub released for hub %p\n", HubIf));
|
||||
|
||||
gBS->SetTimer (HubIf->HubNotify, TimerCancel, USB_ROOTHUB_POLL_INTERVAL);
|
||||
gBS->CloseEvent (HubIf->HubNotify);
|
||||
@@ -1264,7 +1249,7 @@ UsbRootHubRelease (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
USB_HUB_API mUsbHubApi = {
|
||||
USB_HUB_API mUsbHubApi = {
|
||||
UsbHubInit,
|
||||
UsbHubGetPortStatus,
|
||||
UsbHubClearPortChange,
|
||||
@@ -1274,7 +1259,7 @@ USB_HUB_API mUsbHubApi = {
|
||||
UsbHubRelease
|
||||
};
|
||||
|
||||
USB_HUB_API mUsbRootHubApi = {
|
||||
USB_HUB_API mUsbRootHubApi = {
|
||||
UsbRootHubInit,
|
||||
UsbRootHubGetPortStatus,
|
||||
UsbRootHubClearPortChange,
|
||||
|
@@ -12,33 +12,32 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include <IndustryStandard/Usb.h>
|
||||
|
||||
#define USB_ENDPOINT_ADDR(EpAddr) ((EpAddr) & 0x7F)
|
||||
#define USB_ENDPOINT_TYPE(Desc) ((Desc)->Attributes & USB_ENDPOINT_TYPE_MASK)
|
||||
#define USB_ENDPOINT_ADDR(EpAddr) ((EpAddr) & 0x7F)
|
||||
#define USB_ENDPOINT_TYPE(Desc) ((Desc)->Attributes & USB_ENDPOINT_TYPE_MASK)
|
||||
|
||||
|
||||
#define USB_DESC_TYPE_HUB 0x29
|
||||
#define USB_DESC_TYPE_HUB 0x29
|
||||
|
||||
#define USB_DESC_TYPE_HUB_SUPER_SPEED 0x2a
|
||||
|
||||
//
|
||||
// Hub class control transfer target
|
||||
//
|
||||
#define USB_HUB_TARGET_HUB 0
|
||||
#define USB_HUB_TARGET_PORT 3
|
||||
#define USB_HUB_TARGET_HUB 0
|
||||
#define USB_HUB_TARGET_PORT 3
|
||||
//
|
||||
// HUB class specific contrl transfer request type
|
||||
//
|
||||
#define USB_HUB_REQ_GET_STATUS 0
|
||||
#define USB_HUB_REQ_CLEAR_FEATURE 1
|
||||
#define USB_HUB_REQ_SET_FEATURE 3
|
||||
#define USB_HUB_REQ_GET_DESC 6
|
||||
#define USB_HUB_REQ_SET_DESC 7
|
||||
#define USB_HUB_REQ_CLEAR_TT 8
|
||||
#define USB_HUB_REQ_RESET_TT 9
|
||||
#define USB_HUB_REQ_GET_TT_STATE 10
|
||||
#define USB_HUB_REQ_STOP_TT 11
|
||||
#define USB_HUB_REQ_GET_STATUS 0
|
||||
#define USB_HUB_REQ_CLEAR_FEATURE 1
|
||||
#define USB_HUB_REQ_SET_FEATURE 3
|
||||
#define USB_HUB_REQ_GET_DESC 6
|
||||
#define USB_HUB_REQ_SET_DESC 7
|
||||
#define USB_HUB_REQ_CLEAR_TT 8
|
||||
#define USB_HUB_REQ_RESET_TT 9
|
||||
#define USB_HUB_REQ_GET_TT_STATE 10
|
||||
#define USB_HUB_REQ_STOP_TT 11
|
||||
|
||||
#define USB_HUB_REQ_SET_DEPTH 12
|
||||
#define USB_HUB_REQ_SET_DEPTH 12
|
||||
|
||||
//
|
||||
// USB hub class feature selector
|
||||
@@ -51,22 +50,22 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#define USB_HUB_PORT_OVER_CURRENT 3
|
||||
#define USB_HUB_PORT_RESET 4
|
||||
|
||||
#define USB_HUB_PORT_LINK_STATE 5
|
||||
#define USB_HUB_PORT_LINK_STATE 5
|
||||
|
||||
#define USB_HUB_PORT_POWER 8
|
||||
#define USB_HUB_PORT_LOW_SPEED 9
|
||||
#define USB_HUB_C_PORT_CONNECT 16
|
||||
#define USB_HUB_C_PORT_ENABLE 17
|
||||
#define USB_HUB_C_PORT_SUSPEND 18
|
||||
#define USB_HUB_C_PORT_OVER_CURRENT 19
|
||||
#define USB_HUB_C_PORT_RESET 20
|
||||
#define USB_HUB_PORT_TEST 21
|
||||
#define USB_HUB_PORT_INDICATOR 22
|
||||
#define USB_HUB_PORT_POWER 8
|
||||
#define USB_HUB_PORT_LOW_SPEED 9
|
||||
#define USB_HUB_C_PORT_CONNECT 16
|
||||
#define USB_HUB_C_PORT_ENABLE 17
|
||||
#define USB_HUB_C_PORT_SUSPEND 18
|
||||
#define USB_HUB_C_PORT_OVER_CURRENT 19
|
||||
#define USB_HUB_C_PORT_RESET 20
|
||||
#define USB_HUB_PORT_TEST 21
|
||||
#define USB_HUB_PORT_INDICATOR 22
|
||||
|
||||
#define USB_HUB_C_PORT_LINK_STATE 25
|
||||
#define USB_HUB_PORT_REMOTE_WAKE_MASK 27
|
||||
#define USB_HUB_BH_PORT_RESET 28
|
||||
#define USB_HUB_C_BH_PORT_RESET 29
|
||||
#define USB_HUB_C_PORT_LINK_STATE 25
|
||||
#define USB_HUB_PORT_REMOTE_WAKE_MASK 27
|
||||
#define USB_HUB_BH_PORT_RESET 28
|
||||
#define USB_HUB_C_BH_PORT_RESET 29
|
||||
|
||||
//
|
||||
// Constant value for Port Status & Port Change Status of SuperSpeed port
|
||||
@@ -76,18 +75,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// USB hub power control method. In gang power control
|
||||
//
|
||||
#define USB_HUB_GANG_POWER_CTRL 0
|
||||
#define USB_HUB_PORT_POWER_CTRL 0x01
|
||||
#define USB_HUB_GANG_POWER_CTRL 0
|
||||
#define USB_HUB_PORT_POWER_CTRL 0x01
|
||||
//
|
||||
// USB hub status bits
|
||||
//
|
||||
#define USB_HUB_STAT_LOCAL_POWER 0x01
|
||||
#define USB_HUB_STAT_OVER_CURRENT 0x02
|
||||
#define USB_HUB_STAT_C_LOCAL_POWER 0x01
|
||||
#define USB_HUB_STAT_C_OVER_CURRENT 0x02
|
||||
#define USB_HUB_STAT_LOCAL_POWER 0x01
|
||||
#define USB_HUB_STAT_OVER_CURRENT 0x02
|
||||
#define USB_HUB_STAT_C_LOCAL_POWER 0x01
|
||||
#define USB_HUB_STAT_C_OVER_CURRENT 0x02
|
||||
|
||||
#define USB_HUB_CLASS_CODE 0x09
|
||||
#define USB_HUB_SUBCLASS_CODE 0x00
|
||||
#define USB_HUB_CLASS_CODE 0x09
|
||||
#define USB_HUB_SUBCLASS_CODE 0x00
|
||||
|
||||
//
|
||||
// Host software return timeout if port status doesn't change
|
||||
@@ -100,24 +99,22 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
// Hub descriptor, the last two fields are of variable length.
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 Length;
|
||||
UINT8 DescType;
|
||||
UINT8 NumPorts;
|
||||
UINT16 HubCharacter;
|
||||
UINT8 PwrOn2PwrGood;
|
||||
UINT8 HubContrCurrent;
|
||||
UINT8 Filler[16];
|
||||
UINT8 Length;
|
||||
UINT8 DescType;
|
||||
UINT8 NumPorts;
|
||||
UINT16 HubCharacter;
|
||||
UINT8 PwrOn2PwrGood;
|
||||
UINT8 HubContrCurrent;
|
||||
UINT8 Filler[16];
|
||||
} EFI_USB_HUB_DESCRIPTOR;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
typedef struct {
|
||||
UINT16 ChangedBit;
|
||||
EFI_USB_PORT_FEATURE Feature;
|
||||
UINT16 ChangedBit;
|
||||
EFI_USB_PORT_FEATURE Feature;
|
||||
} USB_CHANGE_FEATURE_MAP;
|
||||
|
||||
|
||||
/**
|
||||
Clear the transaction translate buffer if full/low
|
||||
speed control/bulk transfer failed and the transfer
|
||||
@@ -137,14 +134,13 @@ typedef struct {
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubCtrlClearTTBuffer (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Port,
|
||||
IN UINT16 DevAddr,
|
||||
IN UINT16 EpNum,
|
||||
IN UINT16 EpType
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Port,
|
||||
IN UINT16 DevAddr,
|
||||
IN UINT16 EpNum,
|
||||
IN UINT16 EpType
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Test whether the interface is a hub interface.
|
||||
|
||||
@@ -156,10 +152,9 @@ UsbHubCtrlClearTTBuffer (
|
||||
**/
|
||||
BOOLEAN
|
||||
UsbIsHubInterface (
|
||||
IN USB_INTERFACE *UsbIf
|
||||
IN USB_INTERFACE *UsbIf
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Ack the hub change bits. If these bits are not ACKed, Hub will
|
||||
always return changed bit map from its interrupt endpoint.
|
||||
@@ -172,10 +167,9 @@ UsbIsHubInterface (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHubAckHubStatus (
|
||||
IN USB_DEVICE *UsbDev
|
||||
IN USB_DEVICE *UsbDev
|
||||
);
|
||||
|
||||
extern USB_HUB_API mUsbHubApi;
|
||||
extern USB_HUB_API mUsbRootHubApi;
|
||||
extern USB_HUB_API mUsbHubApi;
|
||||
extern USB_HUB_API mUsbRootHubApi;
|
||||
#endif
|
||||
|
||||
|
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "UsbBus.h"
|
||||
|
||||
//
|
||||
@@ -15,14 +14,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
// Use a shor form Usb class Device Path, which could match any usb device, in WantedUsbIoDPList to indicate all Usb devices
|
||||
// are wanted Usb devices
|
||||
//
|
||||
USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath = {
|
||||
USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath = {
|
||||
{
|
||||
{
|
||||
MESSAGING_DEVICE_PATH,
|
||||
MSG_USB_CLASS_DP,
|
||||
{
|
||||
(UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
|
||||
(UINT8)(sizeof (USB_CLASS_DEVICE_PATH)),
|
||||
(UINT8)((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
0xffff, // VendorId
|
||||
@@ -42,7 +41,6 @@ USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Get the capability of the host controller.
|
||||
|
||||
@@ -57,41 +55,31 @@ USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath = {
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHcGetCapability (
|
||||
IN USB_BUS *UsbBus,
|
||||
OUT UINT8 *MaxSpeed,
|
||||
OUT UINT8 *NumOfPort,
|
||||
OUT UINT8 *Is64BitCapable
|
||||
IN USB_BUS *UsbBus,
|
||||
OUT UINT8 *MaxSpeed,
|
||||
OUT UINT8 *NumOfPort,
|
||||
OUT UINT8 *Is64BitCapable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (UsbBus->Usb2Hc != NULL) {
|
||||
Status = UsbBus->Usb2Hc->GetCapability (
|
||||
UsbBus->Usb2Hc,
|
||||
MaxSpeed,
|
||||
NumOfPort,
|
||||
Is64BitCapable
|
||||
);
|
||||
|
||||
UsbBus->Usb2Hc,
|
||||
MaxSpeed,
|
||||
NumOfPort,
|
||||
Is64BitCapable
|
||||
);
|
||||
} else {
|
||||
Status = UsbBus->UsbHc->GetRootHubPortNumber (UsbBus->UsbHc, NumOfPort);
|
||||
|
||||
*MaxSpeed = EFI_USB_SPEED_FULL;
|
||||
*Is64BitCapable = (UINT8) FALSE;
|
||||
*Is64BitCapable = (UINT8)FALSE;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Get the root hub port state.
|
||||
|
||||
@@ -105,12 +93,12 @@ UsbHcGetCapability (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHcGetRootHubPortStatus (
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
OUT EFI_USB_PORT_STATUS *PortStatus
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
OUT EFI_USB_PORT_STATUS *PortStatus
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (UsbBus->Usb2Hc != NULL) {
|
||||
Status = UsbBus->Usb2Hc->GetRootHubPortStatus (UsbBus->Usb2Hc, PortIndex, PortStatus);
|
||||
@@ -121,7 +109,6 @@ UsbHcGetRootHubPortStatus (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the root hub port feature.
|
||||
|
||||
@@ -135,13 +122,12 @@ UsbHcGetRootHubPortStatus (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHcSetRootHubPortFeature (
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (UsbBus->Usb2Hc != NULL) {
|
||||
Status = UsbBus->Usb2Hc->SetRootHubPortFeature (UsbBus->Usb2Hc, PortIndex, Feature);
|
||||
@@ -152,7 +138,6 @@ UsbHcSetRootHubPortFeature (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clear the root hub port feature.
|
||||
|
||||
@@ -166,12 +151,12 @@ UsbHcSetRootHubPortFeature (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHcClearRootHubPortFeature (
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (UsbBus->Usb2Hc != NULL) {
|
||||
Status = UsbBus->Usb2Hc->ClearRootHubPortFeature (UsbBus->Usb2Hc, PortIndex, Feature);
|
||||
@@ -182,7 +167,6 @@ UsbHcClearRootHubPortFeature (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Execute a control transfer to the device.
|
||||
|
||||
@@ -217,8 +201,8 @@ UsbHcControlTransfer (
|
||||
OUT UINT32 *UsbResult
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN IsSlowDevice;
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN IsSlowDevice;
|
||||
|
||||
if (UsbBus->Usb2Hc != NULL) {
|
||||
Status = UsbBus->Usb2Hc->ControlTransfer (
|
||||
@@ -234,27 +218,25 @@ UsbHcControlTransfer (
|
||||
Translator,
|
||||
UsbResult
|
||||
);
|
||||
|
||||
} else {
|
||||
IsSlowDevice = (BOOLEAN)(EFI_USB_SPEED_LOW == DevSpeed);
|
||||
Status = UsbBus->UsbHc->ControlTransfer (
|
||||
UsbBus->UsbHc,
|
||||
DevAddr,
|
||||
IsSlowDevice,
|
||||
(UINT8) MaxPacket,
|
||||
Request,
|
||||
Direction,
|
||||
Data,
|
||||
DataLength,
|
||||
TimeOut,
|
||||
UsbResult
|
||||
);
|
||||
Status = UsbBus->UsbHc->ControlTransfer (
|
||||
UsbBus->UsbHc,
|
||||
DevAddr,
|
||||
IsSlowDevice,
|
||||
(UINT8)MaxPacket,
|
||||
Request,
|
||||
Direction,
|
||||
Data,
|
||||
DataLength,
|
||||
TimeOut,
|
||||
UsbResult
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Execute a bulk transfer to the device's endpoint.
|
||||
|
||||
@@ -293,7 +275,7 @@ UsbHcBulkTransfer (
|
||||
OUT UINT32 *UsbResult
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (UsbBus->Usb2Hc != NULL) {
|
||||
Status = UsbBus->Usb2Hc->BulkTransfer (
|
||||
@@ -315,7 +297,7 @@ UsbHcBulkTransfer (
|
||||
UsbBus->UsbHc,
|
||||
DevAddr,
|
||||
EpAddr,
|
||||
(UINT8) MaxPacket,
|
||||
(UINT8)MaxPacket,
|
||||
*Data,
|
||||
DataLength,
|
||||
DataToggle,
|
||||
@@ -327,7 +309,6 @@ UsbHcBulkTransfer (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Queue or cancel an asynchronous interrupt transfer.
|
||||
|
||||
@@ -366,8 +347,8 @@ UsbHcAsyncInterruptTransfer (
|
||||
IN VOID *Context OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN IsSlowDevice;
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN IsSlowDevice;
|
||||
|
||||
if (UsbBus->Usb2Hc != NULL) {
|
||||
Status = UsbBus->Usb2Hc->AsyncInterruptTransfer (
|
||||
@@ -392,7 +373,7 @@ UsbHcAsyncInterruptTransfer (
|
||||
DevAddr,
|
||||
EpAddr,
|
||||
IsSlowDevice,
|
||||
(UINT8) MaxPacket,
|
||||
(UINT8)MaxPacket,
|
||||
IsNewTransfer,
|
||||
DataToggle,
|
||||
PollingInterval,
|
||||
@@ -405,7 +386,6 @@ UsbHcAsyncInterruptTransfer (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Execute a synchronous interrupt transfer to the target endpoint.
|
||||
|
||||
@@ -442,8 +422,8 @@ UsbHcSyncInterruptTransfer (
|
||||
OUT UINT32 *UsbResult
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN IsSlowDevice;
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN IsSlowDevice;
|
||||
|
||||
if (UsbBus->Usb2Hc != NULL) {
|
||||
Status = UsbBus->Usb2Hc->SyncInterruptTransfer (
|
||||
@@ -460,31 +440,24 @@ UsbHcSyncInterruptTransfer (
|
||||
UsbResult
|
||||
);
|
||||
} else {
|
||||
IsSlowDevice = (BOOLEAN) ((EFI_USB_SPEED_LOW == DevSpeed) ? TRUE : FALSE);
|
||||
Status = UsbBus->UsbHc->SyncInterruptTransfer (
|
||||
UsbBus->UsbHc,
|
||||
DevAddr,
|
||||
EpAddr,
|
||||
IsSlowDevice,
|
||||
(UINT8) MaxPacket,
|
||||
Data,
|
||||
DataLength,
|
||||
DataToggle,
|
||||
TimeOut,
|
||||
UsbResult
|
||||
);
|
||||
IsSlowDevice = (BOOLEAN)((EFI_USB_SPEED_LOW == DevSpeed) ? TRUE : FALSE);
|
||||
Status = UsbBus->UsbHc->SyncInterruptTransfer (
|
||||
UsbBus->UsbHc,
|
||||
DevAddr,
|
||||
EpAddr,
|
||||
IsSlowDevice,
|
||||
(UINT8)MaxPacket,
|
||||
Data,
|
||||
DataLength,
|
||||
DataToggle,
|
||||
TimeOut,
|
||||
UsbResult
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Open the USB host controller protocol BY_CHILD.
|
||||
|
||||
@@ -496,29 +469,28 @@ UsbHcSyncInterruptTransfer (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbOpenHostProtoByChild (
|
||||
IN USB_BUS *Bus,
|
||||
IN EFI_HANDLE Child
|
||||
IN USB_BUS *Bus,
|
||||
IN EFI_HANDLE Child
|
||||
)
|
||||
{
|
||||
EFI_USB_HC_PROTOCOL *UsbHc;
|
||||
EFI_USB2_HC_PROTOCOL *Usb2Hc;
|
||||
EFI_STATUS Status;
|
||||
EFI_USB_HC_PROTOCOL *UsbHc;
|
||||
EFI_USB2_HC_PROTOCOL *Usb2Hc;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (Bus->Usb2Hc != NULL) {
|
||||
Status = gBS->OpenProtocol (
|
||||
Bus->HostHandle,
|
||||
&gEfiUsb2HcProtocolGuid,
|
||||
(VOID **) &Usb2Hc,
|
||||
(VOID **)&Usb2Hc,
|
||||
mUsbBusDriverBinding.DriverBindingHandle,
|
||||
Child,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
|
||||
} else {
|
||||
Status = gBS->OpenProtocol (
|
||||
Bus->HostHandle,
|
||||
&gEfiUsbHcProtocolGuid,
|
||||
(VOID **) &UsbHc,
|
||||
(VOID **)&UsbHc,
|
||||
mUsbBusDriverBinding.DriverBindingHandle,
|
||||
Child,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@@ -528,7 +500,6 @@ UsbOpenHostProtoByChild (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Close the USB host controller protocol BY_CHILD.
|
||||
|
||||
@@ -538,8 +509,8 @@ UsbOpenHostProtoByChild (
|
||||
**/
|
||||
VOID
|
||||
UsbCloseHostProtoByChild (
|
||||
IN USB_BUS *Bus,
|
||||
IN EFI_HANDLE Child
|
||||
IN USB_BUS *Bus,
|
||||
IN EFI_HANDLE Child
|
||||
)
|
||||
{
|
||||
if (Bus->Usb2Hc != NULL) {
|
||||
@@ -549,7 +520,6 @@ UsbCloseHostProtoByChild (
|
||||
mUsbBusDriverBinding.DriverBindingHandle,
|
||||
Child
|
||||
);
|
||||
|
||||
} else {
|
||||
gBS->CloseProtocol (
|
||||
Bus->HostHandle,
|
||||
@@ -560,7 +530,6 @@ UsbCloseHostProtoByChild (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
return the current TPL, copied from the EDKII glue lib.
|
||||
|
||||
@@ -574,7 +543,7 @@ UsbGetCurrentTpl (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_TPL Tpl;
|
||||
EFI_TPL Tpl;
|
||||
|
||||
Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
|
||||
gBS->RestoreTPL (Tpl);
|
||||
@@ -593,45 +562,45 @@ UsbGetCurrentTpl (
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
EFIAPI
|
||||
GetUsbDPFromFullDP (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathPtr;
|
||||
EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathBeginPtr;
|
||||
EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathEndPtr;
|
||||
UINTN Size;
|
||||
EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathPtr;
|
||||
EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathBeginPtr;
|
||||
EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathEndPtr;
|
||||
UINTN Size;
|
||||
|
||||
//
|
||||
// Get the Usb part first Begin node in full device path
|
||||
//
|
||||
UsbDevicePathBeginPtr = DevicePath;
|
||||
while ( (!IsDevicePathEnd (UsbDevicePathBeginPtr))&&
|
||||
while ((!IsDevicePathEnd (UsbDevicePathBeginPtr)) &&
|
||||
((UsbDevicePathBeginPtr->Type != MESSAGING_DEVICE_PATH) ||
|
||||
(UsbDevicePathBeginPtr->SubType != MSG_USB_DP &&
|
||||
UsbDevicePathBeginPtr->SubType != MSG_USB_CLASS_DP
|
||||
( UsbDevicePathBeginPtr->SubType != MSG_USB_DP &&
|
||||
UsbDevicePathBeginPtr->SubType != MSG_USB_CLASS_DP
|
||||
&& UsbDevicePathBeginPtr->SubType != MSG_USB_WWID_DP
|
||||
))) {
|
||||
|
||||
UsbDevicePathBeginPtr = NextDevicePathNode(UsbDevicePathBeginPtr);
|
||||
)))
|
||||
{
|
||||
UsbDevicePathBeginPtr = NextDevicePathNode (UsbDevicePathBeginPtr);
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Usb part first End node in full device path
|
||||
//
|
||||
UsbDevicePathEndPtr = UsbDevicePathBeginPtr;
|
||||
while ((!IsDevicePathEnd (UsbDevicePathEndPtr))&&
|
||||
while ((!IsDevicePathEnd (UsbDevicePathEndPtr)) &&
|
||||
(UsbDevicePathEndPtr->Type == MESSAGING_DEVICE_PATH) &&
|
||||
(UsbDevicePathEndPtr->SubType == MSG_USB_DP ||
|
||||
UsbDevicePathEndPtr->SubType == MSG_USB_CLASS_DP
|
||||
|| UsbDevicePathEndPtr->SubType == MSG_USB_WWID_DP
|
||||
)) {
|
||||
|
||||
UsbDevicePathEndPtr = NextDevicePathNode(UsbDevicePathEndPtr);
|
||||
( UsbDevicePathEndPtr->SubType == MSG_USB_DP ||
|
||||
UsbDevicePathEndPtr->SubType == MSG_USB_CLASS_DP
|
||||
|| UsbDevicePathEndPtr->SubType == MSG_USB_WWID_DP
|
||||
))
|
||||
{
|
||||
UsbDevicePathEndPtr = NextDevicePathNode (UsbDevicePathEndPtr);
|
||||
}
|
||||
|
||||
Size = GetDevicePathSize (UsbDevicePathBeginPtr);
|
||||
Size -= GetDevicePathSize (UsbDevicePathEndPtr);
|
||||
if (Size ==0){
|
||||
if (Size == 0) {
|
||||
//
|
||||
// The passed in DevicePath does not contain the usb nodes
|
||||
//
|
||||
@@ -647,7 +616,7 @@ GetUsbDPFromFullDP (
|
||||
//
|
||||
// Append end device path node
|
||||
//
|
||||
UsbDevicePathEndPtr = (EFI_DEVICE_PATH_PROTOCOL *) ((UINTN) UsbDevicePathPtr + Size);
|
||||
UsbDevicePathEndPtr = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)UsbDevicePathPtr + Size);
|
||||
SetDevicePathEndNode (UsbDevicePathEndPtr);
|
||||
return UsbDevicePathPtr;
|
||||
}
|
||||
@@ -665,14 +634,14 @@ GetUsbDPFromFullDP (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
SearchUsbDPInList (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *UsbDP,
|
||||
IN LIST_ENTRY *UsbIoDPList
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *UsbDP,
|
||||
IN LIST_ENTRY *UsbIoDPList
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *ListIndex;
|
||||
DEVICE_PATH_LIST_ITEM *ListItem;
|
||||
BOOLEAN Found;
|
||||
UINTN UsbDpDevicePathSize;
|
||||
LIST_ENTRY *ListIndex;
|
||||
DEVICE_PATH_LIST_ITEM *ListItem;
|
||||
BOOLEAN Found;
|
||||
UINTN UsbDpDevicePathSize;
|
||||
|
||||
//
|
||||
// Check that UsbDP and UsbIoDPList are valid
|
||||
@@ -681,22 +650,23 @@ SearchUsbDPInList (
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Found = FALSE;
|
||||
Found = FALSE;
|
||||
ListIndex = UsbIoDPList->ForwardLink;
|
||||
while (ListIndex != UsbIoDPList){
|
||||
ListItem = CR(ListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
|
||||
while (ListIndex != UsbIoDPList) {
|
||||
ListItem = CR (ListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
|
||||
//
|
||||
// Compare DEVICE_PATH_LIST_ITEM.DevicePath[]
|
||||
//
|
||||
ASSERT (ListItem->DevicePath != NULL);
|
||||
|
||||
UsbDpDevicePathSize = GetDevicePathSize (UsbDP);
|
||||
UsbDpDevicePathSize = GetDevicePathSize (UsbDP);
|
||||
if (UsbDpDevicePathSize == GetDevicePathSize (ListItem->DevicePath)) {
|
||||
if ((CompareMem (UsbDP, ListItem->DevicePath, UsbDpDevicePathSize)) == 0) {
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ListIndex = ListIndex->ForwardLink;
|
||||
}
|
||||
|
||||
@@ -716,11 +686,11 @@ SearchUsbDPInList (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AddUsbDPToList (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *UsbDP,
|
||||
IN LIST_ENTRY *UsbIoDPList
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *UsbDP,
|
||||
IN LIST_ENTRY *UsbIoDPList
|
||||
)
|
||||
{
|
||||
DEVICE_PATH_LIST_ITEM *ListItem;
|
||||
DEVICE_PATH_LIST_ITEM *ListItem;
|
||||
|
||||
//
|
||||
// Check that UsbDP and UsbIoDPList are valid
|
||||
@@ -729,7 +699,7 @@ AddUsbDPToList (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (SearchUsbDPInList (UsbDP, UsbIoDPList)){
|
||||
if (SearchUsbDPInList (UsbDP, UsbIoDPList)) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -738,7 +708,7 @@ AddUsbDPToList (
|
||||
//
|
||||
ListItem = AllocateZeroPool (sizeof (DEVICE_PATH_LIST_ITEM));
|
||||
ASSERT (ListItem != NULL);
|
||||
ListItem->Signature = DEVICE_PATH_LIST_ITEM_SIGNATURE;
|
||||
ListItem->Signature = DEVICE_PATH_LIST_ITEM_SIGNATURE;
|
||||
ListItem->DevicePath = DuplicateDevicePath (UsbDP);
|
||||
|
||||
InsertTailList (UsbIoDPList, &ListItem->Link);
|
||||
@@ -760,25 +730,25 @@ AddUsbDPToList (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
MatchUsbClass (
|
||||
IN USB_CLASS_DEVICE_PATH *UsbClassDevicePathPtr,
|
||||
IN USB_INTERFACE *UsbIf
|
||||
IN USB_CLASS_DEVICE_PATH *UsbClassDevicePathPtr,
|
||||
IN USB_INTERFACE *UsbIf
|
||||
)
|
||||
{
|
||||
USB_INTERFACE_DESC *IfDesc;
|
||||
EFI_USB_INTERFACE_DESCRIPTOR *ActIfDesc;
|
||||
EFI_USB_DEVICE_DESCRIPTOR *DevDesc;
|
||||
|
||||
|
||||
if ((UsbClassDevicePathPtr->Header.Type != MESSAGING_DEVICE_PATH) ||
|
||||
(UsbClassDevicePathPtr->Header.SubType != MSG_USB_CLASS_DP)){
|
||||
(UsbClassDevicePathPtr->Header.SubType != MSG_USB_CLASS_DP))
|
||||
{
|
||||
ASSERT (0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
IfDesc = UsbIf->IfDesc;
|
||||
IfDesc = UsbIf->IfDesc;
|
||||
ASSERT (IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
|
||||
ActIfDesc = &(IfDesc->Settings[IfDesc->ActiveIndex]->Desc);
|
||||
DevDesc = &(UsbIf->Device->DevDesc->Desc);
|
||||
ActIfDesc = &(IfDesc->Settings[IfDesc->ActiveIndex]->Desc);
|
||||
DevDesc = &(UsbIf->Device->DevDesc->Desc);
|
||||
|
||||
//
|
||||
// If connect class policy, determine whether to create device handle by the five fields
|
||||
@@ -787,36 +757,37 @@ MatchUsbClass (
|
||||
// In addition, hub interface is always matched for this policy.
|
||||
//
|
||||
if ((ActIfDesc->InterfaceClass == USB_HUB_CLASS_CODE) &&
|
||||
(ActIfDesc->InterfaceSubClass == USB_HUB_SUBCLASS_CODE)) {
|
||||
(ActIfDesc->InterfaceSubClass == USB_HUB_SUBCLASS_CODE))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// If vendor id or product id is 0xffff, they will be ignored.
|
||||
//
|
||||
if ((UsbClassDevicePathPtr->VendorId == 0xffff || UsbClassDevicePathPtr->VendorId == DevDesc->IdVendor) &&
|
||||
(UsbClassDevicePathPtr->ProductId == 0xffff || UsbClassDevicePathPtr->ProductId == DevDesc->IdProduct)) {
|
||||
|
||||
if (((UsbClassDevicePathPtr->VendorId == 0xffff) || (UsbClassDevicePathPtr->VendorId == DevDesc->IdVendor)) &&
|
||||
((UsbClassDevicePathPtr->ProductId == 0xffff) || (UsbClassDevicePathPtr->ProductId == DevDesc->IdProduct)))
|
||||
{
|
||||
//
|
||||
// If Class in Device Descriptor is set to 0, the counterparts in interface should be checked.
|
||||
//
|
||||
if (DevDesc->DeviceClass == 0) {
|
||||
if ((UsbClassDevicePathPtr->DeviceClass == ActIfDesc->InterfaceClass ||
|
||||
UsbClassDevicePathPtr->DeviceClass == 0xff) &&
|
||||
(UsbClassDevicePathPtr->DeviceSubClass == ActIfDesc->InterfaceSubClass ||
|
||||
UsbClassDevicePathPtr->DeviceSubClass == 0xff) &&
|
||||
(UsbClassDevicePathPtr->DeviceProtocol == ActIfDesc->InterfaceProtocol ||
|
||||
UsbClassDevicePathPtr->DeviceProtocol == 0xff)) {
|
||||
if (((UsbClassDevicePathPtr->DeviceClass == ActIfDesc->InterfaceClass) ||
|
||||
(UsbClassDevicePathPtr->DeviceClass == 0xff)) &&
|
||||
((UsbClassDevicePathPtr->DeviceSubClass == ActIfDesc->InterfaceSubClass) ||
|
||||
(UsbClassDevicePathPtr->DeviceSubClass == 0xff)) &&
|
||||
((UsbClassDevicePathPtr->DeviceProtocol == ActIfDesc->InterfaceProtocol) ||
|
||||
(UsbClassDevicePathPtr->DeviceProtocol == 0xff)))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
} else if ((UsbClassDevicePathPtr->DeviceClass == DevDesc->DeviceClass ||
|
||||
UsbClassDevicePathPtr->DeviceClass == 0xff) &&
|
||||
(UsbClassDevicePathPtr->DeviceSubClass == DevDesc->DeviceSubClass ||
|
||||
UsbClassDevicePathPtr->DeviceSubClass == 0xff) &&
|
||||
(UsbClassDevicePathPtr->DeviceProtocol == DevDesc->DeviceProtocol ||
|
||||
UsbClassDevicePathPtr->DeviceProtocol == 0xff)) {
|
||||
|
||||
} else if (((UsbClassDevicePathPtr->DeviceClass == DevDesc->DeviceClass) ||
|
||||
(UsbClassDevicePathPtr->DeviceClass == 0xff)) &&
|
||||
((UsbClassDevicePathPtr->DeviceSubClass == DevDesc->DeviceSubClass) ||
|
||||
(UsbClassDevicePathPtr->DeviceSubClass == 0xff)) &&
|
||||
((UsbClassDevicePathPtr->DeviceProtocol == DevDesc->DeviceProtocol) ||
|
||||
(UsbClassDevicePathPtr->DeviceProtocol == 0xff)))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -837,8 +808,8 @@ MatchUsbClass (
|
||||
**/
|
||||
BOOLEAN
|
||||
MatchUsbWwid (
|
||||
IN USB_WWID_DEVICE_PATH *UsbWWIDDevicePathPtr,
|
||||
IN USB_INTERFACE *UsbIf
|
||||
IN USB_WWID_DEVICE_PATH *UsbWWIDDevicePathPtr,
|
||||
IN USB_INTERFACE *UsbIf
|
||||
)
|
||||
{
|
||||
USB_INTERFACE_DESC *IfDesc;
|
||||
@@ -851,21 +822,23 @@ MatchUsbWwid (
|
||||
UINTN Length;
|
||||
|
||||
if ((UsbWWIDDevicePathPtr->Header.Type != MESSAGING_DEVICE_PATH) ||
|
||||
(UsbWWIDDevicePathPtr->Header.SubType != MSG_USB_WWID_DP )){
|
||||
(UsbWWIDDevicePathPtr->Header.SubType != MSG_USB_WWID_DP))
|
||||
{
|
||||
ASSERT (0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
IfDesc = UsbIf->IfDesc;
|
||||
IfDesc = UsbIf->IfDesc;
|
||||
ASSERT (IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
|
||||
ActIfDesc = &(IfDesc->Settings[IfDesc->ActiveIndex]->Desc);
|
||||
DevDesc = &(UsbIf->Device->DevDesc->Desc);
|
||||
ActIfDesc = &(IfDesc->Settings[IfDesc->ActiveIndex]->Desc);
|
||||
DevDesc = &(UsbIf->Device->DevDesc->Desc);
|
||||
|
||||
//
|
||||
// In addition, Hub interface is always matched for this policy.
|
||||
//
|
||||
if ((ActIfDesc->InterfaceClass == USB_HUB_CLASS_CODE) &&
|
||||
(ActIfDesc->InterfaceSubClass == USB_HUB_SUBCLASS_CODE)) {
|
||||
(ActIfDesc->InterfaceSubClass == USB_HUB_SUBCLASS_CODE))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -874,7 +847,8 @@ MatchUsbWwid (
|
||||
//
|
||||
if ((DevDesc->IdVendor != UsbWWIDDevicePathPtr->VendorId) ||
|
||||
(DevDesc->IdProduct != UsbWWIDDevicePathPtr->ProductId) ||
|
||||
(ActIfDesc->InterfaceNumber != UsbWWIDDevicePathPtr->InterfaceNumber)) {
|
||||
(ActIfDesc->InterfaceNumber != UsbWWIDDevicePathPtr->InterfaceNumber))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -888,7 +862,7 @@ MatchUsbWwid (
|
||||
//
|
||||
// Serial number in USB WWID device path is the last 64-or-less UTF-16 characters.
|
||||
//
|
||||
CompareStr = (CHAR16 *) (UINTN) (UsbWWIDDevicePathPtr + 1);
|
||||
CompareStr = (CHAR16 *)(UINTN)(UsbWWIDDevicePathPtr + 1);
|
||||
CompareLen = (DevicePathNodeLength (UsbWWIDDevicePathPtr) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16);
|
||||
if (CompareStr[CompareLen - 1] == L'\0') {
|
||||
CompareLen--;
|
||||
@@ -905,7 +879,8 @@ MatchUsbWwid (
|
||||
|
||||
Length = (StrDesc->Length - 2) / sizeof (CHAR16);
|
||||
if ((Length >= CompareLen) &&
|
||||
(CompareMem (StrDesc->String + Length - CompareLen, CompareStr, CompareLen * sizeof (CHAR16)) == 0)) {
|
||||
(CompareMem (StrDesc->String + Length - CompareLen, CompareStr, CompareLen * sizeof (CHAR16)) == 0))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -925,11 +900,11 @@ MatchUsbWwid (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbBusFreeUsbDPList (
|
||||
IN LIST_ENTRY *UsbIoDPList
|
||||
IN LIST_ENTRY *UsbIoDPList
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *ListIndex;
|
||||
DEVICE_PATH_LIST_ITEM *ListItem;
|
||||
LIST_ENTRY *ListIndex;
|
||||
DEVICE_PATH_LIST_ITEM *ListItem;
|
||||
|
||||
//
|
||||
// Check that ControllerHandle is a valid handle
|
||||
@@ -939,14 +914,15 @@ UsbBusFreeUsbDPList (
|
||||
}
|
||||
|
||||
ListIndex = UsbIoDPList->ForwardLink;
|
||||
while (ListIndex != UsbIoDPList){
|
||||
ListItem = CR(ListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
|
||||
while (ListIndex != UsbIoDPList) {
|
||||
ListItem = CR (ListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
|
||||
//
|
||||
// Free DEVICE_PATH_LIST_ITEM.DevicePath[]
|
||||
//
|
||||
if (ListItem->DevicePath != NULL){
|
||||
FreePool(ListItem->DevicePath);
|
||||
if (ListItem->DevicePath != NULL) {
|
||||
FreePool (ListItem->DevicePath);
|
||||
}
|
||||
|
||||
//
|
||||
// Free DEVICE_PATH_LIST_ITEM itself
|
||||
//
|
||||
@@ -973,28 +949,29 @@ UsbBusFreeUsbDPList (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbBusAddWantedUsbIoDP (
|
||||
IN EFI_USB_BUS_PROTOCOL *UsbBusId,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
IN EFI_USB_BUS_PROTOCOL *UsbBusId,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
)
|
||||
{
|
||||
USB_BUS *Bus;
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePathPtr;
|
||||
USB_BUS *Bus;
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePathPtr;
|
||||
|
||||
//
|
||||
// Check whether remaining device path is valid
|
||||
//
|
||||
if (RemainingDevicePath != NULL && !IsDevicePathEnd (RemainingDevicePath)) {
|
||||
if ((RemainingDevicePath != NULL) && !IsDevicePathEnd (RemainingDevicePath)) {
|
||||
if ((RemainingDevicePath->Type != MESSAGING_DEVICE_PATH) ||
|
||||
(RemainingDevicePath->SubType != MSG_USB_DP &&
|
||||
RemainingDevicePath->SubType != MSG_USB_CLASS_DP
|
||||
&& RemainingDevicePath->SubType != MSG_USB_WWID_DP
|
||||
)) {
|
||||
( (RemainingDevicePath->SubType != MSG_USB_DP) &&
|
||||
(RemainingDevicePath->SubType != MSG_USB_CLASS_DP)
|
||||
&& (RemainingDevicePath->SubType != MSG_USB_WWID_DP)
|
||||
))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if (UsbBusId == NULL){
|
||||
if (UsbBusId == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -1008,7 +985,7 @@ UsbBusAddWantedUsbIoDP (
|
||||
//
|
||||
Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);
|
||||
ASSERT (!EFI_ERROR (Status));
|
||||
DevicePathPtr = DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) &mAllUsbClassDevicePath);
|
||||
DevicePathPtr = DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL *)&mAllUsbClassDevicePath);
|
||||
} else if (!IsDevicePathEnd (RemainingDevicePath)) {
|
||||
//
|
||||
// If RemainingDevicePath isn't the End of Device Path Node,
|
||||
@@ -1043,16 +1020,16 @@ UsbBusAddWantedUsbIoDP (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
UsbBusIsWantedUsbIO (
|
||||
IN USB_BUS *Bus,
|
||||
IN USB_INTERFACE *UsbIf
|
||||
IN USB_BUS *Bus,
|
||||
IN USB_INTERFACE *UsbIf
|
||||
)
|
||||
{
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePathPtr;
|
||||
LIST_ENTRY *WantedUsbIoDPListPtr;
|
||||
LIST_ENTRY *WantedListIndex;
|
||||
DEVICE_PATH_LIST_ITEM *WantedListItem;
|
||||
BOOLEAN DoConvert;
|
||||
UINTN FirstDevicePathSize;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePathPtr;
|
||||
LIST_ENTRY *WantedUsbIoDPListPtr;
|
||||
LIST_ENTRY *WantedListIndex;
|
||||
DEVICE_PATH_LIST_ITEM *WantedListItem;
|
||||
BOOLEAN DoConvert;
|
||||
UINTN FirstDevicePathSize;
|
||||
|
||||
//
|
||||
// Check whether passed in parameters are valid
|
||||
@@ -1060,6 +1037,7 @@ UsbBusIsWantedUsbIO (
|
||||
if ((UsbIf == NULL) || (Bus == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Check whether UsbIf is Hub
|
||||
//
|
||||
@@ -1070,7 +1048,7 @@ UsbBusIsWantedUsbIO (
|
||||
//
|
||||
// Check whether all Usb devices in this bus are wanted
|
||||
//
|
||||
if (SearchUsbDPInList ((EFI_DEVICE_PATH_PROTOCOL *)&mAllUsbClassDevicePath, &Bus->WantedUsbIoDPList)){
|
||||
if (SearchUsbDPInList ((EFI_DEVICE_PATH_PROTOCOL *)&mAllUsbClassDevicePath, &Bus->WantedUsbIoDPList)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1084,37 +1062,42 @@ UsbBusIsWantedUsbIO (
|
||||
DevicePathPtr = GetUsbDPFromFullDP (UsbIf->DevicePath);
|
||||
ASSERT (DevicePathPtr != NULL);
|
||||
|
||||
DoConvert = FALSE;
|
||||
DoConvert = FALSE;
|
||||
WantedListIndex = WantedUsbIoDPListPtr->ForwardLink;
|
||||
while (WantedListIndex != WantedUsbIoDPListPtr){
|
||||
WantedListItem = CR(WantedListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
|
||||
while (WantedListIndex != WantedUsbIoDPListPtr) {
|
||||
WantedListItem = CR (WantedListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
|
||||
ASSERT (WantedListItem->DevicePath->Type == MESSAGING_DEVICE_PATH);
|
||||
switch (WantedListItem->DevicePath->SubType) {
|
||||
case MSG_USB_DP:
|
||||
FirstDevicePathSize = GetDevicePathSize (WantedListItem->DevicePath);
|
||||
if (FirstDevicePathSize == GetDevicePathSize (DevicePathPtr)) {
|
||||
if (CompareMem (
|
||||
WantedListItem->DevicePath,
|
||||
DevicePathPtr,
|
||||
GetDevicePathSize (DevicePathPtr)) == 0
|
||||
) {
|
||||
case MSG_USB_DP:
|
||||
FirstDevicePathSize = GetDevicePathSize (WantedListItem->DevicePath);
|
||||
if (FirstDevicePathSize == GetDevicePathSize (DevicePathPtr)) {
|
||||
if (CompareMem (
|
||||
WantedListItem->DevicePath,
|
||||
DevicePathPtr,
|
||||
GetDevicePathSize (DevicePathPtr)
|
||||
) == 0
|
||||
)
|
||||
{
|
||||
DoConvert = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case MSG_USB_CLASS_DP:
|
||||
if (MatchUsbClass ((USB_CLASS_DEVICE_PATH *)WantedListItem->DevicePath, UsbIf)) {
|
||||
DoConvert = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSG_USB_CLASS_DP:
|
||||
if (MatchUsbClass((USB_CLASS_DEVICE_PATH *)WantedListItem->DevicePath, UsbIf)) {
|
||||
DoConvert = TRUE;
|
||||
}
|
||||
break;
|
||||
case MSG_USB_WWID_DP:
|
||||
if (MatchUsbWwid((USB_WWID_DEVICE_PATH *)WantedListItem->DevicePath, UsbIf)) {
|
||||
DoConvert = TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ASSERT (0);
|
||||
break;
|
||||
|
||||
break;
|
||||
case MSG_USB_WWID_DP:
|
||||
if (MatchUsbWwid ((USB_WWID_DEVICE_PATH *)WantedListItem->DevicePath, UsbIf)) {
|
||||
DoConvert = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
ASSERT (0);
|
||||
break;
|
||||
}
|
||||
|
||||
if (DoConvert) {
|
||||
@@ -1123,12 +1106,13 @@ UsbBusIsWantedUsbIO (
|
||||
|
||||
WantedListIndex = WantedListIndex->ForwardLink;
|
||||
}
|
||||
|
||||
gBS->FreePool (DevicePathPtr);
|
||||
|
||||
//
|
||||
// Check whether the new Usb device path is wanted
|
||||
//
|
||||
if (DoConvert){
|
||||
if (DoConvert) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
@@ -1148,19 +1132,19 @@ UsbBusIsWantedUsbIO (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UsbBusRecursivelyConnectWantedUsbIo (
|
||||
IN EFI_USB_BUS_PROTOCOL *UsbBusId
|
||||
IN EFI_USB_BUS_PROTOCOL *UsbBusId
|
||||
)
|
||||
{
|
||||
USB_BUS *Bus;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
EFI_USB_IO_PROTOCOL *UsbIo;
|
||||
USB_INTERFACE *UsbIf;
|
||||
UINTN UsbIoHandleCount;
|
||||
EFI_HANDLE *UsbIoBuffer;
|
||||
EFI_DEVICE_PATH_PROTOCOL *UsbIoDevicePath;
|
||||
USB_BUS *Bus;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
EFI_USB_IO_PROTOCOL *UsbIo;
|
||||
USB_INTERFACE *UsbIf;
|
||||
UINTN UsbIoHandleCount;
|
||||
EFI_HANDLE *UsbIoBuffer;
|
||||
EFI_DEVICE_PATH_PROTOCOL *UsbIoDevicePath;
|
||||
|
||||
if (UsbBusId == NULL){
|
||||
if (UsbBusId == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -1170,10 +1154,11 @@ UsbBusRecursivelyConnectWantedUsbIo (
|
||||
// Get all Usb IO handles in system
|
||||
//
|
||||
UsbIoHandleCount = 0;
|
||||
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiUsbIoProtocolGuid, NULL, &UsbIoHandleCount, &UsbIoBuffer);
|
||||
if (Status == EFI_NOT_FOUND || UsbIoHandleCount == 0) {
|
||||
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiUsbIoProtocolGuid, NULL, &UsbIoHandleCount, &UsbIoBuffer);
|
||||
if ((Status == EFI_NOT_FOUND) || (UsbIoHandleCount == 0)) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
ASSERT (!EFI_ERROR (Status));
|
||||
|
||||
for (Index = 0; Index < UsbIoHandleCount; Index++) {
|
||||
@@ -1182,30 +1167,33 @@ UsbBusRecursivelyConnectWantedUsbIo (
|
||||
// Note: The usb child handle maybe invalid because of hot plugged out during the loop
|
||||
//
|
||||
UsbIoDevicePath = NULL;
|
||||
Status = gBS->HandleProtocol (UsbIoBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID *) &UsbIoDevicePath);
|
||||
if (EFI_ERROR (Status) || UsbIoDevicePath == NULL) {
|
||||
Status = gBS->HandleProtocol (UsbIoBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID *)&UsbIoDevicePath);
|
||||
if (EFI_ERROR (Status) || (UsbIoDevicePath == NULL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CompareMem (
|
||||
UsbIoDevicePath,
|
||||
Bus->DevicePath,
|
||||
(GetDevicePathSize (Bus->DevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL))
|
||||
) != 0) {
|
||||
UsbIoDevicePath,
|
||||
Bus->DevicePath,
|
||||
(GetDevicePathSize (Bus->DevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL))
|
||||
) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the child Usb IO interface
|
||||
//
|
||||
Status = gBS->HandleProtocol(
|
||||
UsbIoBuffer[Index],
|
||||
&gEfiUsbIoProtocolGuid,
|
||||
(VOID **) &UsbIo
|
||||
);
|
||||
Status = gBS->HandleProtocol (
|
||||
UsbIoBuffer[Index],
|
||||
&gEfiUsbIoProtocolGuid,
|
||||
(VOID **)&UsbIo
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
UsbIf = USB_INTERFACE_FROM_USBIO (UsbIo);
|
||||
|
||||
UsbIf = USB_INTERFACE_FROM_USBIO (UsbIo);
|
||||
|
||||
if (UsbBusIsWantedUsbIO (Bus, UsbIf)) {
|
||||
if (!UsbIf->IsManaged) {
|
||||
@@ -1213,9 +1201,9 @@ UsbBusRecursivelyConnectWantedUsbIo (
|
||||
// Recursively connect the wanted Usb Io handle
|
||||
//
|
||||
DEBUG ((DEBUG_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL before connect is %d\n", (UINT32)UsbGetCurrentTpl ()));
|
||||
Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);
|
||||
UsbIf->IsManaged = (BOOLEAN)!EFI_ERROR (Status);
|
||||
DEBUG ((DEBUG_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl()));
|
||||
Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);
|
||||
UsbIf->IsManaged = (BOOLEAN) !EFI_ERROR (Status);
|
||||
DEBUG ((DEBUG_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,13 +24,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHcGetCapability (
|
||||
IN USB_BUS *UsbBus,
|
||||
OUT UINT8 *MaxSpeed,
|
||||
OUT UINT8 *NumOfPort,
|
||||
OUT UINT8 *Is64BitCapable
|
||||
IN USB_BUS *UsbBus,
|
||||
OUT UINT8 *MaxSpeed,
|
||||
OUT UINT8 *NumOfPort,
|
||||
OUT UINT8 *Is64BitCapable
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Get the root hub port state.
|
||||
|
||||
@@ -44,9 +43,9 @@ UsbHcGetCapability (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHcGetRootHubPortStatus (
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
OUT EFI_USB_PORT_STATUS *PortStatus
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
OUT EFI_USB_PORT_STATUS *PortStatus
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -62,9 +61,9 @@ UsbHcGetRootHubPortStatus (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHcSetRootHubPortFeature (
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -80,9 +79,9 @@ UsbHcSetRootHubPortFeature (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbHcClearRootHubPortFeature (
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
IN USB_BUS *UsbBus,
|
||||
IN UINT8 PortIndex,
|
||||
IN EFI_USB_PORT_FEATURE Feature
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -231,7 +230,6 @@ UsbHcSyncInterruptTransfer (
|
||||
OUT UINT32 *UsbResult
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Open the USB host controller protocol BY_CHILD.
|
||||
|
||||
@@ -243,8 +241,8 @@ UsbHcSyncInterruptTransfer (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbOpenHostProtoByChild (
|
||||
IN USB_BUS *Bus,
|
||||
IN EFI_HANDLE Child
|
||||
IN USB_BUS *Bus,
|
||||
IN EFI_HANDLE Child
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -258,8 +256,8 @@ UsbOpenHostProtoByChild (
|
||||
**/
|
||||
VOID
|
||||
UsbCloseHostProtoByChild (
|
||||
IN USB_BUS *Bus,
|
||||
IN EFI_HANDLE Child
|
||||
IN USB_BUS *Bus,
|
||||
IN EFI_HANDLE Child
|
||||
);
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user