2 NvmExpressDxe driver is used to manage non-volatile memory subsystem which follows
3 NVM Express specification.
5 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "NvmExpress.h"
19 // EFI Component Name Protocol
21 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gNvmExpressComponentName
= {
22 NvmExpressComponentNameGetDriverName
,
23 NvmExpressComponentNameGetControllerName
,
28 // EFI Component Name 2 Protocol
30 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gNvmExpressComponentName2
= {
31 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) NvmExpressComponentNameGetDriverName
,
32 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) NvmExpressComponentNameGetControllerName
,
36 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mNvmExpressDriverNameTable
[] = {
37 { "eng;en", L
"NVM Express Driver" },
41 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mNvmExpressControllerNameTable
[] = {
42 { "eng;en", L
"NVM Express Controller" },
47 Retrieves a Unicode string that is the user readable name of the driver.
49 This function retrieves the user readable name of a driver in the form of a
50 Unicode string. If the driver specified by This has a user readable name in
51 the language specified by Language, then a pointer to the driver name is
52 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
53 by This does not support the language specified by Language,
54 then EFI_UNSUPPORTED is returned.
56 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
57 EFI_COMPONENT_NAME_PROTOCOL instance.
59 @param Language[in] A pointer to a Null-terminated ASCII string
60 array indicating the language. This is the
61 language of the driver name that the caller is
62 requesting, and it must match one of the
63 languages specified in SupportedLanguages. The
64 number of languages supported by a driver is up
65 to the driver writer. Language is specified
66 in RFC 4646 or ISO 639-2 language code format.
68 @param DriverName[out] A pointer to the Unicode string to return.
69 This Unicode string is the name of the
70 driver specified by This in the language
71 specified by Language.
73 @retval EFI_SUCCESS The Unicode string for the Driver specified by
74 This and the language specified by Language was
75 returned in DriverName.
77 @retval EFI_INVALID_PARAMETER Language is NULL.
79 @retval EFI_INVALID_PARAMETER DriverName is NULL.
81 @retval EFI_UNSUPPORTED The driver specified by This does not support
82 the language specified by Language.
87 NvmExpressComponentNameGetDriverName (
88 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
90 OUT CHAR16
**DriverName
93 return LookupUnicodeString2 (
95 This
->SupportedLanguages
,
96 mNvmExpressDriverNameTable
,
98 (BOOLEAN
)(This
== &gNvmExpressComponentName
)
103 Retrieves a Unicode string that is the user readable name of the controller
104 that is being managed by a driver.
106 This function retrieves the user readable name of the controller specified by
107 ControllerHandle and ChildHandle in the form of a Unicode string. If the
108 driver specified by This has a user readable name in the language specified by
109 Language, then a pointer to the controller name is returned in ControllerName,
110 and EFI_SUCCESS is returned. If the driver specified by This is not currently
111 managing the controller specified by ControllerHandle and ChildHandle,
112 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
113 support the language specified by Language, then EFI_UNSUPPORTED is returned.
115 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
116 EFI_COMPONENT_NAME_PROTOCOL instance.
118 @param ControllerHandle[in] The handle of a controller that the driver
119 specified by This is managing. This handle
120 specifies the controller whose name is to be
123 @param ChildHandle[in] The handle of the child controller to retrieve
124 the name of. This is an optional parameter that
125 may be NULL. It will be NULL for device
126 drivers. It will also be NULL for a bus drivers
127 that wish to retrieve the name of the bus
128 controller. It will not be NULL for a bus
129 driver that wishes to retrieve the name of a
132 @param Language[in] A pointer to a Null-terminated ASCII string
133 array indicating the language. This is the
134 language of the driver name that the caller is
135 requesting, and it must match one of the
136 languages specified in SupportedLanguages. The
137 number of languages supported by a driver is up
138 to the driver writer. Language is specified in
139 RFC 4646 or ISO 639-2 language code format.
141 @param ControllerName[out] A pointer to the Unicode string to return.
142 This Unicode string is the name of the
143 controller specified by ControllerHandle and
144 ChildHandle in the language specified by
145 Language from the point of view of the driver
148 @retval EFI_SUCCESS The Unicode string for the user readable name in
149 the language specified by Language for the
150 driver specified by This was returned in
153 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
155 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
158 @retval EFI_INVALID_PARAMETER Language is NULL.
160 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
162 @retval EFI_UNSUPPORTED The driver specified by This is not currently
163 managing the controller specified by
164 ControllerHandle and ChildHandle.
166 @retval EFI_UNSUPPORTED The driver specified by This does not support
167 the language specified by Language.
172 NvmExpressComponentNameGetControllerName (
173 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
174 IN EFI_HANDLE ControllerHandle
,
175 IN EFI_HANDLE ChildHandle OPTIONAL
,
177 OUT CHAR16
**ControllerName
181 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
182 NVME_DEVICE_PRIVATE_DATA
*Device
;
183 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
186 // Make sure this driver is currently managing ControllHandle
188 Status
= EfiTestManagedDevice (
190 gNvmExpressDriverBinding
.DriverBindingHandle
,
191 &gEfiPciIoProtocolGuid
193 if (EFI_ERROR (Status
)) {
197 ControllerNameTable
= mNvmExpressControllerNameTable
;
198 if (ChildHandle
!= NULL
) {
199 Status
= EfiTestChildHandle (
202 &gEfiNvmExpressPassThruProtocolGuid
204 if (EFI_ERROR (Status
)) {
208 // Get the child context
210 Status
= gBS
->OpenProtocol (
212 &gEfiBlockIoProtocolGuid
,
214 gNvmExpressDriverBinding
.DriverBindingHandle
,
216 EFI_OPEN_PROTOCOL_GET_PROTOCOL
218 if (EFI_ERROR (Status
)) {
219 return EFI_UNSUPPORTED
;
221 Device
= NVME_DEVICE_PRIVATE_DATA_FROM_BLOCK_IO (BlockIo
);
222 ControllerNameTable
= Device
->ControllerNameTable
;
225 return LookupUnicodeString2 (
227 This
->SupportedLanguages
,
230 (BOOLEAN
)(This
== &gNvmExpressComponentName
)