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