\r
#define USB_MASS_TRANSPORT_COUNT 3\r
//\r
-// Array of USB transport interfaces. \r
+// Array of USB transport interfaces.\r
//\r
USB_MASS_TRANSPORT *mUsbMassTransport[USB_MASS_TRANSPORT_COUNT] = {\r
&mUsbCbi0Transport,\r
/**\r
Reset the block device.\r
\r
- This function implements EFI_BLOCK_IO_PROTOCOL.Reset(). \r
+ This function implements EFI_BLOCK_IO_PROTOCOL.Reset().\r
It resets the block device hardware.\r
ExtendedVerification is ignored in this implementation.\r
\r
/**\r
Reads the requested number of blocks from the device.\r
\r
- This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks(). \r
+ This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks().\r
It reads the requested number of blocks from the device.\r
All the blocks are read, or an error is returned.\r
\r
/**\r
Writes a specified number of blocks to the device.\r
\r
- This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks(). \r
+ This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks().\r
It writes a specified number of blocks to the device.\r
All blocks are written, or an error is returned.\r
\r
Status = UsbBootWriteBlocks16 (UsbMass, Lba, TotalBlock, Buffer);\r
} else {\r
Status = UsbBootWriteBlocks (UsbMass, (UINT32) Lba, TotalBlock, Buffer);\r
- } \r
+ }\r
\r
if (EFI_ERROR (Status)) {\r
DEBUG ((EFI_D_ERROR, "UsbMassWriteBlocks: UsbBootWriteBlocks (%r) -> Reset\n", Status));\r
EFI_USB_INTERFACE_DESCRIPTOR Interface;\r
UINT8 Index;\r
EFI_STATUS Status;\r
- \r
+\r
Status = gBS->OpenProtocol (\r
Controller,\r
&gEfiUsbIoProtocolGuid,\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
- \r
+\r
Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &Interface);\r
if (EFI_ERROR (Status)) {\r
goto ON_EXIT;\r
}\r
- \r
+\r
Status = EFI_UNSUPPORTED;\r
\r
//\r
}\r
\r
//\r
- // For BOT device, try to get its max LUN. \r
+ // For BOT device, try to get its max LUN.\r
// If max LUN is 0, then it is a non-lun device.\r
// Otherwise, it is a multi-lun device.\r
//\r
This->DriverBindingHandle,\r
Controller\r
);\r
- return Status; \r
+ return Status;\r
}\r
\r
/**\r
ASSERT (MaxLun > 0);\r
ReturnStatus = EFI_NOT_FOUND;\r
\r
- for (Index = 0; Index <= MaxLun; Index++) { \r
+ for (Index = 0; Index <= MaxLun; Index++) {\r
\r
DEBUG ((EFI_D_INFO, "UsbMassInitMultiLun: Start to initialize No.%d logic unit\n", Index));\r
- \r
+\r
UsbIo = NULL;\r
UsbMass = AllocateZeroPool (sizeof (USB_MASS_DEVICE));\r
ASSERT (UsbMass != NULL);\r
- \r
+\r
UsbMass->Signature = USB_MASS_SIGNATURE;\r
UsbMass->UsbIo = UsbIo;\r
UsbMass->BlockIo.Media = &UsbMass->BlockIoMedia;\r
UsbMass->Transport = Transport;\r
UsbMass->Context = Context;\r
UsbMass->Lun = Index;\r
- \r
+\r
//\r
// Initialize the media parameter data for EFI_BLOCK_IO_MEDIA of Block I/O Protocol.\r
//\r
LunNode.Header.Type = MESSAGING_DEVICE_PATH;\r
LunNode.Header.SubType = MSG_DEVICE_LOGICAL_UNIT_DP;\r
LunNode.Lun = UsbMass->Lun;\r
- \r
+\r
SetDevicePathNodeLength (&LunNode.Header, sizeof (LunNode));\r
- \r
+\r
UsbMass->DevicePath = AppendDevicePathNode (DevicePath, &LunNode.Header);\r
- \r
+\r
if (UsbMass->DevicePath == NULL) {\r
DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: failed to create device logic unit device path\n"));\r
Status = EFI_OUT_OF_RESOURCES;\r
&UsbMass->DiskInfo,\r
NULL\r
);\r
- \r
+\r
if (EFI_ERROR (Status)) {\r
DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: InstallMultipleProtocolInterfaces (%r)\n", Status));\r
FreePool (UsbMass->DevicePath);\r
ReturnStatus = EFI_SUCCESS;\r
DEBUG ((EFI_D_INFO, "UsbMassInitMultiLun: Success to initialize No.%d logic unit\n", Index));\r
}\r
- \r
+\r
return ReturnStatus;\r
}\r
\r
DEBUG ((EFI_D_ERROR, "UsbMassInitNonLun: OpenUsbIoProtocol By Driver (%r)\n", Status));\r
goto ON_ERROR;\r
}\r
- \r
+\r
UsbMass->Signature = USB_MASS_SIGNATURE;\r
UsbMass->Controller = Controller;\r
UsbMass->UsbIo = UsbIo;\r
UsbMass->OpticalStorage = FALSE;\r
UsbMass->Transport = Transport;\r
UsbMass->Context = Context;\r
- \r
+\r
//\r
// Initialize the media parameter data for EFI_BLOCK_IO_MEDIA of Block I/O Protocol.\r
//\r
DEBUG ((EFI_D_ERROR, "UsbMassInitNonLun: UsbMassInitMedia (%r)\n", Status));\r
goto ON_ERROR;\r
}\r
- \r
+\r
InitializeDiskInfo (UsbMass);\r
\r
Status = gBS->InstallMultipleProtocolInterfaces (\r
Controller\r
);\r
}\r
- return Status; \r
+ return Status;\r
}\r
\r
\r
VOID *Context;\r
UINT8 MaxLun;\r
EFI_STATUS Status;\r
- EFI_USB_IO_PROTOCOL *UsbIo; \r
+ EFI_USB_IO_PROTOCOL *UsbIo;\r
EFI_TPL OldTpl;\r
\r
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
// Initialize data for device that does not support multiple LUNSs.\r
//\r
Status = UsbMassInitNonLun (This, Controller, Transport, Context);\r
- if (EFI_ERROR (Status)) { \r
+ if (EFI_ERROR (Status)) {\r
DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: UsbMassInitNonLun (%r)\n", Status));\r
}\r
} else {\r
Controller,\r
EFI_OPEN_PROTOCOL_BY_DRIVER\r
);\r
- \r
+\r
if (EFI_ERROR (Status)) {\r
DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: OpenDevicePathProtocol By Driver (%r)\n", Status));\r
goto Exit;\r
Controller,\r
EFI_OPEN_PROTOCOL_BY_DRIVER\r
);\r
- \r
+\r
if (EFI_ERROR (Status)) {\r
DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: OpenUsbIoProtocol By Driver (%r)\n", Status));\r
gBS->CloseProtocol (\r
Controller,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
);\r
- \r
+\r
if (EFI_ERROR(Status)) {\r
//\r
// This is a 2nd type handle(multi-lun root), it needs to close devicepath\r
DEBUG ((EFI_D_INFO, "Success to stop multi-lun root handle\n"));\r
return EFI_SUCCESS;\r
}\r
- \r
+\r
//\r
// This is a 1st type handle(non-multi-lun), which only needs to uninstall\r
// Block I/O Protocol, close USB I/O Protocol and free mass device.\r
//\r
UsbMass = USB_MASS_DEVICE_FROM_BLOCK_IO (BlockIo);\r
- \r
+\r
//\r
// Uninstall Block I/O protocol from the device handle,\r
// then call the transport protocol to stop itself.\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
- \r
+\r
gBS->CloseProtocol (\r
Controller,\r
&gEfiUsbIoProtocolGuid,\r
This->DriverBindingHandle,\r
Controller\r
);\r
- \r
+\r
UsbMass->Transport->CleanUp (UsbMass->Context);\r
FreePool (UsbMass);\r
- \r
+\r
DEBUG ((EFI_D_INFO, "Success to stop non-multi-lun root handle\n"));\r
return EFI_SUCCESS;\r
- } \r
+ }\r
\r
//\r
// This is a 3rd type handle(multi-lun), which needs uninstall\r
- // Block I/O Protocol and Device Path Protocol, close USB I/O Protocol and \r
+ // Block I/O Protocol and Device Path Protocol, close USB I/O Protocol and\r
// free mass device for all children.\r
//\r
AllChildrenStopped = TRUE;\r
This->DriverBindingHandle,\r
ChildHandleBuffer[Index]\r
);\r
- \r
+\r
Status = gBS->UninstallMultipleProtocolInterfaces (\r
ChildHandleBuffer[Index],\r
&gEfiDevicePathProtocolGuid,\r
&UsbMass->DiskInfo,\r
NULL\r
);\r
- \r
+\r
if (EFI_ERROR (Status)) {\r
//\r
// Fail to uninstall Block I/O Protocol and Device Path Protocol, so re-open USB I/O Protocol by child.\r
//\r
AllChildrenStopped = FALSE;\r
DEBUG ((EFI_D_ERROR, "Fail to stop No.%d multi-lun child handle when uninstalling blockio and devicepath\n", (UINT32)Index));\r
- \r
+\r
gBS->OpenProtocol (\r
Controller,\r
&gEfiUsbIoProtocolGuid,\r
if (!AllChildrenStopped) {\r
return EFI_DEVICE_ERROR;\r
}\r
- \r
+\r
DEBUG ((EFI_D_INFO, "Success to stop all %d multi-lun children handles\n", (UINT32) NumberOfChildren));\r
return EFI_SUCCESS;\r
}\r