TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbMassBot.c File Reference
#include "UsbMass.h"

Go to the source code of this file.

Functions

EFI_STATUS UsbBotInit (IN EFI_USB_IO_PROTOCOL *UsbIo, OUT VOID **Context OPTIONAL)
 
EFI_STATUS UsbBotSendCommand (IN USB_BOT_PROTOCOL *UsbBot, IN UINT8 *Cmd, IN UINT8 CmdLen, IN EFI_USB_DATA_DIRECTION DataDir, IN UINT32 TransLen, IN UINT8 Lun)
 
EFI_STATUS UsbBotDataTransfer (IN USB_BOT_PROTOCOL *UsbBot, IN EFI_USB_DATA_DIRECTION DataDir, IN OUT UINT8 *Data, IN OUT UINTN *TransLen, IN UINT32 Timeout)
 
EFI_STATUS UsbBotGetStatus (IN USB_BOT_PROTOCOL *UsbBot, IN UINT32 TransLen, OUT UINT8 *CmdStatus)
 
EFI_STATUS UsbBotExecCommand (IN VOID *Context, IN VOID *Cmd, IN UINT8 CmdLen, IN EFI_USB_DATA_DIRECTION DataDir, IN VOID *Data, IN UINT32 DataLen, IN UINT8 Lun, IN UINT32 Timeout, OUT UINT32 *CmdStatus)
 
EFI_STATUS UsbBotResetDevice (IN VOID *Context, IN BOOLEAN ExtendedVerification)
 
EFI_STATUS UsbBotGetMaxLun (IN VOID *Context, OUT UINT8 *MaxLun)
 
EFI_STATUS UsbBotCleanUp (IN VOID *Context)
 

Variables

USB_MASS_TRANSPORT mUsbBotTransport
 

Detailed Description

Implementation of the USB mass storage Bulk-Only Transport protocol, according to USB Mass Storage Class Bulk-Only Transport, Revision 1.0.

Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file UsbMassBot.c.

Function Documentation

◆ UsbBotCleanUp()

EFI_STATUS UsbBotCleanUp ( IN VOID *  Context)

Clean up the resource used by this BOT protocol.

Parameters
ContextThe context of the BOT protocol, that is, USB_BOT_PROTOCOL.
Return values
EFI_SUCCESSThe resource is cleaned up.

Definition at line 598 of file UsbMassBot.c.

◆ UsbBotDataTransfer()

EFI_STATUS UsbBotDataTransfer ( IN USB_BOT_PROTOCOL UsbBot,
IN EFI_USB_DATA_DIRECTION  DataDir,
IN OUT UINT8 *  Data,
IN OUT UINTN TransLen,
IN UINT32  Timeout 
)

Transfer the data between the device and host.

This function transfers the data between the device and host. BOT transfer is composed of three phases: Command, Data, and Status. This is the Data phase.

Parameters
UsbBotThe USB BOT device
DataDirThe direction of the data
DataThe buffer to hold data
TransLenThe expected length of the data
TimeoutThe time to wait the command to complete
Return values
EFI_SUCCESSThe data is transferred
EFI_SUCCESSNo data to transfer
EFI_NOT_READYThe device return NAK to the transfer
OthersFailed to transfer data

Definition at line 227 of file UsbMassBot.c.

◆ UsbBotExecCommand()

EFI_STATUS UsbBotExecCommand ( IN VOID *  Context,
IN VOID *  Cmd,
IN UINT8  CmdLen,
IN EFI_USB_DATA_DIRECTION  DataDir,
IN VOID *  Data,
IN UINT32  DataLen,
IN UINT8  Lun,
IN UINT32  Timeout,
OUT UINT32 *  CmdStatus 
)

Call the USB Mass Storage Class BOT protocol to issue the command/data/status circle to execute the commands.

Parameters
ContextThe context of the BOT protocol, that is, USB_BOT_PROTOCOL
CmdThe high level command
CmdLenThe command length
DataDirThe direction of the data transfer
DataThe buffer to hold data
DataLenThe length of the data
LunThe number of logic unit
TimeoutThe time to wait command
CmdStatusThe result of high level command execution
Return values
EFI_SUCCESSThe command is executed successfully.
OtherFailed to execute command

Definition at line 393 of file UsbMassBot.c.

◆ UsbBotGetMaxLun()

EFI_STATUS UsbBotGetMaxLun ( IN VOID *  Context,
OUT UINT8 *  MaxLun 
)

Get the max LUN (Logical Unit Number) of USB mass storage device.

