]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h
Change the name of extension
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMass.h
CommitLineData
e237e7ae 1/** @file\r
2\r
e237e7ae 3 Defination for the USB mass storage class driver. The USB mass storage\r
4 class is specified in two layers: the bottom layer is the transportation\r
5 protocol. The top layer is the command set. The transportation layer\r
6 provides the transportation of the command, data and result. The command\r
7 set defines what the command, data and result. The Bulk-Only-Transport and\r
8 Control/Bulk/Interrupt transport are two transportation protocol. USB mass\r
9 storage class adopts various industrial standard as its command set.\r
10\r
cc5166ff 11Copyright (c) 2007 - 2008, Intel Corporation\r
12All rights reserved. This program and the accompanying materials\r
13are licensed and made available under the terms and conditions of the BSD License\r
14which accompanies this distribution. The full text of the license may be found at\r
15http://opensource.org/licenses/bsd-license.php\r
e237e7ae 16\r
cc5166ff 17THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
18WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
e237e7ae 19\r
20**/\r
21\r
22#ifndef _EFI_USBMASS_H_\r
23#define _EFI_USBMASS_H_\r
24\r
ed7748fe 25\r
60c93673 26#include <Uefi.h>\r
ed7748fe 27\r
e237e7ae 28#include <Protocol/BlockIo.h>\r
29#include <Protocol/UsbIo.h>\r
c7e39923 30#include <Protocol/DevicePath.h>\r
ed7748fe 31\r
e237e7ae 32#include <Library/DebugLib.h>\r
33#include <Library/BaseMemoryLib.h>\r
34#include <Library/UefiDriverEntryPoint.h>\r
35#include <Library/UefiBootServicesTableLib.h>\r
36#include <Library/UefiLib.h>\r
37#include <Library/MemoryAllocationLib.h>\r
c7e39923 38#include <Library/DevicePathLib.h>\r
e237e7ae 39\r
d80ed2a7 40#define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == BIT7)\r
41#define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == 0)\r
42#define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_BULK)\r
43#define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT)\r
e237e7ae 44#define USB_IS_ERROR(Result, Error) (((Result) & (Error)) != 0)\r
45\r
cc5166ff 46typedef enum {\r
e237e7ae 47 //\r
48 // Usb mass storage class code\r
49 //\r
50 USB_MASS_STORE_CLASS = 0x08,\r
51\r
52 //\r
53 // Usb mass storage subclass code, specify the command set used.\r
54 //\r
d80ed2a7 55 USB_MASS_STORE_RBC = 0x01, ///< Reduced Block Commands\r
56 USB_MASS_STORE_8020I = 0x02, ///< SFF-8020i, typically a CD/DVD device\r
57 USB_MASS_STORE_QIC = 0x03, ///< Typically a tape device\r
58 USB_MASS_STORE_UFI = 0x04, ///< Typically a floppy disk driver device\r
59 USB_MASS_STORE_8070I = 0x05, ///< SFF-8070i, typically a floppy disk driver device.\r
60 USB_MASS_STORE_SCSI = 0x06, ///< SCSI transparent command set\r
e237e7ae 61\r
62 //\r
63 // Usb mass storage protocol code, specify the transport protocol\r
64 //\r
d80ed2a7 65 USB_MASS_STORE_CBI0 = 0x00, ///< CBI protocol with command completion interrupt\r
66 USB_MASS_STORE_CBI1 = 0x01, ///< CBI protocol without command completion interrupt\r
67 USB_MASS_STORE_BOT = 0x50, ///< Bulk-Only Transport\r
e237e7ae 68\r
41e8ff27 69 USB_MASS_1_MILLISECOND = 1000,\r
70 USB_MASS_1_SECOND = 1000 * USB_MASS_1_MILLISECOND,\r
e237e7ae 71\r
72 USB_MASS_CMD_SUCCESS = 0,\r
73 USB_MASS_CMD_FAIL,\r
c52fa98c 74 USB_MASS_CMD_PERSISTENT\r
cc5166ff 75}USB_MASS_DEV_CLASS_AND_VALUE;\r
e237e7ae 76\r
77typedef\r
78EFI_STATUS\r
79(*USB_MASS_INIT_TRANSPORT) (\r
80 IN EFI_USB_IO_PROTOCOL *Usb,\r
e237e7ae 81 OUT VOID **Context OPTIONAL\r
82 );\r
83\r
84typedef\r
85EFI_STATUS\r
86(*USB_MASS_EXEC_COMMAND) (\r
87 IN VOID *Context,\r
88 IN VOID *Cmd,\r
89 IN UINT8 CmdLen,\r
90 IN EFI_USB_DATA_DIRECTION DataDir,\r
91 IN VOID *Data,\r
92 IN UINT32 DataLen,\r
c7e39923 93 IN UINT8 Lun,\r
e237e7ae 94 IN UINT32 Timeout,\r
95 OUT UINT32 *CmdStatus\r
96 );\r
97\r
98typedef\r
99EFI_STATUS\r
100(*USB_MASS_RESET) (\r
101 IN VOID *Context,\r
102 IN BOOLEAN ExtendedVerification\r
103 );\r
104\r
c7e39923 105typedef\r
106EFI_STATUS\r
107(*USB_MASS_GET_MAX_LUN) (\r
108 IN VOID *Context,\r
109 IN UINT8 *MaxLun\r
110 );\r
111\r
e237e7ae 112typedef\r
113EFI_STATUS\r
d80ed2a7 114(*USB_MASS_CLEAN_UP) (\r
e237e7ae 115 IN VOID *Context\r
116 );\r
117\r
d80ed2a7 118///\r
119/// This structure contains information necessary to select the\r
120/// proper transport protocol. The mass storage class defines\r
121/// two transport protocols. One is the CBI, and the other is BOT.\r
122/// CBI is being obseleted. The design is made modular by this\r
123/// structure so that the CBI protocol can be easily removed when\r
124/// it is no longer necessary.\r
125///\r
e237e7ae 126typedef struct {\r
127 UINT8 Protocol;\r
d80ed2a7 128 USB_MASS_INIT_TRANSPORT Init; ///< Initialize the mass storage transport protocol\r
129 USB_MASS_EXEC_COMMAND ExecCommand; ///< Transport command to the device then get result\r
130 USB_MASS_RESET Reset; ///< Reset the device\r
131 USB_MASS_GET_MAX_LUN GetMaxLun; ///< Get max lun, only for bot\r
132 USB_MASS_CLEAN_UP CleanUp; ///< Clean up the resources.\r
e237e7ae 133} USB_MASS_TRANSPORT;\r
134\r
135\r
cc5166ff 136/**\r
137 Use the USB clear feature control transfer to clear the endpoint\r
138 stall condition.\r
139\r
140 @param UsbIo The USB IO protocol to use\r
141 @param EndpointAddr The endpoint to clear stall for\r
142\r
143 @retval EFI_SUCCESS The endpoint stall condtion is clear\r
144 @retval Others Failed to clear the endpoint stall condtion\r
145\r
146**/\r
e237e7ae 147EFI_STATUS\r
148UsbClearEndpointStall (\r
149 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
cc5166ff 150 IN UINT8 EndpointAddr\r
e237e7ae 151 );\r
152\r
e237e7ae 153#endif\r