//\r
// Definition of USB BOT Transport Protocol\r
//\r
-USB_MASS_TRANSPORT mUsbBotTransport = {\r
+USB_MASS_TRANSPORT mUsbBotTransport = {\r
USB_MASS_STORE_BOT,\r
UsbBotInit,\r
UsbBotExecCommand,\r
**/\r
EFI_STATUS\r
UsbBotInit (\r
- IN EFI_USB_IO_PROTOCOL *UsbIo,\r
- OUT VOID **Context OPTIONAL\r
+ IN EFI_USB_IO_PROTOCOL *UsbIo,\r
+ OUT VOID **Context OPTIONAL\r
)\r
{\r
USB_BOT_PROTOCOL *UsbBot;\r
}\r
\r
if (USB_IS_IN_ENDPOINT (EndPoint.EndpointAddress) &&\r
- (UsbBot->BulkInEndpoint == NULL)) {\r
-\r
- UsbBot->BulkInEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *) (UsbBot + 1);\r
- CopyMem(UsbBot->BulkInEndpoint, &EndPoint, sizeof (EndPoint));\r
+ (UsbBot->BulkInEndpoint == NULL))\r
+ {\r
+ UsbBot->BulkInEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *)(UsbBot + 1);\r
+ CopyMem (UsbBot->BulkInEndpoint, &EndPoint, sizeof (EndPoint));\r
}\r
\r
if (USB_IS_OUT_ENDPOINT (EndPoint.EndpointAddress) &&\r
- (UsbBot->BulkOutEndpoint == NULL)) {\r
-\r
- UsbBot->BulkOutEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *) (UsbBot + 1) + 1;\r
- CopyMem (UsbBot->BulkOutEndpoint, &EndPoint, sizeof(EndPoint));\r
+ (UsbBot->BulkOutEndpoint == NULL))\r
+ {\r
+ UsbBot->BulkOutEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *)(UsbBot + 1) + 1;\r
+ CopyMem (UsbBot->BulkOutEndpoint, &EndPoint, sizeof (EndPoint));\r
}\r
}\r
\r
**/\r
EFI_STATUS\r
UsbBotSendCommand (\r
- IN USB_BOT_PROTOCOL *UsbBot,\r
- IN UINT8 *Cmd,\r
- IN UINT8 CmdLen,\r
- IN EFI_USB_DATA_DIRECTION DataDir,\r
- IN UINT32 TransLen,\r
- IN UINT8 Lun\r
+ IN USB_BOT_PROTOCOL *UsbBot,\r
+ IN UINT8 *Cmd,\r
+ IN UINT8 CmdLen,\r
+ IN EFI_USB_DATA_DIRECTION DataDir,\r
+ IN UINT32 TransLen,\r
+ IN UINT8 Lun\r
)\r
{\r
- USB_BOT_CBW Cbw;\r
- EFI_STATUS Status;\r
- UINT32 Result;\r
- UINTN DataLen;\r
- UINTN Timeout;\r
+ USB_BOT_CBW Cbw;\r
+ EFI_STATUS Status;\r
+ UINT32 Result;\r
+ UINTN DataLen;\r
+ UINTN Timeout;\r
\r
ASSERT ((CmdLen > 0) && (CmdLen <= USB_BOT_MAX_CMDLEN));\r
\r
Cbw.Signature = USB_BOT_CBW_SIGNATURE;\r
Cbw.Tag = UsbBot->CbwTag;\r
Cbw.DataLen = TransLen;\r
- Cbw.Flag = (UINT8) ((DataDir == EfiUsbDataIn) ? BIT7 : 0);\r
+ Cbw.Flag = (UINT8)((DataDir == EfiUsbDataIn) ? BIT7 : 0);\r
Cbw.Lun = Lun;\r
Cbw.CmdLen = CmdLen;\r
\r
&Result\r
);\r
if (EFI_ERROR (Status)) {\r
- if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL) && DataDir == EfiUsbDataOut) {\r
+ if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL) && (DataDir == EfiUsbDataOut)) {\r
//\r
// Respond to Bulk-Out endpoint stall with a Reset Recovery,\r
// according to section 5.3.1 of USB Mass Storage Class Bulk-Only Transport Spec, v1.0.\r
return Status;\r
}\r
\r
-\r
/**\r
Transfer the data between the device and host.\r
\r
**/\r
EFI_STATUS\r
UsbBotDataTransfer (\r
- IN USB_BOT_PROTOCOL *UsbBot,\r
- IN EFI_USB_DATA_DIRECTION DataDir,\r
- IN OUT UINT8 *Data,\r
- IN OUT UINTN *TransLen,\r
- IN UINT32 Timeout\r
+ IN USB_BOT_PROTOCOL *UsbBot,\r
+ IN EFI_USB_DATA_DIRECTION DataDir,\r
+ IN OUT UINT8 *Data,\r
+ IN OUT UINTN *TransLen,\r
+ IN UINT32 Timeout\r
)\r
{\r
- EFI_USB_ENDPOINT_DESCRIPTOR *Endpoint;\r
- EFI_STATUS Status;\r
- UINT32 Result;\r
+ EFI_USB_ENDPOINT_DESCRIPTOR *Endpoint;\r
+ EFI_STATUS Status;\r
+ UINT32 Result;\r
\r
//\r
// If no data to transfer, just return EFI_SUCCESS.\r
} else {\r
DEBUG ((DEBUG_ERROR, "UsbBotDataTransfer: (%r)\n", Status));\r
}\r
- if(Status == EFI_TIMEOUT){\r
- UsbBotResetDevice(UsbBot, FALSE);\r
+\r
+ if (Status == EFI_TIMEOUT) {\r
+ UsbBotResetDevice (UsbBot, FALSE);\r
}\r
}\r
\r
return Status;\r
}\r
\r
-\r
/**\r
Get the command execution status from device.\r
\r
**/\r
EFI_STATUS\r
UsbBotGetStatus (\r
- IN USB_BOT_PROTOCOL *UsbBot,\r
- IN UINT32 TransLen,\r
- OUT UINT8 *CmdStatus\r
+ IN USB_BOT_PROTOCOL *UsbBot,\r
+ IN UINT32 TransLen,\r
+ OUT UINT8 *CmdStatus\r
)\r
{\r
- USB_BOT_CSW Csw;\r
- UINTN Len;\r
- UINT8 Endpoint;\r
- EFI_STATUS Status;\r
- UINT32 Result;\r
- EFI_USB_IO_PROTOCOL *UsbIo;\r
- UINT32 Index;\r
- UINTN Timeout;\r
+ USB_BOT_CSW Csw;\r
+ UINTN Len;\r
+ UINT8 Endpoint;\r
+ EFI_STATUS Status;\r
+ UINT32 Result;\r
+ EFI_USB_IO_PROTOCOL *UsbIo;\r
+ UINT32 Index;\r
+ UINTN Timeout;\r
\r
*CmdStatus = USB_BOT_COMMAND_ERROR;\r
Status = EFI_DEVICE_ERROR;\r
Timeout,\r
&Result\r
);\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL)) {\r
UsbClearEndpointStall (UsbIo, Endpoint);\r
}\r
+\r
continue;\r
}\r
\r
break;\r
}\r
}\r
+\r
//\r
- //The tag is increased even if there is an error.\r
+ // The tag is increased even if there is an error.\r
//\r
UsbBot->CbwTag++;\r
\r
return Status;\r
}\r
\r
-\r
/**\r
Call the USB Mass Storage Class BOT protocol to issue\r
the command/data/status circle to execute the commands.\r
OUT UINT32 *CmdStatus\r
)\r
{\r
- USB_BOT_PROTOCOL *UsbBot;\r
- EFI_STATUS Status;\r
- UINTN TransLen;\r
- UINT8 Result;\r
+ USB_BOT_PROTOCOL *UsbBot;\r
+ EFI_STATUS Status;\r
+ UINTN TransLen;\r
+ UINT8 Result;\r
\r
- *CmdStatus = USB_MASS_CMD_FAIL;\r
- UsbBot = (USB_BOT_PROTOCOL *) Context;\r
+ *CmdStatus = USB_MASS_CMD_FAIL;\r
+ UsbBot = (USB_BOT_PROTOCOL *)Context;\r
\r
//\r
// Send the command to the device. Return immediately if device\r
// failed. The host should attempt to receive the CSW no matter\r
// whether it succeeds or fails.\r
//\r
- TransLen = (UINTN) DataLen;\r
+ TransLen = (UINTN)DataLen;\r
UsbBotDataTransfer (UsbBot, DataDir, Data, &TransLen, Timeout);\r
\r
//\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Reset the USB mass storage device by BOT protocol.\r
\r
**/\r
EFI_STATUS\r
UsbBotResetDevice (\r
- IN VOID *Context,\r
- IN BOOLEAN ExtendedVerification\r
+ IN VOID *Context,\r
+ IN BOOLEAN ExtendedVerification\r
)\r
{\r
USB_BOT_PROTOCOL *UsbBot;\r
UINT32 Result;\r
UINT32 Timeout;\r
\r
- UsbBot = (USB_BOT_PROTOCOL *) Context;\r
+ UsbBot = (USB_BOT_PROTOCOL *)Context;\r
\r
if (ExtendedVerification) {\r
//\r
return Status;\r
}\r
\r
-\r
/**\r
Get the max LUN (Logical Unit Number) of USB mass storage device.\r
\r
**/\r
EFI_STATUS\r
UsbBotGetMaxLun (\r
- IN VOID *Context,\r
- OUT UINT8 *MaxLun\r
+ IN VOID *Context,\r
+ OUT UINT8 *MaxLun\r
)\r
{\r
USB_BOT_PROTOCOL *UsbBot;\r
UINT32 Result;\r
UINT32 Timeout;\r
\r
- if (Context == NULL || MaxLun == NULL) {\r
+ if ((Context == NULL) || (MaxLun == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- UsbBot = (USB_BOT_PROTOCOL *) Context;\r
+ UsbBot = (USB_BOT_PROTOCOL *)Context;\r
\r
//\r
// Issue a class specific Bulk-Only Mass Storage get max lun request.\r
&Request,\r
EfiUsbDataIn,\r
Timeout,\r
- (VOID *) MaxLun,\r
+ (VOID *)MaxLun,\r
1,\r
&Result\r
);\r
- if (EFI_ERROR (Status) || *MaxLun > USB_BOT_MAX_LUN) {\r
+ if (EFI_ERROR (Status) || (*MaxLun > USB_BOT_MAX_LUN)) {\r
//\r
// If the Get LUN request returns an error or the MaxLun is larger than\r
// the maximum LUN value (0x0f) supported by the USB Mass Storage Class\r
**/\r
EFI_STATUS\r
UsbBotCleanUp (\r
- IN VOID *Context\r
+ IN VOID *Context\r
)\r
{\r
FreePool (Context);\r