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

Go to the source code of this file.

Functions

EFI_STATUS UsbBootRequestSense (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbBootExecCmd (IN USB_MASS_DEVICE *UsbMass, IN VOID *Cmd, IN UINT8 CmdLen, IN EFI_USB_DATA_DIRECTION DataDir, IN VOID *Data, IN UINT32 DataLen, IN UINT32 Timeout)
 
EFI_STATUS UsbBootExecCmdWithRetry (IN USB_MASS_DEVICE *UsbMass, IN VOID *Cmd, IN UINT8 CmdLen, IN EFI_USB_DATA_DIRECTION DataDir, IN VOID *Data, IN UINT32 DataLen, IN UINT32 Timeout)
 
EFI_STATUS UsbBootIsUnitReady (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbBootInquiry (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbBootReadCapacity16 (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbBootReadCapacity (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbScsiModeSense (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbBootGetParams (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbBootDetectMedia (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbBootReadWriteBlocks (IN USB_MASS_DEVICE *UsbMass, IN BOOLEAN Write, IN UINT32 Lba, IN UINTN TotalBlock, IN OUT UINT8 *Buffer)
 
EFI_STATUS UsbBootReadWriteBlocks16 (IN USB_MASS_DEVICE *UsbMass, IN BOOLEAN Write, IN UINT64 Lba, IN UINTN TotalBlock, IN OUT UINT8 *Buffer)
 
EFI_STATUS UsbClearEndpointStall (IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 EndpointAddr)
 

Detailed Description

Implementation of the command set of USB Mass Storage Specification for Bootability, Revision 1.0.

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

Definition in file UsbMassBoot.c.

Function Documentation

◆ UsbBootDetectMedia()

EFI_STATUS UsbBootDetectMedia ( IN USB_MASS_DEVICE UsbMass)

Detect whether the removable media is present and whether it has changed.

Parameters
UsbMassThe device to check.
Return values
EFI_SUCCESSThe media status is successfully checked.
OtherFailed to detect media.

Definition at line 682 of file UsbMassBoot.c.

◆ UsbBootExecCmd()

EFI_STATUS UsbBootExecCmd ( IN USB_MASS_DEVICE UsbMass,
IN VOID *  Cmd,
IN UINT8  CmdLen,
IN EFI_USB_DATA_DIRECTION  DataDir,
IN VOID *  Data,
IN UINT32  DataLen,
IN UINT32  Timeout 
)

Execute the USB mass storage bootability commands.

This function executes the USB mass storage bootability commands. If execution failed, retrieve the error by REQUEST_SENSE, then update the device's status, such as ReadyOnly.

Parameters
UsbMassThe device to issue commands to
CmdThe command to execute
CmdLenThe length of the command
DataDirThe direction of data transfer
DataThe buffer to hold the data
DataLenThe length of expected data
TimeoutThe timeout used to transfer
Return values
EFI_SUCCESSCommand is executed successfully
OthersCommand execution failed.

Definition at line 170 of file UsbMassBoot.c.

◆ UsbBootExecCmdWithRetry()

EFI_STATUS UsbBootExecCmdWithRetry ( IN USB_MASS_DEVICE UsbMass,
IN VOID *  Cmd,
IN UINT8  CmdLen,
IN EFI_USB_DATA_DIRECTION  DataDir,
IN VOID *  Data,
IN UINT32  DataLen,
IN UINT32  Timeout 
)

Execute the USB mass storage bootability commands with retrial.

This function executes USB mass storage bootability commands. If the device isn't ready, wait for it. If the device is ready and error occurs, retry the command again until it exceeds the limit of retrial times.

Parameters
UsbMassThe device to issue commands to
CmdThe command to execute
CmdLenThe length of the command
DataDirThe direction of data transfer
DataThe buffer to hold the data
DataLenThe length of expected data
TimeoutThe timeout used to transfer
Return values
EFI_SUCCESSThe command is executed successfully.
EFI_NO_MEDIAThe device media is removed.
OthersCommand execution failed after retrial.

Definition at line 239 of file UsbMassBoot.c.

◆ UsbBootGetParams()

EFI_STATUS UsbBootGetParams ( IN USB_MASS_DEVICE UsbMass)

Get the parameters for the USB mass storage media.

This function get the parameters for the USB mass storage media, It is used both to initialize the media during the Start() phase of Driver Binding Protocol and to re-initialize it when the media is changed. Although the RemoveableMedia is unlikely to change, it is also included here.

Parameters
UsbMassThe device to retrieve disk gemotric.
Return values
EFI_SUCCESSThe disk gemotric is successfully retrieved.
OtherFailed to get the parameters.

Definition at line 624 of file UsbMassBoot.c.

◆ UsbBootInquiry()

EFI_STATUS UsbBootInquiry ( IN USB_MASS_DEVICE UsbMass)

Execute INQUIRY Command to request information regarding parameters of the device be sent to the host computer.

Parameters
UsbMassThe device to inquire.
Return values
EFI_SUCCESSINQUIRY Command is executed successfully.
OthersINQUIRY Command is not executed successfully.

Definition at line 355 of file UsbMassBoot.c.

◆ UsbBootIsUnitReady()

EFI_STATUS UsbBootIsUnitReady ( IN USB_MASS_DEVICE UsbMass)

Execute TEST UNIT READY command to check if the device is ready.

Parameters
UsbMassThe device to test
Return values
EFI_SUCCESSThe device is ready.
OthersDevice not ready.

Definition at line 322 of file UsbMassBoot.c.

◆ UsbBootReadCapacity()

EFI_STATUS UsbBootReadCapacity ( IN USB_MASS_DEVICE UsbMass)

Execute READ CAPACITY command to request information regarding the capacity of the installed medium of the device.

This function executes READ CAPACITY command to get the capacity of the USB mass storage media, including the presence, block size, and last block number.

Parameters
UsbMassThe device to retireve disk gemotric.
Return values
EFI_SUCCESSThe disk geometry is successfully retrieved.
EFI_NOT_READYThe returned block size is zero.
OtherREAD CAPACITY command execution failed.

Definition at line 496 of file UsbMassBoot.c.

◆ UsbBootReadCapacity16()

EFI_STATUS UsbBootReadCapacity16 ( IN USB_MASS_DEVICE UsbMass)

Execute READ CAPACITY 16 bytes command to request information regarding the capacity of the installed medium of the device.

This function executes READ CAPACITY 16 bytes command to get the capacity of the USB mass storage media, including the presence, block size, and last block number.

Parameters
UsbMassThe device to retireve disk gemotric.
Return values
EFI_SUCCESSThe disk geometry is successfully retrieved.
EFI_NOT_READYThe returned block size is zero.
OtherREAD CAPACITY 16 bytes command execution failed.

Definition at line 415 of file UsbMassBoot.c.

◆ UsbBootReadWriteBlocks()

EFI_STATUS UsbBootReadWriteBlocks ( IN USB_MASS_DEVICE UsbMass,
IN BOOLEAN  Write,
IN UINT32  Lba,
IN UINTN  TotalBlock,
IN OUT UINT8 *  Buffer 
)

Read or write some blocks from the device.

Parameters
UsbMassThe USB mass storage device to access
WriteTRUE for write operation.
LbaThe start block number
TotalBlockTotal block number to read or write
BufferThe buffer to read to or write from
Return values
EFI_SUCCESSData are read into the buffer or writen into the device.
OthersFailed to read or write all the data

Definition at line 810 of file UsbMassBoot.c.

◆ UsbBootReadWriteBlocks16()

EFI_STATUS UsbBootReadWriteBlocks16 ( IN USB_MASS_DEVICE UsbMass,
IN BOOLEAN  Write,
IN UINT64  Lba,
IN UINTN  TotalBlock,
IN OUT UINT8 *  Buffer 
)

Read or write some blocks from the device by SCSI 16 byte cmd.

Parameters
UsbMassThe USB mass storage device to access
WriteTRUE for write operation.
LbaThe start block number
TotalBlockTotal block number to read or write
BufferThe buffer to read to or write from
Return values
EFI_SUCCESSData are read into the buffer or writen into the device.
OthersFailed to read or write all the data

Definition at line 896 of file UsbMassBoot.c.

◆ UsbBootRequestSense()

EFI_STATUS UsbBootRequestSense ( IN USB_MASS_DEVICE UsbMass)

Execute REQUEST SENSE Command to retrieve sense data from device.

Parameters
UsbMassThe device whose sense data is requested.
Return values
EFI_SUCCESSThe command is executed successfully.
EFI_DEVICE_ERRORFailed to request sense.
EFI_NO_RESPONSEThe device media doesn't response this request.
EFI_INVALID_PARAMETERThe command has some invalid parameters.
EFI_WRITE_PROTECTEDThe device is write protected.
EFI_MEDIA_CHANGEDThe device media has been changed.

Definition at line 26 of file UsbMassBoot.c.

◆ UsbClearEndpointStall()

EFI_STATUS UsbClearEndpointStall ( IN EFI_USB_IO_PROTOCOL UsbIo,
IN UINT8  EndpointAddr 
)

Use the USB clear feature control transfer to clear the endpoint stall condition.

Parameters
UsbIoThe USB I/O Protocol instance
EndpointAddrThe endpoint to clear stall for
Return values
EFI_SUCCESSThe endpoint stall condition is cleared.
OthersFailed to clear the endpoint stall condition.

Definition at line 977 of file UsbMassBoot.c.

◆ UsbScsiModeSense()

EFI_STATUS UsbScsiModeSense ( IN USB_MASS_DEVICE UsbMass)

Retrieves SCSI mode sense information via MODE SENSE(6) command.

Parameters
UsbMassThe device whose sense data is requested.
Return values
EFI_SUCCESSSCSI mode sense information retrieved successfully.
OtherCommand execution failed.

Definition at line 564 of file UsbMassBoot.c.