2007-07-11 10:47:37 +02:00
|
|
|
/** @file
|
|
|
|
|
|
|
|
Defination for the USB mass storage class driver. The USB mass storage
|
|
|
|
class is specified in two layers: the bottom layer is the transportation
|
|
|
|
protocol. The top layer is the command set. The transportation layer
|
|
|
|
provides the transportation of the command, data and result. The command
|
|
|
|
set defines what the command, data and result. The Bulk-Only-Transport and
|
|
|
|
Control/Bulk/Interrupt transport are two transportation protocol. USB mass
|
|
|
|
storage class adopts various industrial standard as its command set.
|
|
|
|
|
2008-07-23 10:30:25 +02:00
|
|
|
Copyright (c) 2007 - 2008, Intel Corporation
|
|
|
|
All rights reserved. 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
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
2007-07-11 10:47:37 +02:00
|
|
|
|
2008-07-23 10:30:25 +02:00
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
2007-07-11 10:47:37 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef _EFI_USBMASS_H_
|
|
|
|
#define _EFI_USBMASS_H_
|
|
|
|
|
2007-07-20 08:10:09 +02:00
|
|
|
|
2007-07-11 10:47:37 +02:00
|
|
|
#include <PiDxe.h>
|
2007-07-20 08:10:09 +02:00
|
|
|
|
2007-07-11 10:47:37 +02:00
|
|
|
#include <Protocol/BlockIo.h>
|
|
|
|
#include <Protocol/UsbIo.h>
|
2008-06-27 10:09:00 +02:00
|
|
|
#include <Protocol/DevicePath.h>
|
2007-07-20 08:10:09 +02:00
|
|
|
|
2007-07-11 10:47:37 +02:00
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
#include <Library/UefiDriverEntryPoint.h>
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
#include <Library/UefiLib.h>
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
2008-06-27 10:09:00 +02:00
|
|
|
#include <Library/DevicePathLib.h>
|
2007-07-11 10:47:37 +02:00
|
|
|
|
|
|
|
#define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & 0x80) == 0x80)
|
|
|
|
#define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & 0x80) == 0)
|
|
|
|
#define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & 0x03) == 0x02)
|
|
|
|
#define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & 0x03) == 0x03)
|
|
|
|
#define USB_IS_ERROR(Result, Error) (((Result) & (Error)) != 0)
|
|
|
|
|
2008-07-23 10:30:25 +02:00
|
|
|
typedef enum {
|
2007-07-11 10:47:37 +02:00
|
|
|
//
|
|
|
|
// Usb mass storage class code
|
|
|
|
//
|
|
|
|
USB_MASS_STORE_CLASS = 0x08,
|
|
|
|
|
|
|
|
//
|
|
|
|
// Usb mass storage subclass code, specify the command set used.
|
|
|
|
//
|
|
|
|
USB_MASS_STORE_RBC = 0x01, // Reduced Block Commands
|
|
|
|
USB_MASS_STORE_8020I = 0x02, // SFF-8020i, typically a CD/DVD device
|
|
|
|
USB_MASS_STORE_QIC = 0x03, // Typically a tape device
|
2008-02-13 10:08:24 +01:00
|
|
|
USB_MASS_STORE_UFI = 0x04, // Typically a floppy disk driver device
|
2007-07-11 10:47:37 +02:00
|
|
|
USB_MASS_STORE_8070I = 0x05, // SFF-8070i, typically a floppy disk driver device.
|
|
|
|
USB_MASS_STORE_SCSI = 0x06, // SCSI transparent command set
|
|
|
|
|
|
|
|
//
|
|
|
|
// Usb mass storage protocol code, specify the transport protocol
|
|
|
|
//
|
|
|
|
USB_MASS_STORE_CBI0 = 0x00, // CBI protocol with command completion interrupt
|
|
|
|
USB_MASS_STORE_CBI1 = 0x01, // CBI protocol without command completion interrupt
|
|
|
|
USB_MASS_STORE_BOT = 0x50, // Bulk-Only Transport
|
|
|
|
|
2007-10-08 08:14:13 +02:00
|
|
|
USB_MASS_1_MILLISECOND = 1000,
|
|
|
|
USB_MASS_1_SECOND = 1000 * USB_MASS_1_MILLISECOND,
|
2007-07-11 10:47:37 +02:00
|
|
|
|
|
|
|
USB_MASS_CMD_SUCCESS = 0,
|
|
|
|
USB_MASS_CMD_FAIL,
|
2007-07-17 03:48:09 +02:00
|
|
|
USB_MASS_CMD_PERSISTENT
|
2008-07-23 10:30:25 +02:00
|
|
|
}USB_MASS_DEV_CLASS_AND_VALUE;
|
2007-07-11 10:47:37 +02:00
|
|
|
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
|
|
|
(*USB_MASS_INIT_TRANSPORT) (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *Usb,
|
|
|
|
OUT VOID **Context OPTIONAL
|
|
|
|
);
|
|
|
|
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
|
|
|
(*USB_MASS_EXEC_COMMAND) (
|
|
|
|
IN VOID *Context,
|
|
|
|
IN VOID *Cmd,
|
|
|
|
IN UINT8 CmdLen,
|
|
|
|
IN EFI_USB_DATA_DIRECTION DataDir,
|
|
|
|
IN VOID *Data,
|
|
|
|
IN UINT32 DataLen,
|
2008-06-27 10:09:00 +02:00
|
|
|
IN UINT8 Lun,
|
2007-07-11 10:47:37 +02:00
|
|
|
IN UINT32 Timeout,
|
|
|
|
OUT UINT32 *CmdStatus
|
|
|
|
);
|
|
|
|
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
|
|
|
(*USB_MASS_RESET) (
|
|
|
|
IN VOID *Context,
|
|
|
|
IN BOOLEAN ExtendedVerification
|
|
|
|
);
|
|
|
|
|
2008-06-27 10:09:00 +02:00
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
|
|
|
(*USB_MASS_GET_MAX_LUN) (
|
|
|
|
IN VOID *Context,
|
|
|
|
IN UINT8 *MaxLun
|
|
|
|
);
|
|
|
|
|
2007-07-11 10:47:37 +02:00
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
|
|
|
(*USB_MASS_FINI) (
|
|
|
|
IN VOID *Context
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// This structure contains information necessary to select the
|
|
|
|
// proper transport protocol. The mass storage class defines
|
|
|
|
// two transport protocols. One is the CBI, and the other is BOT.
|
|
|
|
// CBI is being obseleted. The design is made modular by this
|
|
|
|
// structure so that the CBI protocol can be easily removed when
|
|
|
|
// it is no longer necessary.
|
|
|
|
//
|
|
|
|
typedef struct {
|
|
|
|
UINT8 Protocol;
|
|
|
|
USB_MASS_INIT_TRANSPORT Init; // Initialize the mass storage transport protocol
|
|
|
|
USB_MASS_EXEC_COMMAND ExecCommand; // Transport command to the device then get result
|
|
|
|
USB_MASS_RESET Reset; // Reset the device
|
2008-06-27 10:09:00 +02:00
|
|
|
USB_MASS_GET_MAX_LUN GetMaxLun; // Get max lun, only for bot
|
2007-07-11 10:47:37 +02:00
|
|
|
USB_MASS_FINI Fini; // Clean up the resources.
|
|
|
|
} USB_MASS_TRANSPORT;
|
|
|
|
|
|
|
|
|
2008-07-23 10:30:25 +02:00
|
|
|
/**
|
|
|
|
Use the USB clear feature control transfer to clear the endpoint
|
|
|
|
stall condition.
|
|
|
|
|
|
|
|
@param UsbIo The USB IO protocol to use
|
|
|
|
@param EndpointAddr The endpoint to clear stall for
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The endpoint stall condtion is clear
|
|
|
|
@retval Others Failed to clear the endpoint stall condtion
|
|
|
|
|
|
|
|
**/
|
2007-07-11 10:47:37 +02:00
|
|
|
EFI_STATUS
|
|
|
|
UsbClearEndpointStall (
|
|
|
|
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
2008-07-23 10:30:25 +02:00
|
|
|
IN UINT8 EndpointAddr
|
2007-07-11 10:47:37 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|