]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.h
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMassImpl.h
CommitLineData
e237e7ae 1/** @file\r
3e03cb4d 2 Definitions of functions for Driver Binding Protocol and Block I/O Protocol,\r
3 and other internal definitions.\r
cc5166ff 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
e237e7ae 8**/\r
9\r
10#ifndef _EFI_USBMASS_IMPL_H_\r
11#define _EFI_USBMASS_IMPL_H_\r
12\r
1436aea4 13#define USB_MASS_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'M')\r
cc5166ff 14\r
d80ed2a7 15#define USB_MASS_DEVICE_FROM_BLOCK_IO(a) \\r
e237e7ae 16 CR (a, USB_MASS_DEVICE, BlockIo, USB_MASS_SIGNATURE)\r
17\r
39840c50 18#define USB_MASS_DEVICE_FROM_DISK_INFO(a) \\r
19 CR (a, USB_MASS_DEVICE, DiskInfo, USB_MASS_SIGNATURE)\r
20\r
62b9bb55 21extern EFI_COMPONENT_NAME_PROTOCOL gUsbMassStorageComponentName;\r
22extern EFI_COMPONENT_NAME2_PROTOCOL gUsbMassStorageComponentName2;\r
e237e7ae 23\r
d80ed2a7 24//\r
25// Functions for Driver Binding Protocol\r
26//\r
27\r
28/**\r
29 Check whether the controller is a supported USB mass storage.\r
30\r
31 @param This The USB mass storage driver binding protocol.\r
32 @param Controller The controller handle to check.\r
33 @param RemainingDevicePath The remaining device path.\r
34\r
35 @retval EFI_SUCCESS The driver supports this controller.\r
36 @retval other This device isn't supported.\r
37\r
38**/\r
39EFI_STATUS\r
40EFIAPI\r
41USBMassDriverBindingSupported (\r
42 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
43 IN EFI_HANDLE Controller,\r
44 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
45 );\r
46\r
47/**\r
48 Starts the USB mass storage device with this driver.\r
49\r
957ca631 50 This function consumes USB I/O Protocol, initializes USB mass storage device,\r
d80ed2a7 51 installs Block I/O Protocol, and submits Asynchronous Interrupt\r
52 Transfer to manage the USB mass storage device.\r
53\r
3e03cb4d 54 @param This The USB mass storage driver binding protocol.\r
55 @param Controller The USB mass storage device to start on\r
56 @param RemainingDevicePath The remaining device path.\r
d80ed2a7 57\r
58 @retval EFI_SUCCESS This driver supports this device.\r
59 @retval EFI_UNSUPPORTED This driver does not support this device.\r
60 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.\r
61 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
62 @retval EFI_ALREADY_STARTED This driver has been started.\r
63\r
64**/\r
65EFI_STATUS\r
66EFIAPI\r
67USBMassDriverBindingStart (\r
68 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
69 IN EFI_HANDLE Controller,\r
70 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
71 );\r
72\r
73/**\r
74 Stop controlling the device.\r
75\r
76 @param This The USB mass storage driver binding\r
77 @param Controller The device controller controlled by the driver.\r
78 @param NumberOfChildren The number of children of this device\r
79 @param ChildHandleBuffer The buffer of children handle.\r
80\r
81 @retval EFI_SUCCESS The driver stopped from controlling the device.\r
3e03cb4d 82 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
83 @retval EFI_UNSUPPORTED Block I/O Protocol is not installed on Controller.\r
d80ed2a7 84 @retval Others Failed to stop the driver\r
85\r
86**/\r
87EFI_STATUS\r
88EFIAPI\r
89USBMassDriverBindingStop (\r
1436aea4
MK
90 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
91 IN EFI_HANDLE Controller,\r
92 IN UINTN NumberOfChildren,\r
93 IN EFI_HANDLE *ChildHandleBuffer\r
d80ed2a7 94 );\r
95\r
96//\r
97// Functions for Block I/O Protocol\r
98//\r
99\r
100/**\r
101 Reset the block device.\r
102\r
d1102dba 103 This function implements EFI_BLOCK_IO_PROTOCOL.Reset().\r
d80ed2a7 104 It resets the block device hardware.\r
105 ExtendedVerification is ignored in this implementation.\r
106\r
107 @param This Indicates a pointer to the calling context.\r
108 @param ExtendedVerification Indicates that the driver may perform a more exhaustive\r
109 verification operation of the device during reset.\r
110\r
111 @retval EFI_SUCCESS The block device was reset.\r
112 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be reset.\r
113\r
114**/\r
115EFI_STATUS\r
116EFIAPI\r
117UsbMassReset (\r
1436aea4
MK
118 IN EFI_BLOCK_IO_PROTOCOL *This,\r
119 IN BOOLEAN ExtendedVerification\r
d80ed2a7 120 );\r
121\r
122/**\r
123 Reads the requested number of blocks from the device.\r
124\r
d1102dba 125 This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks().\r
d80ed2a7 126 It reads the requested number of blocks from the device.\r
127 All the blocks are read, or an error is returned.\r
128\r
129 @param This Indicates a pointer to the calling context.\r
130 @param MediaId The media ID that the read request is for.\r
131 @param Lba The starting logical block address to read from on the device.\r
132 @param BufferSize The size of the Buffer in bytes.\r
133 This must be a multiple of the intrinsic block size of the device.\r
134 @param Buffer A pointer to the destination buffer for the data. The caller is\r
135 responsible for either having implicit or explicit ownership of the buffer.\r
136\r
137 @retval EFI_SUCCESS The data was read correctly from the device.\r
138 @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the read operation.\r
139 @retval EFI_NO_MEDIA There is no media in the device.\r
140 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
141 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic block size of the device.\r
142 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
143 or the buffer is not on proper alignment.\r
144\r
145**/\r
146EFI_STATUS\r
147EFIAPI\r
148UsbMassReadBlocks (\r
1436aea4
MK
149 IN EFI_BLOCK_IO_PROTOCOL *This,\r
150 IN UINT32 MediaId,\r
151 IN EFI_LBA Lba,\r
152 IN UINTN BufferSize,\r
153 OUT VOID *Buffer\r
d80ed2a7 154 );\r
155\r
156/**\r
157 Writes a specified number of blocks to the device.\r
158\r
d1102dba 159 This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks().\r
d80ed2a7 160 It writes a specified number of blocks to the device.\r
161 All blocks are written, or an error is returned.\r
162\r
163 @param This Indicates a pointer to the calling context.\r
164 @param MediaId The media ID that the write request is for.\r
165 @param Lba The starting logical block address to be written.\r
166 @param BufferSize The size of the Buffer in bytes.\r
167 This must be a multiple of the intrinsic block size of the device.\r
168 @param Buffer Pointer to the source buffer for the data.\r
169\r
170 @retval EFI_SUCCESS The data were written correctly to the device.\r
171 @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
172 @retval EFI_NO_MEDIA There is no media in the device.\r
173 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
174 @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the write operation.\r
175 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic\r
176 block size of the device.\r
177 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
178 or the buffer is not on proper alignment.\r
179\r
180**/\r
181EFI_STATUS\r
182EFIAPI\r
183UsbMassWriteBlocks (\r
1436aea4
MK
184 IN EFI_BLOCK_IO_PROTOCOL *This,\r
185 IN UINT32 MediaId,\r
186 IN EFI_LBA Lba,\r
187 IN UINTN BufferSize,\r
188 IN VOID *Buffer\r
d80ed2a7 189 );\r
190\r
191/**\r
192 Flushes all modified data to a physical block device.\r
193\r
194 This function implements EFI_BLOCK_IO_PROTOCOL.FlushBlocks().\r
195 USB mass storage device doesn't support write cache,\r
196 so return EFI_SUCCESS directly.\r
197\r
198 @param This Indicates a pointer to the calling context.\r
199\r
200 @retval EFI_SUCCESS All outstanding data were written correctly to the device.\r
201 @retval EFI_DEVICE_ERROR The device reported an error while attempting to write data.\r
202 @retval EFI_NO_MEDIA There is no media in the device.\r
203\r
204**/\r
205EFI_STATUS\r
206EFIAPI\r
207UsbMassFlushBlocks (\r
208 IN EFI_BLOCK_IO_PROTOCOL *This\r
209 );\r
210\r
3e03cb4d 211//\r
212// EFI Component Name Functions\r
213//\r
214\r
215/**\r
216 Retrieves a Unicode string that is the user readable name of the driver.\r
217\r
218 This function retrieves the user readable name of a driver in the form of a\r
219 Unicode string. If the driver specified by This has a user readable name in\r
220 the language specified by Language, then a pointer to the driver name is\r
221 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
222 by This does not support the language specified by Language,\r
223 then EFI_UNSUPPORTED is returned.\r
224\r
225 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
226 EFI_COMPONENT_NAME_PROTOCOL instance.\r
227 @param Language A pointer to a Null-terminated ASCII string\r
228 array indicating the language. This is the\r
229 language of the driver name that the caller is\r
230 requesting, and it must match one of the\r
231 languages specified in SupportedLanguages. The\r
232 number of languages supported by a driver is up\r
233 to the driver writer. Language is specified\r
0254efc0 234 in RFC 4646 or ISO 639-2 language code format.\r
3e03cb4d 235 @param DriverName A pointer to the Unicode string to return.\r
236 This Unicode string is the name of the\r
237 driver specified by This in the language\r
238 specified by Language.\r
239\r
240 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
241 This and the language specified by Language was\r
242 returned in DriverName.\r
243 @retval EFI_INVALID_PARAMETER Language is NULL.\r
244 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
245 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
246 the language specified by Language.\r
247\r
248**/\r
249EFI_STATUS\r
250EFIAPI\r
251UsbMassStorageGetDriverName (\r
252 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
253 IN CHAR8 *Language,\r
254 OUT CHAR16 **DriverName\r
255 );\r
256\r
3e03cb4d 257/**\r
258 Retrieves a Unicode string that is the user readable name of the controller\r
259 that is being managed by a driver.\r
260\r
261 This function retrieves the user readable name of the controller specified by\r
262 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
263 driver specified by This has a user readable name in the language specified by\r
264 Language, then a pointer to the controller name is returned in ControllerName,\r
265 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
266 managing the controller specified by ControllerHandle and ChildHandle,\r
267 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
268 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
269\r
270 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
271 EFI_COMPONENT_NAME_PROTOCOL instance.\r
272 @param ControllerHandle The handle of a controller that the driver\r
273 specified by This is managing. This handle\r
274 specifies the controller whose name is to be\r
275 returned.\r
276 @param ChildHandle The handle of the child controller to retrieve\r
277 the name of. This is an optional parameter that\r
278 may be NULL. It will be NULL for device\r
279 drivers. It will also be NULL for a bus drivers\r
280 that wish to retrieve the name of the bus\r
281 controller. It will not be NULL for a bus\r
282 driver that wishes to retrieve the name of a\r
283 child controller.\r
284 @param Language A pointer to a Null-terminated ASCII string\r
285 array indicating the language. This is the\r
286 language of the driver name that the caller is\r
287 requesting, and it must match one of the\r
288 languages specified in SupportedLanguages. The\r
289 number of languages supported by a driver is up\r
290 to the driver writer. Language is specified in\r
0254efc0 291 RFC 4646 or ISO 639-2 language code format.\r
3e03cb4d 292 @param ControllerName A pointer to the Unicode string to return.\r
293 This Unicode string is the name of the\r
294 controller specified by ControllerHandle and\r
295 ChildHandle in the language specified by\r
296 Language from the point of view of the driver\r
297 specified by This.\r
298\r
299 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
300 the language specified by Language for the\r
301 driver specified by This was returned in\r
302 DriverName.\r
284ee2e8 303 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
3e03cb4d 304 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
305 EFI_HANDLE.\r
306 @retval EFI_INVALID_PARAMETER Language is NULL.\r
307 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
308 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
309 managing the controller specified by\r
310 ControllerHandle and ChildHandle.\r
311 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
312 the language specified by Language.\r
313\r
314**/\r
315EFI_STATUS\r
316EFIAPI\r
317UsbMassStorageGetControllerName (\r
1436aea4
MK
318 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
319 IN EFI_HANDLE ControllerHandle,\r
320 IN EFI_HANDLE ChildHandle OPTIONAL,\r
321 IN CHAR8 *Language,\r
322 OUT CHAR16 **ControllerName\r
3e03cb4d 323 );\r
d80ed2a7 324\r
e237e7ae 325#endif\r