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