TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbMassBoot.h File Reference

Go to the source code of this file.

Data Structures

struct  USB_BOOT_INQUIRY_CMD
 
struct  USB_BOOT_INQUIRY_DATA
 
struct  USB_BOOT_READ_CAPACITY_CMD
 
struct  USB_BOOT_READ_CAPACITY_DATA
 
struct  USB_BOOT_TEST_UNIT_READY_CMD
 
struct  USB_BOOT_MODE_SENSE10_CMD
 
struct  USB_BOOT_MODE_SENSE10_PARA_HEADER
 
struct  USB_BOOT_READ_WRITE_10_CMD
 
struct  USB_BOOT_REQUEST_SENSE_CMD
 
struct  USB_BOOT_REQUEST_SENSE_DATA
 
struct  USB_SCSI_MODE_SENSE6_CMD
 
struct  USB_SCSI_MODE_SENSE6_PARA_HEADER
 

Macros

#define USB_BOOT_INQUIRY_OPCODE   0x12
 
#define USB_BOOT_REQUEST_SENSE_OPCODE   0x03
 
#define USB_BOOT_MODE_SENSE10_OPCODE   0x5A
 
#define USB_BOOT_READ_CAPACITY_OPCODE   0x25
 
#define USB_BOOT_TEST_UNIT_READY_OPCODE   0x00
 
#define USB_BOOT_READ10_OPCODE   0x28
 
#define USB_BOOT_WRITE10_OPCODE   0x2A
 
#define USB_SCSI_MODE_SENSE6_OPCODE   0x1A
 
#define USB_BOOT_SENSE_NO_SENSE   0x00
 No sense key.
 
#define USB_BOOT_SENSE_RECOVERED   0x01
 Last command succeed with recovery actions.
 
#define USB_BOOT_SENSE_NOT_READY   0x02
 Device not ready.
 
#define USB_BOOT_SNESE_MEDIUM_ERROR   0X03
 Failed probably because flaw in the media.
 
#define USB_BOOT_SENSE_HARDWARE_ERROR   0X04
 Non-recoverable hardware failure.
 
#define USB_BOOT_SENSE_ILLEGAL_REQUEST   0X05
 Illegal parameters in the request.
 
#define USB_BOOT_SENSE_UNIT_ATTENTION   0X06
 Removable medium may have been changed.
 
#define USB_BOOT_SENSE_DATA_PROTECT   0X07
 Write protected.
 
#define USB_BOOT_SENSE_BLANK_CHECK   0X08
 Blank/non-blank medium while reading/writing.
 
#define USB_BOOT_SENSE_VENDOR   0X09
 Vendor specific sense key.
 
#define USB_BOOT_SENSE_ABORTED   0X0B
 Command aborted by the device.
 
#define USB_BOOT_SENSE_VOLUME_OVERFLOW   0x0D
 Partition overflow.
 
#define USB_BOOT_SENSE_MISCOMPARE   0x0E
 Source data mis-match while verfying.
 
#define USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION   0x00
 
#define USB_BOOT_ASC_NOT_READY   0x04
 
#define USB_BOOT_ASC_NO_MEDIA   0x3A
 
#define USB_BOOT_ASC_MEDIA_CHANGE   0x28
 
#define USB_PDT_DIRECT_ACCESS   0x00
 Direct access device.
 
#define USB_PDT_CDROM   0x05
 CDROM.
 
#define USB_PDT_OPTICAL   0x07
 Non-CD optical disks.
 
#define USB_PDT_SIMPLE_DIRECT   0x0E
 Simplified direct access device.
 
#define USB_BOOT_MAX_CARRY_SIZE   SIZE_64KB
 
#define USB_BOOT_COMMAND_RETRY   5
 
#define USB_BOOT_RETRY_UNIT_READY_STALL   (500 * USB_MASS_1_MILLISECOND)
 
#define USB_BOOT_GENERAL_CMD_TIMEOUT   (5 * USB_MASS_1_SECOND)
 
