3 Defination for the USB mass storage class driver. The USB mass storage
4 class is specified in two layers: the bottom layer is the transportation
5 protocol. The top layer is the command set. The transportation layer
6 provides the transportation of the command, data and result. The command
7 set defines what the command, data and result. The Bulk-Only-Transport and
8 Control/Bulk/Interrupt transport are two transportation protocol. USB mass
9 storage class adopts various industrial standard as its command set.
11 Copyright (c) 2007 - 2008, Intel Corporation
12 All rights reserved. This program and the accompanying materials
13 are licensed and made available under the terms and conditions of the BSD License
14 which accompanies this distribution. The full text of the license may be found at
15 http://opensource.org/licenses/bsd-license.php
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #ifndef _EFI_USBMASS_H_
23 #define _EFI_USBMASS_H_
28 #include <Protocol/BlockIo.h>
29 #include <Protocol/UsbIo.h>
30 #include <Protocol/DevicePath.h>
32 #include <Library/DebugLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/UefiDriverEntryPoint.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/UefiLib.h>
37 #include <Library/MemoryAllocationLib.h>
38 #include <Library/DevicePathLib.h>
40 #define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & 0x80) == 0x80)
41 #define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & 0x80) == 0)
42 #define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & 0x03) == 0x02)
43 #define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & 0x03) == 0x03)
44 #define USB_IS_ERROR(Result, Error) (((Result) & (Error)) != 0)
48 // Usb mass storage class code
50 USB_MASS_STORE_CLASS
= 0x08,
53 // Usb mass storage subclass code, specify the command set used.
55 USB_MASS_STORE_RBC
= 0x01, // Reduced Block Commands
56 USB_MASS_STORE_8020I
= 0x02, // SFF-8020i, typically a CD/DVD device
57 USB_MASS_STORE_QIC
= 0x03, // Typically a tape device
58 USB_MASS_STORE_UFI
= 0x04, // Typically a floppy disk driver device
59 USB_MASS_STORE_8070I
= 0x05, // SFF-8070i, typically a floppy disk driver device.
60 USB_MASS_STORE_SCSI
= 0x06, // SCSI transparent command set
63 // Usb mass storage protocol code, specify the transport protocol
65 USB_MASS_STORE_CBI0
= 0x00, // CBI protocol with command completion interrupt
66 USB_MASS_STORE_CBI1
= 0x01, // CBI protocol without command completion interrupt
67 USB_MASS_STORE_BOT
= 0x50, // Bulk-Only Transport
69 USB_MASS_1_MILLISECOND
= 1000,
70 USB_MASS_1_SECOND
= 1000 * USB_MASS_1_MILLISECOND
,
72 USB_MASS_CMD_SUCCESS
= 0,
74 USB_MASS_CMD_PERSISTENT
75 }USB_MASS_DEV_CLASS_AND_VALUE
;
79 (*USB_MASS_INIT_TRANSPORT
) (
80 IN EFI_USB_IO_PROTOCOL
*Usb
,
81 OUT VOID
**Context OPTIONAL
86 (*USB_MASS_EXEC_COMMAND
) (
90 IN EFI_USB_DATA_DIRECTION DataDir
,
102 IN BOOLEAN ExtendedVerification
107 (*USB_MASS_GET_MAX_LUN
) (
119 // This structure contains information necessary to select the
120 // proper transport protocol. The mass storage class defines
121 // two transport protocols. One is the CBI, and the other is BOT.
122 // CBI is being obseleted. The design is made modular by this
123 // structure so that the CBI protocol can be easily removed when
124 // it is no longer necessary.
128 USB_MASS_INIT_TRANSPORT Init
; // Initialize the mass storage transport protocol
129 USB_MASS_EXEC_COMMAND ExecCommand
; // Transport command to the device then get result
130 USB_MASS_RESET Reset
; // Reset the device
131 USB_MASS_GET_MAX_LUN GetMaxLun
; // Get max lun, only for bot
132 USB_MASS_FINI Fini
; // Clean up the resources.
133 } USB_MASS_TRANSPORT
;
137 Use the USB clear feature control transfer to clear the endpoint
140 @param UsbIo The USB IO protocol to use
141 @param EndpointAddr The endpoint to clear stall for
143 @retval EFI_SUCCESS The endpoint stall condtion is clear
144 @retval Others Failed to clear the endpoint stall condtion
148 UsbClearEndpointStall (
149 IN EFI_USB_IO_PROTOCOL
*UsbIo
,
150 IN UINT8 EndpointAddr