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