/* Retrieve the endpoint descriptor from this interface setting. */
EFI_STATUS EFIAPI UsbIoGetEndpointDescriptor(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Index, OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor)
/* Retrieve the endpoint descriptor from this interface setting. */
EFI_STATUS EFIAPI UsbIoGetEndpointDescriptor(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Index, OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor)
{
  USB_INTERFACE  *UsbIf;
  EFI_TPL        OldTpl;
  OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
  UsbIf = USB_INTERFACE_FROM_USBIO (This);
  if ((Descriptor == NULL) || (Index > 15)) {
    gBS->RestoreTPL (OldTpl);
    return EFI_INVALID_PARAMETER;
  }
  if (Index >= UsbIf->IfSetting->Desc.NumEndpoints) {
    gBS->RestoreTPL (OldTpl);
    return EFI_NOT_FOUND;
  }
  CopyMem (
    Descriptor,
    &(UsbIf->IfSetting->Endpoints[Index]->Desc),
    sizeof (EFI_USB_ENDPOINT_DESCRIPTOR)
    );
  gBS->RestoreTPL (OldTpl);
  return EFI_SUCCESS;
}