]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMass.h
CommitLineData
e237e7ae 1/** @file\r
d1102dba 2 Definition of USB Mass Storage Class and its value, USB Mass Transport Protocol,\r
3e03cb4d 3 and other common definitions.\r
e237e7ae 4\r
d1102dba 5Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
e237e7ae 7\r
8**/\r
9\r
10#ifndef _EFI_USBMASS_H_\r
11#define _EFI_USBMASS_H_\r
12\r
60c93673 13#include <Uefi.h>\r
99c1725e 14#include <IndustryStandard/Scsi.h>\r
e237e7ae 15#include <Protocol/BlockIo.h>\r
16#include <Protocol/UsbIo.h>\r
c7e39923 17#include <Protocol/DevicePath.h>\r
39840c50 18#include <Protocol/DiskInfo.h>\r
776a705e 19#include <Library/BaseLib.h>\r
e237e7ae 20#include <Library/DebugLib.h>\r
21#include <Library/BaseMemoryLib.h>\r
22#include <Library/UefiDriverEntryPoint.h>\r
23#include <Library/UefiBootServicesTableLib.h>\r
24#include <Library/UefiLib.h>\r
25#include <Library/MemoryAllocationLib.h>\r
c7e39923 26#include <Library/DevicePathLib.h>\r
e237e7ae 27\r
1436aea4
MK
28typedef struct _USB_MASS_TRANSPORT USB_MASS_TRANSPORT;\r
29typedef struct _USB_MASS_DEVICE USB_MASS_DEVICE;\r
39840c50 30\r
31#include "UsbMassBot.h"\r
32#include "UsbMassCbi.h"\r
33#include "UsbMassBoot.h"\r
34#include "UsbMassDiskInfo.h"\r
35#include "UsbMassImpl.h"\r
36\r
d80ed2a7 37#define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == BIT7)\r
38#define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & BIT7) == 0)\r
39#define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_BULK)\r
40#define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT)\r
e237e7ae 41#define USB_IS_ERROR(Result, Error) (((Result) & (Error)) != 0)\r
42\r
1ccdbf2a 43#define USB_MASS_1_MILLISECOND 1000\r
44#define USB_MASS_1_SECOND (1000 * USB_MASS_1_MILLISECOND)\r
45\r
1436aea4
MK
46#define USB_MASS_CMD_SUCCESS 0\r
47#define USB_MASS_CMD_FAIL 1\r
48#define USB_MASS_CMD_PERSISTENT 2\r
3e03cb4d 49\r
50/**\r
51 Initializes USB transport protocol.\r
52\r
53 This function initializes the USB mass storage class transport protocol.\r
54 It will save its context in the Context if Context isn't NULL.\r
55\r
56 @param UsbIo The USB I/O Protocol instance\r
57 @param Context The buffer to save the context to\r
e237e7ae 58\r
3e03cb4d 59 @retval EFI_SUCCESS The device is successfully initialized.\r
60 @retval EFI_UNSUPPORTED The transport protocol doesn't support the device.\r
61 @retval Other The USB transport initialization fails.\r
62\r
63**/\r
e237e7ae 64typedef\r
65EFI_STATUS\r
66(*USB_MASS_INIT_TRANSPORT) (\r
1436aea4
MK
67 IN EFI_USB_IO_PROTOCOL *Usb,\r
68 OUT VOID **Context OPTIONAL\r
e237e7ae 69 );\r
70\r
3e03cb4d 71/**\r
72 Execute USB mass storage command through the transport protocol.\r
73\r
74 @param Context The USB Transport Protocol.\r
75 @param Cmd The command to transfer to device\r
76 @param CmdLen The length of the command\r
77 @param DataDir The direction of data transfer\r
78 @param Data The buffer to hold the data\r
79 @param DataLen The length of the buffer\r
80 @param Lun Should be 0, this field for bot only\r
81 @param Timeout The time to wait\r
82 @param CmdStatus The result of the command execution\r
83\r
84 @retval EFI_SUCCESS The command is executed successfully.\r
85 @retval Other Failed to execute the command\r
86\r
87**/\r
e237e7ae 88typedef\r
89EFI_STATUS\r
90(*USB_MASS_EXEC_COMMAND) (\r
91 IN VOID *Context,\r
92 IN VOID *Cmd,\r
93 IN UINT8 CmdLen,\r
94 IN EFI_USB_DATA_DIRECTION DataDir,\r
95 IN VOID *Data,\r
96 IN UINT32 DataLen,\r
c7e39923 97 IN UINT8 Lun,\r
e237e7ae 98 IN UINT32 Timeout,\r
99 OUT UINT32 *CmdStatus\r
100 );\r
101\r
3e03cb4d 102/**\r
103 Reset the USB mass storage device by Transport protocol.\r
104\r
105 @param Context The USB Transport Protocol\r
106 @param ExtendedVerification The flag controlling the rule of reset.\r
107 Not used here.\r
108\r
109 @retval EFI_SUCCESS The device is reset.\r
110 @retval Others Failed to reset the device.\r
111\r
112**/\r
e237e7ae 113typedef\r
114EFI_STATUS\r
115(*USB_MASS_RESET) (\r
1436aea4
MK
116 IN VOID *Context,\r
117 IN BOOLEAN ExtendedVerification\r
e237e7ae 118 );\r
119\r
3e03cb4d 120/**\r
121 Get the max LUN (Logical Unit Number) of USB mass storage device.\r
122\r
123 @param Context The context of the transport protocol.\r
124 @param MaxLun Return pointer to the max number of LUN. (e.g. MaxLun=1 means LUN0 and\r
125 LUN1 in all.)\r
126\r
127 @retval EFI_SUCCESS Max LUN is got successfully.\r
128 @retval Others Fail to execute this request.\r
129\r
130**/\r
c7e39923 131typedef\r
132EFI_STATUS\r
133(*USB_MASS_GET_MAX_LUN) (\r
1436aea4
MK
134 IN VOID *Context,\r
135 IN UINT8 *MaxLun\r
c7e39923 136 );\r
137\r
3e03cb4d 138/**\r
139 Clean up the transport protocol's resource.\r
140\r
141 @param Context The instance of transport protocol.\r
142\r
143 @retval EFI_SUCCESS The resource is cleaned up.\r
144\r
145**/\r
e237e7ae 146typedef\r
147EFI_STATUS\r
d80ed2a7 148(*USB_MASS_CLEAN_UP) (\r
1436aea4 149 IN VOID *Context\r
e237e7ae 150 );\r
151\r
d80ed2a7 152///\r
153/// This structure contains information necessary to select the\r
154/// proper transport protocol. The mass storage class defines\r
155/// two transport protocols. One is the CBI, and the other is BOT.\r
156/// CBI is being obseleted. The design is made modular by this\r
157/// structure so that the CBI protocol can be easily removed when\r
158/// it is no longer necessary.\r
159///\r
39840c50 160struct _USB_MASS_TRANSPORT {\r
1436aea4
MK
161 UINT8 Protocol;\r
162 USB_MASS_INIT_TRANSPORT Init; ///< Initialize the mass storage transport protocol\r
163 USB_MASS_EXEC_COMMAND ExecCommand; ///< Transport command to the device then get result\r
164 USB_MASS_RESET Reset; ///< Reset the device\r
165 USB_MASS_GET_MAX_LUN GetMaxLun; ///< Get max lun, only for bot\r
166 USB_MASS_CLEAN_UP CleanUp; ///< Clean up the resources.\r
39840c50 167};\r
e237e7ae 168\r
39840c50 169struct _USB_MASS_DEVICE {\r
1436aea4
MK
170 UINT32 Signature;\r
171 EFI_HANDLE Controller;\r
172 EFI_USB_IO_PROTOCOL *UsbIo;\r
173 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
174 EFI_BLOCK_IO_PROTOCOL BlockIo;\r
175 EFI_BLOCK_IO_MEDIA BlockIoMedia;\r
176 BOOLEAN OpticalStorage;\r
177 UINT8 Lun; ///< Logical Unit Number\r
178 UINT8 Pdt; ///< Peripheral Device Type\r
179 USB_MASS_TRANSPORT *Transport; ///< USB mass storage transport protocol\r
180 VOID *Context;\r
181 EFI_DISK_INFO_PROTOCOL DiskInfo;\r
182 USB_BOOT_INQUIRY_DATA InquiryData;\r
183 BOOLEAN Cdb16Byte;\r
39840c50 184};\r
e237e7ae 185\r
e237e7ae 186#endif\r