]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
Fixed unexpected timeout in Usb MassStorage Driver.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMassBoot.h
index bfef2609ad32d7090ea9cd858a00058900113b4f..136276a51588ecd2b44a7dd29b1a9c5ba223dfb7 100644 (file)
@@ -31,14 +31,13 @@ enum {
   // The opcodes of various usb boot commands:\r
   // INQUIRY/REQUEST_SENSE are "No Timeout Commands" as specified\r
   // by MMC command set. Others are "Group 1 Timeout Commands". That\r
-  // is they should be retried if driver is ready.\r
-  // We can't use the Peripheral Device Type in Inquiry data to\r
+  // is they should be retried if driver is ready. \r
+  // We can't use the Peripheral Device Type in Inquiry data to \r
   // determine the timeout used. For example, both floppy and flash\r
   // are likely set their PDT to 0, or Direct Access Device.\r
   //\r
   USB_BOOT_INQUIRY_OPCODE         = 0x12,\r
   USB_BOOT_REQUEST_SENSE_OPCODE   = 0x03,\r
-\r
   USB_BOOT_MODE_SENSE10_OPCODE    = 0x5A,\r
   USB_BOOT_READ_CAPACITY_OPCODE   = 0x25,\r
   USB_BOOT_TEST_UNIT_READY_OPCODE = 0x00,\r
@@ -70,45 +69,45 @@ enum {
   USB_BOOT_ASC_MEDIA_CHANGE       = 0x28,\r
 \r
   //\r
-  // Other parameters\r
+  // Supported PDT codes, or Peripheral Device Type\r
+  //\r
+  USB_PDT_DIRECT_ACCESS           = 0x00,       // Direct access device\r
+  USB_PDT_CDROM                   = 0x05,       // CDROM\r
+  USB_PDT_OPTICAL                 = 0x07,       // Non-CD optical disks\r
+  USB_PDT_SIMPLE_DIRECT           = 0x0E,       // Simplified direct access device\r
+  \r
+  //\r
+  // Other parameters, Max carried size is 512B * 128 = 64KB\r
   //\r
-  USB_BOOT_IO_BLOCKS              = 64,\r
+  USB_BOOT_IO_BLOCKS              = 128,\r
 \r
   //\r
-  // Boot Retry times\r
+  // Retry mass command times, set by experience\r
   //\r
   USB_BOOT_COMMAND_RETRY          = 5,\r
-  USB_BOOT_WAIT_RETRY             = 5,\r
+  USB_BOOT_INIT_MEDIA_RETRY       = 5,\r
 \r
   //\r
-  // Boot Stall time\r
+  // Wait for unit ready command, set by experience\r
   //\r
-  USB_BOOT_UNIT_READY_STALL       = 50 * USB_MASS_STALL_1_MS,\r
+  USB_BOOT_RETRY_UNIT_READY_STALL = 500 * USB_MASS_1_MILLISECOND,\r
 \r
   //\r
-  // Boot Transfer timeout\r
+  // Mass command timeout, refers to specification[USB20-9.2.6.1]\r
   //\r
   // USB2.0 Spec define the up-limit timeout 5s for all command. USB floppy, \r
   // USB CD-Rom and iPod devices are much slower than USB key when reponse \r
   // most of commands, So we set 5s as timeout here.\r
   // \r
   //\r
-  USB_BOOT_GENERAL_CMD_TIMEOUT    = 5 * USB_MASS_STALL_1_S,\r
-  \r
-  //\r
-  // Supported PDT codes, or Peripheral Device Type\r
-  //\r
-  USB_PDT_DIRECT_ACCESS           = 0x00,       // Direct access device\r
-  USB_PDT_CDROM                   = 0x05,       // CDROM\r
-  USB_PDT_OPTICAL                 = 0x07,       // Non-CD optical disks\r
-  USB_PDT_SIMPLE_DIRECT           = 0x0E        // Simplified direct access device\r
+  USB_BOOT_GENERAL_CMD_TIMEOUT    = 5 * USB_MASS_1_SECOND,\r
 };\r
 \r
 //\r
 // The required commands are INQUIRY, READ CAPACITY, TEST UNIT READY,\r
 // READ10, WRITE10, and REQUEST SENSE. The BLOCK_IO protocol uses LBA\r
 // so it isn't necessary to issue MODE SENSE / READ FORMAT CAPACITY\r
-// command to retrieve the disk gemotrics.\r
+// command to retrieve the disk gemotrics. \r
 //\r
 #pragma pack(1)\r
 typedef struct {\r
@@ -221,7 +220,7 @@ typedef struct {
 \r
 typedef struct {\r
   UINT8             ModeDataLen;\r
- UINT8             MediumType;\r
 UINT8             MediumType;\r
   UINT8             DevicePara;\r
   UINT8             BlkDesLen;\r
 } USB_SCSI_MODE_SENSE6_PARA_HEADER;\r
@@ -245,7 +244,7 @@ typedef struct {
 //\r
 #define USB_BOOT_SWAP32(Data32) \\r
                 ((((Data32) & 0x000000ff) << 24) | (((Data32) & 0xff000000) >> 24) | \\r
-                 (((Data32) & 0x0000ff00) << 8)  | (((Data32) & 0x00ff0000) >> 8))\r
+                 (((Data32) & 0x0000ff00) << 8)  | (((Data32) & 0x00ff0000) >> 8)) \r
 \r
 #define USB_BOOT_SWAP16(Data16) \\r
                 ((((Data16) & 0x00ff) << 8) | (((Data16) & 0xff00) >> 8))\r