Parameters
ContextThe context of the BOT protocol, that is, USB_BOT_PROTOCOL
MaxLunReturn pointer to the max number of LUN. (e.g. MaxLun=1 means LUN0 and LUN1 in all.)
Return values
EFI_SUCCESSMax LUN is got successfully.
OthersFail to execute this request.

Definition at line 536 of file UsbMassBot.c.

◆ UsbBotGetStatus()

EFI_STATUS UsbBotGetStatus ( IN USB_BOT_PROTOCOL UsbBot,
IN UINT32  TransLen,
OUT UINT8 *  CmdStatus 
)

Get the command execution status from device.

This function gets the command execution status from device. BOT transfer is composed of three phases: Command, Data, and Status. This is the Status phase.

This function returns the transfer status of the BOT's CSW status, and returns the high level command execution result in Result. So even if EFI_SUCCESS is returned, the command may still have failed.

Parameters
UsbBotThe USB BOT device.
TransLenThe expected length of the data.
CmdStatusThe result of the command execution.
Return values
EFI_SUCCESSCommand execute result is retrieved and in the Result.
OtherError occurred when trying to get status.

Definition at line 305 of file UsbMassBot.c.

◆ UsbBotInit()

EFI_STATUS UsbBotInit ( IN EFI_USB_IO_PROTOCOL UsbIo,
OUT VOID **Context  OPTIONAL 
)

Initializes USB BOT protocol.

This function initializes the USB mass storage class BOT protocol. It will save its context which is a USB_BOT_PROTOCOL structure in the Context if Context isn't NULL.

Parameters
UsbIoThe USB I/O Protocol instance
ContextThe buffer to save the context to
Return values
EFI_SUCCESSThe device is successfully initialized.
EFI_UNSUPPORTEDThe transport protocol doesn't support the device.
OtherThe USB BOT initialization fails.

Definition at line 40 of file UsbMassBot.c.

◆ UsbBotResetDevice()

EFI_STATUS UsbBotResetDevice ( IN VOID *  Context,
IN BOOLEAN  ExtendedVerification 
)

Reset the USB mass storage device by BOT protocol.

Parameters
ContextThe context of the BOT protocol, that is, USB_BOT_PROTOCOL.
ExtendedVerificationIf FALSE, just issue Bulk-Only Mass Storage Reset request. If TRUE, additionally reset parent hub port.
Return values
EFI_SUCCESSThe device is reset.
OthersFailed to reset the device..

Definition at line 460 of file UsbMassBot.c.

◆ UsbBotSendCommand()

EFI_STATUS UsbBotSendCommand ( IN USB_BOT_PROTOCOL UsbBot,
IN UINT8 *  Cmd,
IN UINT8  CmdLen,
IN EFI_USB_DATA_DIRECTION  DataDir,
IN UINT32  TransLen,
IN UINT8  Lun 
)

Send the command to the device using Bulk-Out endpoint.

This function sends the command to the device using Bulk-Out endpoint. BOT transfer is composed of three phases: Command, Data, and Status. This is the Command phase.

Parameters
UsbBotThe USB BOT device
CmdThe command to transfer to device
CmdLenThe length of the command
DataDirThe direction of the data
TransLenThe expected length of the data
LunThe number of logic unit
Return values
EFI_SUCCESSThe command is sent to the device.
EFI_NOT_READYThe device return NAK to the transfer
OthersFailed to send the command to device

Definition at line 147 of file UsbMassBot.c.

Variable Documentation

◆ mUsbBotTransport

USB_MASS_TRANSPORT mUsbBotTransport
Initial value:
= {
}
#define USB_MASS_STORE_BOT
Bulk-Only Transport.
Definition: Usb.h:38
EFI_STATUS UsbBotExecCommand(IN VOID *Context, IN VOID *Cmd, IN UINT8 CmdLen, IN EFI_USB_DATA_DIRECTION DataDir, IN VOID *Data, IN UINT32 DataLen, IN UINT8 Lun, IN UINT32 Timeout, OUT UINT32 *CmdStatus)
Definition: UsbMassBot.c:393
EFI_STATUS UsbBotInit(IN EFI_USB_IO_PROTOCOL *UsbIo, OUT VOID **Context OPTIONAL)
Definition: UsbMassBot.c:40
EFI_STATUS UsbBotCleanUp(IN VOID *Context)
Definition: UsbMassBot.c:598
EFI_STATUS UsbBotResetDevice(IN VOID *Context, IN BOOLEAN ExtendedVerification)
Definition: UsbMassBot.c:460
EFI_STATUS UsbBotGetMaxLun(IN VOID *Context, OUT UINT8 *MaxLun)
Definition: UsbMassBot.c:536

Definition at line 15 of file UsbMassBot.c.