X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FBus%2FUsb%2FUsbMassStorage%2FDxe%2FUsbMassStorageHelper.c;h=eb7a8bb63a44373fce6505d2464135d3fea54f07;hp=3d6a6d977b2e983ec759cac351c87378b91d1516;hb=c111036f2028bbf2dd91b956be10addb31e8b3b1;hpb=71a62114eb16255adaf886be35edecf0045bb494 diff --git a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.c b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.c index 3d6a6d977b..eb7a8bb63a 100644 --- a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.c +++ b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.c @@ -1,18 +1,18 @@ /*++ -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: UsbMassStorageHelper.c - + Abstract: Helper functions for USB Mass Storage Driver @@ -59,12 +59,6 @@ IsMediaWriteProtected ( IN UINTN SenseCounts ); -STATIC -BOOLEAN -IsLogicalUnitCommunicationOverRun ( - IN REQUEST_SENSE_DATA *SenseData, - IN UINTN SenseCounts - ); EFI_STATUS USBFloppyPacketCommand ( @@ -80,19 +74,19 @@ USBFloppyPacketCommand ( Routine Description: Sends Packet Command to USB Floppy Drive. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. Command - A pointer to the command packet. CommandSize - Indicates the size of the command packet. DataBuffer - A pointer to the buffer for the data transfer - after the command packet. + after the command packet. BufferLength - Indicates the size of the Data Buffer. Direction - Transfer Direction TimeOutInMilliSeconds - Timeout Value - Returns: + Returns: EFI_SUCCESS - Success ---*/ +--*/ { EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; EFI_STATUS Status; @@ -123,14 +117,14 @@ USBFloppyIdentify ( Routine Description: Retrieves device information to tell the device type. - + Arguments: UsbFloppyDevice The USB_FLOPPY_DEV instance. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success ---*/ +--*/ { EFI_STATUS Status; @@ -144,7 +138,7 @@ USBFloppyIdentify ( if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } - + // // Get media removable info from INQUIRY data. // @@ -201,7 +195,7 @@ USBFloppyIdentify ( gBS->FreePool (Idata); return EFI_DEVICE_ERROR; } - + // // Get media information. // @@ -221,22 +215,20 @@ USBFloppyInquiry ( Routine Description: Send Inquiry Packet Command to device and retrieve Inquiry Data. - + Arguments: UsbFloppyDevice The USB_FLOPPY_DEV instance. - Idata A pointer pointing to the address of + Idata A pointer pointing to the address of Inquiry Data. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success ---*/ +--*/ { ATAPI_PACKET_COMMAND Packet; EFI_STATUS Status; - EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; - UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; // // prepare command packet for the Inquiry Packet Command. @@ -272,31 +264,31 @@ USBFloppyInquiry ( EFI_STATUS USBFloppyRead10 ( - IN USB_FLOPPY_DEV *UsbFloppyDevice, - IN VOID *Buffer, - IN EFI_LBA Lba, - IN UINTN NumberOfBlocks + IN USB_FLOPPY_DEV *UsbFloppyDevice, + IN VOID *Buffer, + IN EFI_LBA Lba, + IN UINTN NumberOfBlocks ) /*++ Routine Description: Sends Read10 Packet Command to device to perform data transfer from device to host. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. - Buffer - A pointer to the destination buffer for the data. + Buffer - A pointer to the destination buffer for the data. The caller is responsible for either having implicit or explicit ownership of the buffer. - Lba - The starting logical block address to read from + Lba - The starting logical block address to read from on the device. - NumberOfBlocks - Indicates the number of blocks that the read + NumberOfBlocks - Indicates the number of blocks that the read operation requests. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success ---*/ +--*/ { ATAPI_PACKET_COMMAND Packet; READ10_CMD *Read10Packet; @@ -309,10 +301,8 @@ USBFloppyRead10 ( VOID *ptrBuffer; EFI_STATUS Status; UINT16 TimeOut; - EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; - UINTN SenseCounts; + UINT8 Index; - UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; // // prepare command packet for the Inquiry Packet Command. @@ -333,78 +323,52 @@ USBFloppyRead10 ( } else { SectorCount = MaxBlock; } - // - // fill the Packet data structure - // - Read10Packet->opcode = READ_10; - // - // Lba0 ~ Lba3 specify the start logical block address of the data transfer. - // Lba0 is MSB, Lba3 is LSB - // - Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff); - Read10Packet->Lba2 = (UINT8) (Lba32 >> 8); - Read10Packet->Lba1 = (UINT8) (Lba32 >> 16); - Read10Packet->Lba0 = (UINT8) (Lba32 >> 24); + for (Index = 0; Index < 3; Index ++) { - // - // TranLen0 ~ TranLen1 specify the transfer length in block unit. - // TranLen0 is MSB, TranLen is LSB - // - Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff); - Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8); + // + // fill the Packet data structure + // + Read10Packet->opcode = READ_10; + // + // Lba0 ~ Lba3 specify the start logical block address of the data transfer. + // Lba0 is MSB, Lba3 is LSB + // + Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff); + Read10Packet->Lba2 = (UINT8) (Lba32 >> 8); + Read10Packet->Lba1 = (UINT8) (Lba32 >> 16); + Read10Packet->Lba0 = (UINT8) (Lba32 >> 24); - ByteCount = SectorCount * BlockSize; + // + // TranLen0 ~ TranLen1 specify the transfer length in block unit. + // TranLen0 is MSB, TranLen is LSB + // + Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff); + Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8); - TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT); + ByteCount = SectorCount * BlockSize; - Status = USBFloppyPacketCommand ( - UsbFloppyDevice, - &Packet, - sizeof (ATAPI_PACKET_COMMAND), - (VOID *) ptrBuffer, - ByteCount, - EfiUsbDataIn, - TimeOut - ); - if (EFI_ERROR (Status)) { + TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT); - Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts); - if (!EFI_ERROR (Status)) { - if (IsLogicalUnitCommunicationOverRun ( - UsbFloppyDevice->SenseData, - SenseCounts - )) { - Lba32 = (UINT32) Lba; - ptrBuffer = Buffer; - BlocksRemaining = (UINT16) NumberOfBlocks; - MaxBlock = (UINT16) (MaxBlock / 4); - if (MaxBlock < 1) { - MaxBlock = 1; - } - continue; - } - } else { - return EFI_DEVICE_ERROR; - } - // - // retry read10 command - // Status = USBFloppyPacketCommand ( - UsbFloppyDevice, - &Packet, - sizeof (ATAPI_PACKET_COMMAND), - (VOID *) ptrBuffer, - ByteCount, - EfiUsbDataIn, - TimeOut - ); - if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + UsbFloppyDevice, + &Packet, + sizeof (ATAPI_PACKET_COMMAND), + (VOID *) ptrBuffer, + ByteCount, + EfiUsbDataIn, + TimeOut + ); + if (!EFI_ERROR (Status)) { + break; } } + if (Index == 3) { + return EFI_DEVICE_ERROR; + } + Lba32 += SectorCount; ptrBuffer = (UINT8 *) ptrBuffer + SectorCount * BlockSize; BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount); @@ -413,6 +377,7 @@ USBFloppyRead10 ( return Status; } +STATIC EFI_STATUS USBFloppyReadCapacity ( IN USB_FLOPPY_DEV *UsbFloppyDevice @@ -420,23 +385,22 @@ USBFloppyReadCapacity ( /*++ Routine Description: - Retrieves media capacity information via + Retrieves media capacity information via sending Read Capacity Packet Command. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success ---*/ -{ +--*/ +{ // // status returned by Read Capacity Packet Command // EFI_STATUS Status; ATAPI_PACKET_COMMAND Packet; - EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; // // used for capacity data returned from Usb Floppy @@ -445,7 +409,6 @@ USBFloppyReadCapacity ( ZeroMem (&Data, sizeof (Data)); - UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND)); Packet.Inquiry.opcode = READ_CAPACITY; @@ -483,23 +446,22 @@ USBFloppyReadFormatCapacity ( /*++ Routine Description: - Retrieves media capacity information via sending Read Format + Retrieves media capacity information via sending Read Format Capacity Packet Command. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success ---*/ -{ +--*/ +{ // // status returned by Read Capacity Packet Command // EFI_STATUS Status; ATAPI_PACKET_COMMAND Packet; - EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; // // used for capacity data returned from Usb Floppy @@ -508,7 +470,6 @@ USBFloppyReadFormatCapacity ( ZeroMem (&FormatData, sizeof (FormatData)); - UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND)); Packet.ReadFormatCapacity.opcode = READ_FORMAT_CAPACITY; @@ -537,7 +498,7 @@ USBFloppyReadFormatCapacity ( } else { UsbFloppyDevice->BlkIo.Media->LastBlock = (FormatData.LastLba3 << 24) | - (FormatData.LastLba2 << 16) | + (FormatData.LastLba2 << 16) | (FormatData.LastLba1 << 8) | FormatData.LastLba0; @@ -565,26 +526,24 @@ UsbFloppyRequestSense ( /*++ Routine Description: - Retrieves Sense Data from device via + Retrieves Sense Data from device via sending Request Sense Packet Command. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. SenseCounts - A pointer to the number of Sense Data returned. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success ---*/ +--*/ { EFI_STATUS Status; REQUEST_SENSE_DATA *Sense; UINT8 *Ptr; BOOLEAN SenseReq; ATAPI_PACKET_COMMAND Packet; - EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; - UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; *SenseCounts = 0; @@ -598,7 +557,7 @@ UsbFloppyRequestSense ( ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND)); Packet.RequestSense.opcode = REQUEST_SENSE; Packet.RequestSense.allocation_length = sizeof (REQUEST_SENSE_DATA); - + // // initialize pointer // @@ -666,7 +625,7 @@ UsbFloppyRequestSense ( // SenseReq = FALSE; } - + // // If the sense key numbers exceed Sense Data Buffer size, // just skip the loop and do not fetch the sense key in this function. @@ -687,25 +646,23 @@ UsbFloppyTestUnitReady ( Routine Description: Sends Test Unit ReadyPacket Command to the device. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success ---*/ -{ - ATAPI_PACKET_COMMAND Packet; +--*/ +{ + ATAPI_PACKET_COMMAND Packet; EFI_STATUS Status; - EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; UINT32 RetryIndex; UINT32 MaximumRetryTimes; - - UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; + MaximumRetryTimes = 2; // - // fill command packet + // fill command packet // ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND)); Packet.TestUnitReady.opcode = TEST_UNIT_READY; @@ -737,31 +694,31 @@ UsbFloppyTestUnitReady ( EFI_STATUS USBFloppyWrite10 ( - IN USB_FLOPPY_DEV *UsbFloppyDevice, - IN VOID *Buffer, - IN EFI_LBA Lba, - IN UINTN NumberOfBlocks + IN USB_FLOPPY_DEV *UsbFloppyDevice, + IN VOID *Buffer, + IN EFI_LBA Lba, + IN UINTN NumberOfBlocks ) /*++ Routine Description: Sends Write10 Packet Command to device to perform data transfer from host to device. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. - Buffer - A pointer to the source buffer for the data. + Buffer - A pointer to the source buffer for the data. The caller is responsible for either having implicit or explicit ownership of the buffer. - Lba - The starting logical block address to written to + Lba - The starting logical block address to written to the device. - NumberOfBlocks - Indicates the number of blocks that the write + NumberOfBlocks - Indicates the number of blocks that the write operation requests. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success ---*/ +--*/ { ATAPI_PACKET_COMMAND Packet; READ10_CMD *Write10Packet; @@ -774,10 +731,8 @@ USBFloppyWrite10 ( VOID *ptrBuffer; EFI_STATUS Status; UINT16 TimeOut; - EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; - UINTN SenseCounts; + UINT8 Index; - UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; // // prepare command packet for the Write10 Packet Command. @@ -795,82 +750,56 @@ USBFloppyWrite10 ( while (BlocksRemaining > 0) { if (BlocksRemaining <= MaxBlock) { - SectorCount = BlocksRemaining; } else { - SectorCount = MaxBlock; } - // - // fill the Packet data structure - // - Write10Packet->opcode = WRITE_10; - // - // Lba0 ~ Lba3 specify the start logical block address - // of the data transfer. - // Lba0 is MSB, Lba3 is LSB - // - Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff); - Write10Packet->Lba2 = (UINT8) (Lba32 >> 8); - Write10Packet->Lba1 = (UINT8) (Lba32 >> 16); - Write10Packet->Lba0 = (UINT8) (Lba32 >> 24); + for (Index = 0; Index < 3; Index ++) { + // + // fill the Packet data structure + // + Write10Packet->opcode = WRITE_10; - // - // TranLen0 ~ TranLen1 specify the transfer length in block unit. - // TranLen0 is MSB, TranLen is LSB - // - Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff); - Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8); + // + // Lba0 ~ Lba3 specify the start logical block address + // of the data transfer. + // Lba0 is MSB, Lba3 is LSB + // + Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff); + Write10Packet->Lba2 = (UINT8) (Lba32 >> 8); + Write10Packet->Lba1 = (UINT8) (Lba32 >> 16); + Write10Packet->Lba0 = (UINT8) (Lba32 >> 24); - ByteCount = SectorCount * BlockSize; + // + // TranLen0 ~ TranLen1 specify the transfer length in block unit. + // TranLen0 is MSB, TranLen is LSB + // + Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff); + Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8); - TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT); + ByteCount = SectorCount * BlockSize; - Status = USBFloppyPacketCommand ( - UsbFloppyDevice, - &Packet, - sizeof (ATAPI_PACKET_COMMAND), - (VOID *) ptrBuffer, - ByteCount, - EfiUsbDataOut, - TimeOut - ); - if (EFI_ERROR (Status)) { - Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts); - if (!EFI_ERROR (Status)) { - if (IsLogicalUnitCommunicationOverRun ( - UsbFloppyDevice->SenseData, - SenseCounts - )) { - Lba32 = (UINT32) Lba; - ptrBuffer = Buffer; - BlocksRemaining = (UINT16) NumberOfBlocks; - MaxBlock = (UINT16) (MaxBlock / 4); - if (MaxBlock < 1) { - MaxBlock = 1; - } + TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT); - continue; - } - } - // - // retry write10 command - // Status = USBFloppyPacketCommand ( - UsbFloppyDevice, - &Packet, - sizeof (ATAPI_PACKET_COMMAND), - (VOID *) ptrBuffer, - ByteCount, - EfiUsbDataOut, - TimeOut - ); - if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + UsbFloppyDevice, + &Packet, + sizeof (ATAPI_PACKET_COMMAND), + (VOID *) ptrBuffer, + ByteCount, + EfiUsbDataOut, + TimeOut + ); + if (!EFI_ERROR (Status)) { + break; } } + if (Index == 3) { + return EFI_DEVICE_ERROR; + } + Lba32 += SectorCount; ptrBuffer = (UINT8 *) ptrBuffer + SectorCount * BlockSize; BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount); @@ -888,16 +817,16 @@ UsbFloppyDetectMedia ( Routine Description: Retrieves media information. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. MediaChange - Indicates whether media was changed. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success EFI_INVALID_PARAMETER - Parameter is error ---*/ +--*/ { EFI_STATUS Status; EFI_STATUS FloppyStatus; @@ -910,13 +839,10 @@ UsbFloppyDetectMedia ( UINTN RetryTimes; UINTN MaximumRetryTimes; BOOLEAN NeedRetry; - + BOOLEAN NeedReadCapacity; // // a flag used to determine whether need to perform Read Capacity command. // - BOOLEAN NeedReadCapacity; - - REQUEST_SENSE_DATA *SensePtr; // // init @@ -937,8 +863,6 @@ UsbFloppyDetectMedia ( if (!EFI_ERROR (Status)) { - SensePtr = UsbFloppyDevice->SenseData; - // // No Media // @@ -955,14 +879,14 @@ UsbFloppyDetectMedia ( if (IsMediaChange (UsbFloppyDevice->SenseData, SenseCounts)) { UsbFloppyDevice->BlkIo.Media->MediaId++; } - + // // Media Write-protected // if (IsMediaWriteProtected (UsbFloppyDevice->SenseData, SenseCounts)) { UsbFloppyDevice->BlkIo.Media->ReadOnly = TRUE; } - + // // Media Error // @@ -999,26 +923,26 @@ UsbFloppyDetectMedia ( Status = USBFloppyReadCapacity (UsbFloppyDevice); break; - case USBFLOPPY: + case USBFLOPPY2: UsbMassStorageModeSense (UsbFloppyDevice); Status = USBFloppyReadFormatCapacity (UsbFloppyDevice); if (EFI_ERROR (Status) || !UsbFloppyDevice->BlkMedia.MediaPresent) { // // retry the ReadCapacity command // - UsbFloppyDevice->DeviceType = USBFLOPPY2; + UsbFloppyDevice->DeviceType = USBFLOPPY; Status = EFI_DEVICE_ERROR; } break; - case USBFLOPPY2: + case USBFLOPPY: UsbMassStorageModeSense (UsbFloppyDevice); Status = USBFloppyReadCapacity (UsbFloppyDevice); if (EFI_ERROR (Status)) { // // retry the ReadFormatCapacity command // - UsbFloppyDevice->DeviceType = USBFLOPPY; + UsbFloppyDevice->DeviceType = USBFLOPPY2; } // // force the BlockSize to be 0x200. @@ -1078,7 +1002,7 @@ UsbFloppyDetectMedia ( } if (!IsDriveReady (UsbFloppyDevice->SenseData, SenseCounts, &NeedRetry)) { - + // // Drive not ready: if NeedRetry, then retry once more; // else return error @@ -1160,24 +1084,23 @@ UsbFloppyModeSense5APage5 ( /*++ Routine Description: - Retrieves media capacity information via sending Read Format + Retrieves media capacity information via sending Read Format Capacity Packet Command. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success - ---*/ -{ + +--*/ +{ // // status returned by Read Capacity Packet Command // EFI_STATUS Status; ATAPI_PACKET_COMMAND Packet; - EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; UFI_MODE_PARAMETER_PAGE_5 ModePage5; EFI_LBA LastBlock; UINT32 SectorsPerTrack; @@ -1185,7 +1108,6 @@ UsbFloppyModeSense5APage5 ( UINT32 NumberOfHeads; UINT32 DataBytesPerSector; - UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; ZeroMem (&ModePage5, sizeof (UFI_MODE_PARAMETER_PAGE_5)); @@ -1246,27 +1168,25 @@ UsbFloppyModeSense5APage1C ( /*++ Routine Description: - Retrieves media capacity information via sending Read Format + Retrieves media capacity information via sending Read Format Capacity Packet Command. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success - ---*/ -{ + +--*/ +{ // // status returned by Read Capacity Packet Command // EFI_STATUS Status; ATAPI_PACKET_COMMAND Packet; - EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; UFI_MODE_PARAMETER_PAGE_1C ModePage1C; - UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; ZeroMem (&ModePage1C, sizeof (UFI_MODE_PARAMETER_PAGE_1C)); @@ -1323,26 +1243,24 @@ UsbFloppyModeSense5APage3F ( Routine Description: Retrieves mode sense information via sending Mode Sense Packet Command. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success ---*/ -{ +--*/ +{ // // status returned by Read Capacity Packet Command // EFI_STATUS Status; ATAPI_PACKET_COMMAND Packet; - EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; UFI_MODE_PARAMETER_HEADER Header; UINT32 Size; - UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; Size = sizeof (UFI_MODE_PARAMETER_HEADER); @@ -1381,26 +1299,24 @@ UsbSCSIModeSense1APage3F ( Routine Description: Retrieves mode sense information via sending Mode Sense Packet Command. - + Arguments: UsbFloppyDevice - The USB_FLOPPY_DEV instance. - - Returns: + + Returns: EFI_DEVICE_ERROR - Hardware error EFI_SUCCESS - Success - ---*/ -{ + +--*/ +{ // // status returned by Read Capacity Packet Command // EFI_STATUS Status; ATAPI_PACKET_COMMAND Packet; - EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface; SCSI_MODE_PARAMETER_HEADER6 Header; UINT32 Size; - UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol; Size = sizeof (SCSI_MODE_PARAMETER_HEADER6); @@ -1450,7 +1366,7 @@ IsNoMedia ( for (Index = 0; Index < SenseCounts; Index++) { - if ((SensePtr->sense_key == SK_NOT_READY) && + if ((SensePtr->sense_key == SK_NOT_READY) && (SensePtr->addnl_sense_code == ASC_NO_MEDIA)) { NoMedia = TRUE; @@ -1479,7 +1395,7 @@ IsMediaError ( for (Index = 0; Index < SenseCounts; Index++) { switch (SensePtr->sense_key) { - + // // Medium error case // @@ -1624,29 +1540,3 @@ IsMediaWriteProtected ( return IsWriteProtected; } -BOOLEAN -IsLogicalUnitCommunicationOverRun ( - IN REQUEST_SENSE_DATA *SenseData, - IN UINTN SenseCounts - ) -{ - REQUEST_SENSE_DATA *SensePtr; - UINTN Index; - BOOLEAN IsOverRun; - - IsOverRun = FALSE; - SensePtr = SenseData; - - for (Index = 0; Index < SenseCounts; Index++) { - - if ((SensePtr->sense_key == SK_NOT_READY) && - (SensePtr->addnl_sense_code == ASC_LOGICAL_UNIT_STATUS) && - (SensePtr->addnl_sense_code_qualifier == ASCQ_LOGICAL_UNIT_OVERRUN)) { - IsOverRun = TRUE; - } - - SensePtr++; - } - - return IsOverRun; -}