]>
Commit | Line | Data |
---|---|---|
eb290d02 FT |
1 | /** @file\r |
2 | NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows\r | |
3 | NVM Express specification.\r | |
4 | \r | |
d6c55989 | 5 | Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>\r |
eb290d02 FT |
6 | This program and the accompanying materials\r |
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 | |
14 | **/\r | |
15 | \r | |
16 | #ifndef _EFI_NVM_EXPRESS_H_\r | |
17 | #define _EFI_NVM_EXPRESS_H_\r | |
18 | \r | |
19 | #include <Uefi.h>\r | |
20 | \r | |
21 | #include <IndustryStandard/Pci.h>\r | |
22 | \r | |
23 | #include <Protocol/ComponentName.h>\r | |
24 | #include <Protocol/ComponentName2.h>\r | |
25 | #include <Protocol/DriverBinding.h>\r | |
26 | #include <Protocol/LoadedImage.h>\r | |
27 | #include <Protocol/DevicePath.h>\r | |
28 | #include <Protocol/PciIo.h>\r | |
d6c55989 | 29 | #include <Protocol/NvmExpressPassthru.h>\r |
eb290d02 FT |
30 | #include <Protocol/BlockIo.h>\r |
31 | #include <Protocol/DiskInfo.h>\r | |
32 | #include <Protocol/DriverSupportedEfiVersion.h>\r | |
754b489b | 33 | #include <Protocol/StorageSecurityCommand.h>\r |
eb290d02 FT |
34 | \r |
35 | #include <Library/BaseLib.h>\r | |
36 | #include <Library/BaseMemoryLib.h>\r | |
37 | #include <Library/DebugLib.h>\r | |
38 | #include <Library/PrintLib.h>\r | |
39 | #include <Library/UefiLib.h>\r | |
40 | #include <Library/DevicePathLib.h>\r | |
41 | #include <Library/MemoryAllocationLib.h>\r | |
42 | #include <Library/UefiBootServicesTableLib.h>\r | |
43 | #include <Library/UefiDriverEntryPoint.h>\r | |
44 | \r | |
45 | typedef struct _NVME_CONTROLLER_PRIVATE_DATA NVME_CONTROLLER_PRIVATE_DATA;\r | |
46 | typedef struct _NVME_DEVICE_PRIVATE_DATA NVME_DEVICE_PRIVATE_DATA;\r | |
47 | \r | |
eb290d02 FT |
48 | #include "NvmExpressBlockIo.h"\r |
49 | #include "NvmExpressDiskInfo.h"\r | |
50 | #include "NvmExpressHci.h"\r | |
51 | \r | |
52 | extern EFI_DRIVER_BINDING_PROTOCOL gNvmExpressDriverBinding;\r | |
53 | extern EFI_COMPONENT_NAME_PROTOCOL gNvmExpressComponentName;\r | |
54 | extern EFI_COMPONENT_NAME2_PROTOCOL gNvmExpressComponentName2;\r | |
55 | extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gNvmExpressDriverSupportedEfiVersion;\r | |
56 | \r | |
57 | #define PCI_CLASS_MASS_STORAGE_NVM 0x08 // mass storage sub-class non-volatile memory.\r | |
58 | #define PCI_IF_NVMHCI 0x02 // mass storage programming interface NVMHCI.\r | |
59 | \r | |
7b8883c6 FT |
60 | #define NVME_ASQ_SIZE 1 // Number of admin submission queue entries, which is 0-based\r |
61 | #define NVME_ACQ_SIZE 1 // Number of admin completion queue entries, which is 0-based\r | |
eb290d02 | 62 | \r |
7b8883c6 FT |
63 | #define NVME_CSQ_SIZE 1 // Number of I/O submission queue entries, which is 0-based\r |
64 | #define NVME_CCQ_SIZE 1 // Number of I/O completion queue entries, which is 0-based\r | |
eb290d02 | 65 | \r |
d6c55989 | 66 | #define NVME_MAX_QUEUES 2 // Number of queues supported by the driver\r |
eb290d02 FT |
67 | \r |
68 | #define NVME_CONTROLLER_ID 0\r | |
69 | \r | |
70 | //\r | |
71 | // Time out value for Nvme transaction execution\r | |
72 | //\r | |
73 | #define NVME_GENERIC_TIMEOUT EFI_TIMER_PERIOD_SECONDS (5)\r | |
74 | \r | |
75 | //\r | |
76 | // Unique signature for private data structure.\r | |
77 | //\r | |
78 | #define NVME_CONTROLLER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('N','V','M','E')\r | |
79 | \r | |
80 | //\r | |
81 | // Nvme private data structure.\r | |
82 | //\r | |
83 | struct _NVME_CONTROLLER_PRIVATE_DATA {\r | |
d6c55989 | 84 | UINT32 Signature;\r |
eb290d02 | 85 | \r |
d6c55989 FT |
86 | EFI_HANDLE ControllerHandle;\r |
87 | EFI_HANDLE ImageHandle;\r | |
88 | EFI_HANDLE DriverBindingHandle;\r | |
eb290d02 | 89 | \r |
d6c55989 FT |
90 | EFI_PCI_IO_PROTOCOL *PciIo;\r |
91 | UINT64 PciAttributes;\r | |
eb290d02 | 92 | \r |
d6c55989 | 93 | EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r |
eb290d02 | 94 | \r |
d6c55989 FT |
95 | EFI_NVM_EXPRESS_PASS_THRU_MODE PassThruMode;\r |
96 | EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL Passthru;\r | |
eb290d02 FT |
97 | \r |
98 | //\r | |
99 | // pointer to identify controller data\r | |
100 | //\r | |
d6c55989 | 101 | NVME_ADMIN_CONTROLLER_DATA *ControllerData;\r |
eb290d02 FT |
102 | \r |
103 | //\r | |
104 | // 6 x 4kB aligned buffers will be carved out of this buffer.\r | |
105 | // 1st 4kB boundary is the start of the admin submission queue.\r | |
d6c55989 | 106 | // 2nd 4kB boundary is the start of the I/O submission queue #1.\r |
eb290d02 | 107 | // 3rd 4kB boundary is the start of the admin completion queue.\r |
d6c55989 | 108 | // 4th 4kB boundary is the start of the I/O completion queue #1.\r |
eb290d02 FT |
109 | // 5th 4kB boundary is the start of the first PRP list page.\r |
110 | // 6th 4kB boundary is the start of the second PRP list page.\r | |
111 | //\r | |
d6c55989 FT |
112 | UINT8 *Buffer;\r |
113 | UINT8 *BufferPciAddr;\r | |
eb290d02 FT |
114 | \r |
115 | //\r | |
116 | // Pointers to 4kB aligned submission & completion queues.\r | |
117 | //\r | |
d6c55989 FT |
118 | NVME_SQ *SqBuffer[NVME_MAX_QUEUES];\r |
119 | NVME_CQ *CqBuffer[NVME_MAX_QUEUES];\r | |
120 | NVME_SQ *SqBufferPciAddr[NVME_MAX_QUEUES];\r | |
121 | NVME_CQ *CqBufferPciAddr[NVME_MAX_QUEUES];\r | |
eb290d02 FT |
122 | \r |
123 | //\r | |
124 | // Submission and completion queue indices.\r | |
125 | //\r | |
d6c55989 FT |
126 | NVME_SQTDBL SqTdbl[NVME_MAX_QUEUES];\r |
127 | NVME_CQHDBL CqHdbl[NVME_MAX_QUEUES];\r | |
eb290d02 | 128 | \r |
d6c55989 FT |
129 | UINT8 Pt[NVME_MAX_QUEUES];\r |
130 | UINT16 Cid[NVME_MAX_QUEUES];\r | |
eb290d02 FT |
131 | \r |
132 | //\r | |
133 | // Nvme controller capabilities\r | |
134 | //\r | |
d6c55989 | 135 | NVME_CAP Cap;\r |
eb290d02 | 136 | \r |
d6c55989 | 137 | VOID *Mapping;\r |
eb290d02 FT |
138 | };\r |
139 | \r | |
140 | #define NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU(a) \\r | |
141 | CR (a, \\r | |
142 | NVME_CONTROLLER_PRIVATE_DATA, \\r | |
143 | Passthru, \\r | |
144 | NVME_CONTROLLER_PRIVATE_DATA_SIGNATURE \\r | |
145 | )\r | |
146 | \r | |
147 | //\r | |
148 | // Unique signature for private data structure.\r | |
149 | //\r | |
150 | #define NVME_DEVICE_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('X','S','S','D')\r | |
151 | \r | |
152 | //\r | |
153 | // Nvme device private data structure\r | |
154 | //\r | |
155 | struct _NVME_DEVICE_PRIVATE_DATA {\r | |
754b489b | 156 | UINT32 Signature;\r |
eb290d02 | 157 | \r |
754b489b TF |
158 | EFI_HANDLE DeviceHandle;\r |
159 | EFI_HANDLE ControllerHandle;\r | |
160 | EFI_HANDLE DriverBindingHandle;\r | |
eb290d02 | 161 | \r |
754b489b | 162 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r |
eb290d02 | 163 | \r |
754b489b | 164 | EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r |
eb290d02 | 165 | \r |
754b489b TF |
166 | UINT32 NamespaceId;\r |
167 | UINT64 NamespaceUuid;\r | |
eb290d02 | 168 | \r |
754b489b TF |
169 | EFI_BLOCK_IO_MEDIA Media;\r |
170 | EFI_BLOCK_IO_PROTOCOL BlockIo;\r | |
171 | EFI_DISK_INFO_PROTOCOL DiskInfo;\r | |
172 | EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity;\r | |
eb290d02 | 173 | \r |
754b489b | 174 | EFI_LBA NumBlocks;\r |
eb290d02 | 175 | \r |
754b489b TF |
176 | CHAR16 ModelName[80];\r |
177 | NVME_ADMIN_NAMESPACE_DATA NamespaceData;\r | |
eb290d02 | 178 | \r |
754b489b | 179 | NVME_CONTROLLER_PRIVATE_DATA *Controller;\r |
eb290d02 FT |
180 | \r |
181 | };\r | |
182 | \r | |
183 | //\r | |
184 | // Statments to retrieve the private data from produced protocols.\r | |
185 | //\r | |
186 | #define NVME_DEVICE_PRIVATE_DATA_FROM_BLOCK_IO(a) \\r | |
187 | CR (a, \\r | |
188 | NVME_DEVICE_PRIVATE_DATA, \\r | |
189 | BlockIo, \\r | |
190 | NVME_DEVICE_PRIVATE_DATA_SIGNATURE \\r | |
191 | )\r | |
192 | \r | |
193 | #define NVME_DEVICE_PRIVATE_DATA_FROM_DISK_INFO(a) \\r | |
194 | CR (a, \\r | |
195 | NVME_DEVICE_PRIVATE_DATA, \\r | |
196 | DiskInfo, \\r | |
197 | NVME_DEVICE_PRIVATE_DATA_SIGNATURE \\r | |
198 | )\r | |
199 | \r | |
754b489b TF |
200 | #define NVME_DEVICE_PRIVATE_DATA_FROM_STORAGE_SECURITY(a)\\r |
201 | CR (a, \\r | |
202 | NVME_DEVICE_PRIVATE_DATA, \\r | |
203 | StorageSecurity, \\r | |
204 | NVME_DEVICE_PRIVATE_DATA_SIGNATURE \\r | |
205 | )\r | |
206 | \r | |
eb290d02 FT |
207 | /**\r |
208 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
209 | \r | |
210 | This function retrieves the user readable name of a driver in the form of a\r | |
211 | Unicode string. If the driver specified by This has a user readable name in\r | |
212 | the language specified by Language, then a pointer to the driver name is\r | |
213 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
214 | by This does not support the language specified by Language,\r | |
215 | then EFI_UNSUPPORTED is returned.\r | |
216 | \r | |
217 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
218 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
219 | \r | |
220 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
221 | array indicating the language. This is the\r | |
222 | language of the driver name that the caller is\r | |
223 | requesting, and it must match one of the\r | |
224 | languages specified in SupportedLanguages. The\r | |
225 | number of languages supported by a driver is up\r | |
226 | to the driver writer. Language is specified\r | |
227 | in RFC 4646 or ISO 639-2 language code format.\r | |
228 | \r | |
229 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
230 | This Unicode string is the name of the\r | |
231 | driver specified by This in the language\r | |
232 | specified by Language.\r | |
233 | \r | |
234 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
235 | This and the language specified by Language was\r | |
236 | returned in DriverName.\r | |
237 | \r | |
238 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
239 | \r | |
240 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
241 | \r | |
242 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
243 | the language specified by Language.\r | |
244 | \r | |
245 | **/\r | |
246 | EFI_STATUS\r | |
247 | EFIAPI\r | |
248 | NvmExpressComponentNameGetDriverName (\r | |
249 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
250 | IN CHAR8 *Language,\r | |
251 | OUT CHAR16 **DriverName\r | |
252 | );\r | |
253 | \r | |
254 | /**\r | |
255 | Retrieves a Unicode string that is the user readable name of the controller\r | |
256 | that is being managed by a driver.\r | |
257 | \r | |
258 | This function retrieves the user readable name of the controller specified by\r | |
259 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
260 | driver specified by This has a user readable name in the language specified by\r | |
261 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
262 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
263 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
264 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
265 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
266 | \r | |
267 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
268 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
269 | \r | |
270 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
271 | specified by This is managing. This handle\r | |
272 | specifies the controller whose name is to be\r | |
273 | returned.\r | |
274 | \r | |
275 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
276 | the name of. This is an optional parameter that\r | |
277 | may be NULL. It will be NULL for device\r | |
278 | drivers. It will also be NULL for a bus drivers\r | |
279 | that wish to retrieve the name of the bus\r | |
280 | controller. It will not be NULL for a bus\r | |
281 | driver that wishes to retrieve the name of a\r | |
282 | child controller.\r | |
283 | \r | |
284 | @param Language[in] 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 | |
291 | RFC 4646 or ISO 639-2 language code format.\r | |
292 | \r | |
293 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
294 | This Unicode string is the name of the\r | |
295 | controller specified by ControllerHandle and\r | |
296 | ChildHandle in the language specified by\r | |
297 | Language from the point of view of the driver\r | |
298 | specified by This.\r | |
299 | \r | |
300 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
301 | the language specified by Language for the\r | |
302 | driver specified by This was returned in\r | |
303 | DriverName.\r | |
304 | \r | |
305 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r | |
306 | \r | |
307 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
308 | EFI_HANDLE.\r | |
309 | \r | |
310 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
311 | \r | |
312 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
313 | \r | |
314 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
315 | managing the controller specified by\r | |
316 | ControllerHandle and ChildHandle.\r | |
317 | \r | |
318 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
319 | the language specified by Language.\r | |
320 | \r | |
321 | **/\r | |
322 | EFI_STATUS\r | |
323 | EFIAPI\r | |
324 | NvmExpressComponentNameGetControllerName (\r | |
325 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
326 | IN EFI_HANDLE ControllerHandle,\r | |
327 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
328 | IN CHAR8 *Language,\r | |
329 | OUT CHAR16 **ControllerName\r | |
330 | );\r | |
331 | \r | |
332 | /**\r | |
333 | Tests to see if this driver supports a given controller. If a child device is provided,\r | |
334 | it further tests to see if this driver supports creating a handle for the specified child device.\r | |
335 | \r | |
336 | This function checks to see if the driver specified by This supports the device specified by\r | |
337 | ControllerHandle. Drivers will typically use the device path attached to\r | |
338 | ControllerHandle and/or the services from the bus I/O abstraction attached to\r | |
339 | ControllerHandle to determine if the driver supports ControllerHandle. This function\r | |
340 | may be called many times during platform initialization. In order to reduce boot times, the tests\r | |
341 | performed by this function must be very small, and take as little time as possible to execute. This\r | |
342 | function must not change the state of any hardware devices, and this function must be aware that the\r | |
343 | device specified by ControllerHandle may already be managed by the same driver or a\r | |
344 | different driver. This function must match its calls to AllocatePages() with FreePages(),\r | |
345 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r | |
346 | Since ControllerHandle may have been previously started by the same driver, if a protocol is\r | |
347 | already in the opened state, then it must not be closed with CloseProtocol(). This is required\r | |
348 | to guarantee the state of ControllerHandle is not modified by this function.\r | |
349 | \r | |
350 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
351 | @param[in] ControllerHandle The handle of the controller to test. This handle\r | |
352 | must support a protocol interface that supplies\r | |
353 | an I/O abstraction to the driver.\r | |
354 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r | |
355 | parameter is ignored by device drivers, and is optional for bus\r | |
356 | drivers. For bus drivers, if this parameter is not NULL, then\r | |
357 | the bus driver must determine if the bus controller specified\r | |
358 | by ControllerHandle and the child controller specified\r | |
359 | by RemainingDevicePath are both supported by this\r | |
360 | bus driver.\r | |
361 | \r | |
362 | @retval EFI_SUCCESS The device specified by ControllerHandle and\r | |
363 | RemainingDevicePath is supported by the driver specified by This.\r | |
364 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r | |
365 | RemainingDevicePath is already being managed by the driver\r | |
366 | specified by This.\r | |
367 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r | |
368 | RemainingDevicePath is already being managed by a different\r | |
369 | driver or an application that requires exclusive access.\r | |
370 | Currently not implemented.\r | |
371 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r | |
372 | RemainingDevicePath is not supported by the driver specified by This.\r | |
373 | **/\r | |
374 | EFI_STATUS\r | |
375 | EFIAPI\r | |
376 | NvmExpressDriverBindingSupported (\r | |
377 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
378 | IN EFI_HANDLE Controller,\r | |
379 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
380 | );\r | |
381 | \r | |
382 | /**\r | |
383 | Starts a device controller or a bus controller.\r | |
384 | \r | |
385 | The Start() function is designed to be invoked from the EFI boot service ConnectController().\r | |
386 | As a result, much of the error checking on the parameters to Start() has been moved into this\r | |
387 | common boot service. It is legal to call Start() from other locations,\r | |
388 | but the following calling restrictions must be followed or the system behavior will not be deterministic.\r | |
389 | 1. ControllerHandle must be a valid EFI_HANDLE.\r | |
390 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r | |
391 | EFI_DEVICE_PATH_PROTOCOL.\r | |
392 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r | |
393 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r | |
394 | \r | |
395 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
396 | @param[in] ControllerHandle The handle of the controller to start. This handle\r | |
397 | must support a protocol interface that supplies\r | |
398 | an I/O abstraction to the driver.\r | |
399 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r | |
400 | parameter is ignored by device drivers, and is optional for bus\r | |
401 | drivers. For a bus driver, if this parameter is NULL, then handles\r | |
402 | for all the children of Controller are created by this driver.\r | |
403 | If this parameter is not NULL and the first Device Path Node is\r | |
404 | not the End of Device Path Node, then only the handle for the\r | |
405 | child device specified by the first Device Path Node of\r | |
406 | RemainingDevicePath is created by this driver.\r | |
407 | If the first Device Path Node of RemainingDevicePath is\r | |
408 | the End of Device Path Node, no child handle is created by this\r | |
409 | driver.\r | |
410 | \r | |
411 | @retval EFI_SUCCESS The device was started.\r | |
412 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r | |
413 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
414 | @retval Others The driver failded to start the device.\r | |
415 | \r | |
416 | **/\r | |
417 | EFI_STATUS\r | |
418 | EFIAPI\r | |
419 | NvmExpressDriverBindingStart (\r | |
420 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
421 | IN EFI_HANDLE Controller,\r | |
422 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
423 | );\r | |
424 | \r | |
425 | /**\r | |
426 | Stops a device controller or a bus controller.\r | |
427 | \r | |
428 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r | |
429 | As a result, much of the error checking on the parameters to Stop() has been moved\r | |
430 | into this common boot service. It is legal to call Stop() from other locations,\r | |
431 | but the following calling restrictions must be followed or the system behavior will not be deterministic.\r | |
432 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r | |
433 | same driver's Start() function.\r | |
434 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
435 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r | |
436 | Start() function, and the Start() function must have called OpenProtocol() on\r | |
437 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
438 | \r | |
439 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
440 | @param[in] ControllerHandle A handle to the device being stopped. The handle must\r | |
441 | support a bus specific I/O protocol for the driver\r | |
442 | to use to stop the device.\r | |
443 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
444 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r | |
445 | if NumberOfChildren is 0.\r | |
446 | \r | |
447 | @retval EFI_SUCCESS The device was stopped.\r | |
448 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
449 | \r | |
450 | **/\r | |
451 | EFI_STATUS\r | |
452 | EFIAPI\r | |
453 | NvmExpressDriverBindingStop (\r | |
454 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
455 | IN EFI_HANDLE Controller,\r | |
456 | IN UINTN NumberOfChildren,\r | |
457 | IN EFI_HANDLE *ChildHandleBuffer\r | |
458 | );\r | |
459 | \r | |
460 | /**\r | |
461 | Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function supports\r | |
462 | both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the nonblocking\r | |
463 | I/O functionality is optional.\r | |
464 | \r | |
d6c55989 | 465 | @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r |
eb290d02 FT |
466 | @param[in] NamespaceId Is a 32 bit Namespace ID to which the Express HCI command packet will be sent.\r |
467 | A value of 0 denotes the NVM Express controller, a value of all 0FFh in the namespace\r | |
468 | ID specifies that the command packet should be sent to all valid namespaces.\r | |
eb290d02 FT |
469 | @param[in,out] Packet A pointer to the NVM Express HCI Command Packet to send to the NVMe namespace specified\r |
470 | by NamespaceId.\r | |
471 | @param[in] Event If nonblocking I/O is not supported then Event is ignored, and blocking I/O is performed.\r | |
472 | If Event is NULL, then blocking I/O is performed. If Event is not NULL and non blocking I/O\r | |
473 | is supported, then nonblocking I/O is performed, and Event will be signaled when the NVM\r | |
474 | Express Command Packet completes.\r | |
475 | \r | |
476 | @retval EFI_SUCCESS The NVM Express Command Packet was sent by the host. TransferLength bytes were transferred\r | |
477 | to, or from DataBuffer.\r | |
478 | @retval EFI_BAD_BUFFER_SIZE The NVM Express Command Packet was not executed. The number of bytes that could be transferred\r | |
479 | is returned in TransferLength.\r | |
480 | @retval EFI_NOT_READY The NVM Express Command Packet could not be sent because the controller is not ready. The caller\r | |
481 | may retry again later.\r | |
482 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the NVM Express Command Packet.\r | |
d6c55989 | 483 | @retval EFI_INVALID_PARAMETER Namespace, or the contents of EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM\r |
eb290d02 FT |
484 | Express Command Packet was not sent, so no additional status information is available.\r |
485 | @retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the host adapter.\r | |
486 | The NVM Express Command Packet was not sent, so no additional status information is available.\r | |
487 | @retval EFI_TIMEOUT A timeout occurred while waiting for the NVM Express Command Packet to execute.\r | |
488 | \r | |
489 | **/\r | |
490 | EFI_STATUS\r | |
491 | EFIAPI\r | |
492 | NvmExpressPassThru (\r | |
d6c55989 | 493 | IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r |
eb290d02 | 494 | IN UINT32 NamespaceId,\r |
d6c55989 | 495 | IN OUT EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet,\r |
eb290d02 FT |
496 | IN EFI_EVENT Event OPTIONAL\r |
497 | );\r | |
498 | \r | |
499 | /**\r | |
d6c55989 FT |
500 | Used to retrieve the next namespace ID for this NVM Express controller.\r |
501 | \r | |
502 | The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves the next valid\r | |
503 | namespace ID on this NVM Express controller.\r | |
eb290d02 | 504 | \r |
d6c55989 FT |
505 | If on input the value pointed to by NamespaceId is 0xFFFFFFFF, then the first valid namespace\r |
506 | ID defined on the NVM Express controller is returned in the location pointed to by NamespaceId\r | |
507 | and a status of EFI_SUCCESS is returned.\r | |
eb290d02 | 508 | \r |
d6c55989 FT |
509 | If on input the value pointed to by NamespaceId is an invalid namespace ID other than 0xFFFFFFFF,\r |
510 | then EFI_INVALID_PARAMETER is returned.\r | |
eb290d02 | 511 | \r |
d6c55989 FT |
512 | If on input the value pointed to by NamespaceId is a valid namespace ID, then the next valid\r |
513 | namespace ID on the NVM Express controller is returned in the location pointed to by NamespaceId,\r | |
514 | and EFI_SUCCESS is returned.\r | |
eb290d02 | 515 | \r |
d6c55989 FT |
516 | If the value pointed to by NamespaceId is the namespace ID of the last namespace on the NVM\r |
517 | Express controller, then EFI_NOT_FOUND is returned.\r | |
eb290d02 | 518 | \r |
d6c55989 | 519 | @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r |
eb290d02 FT |
520 | @param[in,out] NamespaceId On input, a pointer to a legal NamespaceId for an NVM Express\r |
521 | namespace present on the NVM Express controller. On output, a\r | |
522 | pointer to the next NamespaceId of an NVM Express namespace on\r | |
523 | an NVM Express controller. An input value of 0xFFFFFFFF retrieves\r | |
524 | the first NamespaceId for an NVM Express namespace present on an\r | |
525 | NVM Express controller.\r | |
eb290d02 | 526 | \r |
d6c55989 | 527 | @retval EFI_SUCCESS The Namespace ID of the next Namespace was returned.\r |
eb290d02 | 528 | @retval EFI_NOT_FOUND There are no more namespaces defined on this controller.\r |
d6c55989 | 529 | @retval EFI_INVALID_PARAMETER NamespaceId is an invalid value other than 0xFFFFFFFF.\r |
eb290d02 FT |
530 | \r |
531 | **/\r | |
532 | EFI_STATUS\r | |
533 | EFIAPI\r | |
534 | NvmExpressGetNextNamespace (\r | |
d6c55989 FT |
535 | IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r |
536 | IN OUT UINT32 *NamespaceId\r | |
eb290d02 FT |
537 | );\r |
538 | \r | |
539 | /**\r | |
d6c55989 FT |
540 | Used to translate a device path node to a namespace ID.\r |
541 | \r | |
542 | The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamespace() function determines the namespace ID associated with the\r | |
543 | namespace described by DevicePath.\r | |
544 | \r | |
545 | If DevicePath is a device path node type that the NVM Express Pass Thru driver supports, then the NVM Express\r | |
546 | Pass Thru driver will attempt to translate the contents DevicePath into a namespace ID.\r | |
eb290d02 | 547 | \r |
d6c55989 | 548 | If this translation is successful, then that namespace ID is returned in NamespaceId, and EFI_SUCCESS is returned\r |
eb290d02 | 549 | \r |
d6c55989 | 550 | @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r |
eb290d02 FT |
551 | @param[in] DevicePath A pointer to the device path node that describes an NVM Express namespace on\r |
552 | the NVM Express controller.\r | |
553 | @param[out] NamespaceId The NVM Express namespace ID contained in the device path node.\r | |
eb290d02 | 554 | \r |
d6c55989 FT |
555 | @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId.\r |
556 | @retval EFI_INVALID_PARAMETER If DevicePath or NamespaceId are NULL, then EFI_INVALID_PARAMETER is returned.\r | |
eb290d02 FT |
557 | @retval EFI_UNSUPPORTED If DevicePath is not a device path node type that the NVM Express Pass Thru driver\r |
558 | supports, then EFI_UNSUPPORTED is returned.\r | |
d6c55989 FT |
559 | @retval EFI_NOT_FOUND If DevicePath is a device path node type that the NVM Express Pass Thru driver\r |
560 | supports, but there is not a valid translation from DevicePath to a namespace ID,\r | |
561 | then EFI_NOT_FOUND is returned.\r | |
eb290d02 FT |
562 | **/\r |
563 | EFI_STATUS\r | |
564 | EFIAPI\r | |
565 | NvmExpressGetNamespace (\r | |
d6c55989 | 566 | IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r |
eb290d02 | 567 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r |
d6c55989 | 568 | OUT UINT32 *NamespaceId\r |
eb290d02 FT |
569 | );\r |
570 | \r | |
571 | /**\r | |
572 | Used to allocate and build a device path node for an NVM Express namespace on an NVM Express controller.\r | |
573 | \r | |
d6c55989 | 574 | The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device\r |
eb290d02 FT |
575 | path node for the NVM Express namespace specified by NamespaceId.\r |
576 | \r | |
d6c55989 | 577 | If the NamespaceId is not valid, then EFI_NOT_FOUND is returned.\r |
eb290d02 FT |
578 | \r |
579 | If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.\r | |
580 | \r | |
581 | If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.\r | |
582 | \r | |
583 | Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of DevicePath are\r | |
584 | initialized to describe the NVM Express namespace specified by NamespaceId, and EFI_SUCCESS is returned.\r | |
585 | \r | |
d6c55989 | 586 | @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r |
eb290d02 FT |
587 | @param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be\r |
588 | allocated and built. Caller must set the NamespaceId to zero if the\r | |
589 | device path node will contain a valid UUID.\r | |
eb290d02 FT |
590 | @param[in,out] DevicePath A pointer to a single device path node that describes the NVM Express\r |
591 | namespace specified by NamespaceId. This function is responsible for\r | |
592 | allocating the buffer DevicePath with the boot service AllocatePool().\r | |
593 | It is the caller's responsibility to free DevicePath when the caller\r | |
594 | is finished with DevicePath.\r | |
595 | @retval EFI_SUCCESS The device path node that describes the NVM Express namespace specified\r | |
596 | by NamespaceId was allocated and returned in DevicePath.\r | |
d6c55989 | 597 | @retval EFI_NOT_FOUND The NamespaceId is not valid.\r |
eb290d02 FT |
598 | @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r |
599 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the DevicePath node.\r | |
600 | \r | |
601 | **/\r | |
602 | EFI_STATUS\r | |
603 | EFIAPI\r | |
604 | NvmExpressBuildDevicePath (\r | |
d6c55989 | 605 | IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r |
eb290d02 | 606 | IN UINT32 NamespaceId,\r |
eb290d02 FT |
607 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r |
608 | );\r | |
609 | \r | |
610 | #endif\r |