UsbMassBoot.h revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Definition of the command set of USB Mass Storage Specification
for Bootability, Revision 1.0.
Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _EFI_USB_MASS_BOOT_H_
#define _EFI_USB_MASS_BOOT_H_
//
// The opcodes of various USB boot commands:
// INQUIRY/REQUEST_SENSE are "No Timeout Commands" as specified
// by Multi-Media Commands (MMC) set.
// Others are "Group 1 Timeout Commands". That is,
// they should be retried if driver is ready.
//
#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
//
// The Sense Key part of the sense data. Sense data has three levels:
// Sense key, Additional Sense Code and Additional Sense Code Qualifier
//
#define USB_BOOT_ASC_NOT_READY 0x04
#define USB_BOOT_ASC_NO_MEDIA 0x3A
#define USB_BOOT_ASC_MEDIA_CHANGE 0x28
//
// Supported PDT codes, or Peripheral Device Type
//
//
// Other parameters, Max carried size is 512B * 128 = 64KB
//
#define USB_BOOT_IO_BLOCKS 128
//
// Retry mass command times, set by experience
//
#define USB_BOOT_COMMAND_RETRY 5
//
// Wait for unit ready command, set by experience
//
//
// Mass command timeout, refers to specification[USB20-9.2.6.1]
//
// USB2.0 Spec define the up-limit timeout 5s for all command. USB floppy,
// USB CD-Rom and iPod devices are much slower than USB key when reponse
// most of commands, So we set 5s as timeout here.
//
//
// The required commands are INQUIRY, READ CAPACITY, TEST UNIT READY,
// READ10, WRITE10, and REQUEST SENSE. The BLOCK_IO protocol uses LBA
// so it isn't necessary to issue MODE SENSE / READ FORMAT CAPACITY
// command to retrieve the disk gemotrics.
//
#pragma pack(1)
typedef struct {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
#pragma pack()
//
// Convert a LUN number to that in the command
//
//
// Get the removable, PDT, and sense key bits from the command data
//
/**
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. Althought the RemoveableMedia is unlikely to change,
it is also included here.
@param UsbMass The device to retrieve disk gemotric.
@retval EFI_SUCCESS The disk gemotric is successfully retrieved.
@retval Other Failed to get the parameters.
**/
);
/**
Execute TEST UNIT READY command to check if the device is ready.
@param UsbMass The device to test
@retval EFI_SUCCESS The device is ready.
@retval Others Device not ready.
**/
);
/**
Detect whether the removable media is present and whether it has changed.
@param UsbMass The device to check.
@retval EFI_SUCCESS The media status is successfully checked.
@retval Other Failed to detect media.
**/
);
/**
Read some blocks from the device.
@param UsbMass The USB mass storage device to read from
@param Lba The start block number
@param TotalBlock Total block number to read
@param Buffer The buffer to read to
@retval EFI_SUCCESS Data are read into the buffer
@retval Others Failed to read all the data
**/
);
/**
Write some blocks to the device.
@param UsbMass The USB mass storage device to write to
@param Lba The start block number
@param TotalBlock Total block number to write
@param Buffer Pointer to the source buffer for the data.
@retval EFI_SUCCESS Data are written into the buffer
@retval Others Failed to write all the data
**/
);
/**
Read some blocks from the device by SCSI 16 byte cmd.
@param UsbMass The USB mass storage device to read from
@param Lba The start block number
@param TotalBlock Total block number to read
@param Buffer The buffer to read to
@retval EFI_SUCCESS Data are read into the buffer
@retval Others Failed to read all the data
**/
);
/**
Write some blocks to the device by SCSI 16 byte cmd.
@param UsbMass The USB mass storage device to write to
@param Lba The start block number
@param TotalBlock Total block number to write
@param Buffer Pointer to the source buffer for the data.
@retval EFI_SUCCESS Data are written into the buffer
@retval Others Failed to write all the data
**/
);
/**
Use the USB clear feature control transfer to clear the endpoint stall condition.
@param UsbIo The USB I/O Protocol instance
@param EndpointAddr The endpoint to clear stall for
@retval EFI_SUCCESS The endpoint stall condition is cleared.
@retval Others Failed to clear the endpoint stall condition.
**/
);
#endif