/* Return the max packet size for endpoint zero. This function is the first function called to get descriptors during bus enumeration. */
EFI_STATUS UsbGetMaxPacketSize0(IN USB_DEVICE *UsbDev)
/* Return the max packet size for endpoint zero. This function is the first function called to get descriptors during bus enumeration. */
EFI_STATUS UsbGetMaxPacketSize0(IN USB_DEVICE *UsbDev)
{
  EFI_USB_DEVICE_DESCRIPTOR  DevDesc;
  EFI_STATUS                 Status;
  UINTN                      Index;
  for (Index = 0; Index < 3; Index++) {
    Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_DEVICE, 0, 0, &DevDesc, 8);
    if (!EFI_ERROR (Status)) {
      if ((DevDesc.BcdUSB >= 0x0300) && (DevDesc.MaxPacketSize0 == 9)) {
        UsbDev->MaxPacket0 = 1 << 9;
        return EFI_SUCCESS;
      }
      UsbDev->MaxPacket0 = DevDesc.MaxPacketSize0;
      return EFI_SUCCESS;
    }
    gBS->Stall (USB_RETRY_MAX_PACK_SIZE_STALL);
  }
  return EFI_DEVICE_ERROR;
}