#define USB_BOOT_LUN(Lun)   ((Lun) << 5)
 
#define USB_BOOT_REMOVABLE(RmbByte)   (((RmbByte) & BIT7) != 0)
 
#define USB_BOOT_PDT(Pdt)   ((Pdt) & 0x1f)
 
#define USB_BOOT_SENSE_KEY(Key)   ((Key) & 0x0f)
 

Functions

EFI_STATUS UsbBootGetParams (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbBootIsUnitReady (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbBootDetectMedia (IN USB_MASS_DEVICE *UsbMass)
 
EFI_STATUS UsbBootReadBlocks (IN USB_MASS_DEVICE *UsbMass, IN UINT32 Lba, IN UINTN TotalBlock, OUT UINT8 *Buffer)
 
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

Definition 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.h.

Macro Definition Documentation

◆ USB_BOOT_ASC_MEDIA_CHANGE

#define USB_BOOT_ASC_MEDIA_CHANGE   0x28

Definition at line 51 of file UsbMassBoot.h.

◆ USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION

#define USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION   0x00

Definition at line 48 of file UsbMassBoot.h.

◆ USB_BOOT_ASC_NO_MEDIA

#define USB_BOOT_ASC_NO_MEDIA   0x3A

Definition at line 50 of file UsbMassBoot.h.

◆ USB_BOOT_ASC_NOT_READY

#define USB_BOOT_ASC_NOT_READY   0x04

Definition at line 49 of file UsbMassBoot.h.

◆ USB_BOOT_COMMAND_RETRY

#define USB_BOOT_COMMAND_RETRY   5

Definition at line 69 of file UsbMassBoot.h.

◆ USB_BOOT_GENERAL_CMD_TIMEOUT

#define USB_BOOT_GENERAL_CMD_TIMEOUT   (5 * USB_MASS_1_SECOND)

Definition at line 83 of file UsbMassBoot.h.

◆ USB_BOOT_INQUIRY_OPCODE

#define USB_BOOT_INQUIRY_OPCODE   0x12

Definition at line 20 of file UsbMassBoot.h.

◆ USB_BOOT_LUN

#define USB_BOOT_LUN (   Lun)    ((Lun) << 5)

Definition at line 201 of file UsbMassBoot.h.

◆ USB_BOOT_MAX_CARRY_SIZE

#define USB_BOOT_MAX_CARRY_SIZE   SIZE_64KB

Definition at line 64 of file UsbMassBoot.h.

◆ USB_BOOT_MODE_SENSE10_OPCODE

#define USB_BOOT_MODE_SENSE10_OPCODE   0x5A

Definition at line 22 of file UsbMassBoot.h.

◆ USB_BOOT_PDT

#define USB_BOOT_PDT (   Pdt)    ((Pdt) & 0x1f)

Definition at line 207 of file UsbMassBoot.h.

◆ USB_BOOT_READ10_OPCODE

#define USB_BOOT_READ10_OPCODE   0x28

Definition at line 25 of file UsbMassBoot.h.

◆ USB_BOOT_READ_CAPACITY_OPCODE

#define USB_BOOT_READ_CAPACITY_OPCODE   0x25

Definition at line 23 of file UsbMassBoot.h.

◆ USB_BOOT_REMOVABLE

#define USB_BOOT_REMOVABLE (   RmbByte)    (((RmbByte) & BIT7) != 0)

Definition at line 206 of file UsbMassBoot.h.

◆ USB_BOOT_REQUEST_SENSE_OPCODE

#define USB_BOOT_REQUEST_SENSE_OPCODE   0x03

Definition at line 21 of file UsbMassBoot.h.

◆ USB_BOOT_RETRY_UNIT_READY_STALL

#define USB_BOOT_RETRY_UNIT_READY_STALL   (500 * USB_MASS_1_MILLISECOND)

Definition at line 74 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_ABORTED

#define USB_BOOT_SENSE_ABORTED   0X0B

Command aborted by the device.

Definition at line 44 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_BLANK_CHECK

#define USB_BOOT_SENSE_BLANK_CHECK   0X08

Blank/non-blank medium while reading/writing.

Definition at line 42 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_DATA_PROTECT

#define USB_BOOT_SENSE_DATA_PROTECT   0X07

Write protected.

Definition at line 41 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_HARDWARE_ERROR

#define USB_BOOT_SENSE_HARDWARE_ERROR   0X04

Non-recoverable hardware failure.

Definition at line 38 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_ILLEGAL_REQUEST

#define USB_BOOT_SENSE_ILLEGAL_REQUEST   0X05

Illegal parameters in the request.

Definition at line 39 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_KEY

#define USB_BOOT_SENSE_KEY (   Key)    ((Key) & 0x0f)

Definition at line 208 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_MISCOMPARE

#define USB_BOOT_SENSE_MISCOMPARE   0x0E

Source data mis-match while verfying.

Definition at line 46 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_NO_SENSE

#define USB_BOOT_SENSE_NO_SENSE   0x00

No sense key.

Definition at line 34 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_NOT_READY

#define USB_BOOT_SENSE_NOT_READY   0x02

Device not ready.

Definition at line 36 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_RECOVERED

#define USB_BOOT_SENSE_RECOVERED   0x01

Last command succeed with recovery actions.

Definition at line 35 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_UNIT_ATTENTION

#define USB_BOOT_SENSE_UNIT_ATTENTION   0X06

Removable medium may have been changed.

Definition at line 40 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_VENDOR

#define USB_BOOT_SENSE_VENDOR   0X09

Vendor specific sense key.

Definition at line 43 of file UsbMassBoot.h.

◆ USB_BOOT_SENSE_VOLUME_OVERFLOW

#define USB_BOOT_SENSE_VOLUME_OVERFLOW   0x0D

Partition overflow.

Definition at line 45 of file UsbMassBoot.h.

◆ USB_BOOT_SNESE_MEDIUM_ERROR

#define USB_BOOT_SNESE_MEDIUM_ERROR   0X03

Failed probably because flaw in the media.

Definition at line 37 of file UsbMassBoot.h.

◆ USB_BOOT_TEST_UNIT_READY_OPCODE

#define USB_BOOT_TEST_UNIT_READY_OPCODE   0x00

Definition at line 24 of file UsbMassBoot.h.

◆ USB_BOOT_WRITE10_OPCODE

#define USB_BOOT_WRITE10_OPCODE   0x2A

Definition at line 26 of file UsbMassBoot.h.

◆ USB_PDT_CDROM

#define USB_PDT_CDROM   0x05

CDROM.

Definition at line 57 of file UsbMassBoot.h.

◆ USB_PDT_DIRECT_ACCESS

#define USB_PDT_DIRECT_ACCESS   0x00

Direct access device.

Definition at line 56 of file UsbMassBoot.h.

◆ USB_PDT_OPTICAL

#define USB_PDT_OPTICAL   0x07

Non-CD optical disks.

Definition at line 58 of file UsbMassBoot.h.

◆ USB_PDT_SIMPLE_DIRECT

#define USB_PDT_SIMPLE_DIRECT   0x0E

Simplified direct access device.

Definition at line 59 of file UsbMassBoot.h.

◆ USB_SCSI_MODE_SENSE6_OPCODE

#define USB_SCSI_MODE_SENSE6_OPCODE   0x1A

Definition at line 28 of file UsbMassBoot.h.

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.

◆ 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.

◆ 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.

◆ UsbBootReadBlocks()

EFI_STATUS UsbBootReadBlocks ( IN USB_MASS_DEVICE UsbMass,
IN UINT32  Lba,
IN UINTN  TotalBlock,
OUT UINT8 *  Buffer 
)

Read some blocks from the device.

Parameters
UsbMassThe USB mass storage device to read from
LbaThe start block number
TotalBlockTotal block number to read
BufferThe buffer to read to
Return values
EFI_SUCCESSData are read into the buffer
OthersFailed to read all the data

◆ 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.

◆ 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.