]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h
Update auth-variable and secure boot UI driver to support only time-based PK, KEK...
[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
39840c50 5Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 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
39840c50 25#include <Protocol/DiskInfo.h>\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
39840c50 35typedef struct _USB_MASS_TRANSPORT USB_MASS_TRANSPORT;\r
36typedef struct _USB_MASS_DEVICE USB_MASS_DEVICE;\r
37\r
38#include "UsbMassBot.h"\r
39#include "UsbMassCbi.h"\r
40#include "UsbMassBoot.h"\r
41#include "UsbMassDiskInfo.h"\r
42#include "UsbMassImpl.h"\r
43\r
d80ed2a7 44#define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == BIT7)\r
45#define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == 0)\r
46#define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_BULK)\r
47#define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT)\r
e237e7ae 48#define USB_IS_ERROR(Result, Error) (((Result) & (Error)) != 0)\r
49\r
1ccdbf2a 50//\r
51// Usb mass storage class code\r
52//\r
53#define USB_MASS_STORE_CLASS 0x08\r
54\r
55//\r
56// Usb mass storage subclass code, specify the command set used.\r
57//\r
58#define USB_MASS_STORE_RBC 0x01 ///< Reduced Block Commands\r
59#define USB_MASS_STORE_8020I 0x02 ///< SFF-8020i, typically a CD/DVD device\r
60#define USB_MASS_STORE_QIC 0x03 ///< Typically a tape device\r
61#define USB_MASS_STORE_UFI 0x04 ///< Typically a floppy disk driver device\r
62#define USB_MASS_STORE_8070I 0x05 ///< SFF-8070i, typically a floppy disk driver device.\r
63#define USB_MASS_STORE_SCSI 0x06 ///< SCSI transparent command set\r
64\r
65//\r
66// Usb mass storage protocol code, specify the transport protocol\r
67//\r
68#define USB_MASS_STORE_CBI0 0x00 ///< CBI protocol with command completion interrupt\r
69#define USB_MASS_STORE_CBI1 0x01 ///< CBI protocol without command completion interrupt\r
70#define USB_MASS_STORE_BOT 0x50 ///< Bulk-Only Transport\r
71\r
72#define USB_MASS_1_MILLISECOND 1000\r
73#define USB_MASS_1_SECOND (1000 * USB_MASS_1_MILLISECOND)\r
74\r
75#define USB_MASS_CMD_SUCCESS 0\r
76#define USB_MASS_CMD_FAIL 1\r
77#define USB_MASS_CMD_PERSISTENT 2\r
3e03cb4d 78\r
79/**\r
80 Initializes USB transport protocol.\r
81\r
82 This function initializes the USB mass storage class transport protocol.\r
83 It will save its context in the Context if Context isn't NULL.\r
84\r
85 @param UsbIo The USB I/O Protocol instance\r
86 @param Context The buffer to save the context to\r
e237e7ae 87\r
3e03cb4d 88 @retval EFI_SUCCESS The device is successfully initialized.\r
89 @retval EFI_UNSUPPORTED The transport protocol doesn't support the device.\r
90 @retval Other The USB transport initialization fails.\r
91\r
92**/\r
e237e7ae 93typedef\r
94EFI_STATUS\r
95(*USB_MASS_INIT_TRANSPORT) (\r
96 IN EFI_USB_IO_PROTOCOL *Usb,\r
e237e7ae 97 OUT VOID **Context OPTIONAL\r
98 );\r
99\r
3e03cb4d 100/**\r
101 Execute USB mass storage command through the transport protocol.\r
102\r
103 @param Context The USB Transport Protocol.\r
104 @param Cmd The command to transfer to device\r
105 @param CmdLen The length of the command\r
106 @param DataDir The direction of data transfer\r
107 @param Data The buffer to hold the data\r
108 @param DataLen The length of the buffer\r
109 @param Lun Should be 0, this field for bot only\r
110 @param Timeout The time to wait\r
111 @param CmdStatus The result of the command execution\r
112\r
113 @retval EFI_SUCCESS The command is executed successfully.\r
114 @retval Other Failed to execute the command\r
115\r
116**/\r
e237e7ae 117typedef\r
118EFI_STATUS\r
119(*USB_MASS_EXEC_COMMAND) (\r
120 IN VOID *Context,\r
121 IN VOID *Cmd,\r
122 IN UINT8 CmdLen,\r
123 IN EFI_USB_DATA_DIRECTION DataDir,\r
124 IN VOID *Data,\r
125 IN UINT32 DataLen,\r
c7e39923 126 IN UINT8 Lun,\r
e237e7ae 127 IN UINT32 Timeout,\r
128 OUT UINT32 *CmdStatus\r
129 );\r
130\r
3e03cb4d 131/**\r
132 Reset the USB mass storage device by Transport protocol.\r
133\r
134 @param Context The USB Transport Protocol\r
135 @param ExtendedVerification The flag controlling the rule of reset.\r
136 Not used here.\r
137\r
138 @retval EFI_SUCCESS The device is reset.\r
139 @retval Others Failed to reset the device.\r
140\r
141**/\r
e237e7ae 142typedef\r
143EFI_STATUS\r
144(*USB_MASS_RESET) (\r
145 IN VOID *Context,\r
146 IN BOOLEAN ExtendedVerification\r
147 );\r
148\r
3e03cb4d 149/**\r
150 Get the max LUN (Logical Unit Number) of USB mass storage device.\r
151\r
152 @param Context The context of the transport protocol.\r
153 @param MaxLun Return pointer to the max number of LUN. (e.g. MaxLun=1 means LUN0 and\r
154 LUN1 in all.)\r
155\r
156 @retval EFI_SUCCESS Max LUN is got successfully.\r
157 @retval Others Fail to execute this request.\r
158\r
159**/\r
c7e39923 160typedef\r
161EFI_STATUS\r
162(*USB_MASS_GET_MAX_LUN) (\r
163 IN VOID *Context,\r
164 IN UINT8 *MaxLun\r
165 );\r
166\r
3e03cb4d 167/**\r
168 Clean up the transport protocol's resource.\r
169\r
170 @param Context The instance of transport protocol.\r
171\r
172 @retval EFI_SUCCESS The resource is cleaned up.\r
173\r
174**/\r
e237e7ae 175typedef\r
176EFI_STATUS\r
d80ed2a7 177(*USB_MASS_CLEAN_UP) (\r
e237e7ae 178 IN VOID *Context\r
179 );\r
180\r
d80ed2a7 181///\r
182/// This structure contains information necessary to select the\r
183/// proper transport protocol. The mass storage class defines\r
184/// two transport protocols. One is the CBI, and the other is BOT.\r
185/// CBI is being obseleted. The design is made modular by this\r
186/// structure so that the CBI protocol can be easily removed when\r
187/// it is no longer necessary.\r
188///\r
39840c50 189struct _USB_MASS_TRANSPORT {\r
e237e7ae 190 UINT8 Protocol;\r
d80ed2a7 191 USB_MASS_INIT_TRANSPORT Init; ///< Initialize the mass storage transport protocol\r
192 USB_MASS_EXEC_COMMAND ExecCommand; ///< Transport command to the device then get result\r
193 USB_MASS_RESET Reset; ///< Reset the device\r
194 USB_MASS_GET_MAX_LUN GetMaxLun; ///< Get max lun, only for bot\r
195 USB_MASS_CLEAN_UP CleanUp; ///< Clean up the resources.\r
39840c50 196};\r
e237e7ae 197\r
39840c50 198struct _USB_MASS_DEVICE {\r
3e03cb4d 199 UINT32 Signature;\r
200 EFI_HANDLE Controller;\r
201 EFI_USB_IO_PROTOCOL *UsbIo;\r
202 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
203 EFI_BLOCK_IO_PROTOCOL BlockIo;\r
204 EFI_BLOCK_IO_MEDIA BlockIoMedia;\r
205 BOOLEAN OpticalStorage;\r
206 UINT8 Lun; ///< Logical Unit Number\r
207 UINT8 Pdt; ///< Peripheral Device Type\r
208 USB_MASS_TRANSPORT *Transport; ///< USB mass storage transport protocol\r
39840c50 209 VOID *Context;\r
210 EFI_DISK_INFO_PROTOCOL DiskInfo;\r
211 USB_BOOT_INQUIRY_DATA InquiryData;\r
212};\r
e237e7ae 213\r
e237e7ae 214#endif\r