/*++\r
\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
Module Name:\r
\r
UsbMassStorageHelper.c\r
- \r
+\r
Abstract:\r
\r
Helper functions for USB Mass Storage Driver\r
IN UINTN SenseCounts\r
);\r
\r
-STATIC\r
-BOOLEAN\r
-IsLogicalUnitCommunicationOverRun (\r
- IN REQUEST_SENSE_DATA *SenseData,\r
- IN UINTN SenseCounts\r
- );\r
\r
EFI_STATUS\r
USBFloppyPacketCommand (\r
\r
Routine Description:\r
Sends Packet Command to USB Floppy Drive.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
Command - A pointer to the command packet.\r
CommandSize - Indicates the size of the command packet.\r
DataBuffer - A pointer to the buffer for the data transfer\r
- after the command packet. \r
+ after the command packet.\r
BufferLength - Indicates the size of the Data Buffer.\r
Direction - Transfer Direction\r
TimeOutInMilliSeconds - Timeout Value\r
- Returns: \r
+ Returns:\r
EFI_SUCCESS - Success\r
---*/ \r
+--*/\r
{\r
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
EFI_STATUS Status;\r
\r
Routine Description:\r
Retrieves device information to tell the device type.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice The USB_FLOPPY_DEV instance.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
---*/ \r
+--*/\r
{\r
\r
EFI_STATUS Status;\r
if (EFI_ERROR (Status)) {\r
return EFI_DEVICE_ERROR;\r
}\r
- \r
+\r
//\r
// Get media removable info from INQUIRY data.\r
//\r
gBS->FreePool (Idata);\r
return EFI_DEVICE_ERROR;\r
}\r
- \r
+\r
//\r
// Get media information.\r
//\r
\r
Routine Description:\r
Send Inquiry Packet Command to device and retrieve Inquiry Data.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice The USB_FLOPPY_DEV instance.\r
- Idata A pointer pointing to the address of \r
+ Idata A pointer pointing to the address of\r
Inquiry Data.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
---*/ \r
+--*/\r
{\r
ATAPI_PACKET_COMMAND Packet;\r
EFI_STATUS Status;\r
- EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
\r
- UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
\r
//\r
// prepare command packet for the Inquiry Packet Command.\r
\r
EFI_STATUS\r
USBFloppyRead10 (\r
- IN USB_FLOPPY_DEV *UsbFloppyDevice,\r
- IN VOID *Buffer,\r
- IN EFI_LBA Lba,\r
- IN UINTN NumberOfBlocks\r
+ IN USB_FLOPPY_DEV *UsbFloppyDevice,\r
+ IN VOID *Buffer,\r
+ IN EFI_LBA Lba,\r
+ IN UINTN NumberOfBlocks\r
)\r
/*++\r
\r
Routine Description:\r
Sends Read10 Packet Command to device to perform data transfer\r
from device to host.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
- Buffer - A pointer to the destination buffer for the data. \r
+ Buffer - A pointer to the destination buffer for the data.\r
The caller is responsible for either having implicit\r
or explicit ownership of the buffer.\r
- Lba - The starting logical block address to read from \r
+ Lba - The starting logical block address to read from\r
on the device.\r
- NumberOfBlocks - Indicates the number of blocks that the read \r
+ NumberOfBlocks - Indicates the number of blocks that the read\r
operation requests.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
---*/ \r
+--*/\r
{\r
ATAPI_PACKET_COMMAND Packet;\r
READ10_CMD *Read10Packet;\r
VOID *ptrBuffer;\r
EFI_STATUS Status;\r
UINT16 TimeOut;\r
- EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
- UINTN SenseCounts;\r
+ UINT8 Index;\r
\r
- UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
\r
//\r
// prepare command packet for the Inquiry Packet Command.\r
} else {\r
SectorCount = MaxBlock;\r
}\r
- //\r
- // fill the Packet data structure\r
- //\r
- Read10Packet->opcode = READ_10;\r
\r
- //\r
- // Lba0 ~ Lba3 specify the start logical block address of the data transfer.\r
- // Lba0 is MSB, Lba3 is LSB\r
- //\r
- Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff);\r
- Read10Packet->Lba2 = (UINT8) (Lba32 >> 8);\r
- Read10Packet->Lba1 = (UINT8) (Lba32 >> 16);\r
- Read10Packet->Lba0 = (UINT8) (Lba32 >> 24);\r
+ for (Index = 0; Index < 3; Index ++) {\r
\r
- //\r
- // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
- // TranLen0 is MSB, TranLen is LSB\r
- //\r
- Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);\r
- Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8);\r
+ //\r
+ // fill the Packet data structure\r
+ //\r
+ Read10Packet->opcode = READ_10;\r
+ //\r
+ // Lba0 ~ Lba3 specify the start logical block address of the data transfer.\r
+ // Lba0 is MSB, Lba3 is LSB\r
+ //\r
+ Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff);\r
+ Read10Packet->Lba2 = (UINT8) (Lba32 >> 8);\r
+ Read10Packet->Lba1 = (UINT8) (Lba32 >> 16);\r
+ Read10Packet->Lba0 = (UINT8) (Lba32 >> 24);\r
\r
- ByteCount = SectorCount * BlockSize;\r
+ //\r
+ // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
+ // TranLen0 is MSB, TranLen is LSB\r
+ //\r
+ Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);\r
+ Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8);\r
\r
- TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
+ ByteCount = SectorCount * BlockSize;\r
\r
- Status = USBFloppyPacketCommand (\r
- UsbFloppyDevice,\r
- &Packet,\r
- sizeof (ATAPI_PACKET_COMMAND),\r
- (VOID *) ptrBuffer,\r
- ByteCount,\r
- EfiUsbDataIn,\r
- TimeOut\r
- );\r
- if (EFI_ERROR (Status)) {\r
+ TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
\r
- Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts);\r
- if (!EFI_ERROR (Status)) {\r
- if (IsLogicalUnitCommunicationOverRun (\r
- UsbFloppyDevice->SenseData,\r
- SenseCounts\r
- )) {\r
- Lba32 = (UINT32) Lba;\r
- ptrBuffer = Buffer;\r
- BlocksRemaining = (UINT16) NumberOfBlocks;\r
- MaxBlock = (UINT16) (MaxBlock / 4);\r
- if (MaxBlock < 1) {\r
- MaxBlock = 1;\r
- }\r
\r
- continue;\r
- }\r
- } else {\r
- return EFI_DEVICE_ERROR;\r
- }\r
- //\r
- // retry read10 command\r
- //\r
Status = USBFloppyPacketCommand (\r
- UsbFloppyDevice,\r
- &Packet,\r
- sizeof (ATAPI_PACKET_COMMAND),\r
- (VOID *) ptrBuffer,\r
- ByteCount,\r
- EfiUsbDataIn,\r
- TimeOut\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_DEVICE_ERROR;\r
+ UsbFloppyDevice,\r
+ &Packet,\r
+ sizeof (ATAPI_PACKET_COMMAND),\r
+ (VOID *) ptrBuffer,\r
+ ByteCount,\r
+ EfiUsbDataIn,\r
+ TimeOut\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ break;\r
}\r
}\r
\r
+ if (Index == 3) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
Lba32 += SectorCount;\r
ptrBuffer = (UINT8 *) ptrBuffer + SectorCount * BlockSize;\r
BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);\r
return Status;\r
}\r
\r
+STATIC\r
EFI_STATUS\r
USBFloppyReadCapacity (\r
IN USB_FLOPPY_DEV *UsbFloppyDevice\r
/*++\r
\r
Routine Description:\r
- Retrieves media capacity information via \r
+ Retrieves media capacity information via\r
sending Read Capacity Packet Command.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
---*/ \r
-{ \r
+--*/\r
+{\r
//\r
// status returned by Read Capacity Packet Command\r
//\r
EFI_STATUS Status;\r
ATAPI_PACKET_COMMAND Packet;\r
- EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
\r
//\r
// used for capacity data returned from Usb Floppy\r
\r
ZeroMem (&Data, sizeof (Data));\r
\r
- UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
\r
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
Packet.Inquiry.opcode = READ_CAPACITY;\r
/*++\r
\r
Routine Description:\r
- Retrieves media capacity information via sending Read Format \r
+ Retrieves media capacity information via sending Read Format\r
Capacity Packet Command.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
---*/ \r
-{ \r
+--*/\r
+{\r
//\r
// status returned by Read Capacity Packet Command\r
//\r
EFI_STATUS Status;\r
ATAPI_PACKET_COMMAND Packet;\r
- EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
\r
//\r
// used for capacity data returned from Usb Floppy\r
\r
ZeroMem (&FormatData, sizeof (FormatData));\r
\r
- UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
\r
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
Packet.ReadFormatCapacity.opcode = READ_FORMAT_CAPACITY;\r
} else {\r
\r
UsbFloppyDevice->BlkIo.Media->LastBlock = (FormatData.LastLba3 << 24) |\r
- (FormatData.LastLba2 << 16) | \r
+ (FormatData.LastLba2 << 16) |\r
(FormatData.LastLba1 << 8) |\r
FormatData.LastLba0;\r
\r
/*++\r
\r
Routine Description:\r
- Retrieves Sense Data from device via \r
+ Retrieves Sense Data from device via\r
sending Request Sense Packet Command.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
SenseCounts - A pointer to the number of Sense Data returned.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
---*/ \r
+--*/\r
{\r
EFI_STATUS Status;\r
REQUEST_SENSE_DATA *Sense;\r
UINT8 *Ptr;\r
BOOLEAN SenseReq;\r
ATAPI_PACKET_COMMAND Packet;\r
- EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
\r
- UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
\r
*SenseCounts = 0;\r
\r
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
Packet.RequestSense.opcode = REQUEST_SENSE;\r
Packet.RequestSense.allocation_length = sizeof (REQUEST_SENSE_DATA);\r
- \r
+\r
//\r
// initialize pointer\r
//\r
//\r
SenseReq = FALSE;\r
}\r
- \r
+\r
//\r
// If the sense key numbers exceed Sense Data Buffer size,\r
// just skip the loop and do not fetch the sense key in this function.\r
\r
Routine Description:\r
Sends Test Unit ReadyPacket Command to the device.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
---*/ \r
-{ \r
- ATAPI_PACKET_COMMAND Packet; \r
+--*/\r
+{\r
+ ATAPI_PACKET_COMMAND Packet;\r
EFI_STATUS Status;\r
- EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
UINT32 RetryIndex;\r
UINT32 MaximumRetryTimes;\r
- \r
- UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
+\r
MaximumRetryTimes = 2;\r
//\r
- // fill command packet \r
+ // fill command packet\r
//\r
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
Packet.TestUnitReady.opcode = TEST_UNIT_READY;\r
\r
EFI_STATUS\r
USBFloppyWrite10 (\r
- IN USB_FLOPPY_DEV *UsbFloppyDevice,\r
- IN VOID *Buffer,\r
- IN EFI_LBA Lba,\r
- IN UINTN NumberOfBlocks\r
+ IN USB_FLOPPY_DEV *UsbFloppyDevice,\r
+ IN VOID *Buffer,\r
+ IN EFI_LBA Lba,\r
+ IN UINTN NumberOfBlocks\r
)\r
/*++\r
\r
Routine Description:\r
Sends Write10 Packet Command to device to perform data transfer\r
from host to device.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
- Buffer - A pointer to the source buffer for the data. \r
+ Buffer - A pointer to the source buffer for the data.\r
The caller is responsible for either having implicit\r
or explicit ownership of the buffer.\r
- Lba - The starting logical block address to written to \r
+ Lba - The starting logical block address to written to\r
the device.\r
- NumberOfBlocks - Indicates the number of blocks that the write \r
+ NumberOfBlocks - Indicates the number of blocks that the write\r
operation requests.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
---*/ \r
+--*/\r
{\r
ATAPI_PACKET_COMMAND Packet;\r
READ10_CMD *Write10Packet;\r
VOID *ptrBuffer;\r
EFI_STATUS Status;\r
UINT16 TimeOut;\r
- EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
- UINTN SenseCounts;\r
+ UINT8 Index;\r
\r
- UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
\r
//\r
// prepare command packet for the Write10 Packet Command.\r
while (BlocksRemaining > 0) {\r
\r
if (BlocksRemaining <= MaxBlock) {\r
-\r
SectorCount = BlocksRemaining;\r
} else {\r
-\r
SectorCount = MaxBlock;\r
}\r
- //\r
- // fill the Packet data structure\r
- //\r
- Write10Packet->opcode = WRITE_10;\r
\r
- //\r
- // Lba0 ~ Lba3 specify the start logical block address\r
- // of the data transfer.\r
- // Lba0 is MSB, Lba3 is LSB\r
- //\r
- Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff);\r
- Write10Packet->Lba2 = (UINT8) (Lba32 >> 8);\r
- Write10Packet->Lba1 = (UINT8) (Lba32 >> 16);\r
- Write10Packet->Lba0 = (UINT8) (Lba32 >> 24);\r
+ for (Index = 0; Index < 3; Index ++) {\r
+ //\r
+ // fill the Packet data structure\r
+ //\r
+ Write10Packet->opcode = WRITE_10;\r
\r
- //\r
- // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
- // TranLen0 is MSB, TranLen is LSB\r
- //\r
- Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);\r
- Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8);\r
+ //\r
+ // Lba0 ~ Lba3 specify the start logical block address\r
+ // of the data transfer.\r
+ // Lba0 is MSB, Lba3 is LSB\r
+ //\r
+ Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff);\r
+ Write10Packet->Lba2 = (UINT8) (Lba32 >> 8);\r
+ Write10Packet->Lba1 = (UINT8) (Lba32 >> 16);\r
+ Write10Packet->Lba0 = (UINT8) (Lba32 >> 24);\r
\r
- ByteCount = SectorCount * BlockSize;\r
+ //\r
+ // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
+ // TranLen0 is MSB, TranLen is LSB\r
+ //\r
+ Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);\r
+ Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8);\r
\r
- TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
+ ByteCount = SectorCount * BlockSize;\r
\r
- Status = USBFloppyPacketCommand (\r
- UsbFloppyDevice,\r
- &Packet,\r
- sizeof (ATAPI_PACKET_COMMAND),\r
- (VOID *) ptrBuffer,\r
- ByteCount,\r
- EfiUsbDataOut,\r
- TimeOut\r
- );\r
- if (EFI_ERROR (Status)) {\r
- Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts);\r
- if (!EFI_ERROR (Status)) {\r
- if (IsLogicalUnitCommunicationOverRun (\r
- UsbFloppyDevice->SenseData,\r
- SenseCounts\r
- )) {\r
- Lba32 = (UINT32) Lba;\r
- ptrBuffer = Buffer;\r
- BlocksRemaining = (UINT16) NumberOfBlocks;\r
- MaxBlock = (UINT16) (MaxBlock / 4);\r
- if (MaxBlock < 1) {\r
- MaxBlock = 1;\r
- }\r
+ TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
\r
- continue;\r
- }\r
- }\r
- //\r
- // retry write10 command\r
- //\r
Status = USBFloppyPacketCommand (\r
- UsbFloppyDevice,\r
- &Packet,\r
- sizeof (ATAPI_PACKET_COMMAND),\r
- (VOID *) ptrBuffer,\r
- ByteCount,\r
- EfiUsbDataOut,\r
- TimeOut\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_DEVICE_ERROR;\r
+ UsbFloppyDevice,\r
+ &Packet,\r
+ sizeof (ATAPI_PACKET_COMMAND),\r
+ (VOID *) ptrBuffer,\r
+ ByteCount,\r
+ EfiUsbDataOut,\r
+ TimeOut\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ break;\r
}\r
}\r
\r
+ if (Index == 3) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
Lba32 += SectorCount;\r
ptrBuffer = (UINT8 *) ptrBuffer + SectorCount * BlockSize;\r
BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);\r
\r
Routine Description:\r
Retrieves media information.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
MediaChange - Indicates whether media was changed.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
EFI_INVALID_PARAMETER - Parameter is error\r
---*/ \r
+--*/\r
{\r
EFI_STATUS Status;\r
EFI_STATUS FloppyStatus;\r
UINTN RetryTimes;\r
UINTN MaximumRetryTimes;\r
BOOLEAN NeedRetry;\r
-\r
+ BOOLEAN NeedReadCapacity;\r
//\r
// a flag used to determine whether need to perform Read Capacity command.\r
//\r
- BOOLEAN NeedReadCapacity;\r
-\r
- REQUEST_SENSE_DATA *SensePtr;\r
\r
//\r
// init\r
\r
if (!EFI_ERROR (Status)) {\r
\r
- SensePtr = UsbFloppyDevice->SenseData;\r
-\r
//\r
// No Media\r
//\r
if (IsMediaChange (UsbFloppyDevice->SenseData, SenseCounts)) {\r
UsbFloppyDevice->BlkIo.Media->MediaId++;\r
}\r
- \r
+\r
//\r
// Media Write-protected\r
//\r
if (IsMediaWriteProtected (UsbFloppyDevice->SenseData, SenseCounts)) {\r
UsbFloppyDevice->BlkIo.Media->ReadOnly = TRUE;\r
}\r
- \r
+\r
//\r
// Media Error\r
//\r
Status = USBFloppyReadCapacity (UsbFloppyDevice);\r
break;\r
\r
- case USBFLOPPY:\r
+ case USBFLOPPY2:\r
UsbMassStorageModeSense (UsbFloppyDevice);\r
Status = USBFloppyReadFormatCapacity (UsbFloppyDevice);\r
if (EFI_ERROR (Status) || !UsbFloppyDevice->BlkMedia.MediaPresent) {\r
//\r
// retry the ReadCapacity command\r
//\r
- UsbFloppyDevice->DeviceType = USBFLOPPY2;\r
+ UsbFloppyDevice->DeviceType = USBFLOPPY;\r
Status = EFI_DEVICE_ERROR;\r
}\r
break;\r
\r
- case USBFLOPPY2:\r
+ case USBFLOPPY:\r
UsbMassStorageModeSense (UsbFloppyDevice);\r
Status = USBFloppyReadCapacity (UsbFloppyDevice);\r
if (EFI_ERROR (Status)) {\r
//\r
// retry the ReadFormatCapacity command\r
//\r
- UsbFloppyDevice->DeviceType = USBFLOPPY;\r
+ UsbFloppyDevice->DeviceType = USBFLOPPY2;\r
}\r
//\r
// force the BlockSize to be 0x200.\r
}\r
\r
if (!IsDriveReady (UsbFloppyDevice->SenseData, SenseCounts, &NeedRetry)) {\r
- \r
+\r
//\r
// Drive not ready: if NeedRetry, then retry once more;\r
// else return error\r
/*++\r
\r
Routine Description:\r
- Retrieves media capacity information via sending Read Format \r
+ Retrieves media capacity information via sending Read Format\r
Capacity Packet Command.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
- \r
---*/ \r
-{ \r
+\r
+--*/\r
+{\r
//\r
// status returned by Read Capacity Packet Command\r
//\r
EFI_STATUS Status;\r
ATAPI_PACKET_COMMAND Packet;\r
- EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
UFI_MODE_PARAMETER_PAGE_5 ModePage5;\r
EFI_LBA LastBlock;\r
UINT32 SectorsPerTrack;\r
UINT32 NumberOfHeads;\r
UINT32 DataBytesPerSector;\r
\r
- UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
\r
ZeroMem (&ModePage5, sizeof (UFI_MODE_PARAMETER_PAGE_5));\r
\r
/*++\r
\r
Routine Description:\r
- Retrieves media capacity information via sending Read Format \r
+ Retrieves media capacity information via sending Read Format\r
Capacity Packet Command.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
- \r
---*/ \r
-{ \r
+\r
+--*/\r
+{\r
//\r
// status returned by Read Capacity Packet Command\r
//\r
EFI_STATUS Status;\r
ATAPI_PACKET_COMMAND Packet;\r
- EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
UFI_MODE_PARAMETER_PAGE_1C ModePage1C;\r
\r
- UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
\r
ZeroMem (&ModePage1C, sizeof (UFI_MODE_PARAMETER_PAGE_1C));\r
\r
Routine Description:\r
Retrieves mode sense information via sending Mode Sense\r
Packet Command.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
\r
---*/ \r
-{ \r
+--*/\r
+{\r
//\r
// status returned by Read Capacity Packet Command\r
//\r
EFI_STATUS Status;\r
ATAPI_PACKET_COMMAND Packet;\r
- EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
UFI_MODE_PARAMETER_HEADER Header;\r
UINT32 Size;\r
\r
- UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
\r
Size = sizeof (UFI_MODE_PARAMETER_HEADER);\r
\r
Routine Description:\r
Retrieves mode sense information via sending Mode Sense\r
Packet Command.\r
- \r
+\r
Arguments:\r
UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_DEVICE_ERROR - Hardware error\r
EFI_SUCCESS - Success\r
- \r
---*/ \r
-{ \r
+\r
+--*/\r
+{\r
//\r
// status returned by Read Capacity Packet Command\r
//\r
EFI_STATUS Status;\r
ATAPI_PACKET_COMMAND Packet;\r
- EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
SCSI_MODE_PARAMETER_HEADER6 Header;\r
UINT32 Size;\r
\r
- UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
\r
Size = sizeof (SCSI_MODE_PARAMETER_HEADER6);\r
\r
\r
for (Index = 0; Index < SenseCounts; Index++) {\r
\r
- if ((SensePtr->sense_key == SK_NOT_READY) && \r
+ if ((SensePtr->sense_key == SK_NOT_READY) &&\r
(SensePtr->addnl_sense_code == ASC_NO_MEDIA)) {\r
\r
NoMedia = TRUE;\r
for (Index = 0; Index < SenseCounts; Index++) {\r
\r
switch (SensePtr->sense_key) {\r
- \r
+\r
//\r
// Medium error case\r
//\r
return IsWriteProtected;\r
}\r
\r
-BOOLEAN\r
-IsLogicalUnitCommunicationOverRun (\r
- IN REQUEST_SENSE_DATA *SenseData,\r
- IN UINTN SenseCounts\r
- )\r
-{\r
- REQUEST_SENSE_DATA *SensePtr;\r
- UINTN Index;\r
- BOOLEAN IsOverRun;\r
-\r
- IsOverRun = FALSE;\r
- SensePtr = SenseData;\r
-\r
- for (Index = 0; Index < SenseCounts; Index++) {\r
-\r
- if ((SensePtr->sense_key == SK_NOT_READY) &&\r
- (SensePtr->addnl_sense_code == ASC_LOGICAL_UNIT_STATUS) &&\r
- (SensePtr->addnl_sense_code_qualifier == ASCQ_LOGICAL_UNIT_OVERRUN)) {\r
- IsOverRun = TRUE;\r
- }\r
-\r
- SensePtr++;\r
- }\r
-\r
- return IsOverRun;\r
-}\r