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