2007-06-28 00:53:31 +02:00
|
|
|
/** @file
|
2007-07-12 19:31:28 +02:00
|
|
|
Common Dxe Libarary for USB
|
2007-06-19 12:55:24 +02:00
|
|
|
|
2007-06-28 00:53:31 +02:00
|
|
|
Copyright (c) 2006, Intel Corporation<BR>
|
|
|
|
All rights reserved. This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
|
|
|
|
|
2007-06-28 00:53:31 +02:00
|
|
|
#ifndef __USB_DXE_LIB_H__
|
|
|
|
#define __USB_DXE_LIB_H__
|
2007-06-19 12:55:24 +02:00
|
|
|
|
2007-06-22 18:22:26 +02:00
|
|
|
#include <Protocol/UsbIo.h>
|
2007-07-12 19:31:28 +02:00
|
|
|
|
2007-06-19 12:55:24 +02:00
|
|
|
//
|
|
|
|
// define the timeout time as 3ms
|
|
|
|
//
|
|
|
|
#define TIMEOUT_VALUE 3 * 1000
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Get Hid Descriptor
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param InterfaceNum Hid interface number
|
|
|
|
@param HidDescriptor Caller allocated buffer to store Usb hid descriptor if
|
|
|
|
successfully returned.
|
|
|
|
|
|
|
|
@return Status of getting HID descriptor through USB I/O
|
|
|
|
protocol's UsbControlTransfer().
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-06-19 12:55:24 +02:00
|
|
|
UsbGetHidDescriptor (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT8 InterfaceNum,
|
|
|
|
OUT EFI_USB_HID_DESCRIPTOR *HidDescriptor
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
get Report Class descriptor
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL.
|
|
|
|
@param InterfaceNum Report interface number.
|
|
|
|
@param DescriptorSize Length of DescriptorBuffer.
|
|
|
|
@param DescriptorBuffer Caller allocated buffer to store Usb report descriptor
|
|
|
|
if successfully returned.
|
|
|
|
|
|
|
|
@return Status of getting Report Class descriptor through USB
|
|
|
|
I/O protocol's UsbControlTransfer().
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-06-19 12:55:24 +02:00
|
|
|
UsbGetReportDescriptor (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT8 InterfaceNum,
|
|
|
|
IN UINT16 DescriptorSize,
|
|
|
|
OUT UINT8 *DescriptorBuffer
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Get Hid Protocol Request
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Interface Which interface the caller wants to get protocol
|
|
|
|
@param Protocol Protocol value returned.
|
|
|
|
|
|
|
|
@return Status of getting Protocol Request through USB I/O
|
|
|
|
protocol's UsbControlTransfer().
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-06-19 12:55:24 +02:00
|
|
|
UsbGetProtocolRequest (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT8 Interface,
|
|
|
|
IN UINT8 *Protocol
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Set Hid Protocol Request
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Interface Which interface the caller wants to set protocol
|
|
|
|
@param Protocol Protocol value the caller wants to set.
|
|
|
|
|
|
|
|
@return Status of setting Protocol Request through USB I/O
|
|
|
|
protocol's UsbControlTransfer().
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-06-19 12:55:24 +02:00
|
|
|
UsbSetProtocolRequest (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT8 Interface,
|
|
|
|
IN UINT8 Protocol
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Set Idel request.
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Interface Which interface the caller wants to set.
|
|
|
|
@param ReportId Which report the caller wants to set.
|
|
|
|
@param Duration Idle rate the caller wants to set.
|
|
|
|
|
|
|
|
@return Status of setting IDLE Request through USB I/O
|
|
|
|
protocol's UsbControlTransfer().
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-06-19 12:55:24 +02:00
|
|
|
UsbSetIdleRequest (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT8 Interface,
|
|
|
|
IN UINT8 ReportId,
|
|
|
|
IN UINT8 Duration
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Get Idel request.
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Interface Which interface the caller wants to get.
|
|
|
|
@param ReportId Which report the caller wants to get.
|
|
|
|
@param Duration Idle rate the caller wants to get.
|
|
|
|
|
|
|
|
@return Status of getting IDLE Request through USB I/O
|
|
|
|
protocol's UsbControlTransfer().
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-06-19 12:55:24 +02:00
|
|
|
UsbGetIdleRequest (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT8 Interface,
|
|
|
|
IN UINT8 ReportId,
|
|
|
|
OUT UINT8 *Duration
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Hid Set Report request.
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Interface Which interface the caller wants to set.
|
|
|
|
@param ReportId Which report the caller wants to set.
|
|
|
|
@param ReportType Type of report.
|
|
|
|
@param ReportLen Length of report descriptor.
|
|
|
|
@param Report Report Descriptor buffer.
|
|
|
|
|
|
|
|
@return Status of setting Report Request through USB I/O
|
|
|
|
protocol's UsbControlTransfer().
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-06-19 12:55:24 +02:00
|
|
|
UsbSetReportRequest (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT8 Interface,
|
|
|
|
IN UINT8 ReportId,
|
|
|
|
IN UINT8 ReportType,
|
|
|
|
IN UINT16 ReportLen,
|
|
|
|
IN UINT8 *Report
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Hid Set Report request.
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Interface Which interface the caller wants to set.
|
|
|
|
@param ReportId Which report the caller wants to set.
|
|
|
|
@param ReportType Type of report.
|
|
|
|
@param ReportLen Length of report descriptor.
|
|
|
|
@param Report Caller allocated buffer to store Report Descriptor.
|
|
|
|
|
|
|
|
@return Status of getting Report Request through USB I/O
|
|
|
|
protocol's UsbControlTransfer().
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-06-19 12:55:24 +02:00
|
|
|
UsbGetReportRequest (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT8 Interface,
|
|
|
|
IN UINT8 ReportId,
|
|
|
|
IN UINT8 ReportType,
|
|
|
|
IN UINT16 ReportLen,
|
|
|
|
IN UINT8 *Report
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Usb Get Descriptor
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Value Device Request Value
|
|
|
|
@param Index Device Request Index
|
|
|
|
@param DescriptorLength Descriptor Length
|
|
|
|
@param Descriptor Descriptor buffer to contain result
|
|
|
|
@param Status Transfer Status
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Parameter is error
|
|
|
|
@retval EFI_SUCCESS Success
|
|
|
|
@retval EFI_TIMEOUT Device has no response
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2008-07-21 09:26:20 +02:00
|
|
|
EFIAPI
|
2007-06-19 12:55:24 +02:00
|
|
|
UsbGetDescriptor (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT16 Value,
|
|
|
|
IN UINT16 Index,
|
|
|
|
IN UINT16 DescriptorLength,
|
|
|
|
OUT VOID *Descriptor,
|
|
|
|
OUT UINT32 *Status
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Usb Set Descriptor
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Value Device Request Value
|
|
|
|
@param Index Device Request Index
|
|
|
|
@param DescriptorLength Descriptor Length
|
|
|
|
@param Descriptor Descriptor buffer to set
|
|
|
|
@param Status Transfer Status
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Parameter is error
|
|
|
|
@retval EFI_SUCCESS Success
|
|
|
|
@retval EFI_TIMEOUT Device has no response
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-06-19 12:55:24 +02:00
|
|
|
UsbSetDescriptor (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT16 Value,
|
|
|
|
IN UINT16 Index,
|
|
|
|
IN UINT16 DescriptorLength,
|
|
|
|
IN VOID *Descriptor,
|
|
|
|
OUT UINT32 *Status
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Usb Get Device Interface
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Index Interface index value
|
|
|
|
@param AltSetting Alternate setting
|
|
|
|
@param Status Trasnsfer status
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Parameter is error
|
|
|
|
@retval EFI_SUCCESS Success
|
|
|
|
@retval EFI_TIMEOUT Device has no response
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-07-12 19:31:28 +02:00
|
|
|
UsbGetInterface (
|
2007-06-19 12:55:24 +02:00
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT16 Index,
|
|
|
|
OUT UINT8 *AltSetting,
|
|
|
|
OUT UINT32 *Status
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Usb Set Device Interface
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param InterfaceNo Interface Number
|
|
|
|
@param AltSetting Alternate setting
|
|
|
|
@param Status Trasnsfer status
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Parameter is error
|
|
|
|
@retval EFI_SUCCESS Success
|
|
|
|
@retval EFI_TIMEOUT Device has no response
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-07-12 19:31:28 +02:00
|
|
|
UsbSetInterface (
|
2007-06-19 12:55:24 +02:00
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT16 InterfaceNo,
|
|
|
|
IN UINT16 AltSetting,
|
|
|
|
OUT UINT32 *Status
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Usb Get Device Configuration
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param ConfigValue Config Value
|
|
|
|
@param Status Transfer Status
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Parameter is error
|
|
|
|
@retval EFI_SUCCESS Success
|
|
|
|
@retval EFI_TIMEOUT Device has no response
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-07-12 19:31:28 +02:00
|
|
|
UsbGetConfiguration (
|
2007-06-19 12:55:24 +02:00
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
OUT UINT8 *ConfigValue,
|
|
|
|
OUT UINT32 *Status
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Usb Set Device Configuration
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Value Configuration Value to set
|
|
|
|
@param Status Transfer status
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Parameter is error
|
|
|
|
@retval EFI_SUCCESS Success
|
|
|
|
@retval EFI_TIMEOUT Device has no response
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-07-12 19:31:28 +02:00
|
|
|
UsbSetConfiguration (
|
2007-06-19 12:55:24 +02:00
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT16 Value,
|
|
|
|
OUT UINT32 *Status
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Usb Set Device Feature
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Recipient Interface/Device/Endpoint
|
|
|
|
@param Value Request value
|
|
|
|
@param Target Request Index
|
|
|
|
@param Status Transfer status
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Parameter is error
|
|
|
|
@retval EFI_SUCCESS Success
|
|
|
|
@retval EFI_TIMEOUT Device has no response
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-07-12 19:31:28 +02:00
|
|
|
UsbSetFeature (
|
2007-06-19 12:55:24 +02:00
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
2007-07-12 19:31:28 +02:00
|
|
|
IN UINTN Recipient,
|
2007-06-19 12:55:24 +02:00
|
|
|
IN UINT16 Value,
|
|
|
|
IN UINT16 Target,
|
|
|
|
OUT UINT32 *Status
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Usb Clear Device Feature
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Recipient Interface/Device/Endpoint
|
|
|
|
@param Value Request value
|
|
|
|
@param Target Request Index
|
|
|
|
@param Status Transfer status
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Parameter is error
|
|
|
|
@retval EFI_SUCCESS Success
|
|
|
|
@retval EFI_TIMEOUT Device has no response
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-07-12 19:31:28 +02:00
|
|
|
UsbClearFeature (
|
2007-06-19 12:55:24 +02:00
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
2007-07-12 19:31:28 +02:00
|
|
|
IN UINTN Recipient,
|
2007-06-19 12:55:24 +02:00
|
|
|
IN UINT16 Value,
|
|
|
|
IN UINT16 Target,
|
|
|
|
OUT UINT32 *Status
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Usb Get Device Status
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param Recipient Interface/Device/Endpoint
|
|
|
|
@param Target Request index
|
|
|
|
@param DevStatus Device status
|
|
|
|
@param Status Transfer status
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Parameter is error
|
|
|
|
@retval EFI_SUCCESS Success
|
|
|
|
@retval EFI_TIMEOUT Device has no response
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-07-12 19:31:28 +02:00
|
|
|
UsbGetStatus (
|
2007-06-19 12:55:24 +02:00
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
2007-07-12 19:31:28 +02:00
|
|
|
IN UINTN Recipient,
|
2007-06-19 12:55:24 +02:00
|
|
|
IN UINT16 Target,
|
|
|
|
OUT UINT16 *DevStatus,
|
|
|
|
OUT UINT32 *Status
|
|
|
|
);
|
|
|
|
|
2008-07-16 08:31:22 +02:00
|
|
|
/**
|
|
|
|
Clear endpoint stall
|
|
|
|
|
|
|
|
@param UsbIo EFI_USB_IO_PROTOCOL
|
|
|
|
@param EndpointNo Endpoint Number
|
|
|
|
@param Status Transfer Status
|
|
|
|
|
|
|
|
@retval EFI_NOT_FOUND Can't find the Endpoint
|
|
|
|
@retval EFI_DEVICE_ERROR Hardware error
|
|
|
|
@retval EFI_SUCCESS Success
|
|
|
|
|
|
|
|
**/
|
2007-06-19 12:55:24 +02:00
|
|
|
EFI_STATUS
|
2007-07-30 09:54:23 +02:00
|
|
|
EFIAPI
|
2007-06-19 12:55:24 +02:00
|
|
|
UsbClearEndpointHalt (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
|
|
|
IN UINT8 EndpointNo,
|
|
|
|
OUT UINT32 *Status
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|