mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/Usb: Replace macro USB_BOOT_IO_BLOCKS
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>
This commit is contained in:
parent
dd190645eb
commit
824b6e3b5f
|
@ -814,11 +814,13 @@ UsbBootReadBlocks (
|
||||||
USB_BOOT_READ10_CMD ReadCmd;
|
USB_BOOT_READ10_CMD ReadCmd;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT16 Count;
|
UINT16 Count;
|
||||||
|
UINT16 CountMax;
|
||||||
UINT32 BlockSize;
|
UINT32 BlockSize;
|
||||||
UINT32 ByteSize;
|
UINT32 ByteSize;
|
||||||
UINT32 Timeout;
|
UINT32 Timeout;
|
||||||
|
|
||||||
BlockSize = UsbMass->BlockIoMedia.BlockSize;
|
BlockSize = UsbMass->BlockIoMedia.BlockSize;
|
||||||
|
CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize);
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
while (TotalBlock > 0) {
|
while (TotalBlock > 0) {
|
||||||
|
@ -827,7 +829,7 @@ UsbBootReadBlocks (
|
||||||
// on the device. We must split the total block because the READ10
|
// on the device. We must split the total block because the READ10
|
||||||
// command only has 16 bit transfer length (in the unit of block).
|
// command only has 16 bit transfer length (in the unit of block).
|
||||||
//
|
//
|
||||||
Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS);
|
Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax);
|
||||||
ByteSize = (UINT32)Count * BlockSize;
|
ByteSize = (UINT32)Count * BlockSize;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -890,11 +892,13 @@ UsbBootWriteBlocks (
|
||||||
USB_BOOT_WRITE10_CMD WriteCmd;
|
USB_BOOT_WRITE10_CMD WriteCmd;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT16 Count;
|
UINT16 Count;
|
||||||
|
UINT16 CountMax;
|
||||||
UINT32 BlockSize;
|
UINT32 BlockSize;
|
||||||
UINT32 ByteSize;
|
UINT32 ByteSize;
|
||||||
UINT32 Timeout;
|
UINT32 Timeout;
|
||||||
|
|
||||||
BlockSize = UsbMass->BlockIoMedia.BlockSize;
|
BlockSize = UsbMass->BlockIoMedia.BlockSize;
|
||||||
|
CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize);
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
while (TotalBlock > 0) {
|
while (TotalBlock > 0) {
|
||||||
|
@ -903,7 +907,7 @@ UsbBootWriteBlocks (
|
||||||
// on the device. We must split the total block because the WRITE10
|
// on the device. We must split the total block because the WRITE10
|
||||||
// command only has 16 bit transfer length (in the unit of block).
|
// command only has 16 bit transfer length (in the unit of block).
|
||||||
//
|
//
|
||||||
Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS);
|
Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax);
|
||||||
ByteSize = (UINT32)Count * BlockSize;
|
ByteSize = (UINT32)Count * BlockSize;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -966,18 +970,20 @@ UsbBootReadBlocks16 (
|
||||||
UINT8 ReadCmd[16];
|
UINT8 ReadCmd[16];
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT16 Count;
|
UINT16 Count;
|
||||||
|
UINT16 CountMax;
|
||||||
UINT32 BlockSize;
|
UINT32 BlockSize;
|
||||||
UINT32 ByteSize;
|
UINT32 ByteSize;
|
||||||
UINT32 Timeout;
|
UINT32 Timeout;
|
||||||
|
|
||||||
BlockSize = UsbMass->BlockIoMedia.BlockSize;
|
BlockSize = UsbMass->BlockIoMedia.BlockSize;
|
||||||
|
CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize);
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
while (TotalBlock > 0) {
|
while (TotalBlock > 0) {
|
||||||
//
|
//
|
||||||
// Split the total blocks into smaller pieces.
|
// Split the total blocks into smaller pieces.
|
||||||
//
|
//
|
||||||
Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS);
|
Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax);
|
||||||
ByteSize = (UINT32)Count * BlockSize;
|
ByteSize = (UINT32)Count * BlockSize;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1040,18 +1046,20 @@ UsbBootWriteBlocks16 (
|
||||||
UINT8 WriteCmd[16];
|
UINT8 WriteCmd[16];
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT16 Count;
|
UINT16 Count;
|
||||||
|
UINT16 CountMax;
|
||||||
UINT32 BlockSize;
|
UINT32 BlockSize;
|
||||||
UINT32 ByteSize;
|
UINT32 ByteSize;
|
||||||
UINT32 Timeout;
|
UINT32 Timeout;
|
||||||
|
|
||||||
BlockSize = UsbMass->BlockIoMedia.BlockSize;
|
BlockSize = UsbMass->BlockIoMedia.BlockSize;
|
||||||
|
CountMax = (UINT16)(USB_BOOT_MAX_CARRY_SIZE / BlockSize);
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
while (TotalBlock > 0) {
|
while (TotalBlock > 0) {
|
||||||
//
|
//
|
||||||
// Split the total blocks into smaller pieces.
|
// Split the total blocks into smaller pieces.
|
||||||
//
|
//
|
||||||
Count = (UINT16)((TotalBlock < USB_BOOT_IO_BLOCKS) ? TotalBlock : USB_BOOT_IO_BLOCKS);
|
Count = (UINT16)((TotalBlock < CountMax) ? TotalBlock : CountMax);
|
||||||
ByteSize = (UINT32)Count * BlockSize;
|
ByteSize = (UINT32)Count * BlockSize;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -65,9 +65,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#define USB_PDT_SIMPLE_DIRECT 0x0E ///< Simplified direct access device
|
#define USB_PDT_SIMPLE_DIRECT 0x0E ///< Simplified direct access device
|
||||||
|
|
||||||
//
|
//
|
||||||
// Other parameters, Max carried size is 512B * 128 = 64KB
|
// Other parameters, Max carried size is 64KB.
|
||||||
//
|
//
|
||||||
#define USB_BOOT_IO_BLOCKS 128
|
#define USB_BOOT_MAX_CARRY_SIZE SIZE_64KB
|
||||||
|
|
||||||
//
|
//
|
||||||
// Retry mass command times, set by experience
|
// Retry mass command times, set by experience
|
||||||
|
|
Loading…
Reference in New Issue