]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMass.h
CommitLineData
e237e7ae 1/** @file\r
3e03cb4d 2 Definition of USB Mass Storage Class and its value, USB Mass Transport Protocol, \r
3 and other common definitions.\r
e237e7ae 4\r
cd5ebaa0
HT
5Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
6This program and the accompanying materials\r
cc5166ff 7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
e237e7ae 10\r
cc5166ff 11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
e237e7ae 13\r
14**/\r
15\r
16#ifndef _EFI_USBMASS_H_\r
17#define _EFI_USBMASS_H_\r
18\r
ed7748fe 19\r
60c93673 20#include <Uefi.h>\r
ed7748fe 21\r
e237e7ae 22#include <Protocol/BlockIo.h>\r
23#include <Protocol/UsbIo.h>\r
c7e39923 24#include <Protocol/DevicePath.h>\r
ed7748fe 25\r
776a705e 26#include <Library/BaseLib.h>\r
e237e7ae 27#include <Library/DebugLib.h>\r
28#include <Library/BaseMemoryLib.h>\r
29#include <Library/UefiDriverEntryPoint.h>\r
30#include <Library/UefiBootServicesTableLib.h>\r
31#include <Library/UefiLib.h>\r
32#include <Library/MemoryAllocationLib.h>\r
c7e39923 33#include <Library/DevicePathLib.h>\r
e237e7ae 34\r
d80ed2a7 35#define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == BIT7)\r
36#define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == 0)\r
37#define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_BULK)\r
38#define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT)\r
e237e7ae 39#define USB_IS_ERROR(Result, Error) (((Result) & (Error)) != 0)\r
40\r
1ccdbf2a 41//\r
42// Usb mass storage class code\r
43//\r
44#define USB_MASS_STORE_CLASS 0x08\r
45\r
46//\r
47// Usb mass storage subclass code, specify the command set used.\r
48//\r
49#define USB_MASS_STORE_RBC 0x01 ///< Reduced Block Commands\r
50#define USB_MASS_STORE_8020I 0x02 ///< SFF-8020i, typically a CD/DVD device\r
51#define USB_MASS_STORE_QIC 0x03 ///< Typically a tape device\r
52#define USB_MASS_STORE_UFI 0x04 ///< Typically a floppy disk driver device\r
53#define USB_MASS_STORE_8070I 0x05 ///< SFF-8070i, typically a floppy disk driver device.\r
54#define USB_MASS_STORE_SCSI 0x06 ///< SCSI transparent command set\r
55\r
56//\r
57// Usb mass storage protocol code, specify the transport protocol\r
58//\r
59#define USB_MASS_STORE_CBI0 0x00 ///< CBI protocol with command completion interrupt\r
60#define USB_MASS_STORE_CBI1 0x01 ///< CBI protocol without command completion interrupt\r
61#define USB_MASS_STORE_BOT 0x50 ///< Bulk-Only Transport\r
62\r
63#define USB_MASS_1_MILLISECOND 1000\r
64#define USB_MASS_1_SECOND (1000 * USB_MASS_1_MILLISECOND)\r
65\r
66#define USB_MASS_CMD_SUCCESS 0\r
67#define USB_MASS_CMD_FAIL 1\r
68#define USB_MASS_CMD_PERSISTENT 2\r
3e03cb4d 69\r
70/**\r
71 Initializes USB transport protocol.\r
72\r
73 This function initializes the USB mass storage class transport protocol.\r
74 It will save its context in the Context if Context isn't NULL.\r
75\r
76 @param UsbIo The USB I/O Protocol instance\r
77 @param Context The buffer to save the context to\r
e237e7ae 78\r
3e03cb4d 79 @retval EFI_SUCCESS The device is successfully initialized.\r
80 @retval EFI_UNSUPPORTED The transport protocol doesn't support the device.\r
81 @retval Other The USB transport initialization fails.\r
82\r
83**/\r
e237e7ae 84typedef\r
85EFI_STATUS\r
86(*USB_MASS_INIT_TRANSPORT) (\r
87 IN EFI_USB_IO_PROTOCOL *Usb,\r
e237e7ae 88 OUT VOID **Context OPTIONAL\r
89 );\r
90\r
3e03cb4d 91/**\r
92 Execute USB mass storage command through the transport protocol.\r
93\r
94 @param Context The USB Transport Protocol.\r
95 @param Cmd The command to transfer to device\r
96 @param CmdLen The length of the command\r
97 @param DataDir The direction of data transfer\r
98 @param Data The buffer to hold the data\r
99 @param DataLen The length of the buffer\r
100 @param Lun Should be 0, this field for bot only\r
101 @param Timeout The time to wait\r
102 @param CmdStatus The result of the command execution\r
103\r
104 @retval EFI_SUCCESS The command is executed successfully.\r
105 @retval Other Failed to execute the command\r
106\r
107**/\r
e237e7ae 108typedef\r
109EFI_STATUS\r
110(*USB_MASS_EXEC_COMMAND) (\r
111 IN VOID *Context,\r
112 IN VOID *Cmd,\r
113 IN UINT8 CmdLen,\r
114 IN EFI_USB_DATA_DIRECTION DataDir,\r
115 IN VOID *Data,\r
116 IN UINT32 DataLen,\r
c7e39923 117 IN UINT8 Lun,\r
e237e7ae 118 IN UINT32 Timeout,\r
119 OUT UINT32 *CmdStatus\r
120 );\r
121\r
3e03cb4d 122/**\r
123 Reset the USB mass storage device by Transport protocol.\r
124\r
125 @param Context The USB Transport Protocol\r
126 @param ExtendedVerification The flag controlling the rule of reset.\r
127 Not used here.\r
128\r
129 @retval EFI_SUCCESS The device is reset.\r
130 @retval Others Failed to reset the device.\r
131\r
132**/\r
e237e7ae 133typedef\r
134EFI_STATUS\r
135(*USB_MASS_RESET) (\r
136 IN VOID *Context,\r
137 IN BOOLEAN ExtendedVerification\r
138 );\r
139\r
3e03cb4d 140/**\r
141 Get the max LUN (Logical Unit Number) of USB mass storage device.\r
142\r
143 @param Context The context of the transport protocol.\r
144 @param MaxLun Return pointer to the max number of LUN. (e.g. MaxLun=1 means LUN0 and\r
145 LUN1 in all.)\r
146\r
147 @retval EFI_SUCCESS Max LUN is got successfully.\r
148 @retval Others Fail to execute this request.\r
149\r
150**/\r
c7e39923 151typedef\r
152EFI_STATUS\r
153(*USB_MASS_GET_MAX_LUN) (\r
154 IN VOID *Context,\r
155 IN UINT8 *MaxLun\r
156 );\r
157\r
3e03cb4d 158/**\r
159 Clean up the transport protocol's resource.\r
160\r
161 @param Context The instance of transport protocol.\r
162\r
163 @retval EFI_SUCCESS The resource is cleaned up.\r
164\r
165**/\r
e237e7ae 166typedef\r
167EFI_STATUS\r
d80ed2a7 168(*USB_MASS_CLEAN_UP) (\r
e237e7ae 169 IN VOID *Context\r
170 );\r
171\r
d80ed2a7 172///\r
173/// This structure contains information necessary to select the\r
174/// proper transport protocol. The mass storage class defines\r
175/// two transport protocols. One is the CBI, and the other is BOT.\r
176/// CBI is being obseleted. The design is made modular by this\r
177/// structure so that the CBI protocol can be easily removed when\r
178/// it is no longer necessary.\r
179///\r
e237e7ae 180typedef struct {\r
181 UINT8 Protocol;\r
d80ed2a7 182 USB_MASS_INIT_TRANSPORT Init; ///< Initialize the mass storage transport protocol\r
183 USB_MASS_EXEC_COMMAND ExecCommand; ///< Transport command to the device then get result\r
184 USB_MASS_RESET Reset; ///< Reset the device\r
185 USB_MASS_GET_MAX_LUN GetMaxLun; ///< Get max lun, only for bot\r
186 USB_MASS_CLEAN_UP CleanUp; ///< Clean up the resources.\r
e237e7ae 187} USB_MASS_TRANSPORT;\r
188\r
3e03cb4d 189typedef struct {\r
190 UINT32 Signature;\r
191 EFI_HANDLE Controller;\r
192 EFI_USB_IO_PROTOCOL *UsbIo;\r
193 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
194 EFI_BLOCK_IO_PROTOCOL BlockIo;\r
195 EFI_BLOCK_IO_MEDIA BlockIoMedia;\r
196 BOOLEAN OpticalStorage;\r
197 UINT8 Lun; ///< Logical Unit Number\r
198 UINT8 Pdt; ///< Peripheral Device Type\r
199 USB_MASS_TRANSPORT *Transport; ///< USB mass storage transport protocol\r
200 VOID *Context; \r
201} USB_MASS_DEVICE;\r
e237e7ae 202\r
e237e7ae 203#endif\r