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

Go to the source code of this file.

Functions

EFI_STATUS UsbCbiInit (IN EFI_USB_IO_PROTOCOL *UsbIo, OUT VOID **Context OPTIONAL)
 
EFI_STATUS UsbCbiSendCommand (IN USB_CBI_PROTOCOL *UsbCbi, IN UINT8 *Cmd, IN UINT8 CmdLen, IN UINT32 Timeout)
 
EFI_STATUS UsbCbiDataTransfer (IN USB_CBI_PROTOCOL *UsbCbi, IN EFI_USB_DATA_DIRECTION DataDir, IN OUT UINT8 *Data, IN OUT UINTN *TransLen, IN UINT32 Timeout)
 
EFI_STATUS UsbCbiGetStatus (IN USB_CBI_PROTOCOL *UsbCbi, IN UINT32 Timeout, OUT USB_CBI_STATUS *Result)
 
EFI_STATUS UsbCbiExecCommand (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 UsbCbiResetDevice (IN VOID *Context, IN BOOLEAN ExtendedVerification)
 
EFI_STATUS UsbCbiCleanUp (IN VOID *Context)
 

Variables

USB_MASS_TRANSPORT mUsbCbi0Transport
 
USB_MASS_TRANSPORT mUsbCbi1Transport
 

Detailed Description

Implementation of the USB mass storage Control/Bulk/Interrupt transport, according to USB Mass Storage Class Control/Bulk/Interrupt (CBI) Transport, Revision 1.1. Notice: it is being obsoleted by the standard body in favor of the BOT (Bulk-Only Transport).

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

Definition in file UsbMassCbi.c.

Function Documentation

◆ UsbCbiCleanUp()

EFI_STATUS UsbCbiCleanUp ( IN VOID *  Context)

Clean up the CBI protocol's resource.

Parameters
ContextThe instance of CBI protocol.
Return values
EFI_SUCCESSThe resource is cleaned up.

Definition at line 597 of file UsbMassCbi.c.

◆ UsbCbiDataTransfer()

EFI_STATUS UsbCbiDataTransfer ( IN USB_CBI_PROTOCOL UsbCbi,
IN EFI_USB_DATA_DIRECTION  DataDir,
IN OUT UINT8 *  Data,
IN OUT UINTN TransLen,
IN UINT32  Timeout 
)

Transfer data between the device and host.

This function transfers data between the device and host. The CBI contains three phases: Command, Data, and Status. This is Data phase.

Parameters
UsbCbiThe USB CBI device
DataDirThe direction of the data transfer
DataThe buffer to hold the data for input or output.
TransLenOn input, the expected transfer length. On output, the length of data actually transferred.
TimeoutThe time to wait for the command to execute
Return values
EFI_SUCCESSThe data transferred successfully.
EFI_SUCCESSNo data to transfer
OthersFailed to transfer all the data

Definition at line 247 of file UsbMassCbi.c.

◆ UsbCbiExecCommand()

EFI_STATUS UsbCbiExecCommand ( 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 
)

Execute USB mass storage command through the CBI0/CBI1 transport protocol.

Parameters
ContextThe USB CBI Protocol.
CmdThe command to transfer to device
CmdLenThe length of the command
DataDirThe direction of data transfer
DataThe buffer to hold the data
DataLenThe length of the buffer
LunShould be 0, this field for bot only
TimeoutThe time to wait
CmdStatusThe result of the command execution
Return values
EFI_SUCCESSThe command is executed successfully.
OtherFailed to execute the command

Definition at line 426 of file UsbMassCbi.c.

◆ UsbCbiGetStatus()

EFI_STATUS UsbCbiGetStatus ( IN USB_CBI_PROTOCOL UsbCbi,
IN UINT32  Timeout,
OUT USB_CBI_STATUS Result 
)

Gets the result of high level command execution from interrupt endpoint.

This function returns the USB transfer status, and put the high level command execution result in Result. The CBI contains three phases: Command, Data, and Status. This is Status phase.

Parameters
UsbCbiThe USB CBI protocol
TimeoutThe time to wait for the command to execute
ResultThe result of the command execution.
Return values
EFI_SUCCESSThe high level command execution result is retrieved in Result.
OthersFailed to retrieve the result.

Definition at line 364 of file UsbMassCbi.c.

◆ UsbCbiInit()

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

Initializes USB CBI protocol.

This function initializes the USB mass storage class CBI protocol. It will save its context which is a USB_CBI_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 CBI initialization fails.

Definition at line 54 of file UsbMassCbi.c.

◆ UsbCbiResetDevice()

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

Reset the USB mass storage device by CBI protocol.

This function resets the USB mass storage device by CBI protocol. The reset is defined as a non-data command. Don't use UsbCbiExecCommand to send the command to device because that may introduce recursive loop.

Parameters
ContextThe USB CBI protocol
ExtendedVerificationThe flag controlling the rule of reset. Not used here.
Return values
EFI_SUCCESSThe device is reset.
OthersFailed to reset the device.

Definition at line 542 of file UsbMassCbi.c.

◆ UsbCbiSendCommand()

EFI_STATUS UsbCbiSendCommand ( IN USB_CBI_PROTOCOL UsbCbi,
IN UINT8 *  Cmd,
IN UINT8  CmdLen,
IN UINT32  Timeout 
)

Send the command to the device using class specific control transfer.

This function sends command to the device using class specific control transfer. The CBI contains three phases: Command, Data, and Status. This is Command phase.

Parameters
UsbCbiThe USB CBI protocol
CmdThe high level command to transfer to device
CmdLenThe length of the command
TimeoutThe time to wait the command to finish
Return values
EFI_SUCCESSThe command is sent to the device.
OthersThe command failed to transfer to device

Definition at line 170 of file UsbMassCbi.c.

Variable Documentation

◆ mUsbCbi0Transport

USB_MASS_TRANSPORT mUsbCbi0Transport
Initial value:
= {
}
#define NULL
Definition: Base.h:319
#define USB_MASS_STORE_CBI0
CBI protocol with command completion interrupt.
Definition: Usb.h:36
EFI_STATUS UsbCbiCleanUp(IN VOID *Context)
Definition: UsbMassCbi.c:597
EFI_STATUS UsbCbiResetDevice(IN VOID *Context, IN BOOLEAN ExtendedVerification)
Definition: UsbMassCbi.c:542
EFI_STATUS UsbCbiExecCommand(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: UsbMassCbi.c:426
EFI_STATUS UsbCbiInit(IN EFI_USB_IO_PROTOCOL *UsbIo, OUT VOID **Context OPTIONAL)
Definition: UsbMassCbi.c:54

Definition at line 17 of file UsbMassCbi.c.

◆ mUsbCbi1Transport

USB_MASS_TRANSPORT mUsbCbi1Transport
Initial value:
= {
}
#define USB_MASS_STORE_CBI1
CBI protocol without command completion interrupt.
Definition: Usb.h:37

Definition at line 29 of file UsbMassCbi.c.