Booting from USB may fail while the macro USB_BOOT_IO_BLOCKS
set to 128 because the block size of some USB devices are exceeded
512, like some virtual CD-ROM from BMC, the block size is 2048.
So,the count blocks to transfer should be calculated by block
size of the USB devices.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang <ming.huang@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
USB_BOOT_READ10_CMD ReadCmd;\r
EFI_STATUS Status;\r
UINT16 Count;\r
USB_BOOT_READ10_CMD ReadCmd;\r
EFI_STATUS Status;\r
UINT16 Count;\r
UINT32 BlockSize;\r
UINT32 ByteSize;\r
UINT32 Timeout;\r
\r
BlockSize = UsbMass->BlockIoMedia.BlockSize;\r
UINT32 BlockSize;\r
UINT32 ByteSize;\r
UINT32 Timeout;\r
\r
BlockSize = UsbMass->BlockIoMedia.BlockSize;\r
+ CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize);\r
Status = EFI_SUCCESS;\r
\r
while (TotalBlock > 0) {\r
Status = EFI_SUCCESS;\r
\r
while (TotalBlock > 0) {\r
// on the device. We must split the total block because the READ10\r
// command only has 16 bit transfer length (in the unit of block).\r
//\r
// on the device. We must split the total block because the READ10\r
// command only has 16 bit transfer length (in the unit of block).\r
//\r
- Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS);\r
+ Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax);\r
ByteSize = (UINT32)Count * BlockSize;\r
\r
//\r
ByteSize = (UINT32)Count * BlockSize;\r
\r
//\r
USB_BOOT_WRITE10_CMD WriteCmd;\r
EFI_STATUS Status;\r
UINT16 Count;\r
USB_BOOT_WRITE10_CMD WriteCmd;\r
EFI_STATUS Status;\r
UINT16 Count;\r
UINT32 BlockSize;\r
UINT32 ByteSize;\r
UINT32 Timeout;\r
\r
BlockSize = UsbMass->BlockIoMedia.BlockSize;\r
UINT32 BlockSize;\r
UINT32 ByteSize;\r
UINT32 Timeout;\r
\r
BlockSize = UsbMass->BlockIoMedia.BlockSize;\r
+ CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize);\r
Status = EFI_SUCCESS;\r
\r
while (TotalBlock > 0) {\r
Status = EFI_SUCCESS;\r
\r
while (TotalBlock > 0) {\r
// on the device. We must split the total block because the WRITE10\r
// command only has 16 bit transfer length (in the unit of block).\r
//\r
// on the device. We must split the total block because the WRITE10\r
// command only has 16 bit transfer length (in the unit of block).\r
//\r
- Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS);\r
+ Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax);\r
ByteSize = (UINT32)Count * BlockSize;\r
\r
//\r
ByteSize = (UINT32)Count * BlockSize;\r
\r
//\r
UINT8 ReadCmd[16];\r
EFI_STATUS Status;\r
UINT16 Count;\r
UINT8 ReadCmd[16];\r
EFI_STATUS Status;\r
UINT16 Count;\r
UINT32 BlockSize;\r
UINT32 ByteSize;\r
UINT32 Timeout;\r
\r
BlockSize = UsbMass->BlockIoMedia.BlockSize;\r
UINT32 BlockSize;\r
UINT32 ByteSize;\r
UINT32 Timeout;\r
\r
BlockSize = UsbMass->BlockIoMedia.BlockSize;\r
+ CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize);\r
Status = EFI_SUCCESS;\r
\r
while (TotalBlock > 0) {\r
//\r
// Split the total blocks into smaller pieces.\r
//\r
Status = EFI_SUCCESS;\r
\r
while (TotalBlock > 0) {\r
//\r
// Split the total blocks into smaller pieces.\r
//\r
- Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS);\r
+ Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax);\r
ByteSize = (UINT32)Count * BlockSize;\r
\r
//\r
ByteSize = (UINT32)Count * BlockSize;\r
\r
//\r
UINT8 WriteCmd[16];\r
EFI_STATUS Status;\r
UINT16 Count;\r
UINT8 WriteCmd[16];\r
EFI_STATUS Status;\r
UINT16 Count;\r
UINT32 BlockSize;\r
UINT32 ByteSize;\r
UINT32 Timeout;\r
\r
BlockSize = UsbMass->BlockIoMedia.BlockSize;\r
UINT32 BlockSize;\r
UINT32 ByteSize;\r
UINT32 Timeout;\r
\r
BlockSize = UsbMass->BlockIoMedia.BlockSize;\r
+ CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize);\r
Status = EFI_SUCCESS;\r
\r
while (TotalBlock > 0) {\r
//\r
// Split the total blocks into smaller pieces.\r
//\r
Status = EFI_SUCCESS;\r
\r
while (TotalBlock > 0) {\r
//\r
// Split the total blocks into smaller pieces.\r
//\r
- Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS);\r
+ Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax);\r
ByteSize = (UINT32)Count * BlockSize;\r
\r
//\r
ByteSize = (UINT32)Count * BlockSize;\r
\r
//\r
#define USB_PDT_SIMPLE_DIRECT 0x0E ///< Simplified direct access device\r
\r
//\r
#define USB_PDT_SIMPLE_DIRECT 0x0E ///< Simplified direct access device\r
\r
//\r
-// Other parameters, Max carried size is 512B * 128 = 64KB\r
+// Other parameters, Max carried size is 64KB.\r
-#define USB_BOOT_IO_BLOCKS 128\r
+#define USB_BOOT_MAX_CARRY_SIZE SIZE_64KB\r
\r
//\r
// Retry mass command times, set by experience\r
\r
//\r
// Retry mass command times, set by experience\r