/*++\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
UsbMassStorage.c\r
- \r
+\r
Abstract:\r
\r
USB Mass Storage Driver\r
EFI_OUT_OF_RESOURCES- Can't allocate memory resources\r
EFI_ALREADY_STARTED - Thios driver has been started\r
--*/\r
-{ \r
- EFI_STATUS Status; \r
+{\r
+ EFI_STATUS Status;\r
EFI_USB_ATAPI_PROTOCOL *AtapiProtocol;\r
USB_FLOPPY_DEV *UsbFloppyDevice;\r
- \r
+\r
UsbFloppyDevice = NULL;\r
//\r
// Check whether Usb Atapi Protocol attached on the controller handle.\r
EFI_DEVICE_ERROR\r
others\r
\r
---*/ \r
+--*/\r
{\r
EFI_STATUS Status;\r
USB_FLOPPY_DEV *UsbFloppyDevice;\r
\r
Routine Description:\r
Implements EFI_BLOCK_IO_PROTOCOL.Reset() function.\r
- \r
+\r
Arguments:\r
This The EFI_BLOCK_IO_PROTOCOL instance.\r
ExtendedVerification\r
Indicates that the driver may perform a more exhaustive\r
verification operation of the device during reset.\r
(This parameter is ingored in this driver.)\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_SUCCESS - Success\r
---*/ \r
+--*/\r
{\r
USB_FLOPPY_DEV *UsbFloppyDevice;\r
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;\r
//\r
// directly calling EFI_USB_ATAPI_PROTOCOL.Reset() to implement reset.\r
//\r
- Status = UsbAtapiInterface->UsbAtapiReset (UsbAtapiInterface, TRUE);\r
+ Status = UsbAtapiInterface->UsbAtapiReset (UsbAtapiInterface, ExtendedVerification);\r
\r
return Status;\r
}\r
\r
Routine Description:\r
Implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks() function.\r
- \r
+\r
Arguments:\r
This The EFI_BLOCK_IO_PROTOCOL instance.\r
MediaId The media id that the read request is for.\r
LBA The starting logical block address to read from on the device.\r
BufferSize\r
- The size of the Buffer in bytes. This must be a multiple of \r
+ The size of the Buffer in bytes. This must be a multiple of\r
the intrinsic block size of the device.\r
- Buffer A pointer to the destination buffer for the data. The caller \r
+ Buffer A pointer to the destination buffer for the data. The caller\r
is responsible for either having implicit or explicit ownership\r
- of the buffer. \r
- \r
- Returns: \r
+ of the buffer.\r
+\r
+ Returns:\r
EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success \r
+ EFI_SUCCESS - Success\r
EFI_DEVICE_ERROR - Hardware Error\r
EFI_NO_MEDIA - No media\r
EFI_MEDIA_CHANGED - Media Change\r
EFI_BAD_BUFFER_SIZE - Buffer size is bad\r
- --*/ \r
+ --*/\r
{\r
USB_FLOPPY_DEV *UsbFloppyDevice;\r
EFI_STATUS Status;\r
UINTN BlockSize;\r
UINTN NumberOfBlocks;\r
BOOLEAN MediaChange;\r
- EFI_TPL OldTpl;\r
\r
- OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
Status = EFI_SUCCESS;\r
MediaChange = FALSE;\r
-\r
UsbFloppyDevice = USB_FLOPPY_DEV_FROM_THIS (This);\r
\r
//\r
}\r
\r
if (MediaChange) {\r
- gBS->RestoreTPL (OldTpl);\r
gBS->ReinstallProtocolInterface (\r
UsbFloppyDevice->Handle,\r
&gEfiBlockIoProtocolGuid,\r
&UsbFloppyDevice->BlkIo,\r
&UsbFloppyDevice->BlkIo\r
);\r
- gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
}\r
\r
Media = UsbFloppyDevice->BlkIo.Media;\r
goto Done;\r
}\r
\r
- if (!EFI_ERROR (Status)) {\r
-\r
- Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, 1);\r
- if (EFI_ERROR (Status)) {\r
- This->Reset (This, TRUE);\r
- Status = EFI_DEVICE_ERROR;\r
- goto Done;\r
- }\r
-\r
- LBA += 1;\r
- NumberOfBlocks -= 1;\r
- Buffer = (UINT8 *) Buffer + This->Media->BlockSize;\r
+ while (NumberOfBlocks > 0) {\r
\r
- if (NumberOfBlocks == 0) {\r
- Status = EFI_SUCCESS;\r
- goto Done;\r
+ if (NumberOfBlocks > BLOCK_UNIT) {\r
+ Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, BLOCK_UNIT);\r
+ } else {\r
+ Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);\r
}\r
\r
- Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);\r
if (EFI_ERROR (Status)) {\r
This->Reset (This, TRUE);\r
Status = EFI_DEVICE_ERROR;\r
}\r
- }\r
\r
-Done:\r
- gBS->RestoreTPL (OldTpl);\r
+ if (NumberOfBlocks > BLOCK_UNIT) {\r
+ NumberOfBlocks -= BLOCK_UNIT;\r
+ LBA += BLOCK_UNIT;\r
+ Buffer = (UINT8 *) Buffer + This->Media->BlockSize * BLOCK_UNIT;\r
+ } else {\r
+ NumberOfBlocks -= NumberOfBlocks;\r
+ LBA += NumberOfBlocks;\r
+ Buffer = (UINT8 *) Buffer + This->Media->BlockSize * NumberOfBlocks;\r
+ }\r
+ }\r
+\r
+ Done:\r
return Status;\r
}\r
\r
\r
Routine Description:\r
Implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks() function.\r
- \r
+\r
Arguments:\r
This The EFI_BLOCK_IO_PROTOCOL instance.\r
MediaId The media id that the write request is for.\r
LBA The starting logical block address to be written.\r
- The caller is responsible for writing to only \r
+ The caller is responsible for writing to only\r
legitimate locations.\r
BufferSize\r
- The size of the Buffer in bytes. This must be a multiple of \r
+ The size of the Buffer in bytes. This must be a multiple of\r
the intrinsic block size of the device.\r
- Buffer A pointer to the source buffer for the data. The caller \r
+ Buffer A pointer to the source buffer for the data. The caller\r
is responsible for either having implicit or explicit ownership\r
- of the buffer. \r
- \r
- Returns: \r
+ of the buffer.\r
+\r
+ Returns:\r
EFI_INVALID_PARAMETER - Parameter is error\r
- EFI_SUCCESS - Success \r
+ EFI_SUCCESS - Success\r
EFI_DEVICE_ERROR - Hardware Error\r
EFI_NO_MEDIA - No media\r
EFI_MEDIA_CHANGED - Media Change\r
EFI_BAD_BUFFER_SIZE - Buffer size is bad\r
\r
---*/ \r
+--*/\r
{\r
USB_FLOPPY_DEV *UsbFloppyDevice;\r
EFI_STATUS Status;\r
UINTN BlockSize;\r
UINTN NumberOfBlocks;\r
BOOLEAN MediaChange;\r
- EFI_TPL OldTpl;\r
\r
- OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
Status = EFI_SUCCESS;\r
MediaChange = FALSE;\r
\r
}\r
\r
if (MediaChange) {\r
- gBS->RestoreTPL (OldTpl);\r
gBS->ReinstallProtocolInterface (\r
UsbFloppyDevice->Handle,\r
&gEfiBlockIoProtocolGuid,\r
&UsbFloppyDevice->BlkIo,\r
&UsbFloppyDevice->BlkIo\r
);\r
- gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
}\r
\r
Media = UsbFloppyDevice->BlkIo.Media;\r
goto Done;\r
}\r
\r
- if (!EFI_ERROR (Status)) {\r
- Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, 1);\r
- if (EFI_ERROR (Status)) {\r
- This->Reset (This, TRUE);\r
- Status = EFI_DEVICE_ERROR;\r
- goto Done;\r
- }\r
-\r
- LBA += 1;\r
- NumberOfBlocks -= 1;\r
- Buffer = (UINT8 *) Buffer + This->Media->BlockSize;\r
+ while (NumberOfBlocks > 0) {\r
\r
- if (NumberOfBlocks == 0) {\r
- Status = EFI_SUCCESS;\r
- goto Done;\r
+ if (NumberOfBlocks > BLOCK_UNIT) {\r
+ Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, BLOCK_UNIT);\r
+ } else {\r
+ Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);\r
}\r
\r
- Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);\r
if (EFI_ERROR (Status)) {\r
This->Reset (This, TRUE);\r
Status = EFI_DEVICE_ERROR;\r
}\r
- }\r
+\r
+ if (NumberOfBlocks > BLOCK_UNIT) {\r
+ NumberOfBlocks -= BLOCK_UNIT;\r
+ LBA += BLOCK_UNIT;\r
+ Buffer = (UINT8 *) Buffer + This->Media->BlockSize * BLOCK_UNIT;\r
+ } else {\r
+ NumberOfBlocks -= NumberOfBlocks;\r
+ LBA += NumberOfBlocks;\r
+ Buffer = (UINT8 *) Buffer + This->Media->BlockSize * NumberOfBlocks;\r
+ }\r
+ }\r
\r
Done:\r
- gBS->RestoreTPL (OldTpl);\r
+\r
return Status;\r
}\r
\r
Routine Description:\r
Implements EFI_BLOCK_IO_PROTOCOL.FlushBlocks() function.\r
(In this driver, this function just returns EFI_SUCCESS.)\r
- \r
+\r
Arguments:\r
This The EFI_BLOCK_IO_PROTOCOL instance.\r
- \r
- Returns: \r
+\r
+ Returns:\r
EFI_SUCCESS - Success\r
---*/ \r
+--*/\r
{\r
return EFI_SUCCESS;\r
}\r