2 UEFI Component Name(2) protocol implementation for iSCSI.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 // EFI Component Name Protocol
14 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName
= {
15 IScsiComponentNameGetDriverName
,
16 IScsiComponentNameGetControllerName
,
21 // EFI Component Name 2 Protocol
23 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2
= {
24 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)IScsiComponentNameGetDriverName
,
25 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)IScsiComponentNameGetControllerName
,
29 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIScsiDriverNameTable
[] = {
40 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gIScsiControllerNameTable
= NULL
;
43 Retrieves a Unicode string that is the user readable name of the driver.
45 This function retrieves the user readable name of a driver in the form of a
46 Unicode string. If the driver specified by This has a user readable name in
47 the language specified by Language, then a pointer to the driver name is
48 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
49 by This does not support the language specified by Language,
50 then EFI_UNSUPPORTED is returned.
52 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
53 EFI_COMPONENT_NAME_PROTOCOL instance.
55 @param[in] Language A pointer to a Null-terminated ASCII string
56 array indicating the language. This is the
57 language of the driver name that the caller is
58 requesting, and it must match one of the
59 languages specified in SupportedLanguages. The
60 number of languages supported by a driver is up
61 to the driver writer. Language is specified
62 in RFC 4646 or ISO 639-2 language code format.
64 @param[out] DriverName A pointer to the Unicode string to return.
65 This Unicode string is the name of the
66 driver specified by This in the language
67 specified by Language.
69 @retval EFI_SUCCESS The Unicode string for the Driver specified by
70 This and the language specified by Language was
71 returned in DriverName.
73 @retval EFI_INVALID_PARAMETER Language is NULL.
75 @retval EFI_INVALID_PARAMETER DriverName is NULL.
77 @retval EFI_UNSUPPORTED The driver specified by This does not support
78 the language specified by Language.
83 IScsiComponentNameGetDriverName (
84 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
86 OUT CHAR16
**DriverName
89 return LookupUnicodeString2 (
91 This
->SupportedLanguages
,
92 mIScsiDriverNameTable
,
94 (BOOLEAN
)(This
== &gIScsiComponentName
)
99 Update the component name for the iSCSI instance.
101 @param[in] IScsiExtScsiPassThru A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
102 @param[in] Ipv6Flag TRUE if IP6 network stack is used.
104 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
105 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
106 @retval EFI_UNSUPPORTED Can't get the corresponding NIC info from the Controller handle.
111 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*IScsiExtScsiPassThru
,
116 CHAR16 HandleName
[80];
117 ISCSI_DRIVER_DATA
*Private
;
120 if (IScsiExtScsiPassThru
== NULL
) {
121 return EFI_INVALID_PARAMETER
;
124 Private
= ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (IScsiExtScsiPassThru
);
125 NicIndex
= Private
->Session
->ConfigData
->NicIndex
;
130 L
"iSCSI (%s, NicIndex=%d)",
131 Ipv6Flag
? L
"IPv6" : L
"IPv4",
135 if (gIScsiControllerNameTable
!= NULL
) {
136 FreeUnicodeStringTable (gIScsiControllerNameTable
);
137 gIScsiControllerNameTable
= NULL
;
140 Status
= AddUnicodeString2 (
142 gIScsiComponentName
.SupportedLanguages
,
143 &gIScsiControllerNameTable
,
147 if (EFI_ERROR (Status
)) {
151 return AddUnicodeString2 (
153 gIScsiComponentName2
.SupportedLanguages
,
154 &gIScsiControllerNameTable
,
161 Retrieves a Unicode string that is the user readable name of the controller
162 that is being managed by a driver.
164 This function retrieves the user readable name of the controller specified by
165 ControllerHandle and ChildHandle in the form of a Unicode string. If the
166 driver specified by This has a user readable name in the language specified by
167 Language, then a pointer to the controller name is returned in ControllerName,
168 and EFI_SUCCESS is returned. If the driver specified by This is not currently
169 managing the controller specified by ControllerHandle and ChildHandle,
170 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
171 support the language specified by Language, then EFI_UNSUPPORTED is returned.
173 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
174 EFI_COMPONENT_NAME_PROTOCOL instance.
176 @param[in] ControllerHandle The handle of a controller that the driver
177 specified by This is managing. This handle
178 specifies the controller whose name is to be
181 @param[in] ChildHandle The handle of the child controller to retrieve
182 the name of. This is an optional parameter that
183 may be NULL. It will be NULL for device
184 drivers. It will also be NULL for a bus drivers
185 that wish to retrieve the name of the bus
186 controller. It will not be NULL for a bus
187 driver that wishes to retrieve the name of a
190 @param[in] Language A pointer to a Null-terminated ASCII string
191 array indicating the language. This is the
192 language of the driver name that the caller is
193 requesting, and it must match one of the
194 languages specified in SupportedLanguages. The
195 number of languages supported by a driver is up
196 to the driver writer. Language is specified in
197 RFC 4646 or ISO 639-2 language code format.
199 @param[out] ControllerName A pointer to the Unicode string to return.
200 This Unicode string is the name of the
201 controller specified by ControllerHandle and
202 ChildHandle in the language specified by
203 Language, from the point of view of the driver
206 @retval EFI_SUCCESS The Unicode string for the user readable name in
207 the language specified by Language for the
208 driver specified by This was returned in
211 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
213 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
216 @retval EFI_INVALID_PARAMETER Language is NULL.
218 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
220 @retval EFI_UNSUPPORTED The driver specified by This is not currently
221 managing the controller specified by
222 ControllerHandle and ChildHandle.
224 @retval EFI_UNSUPPORTED The driver specified by This does not support
225 the language specified by Language.
230 IScsiComponentNameGetControllerName (
231 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
232 IN EFI_HANDLE ControllerHandle
,
233 IN EFI_HANDLE ChildHandle OPTIONAL
,
235 OUT CHAR16
**ControllerName
240 EFI_HANDLE IScsiController
;
242 EFI_GUID
*IScsiPrivateGuid
;
243 ISCSI_PRIVATE_PROTOCOL
*IScsiIdentifier
;
245 EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*IScsiExtScsiPassThru
;
247 if (ControllerHandle
== NULL
) {
248 return EFI_UNSUPPORTED
;
252 // Get the handle of the controller we are controlling.
254 IScsiController
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp4ProtocolGuid
);
255 if (IScsiController
!= NULL
) {
256 IScsiPrivateGuid
= &gIScsiV4PrivateGuid
;
259 IScsiController
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp6ProtocolGuid
);
260 if (IScsiController
!= NULL
) {
261 IScsiPrivateGuid
= &gIScsiV6PrivateGuid
;
264 return EFI_UNSUPPORTED
;
268 Status
= gBS
->OpenProtocol (
271 (VOID
**)&IScsiIdentifier
,
274 EFI_OPEN_PROTOCOL_GET_PROTOCOL
276 if (EFI_ERROR (Status
)) {
280 if (ChildHandle
!= NULL
) {
283 // Make sure this driver produced ChildHandle
285 Status
= EfiTestChildHandle (
288 &gEfiTcp4ProtocolGuid
290 if (EFI_ERROR (Status
)) {
295 // Make sure this driver produced ChildHandle
297 Status
= EfiTestChildHandle (
300 &gEfiTcp6ProtocolGuid
302 if (EFI_ERROR (Status
)) {
308 // Retrieve an instance of a produced protocol from ChildHandle
310 Status
= gBS
->OpenProtocol (
312 &gEfiExtScsiPassThruProtocolGuid
,
313 (VOID
**)&IScsiExtScsiPassThru
,
316 EFI_OPEN_PROTOCOL_GET_PROTOCOL
318 if (EFI_ERROR (Status
)) {
323 // Update the component name for this child handle.
325 Status
= UpdateName (IScsiExtScsiPassThru
, Ipv6Flag
);
326 if (EFI_ERROR (Status
)) {
331 return LookupUnicodeString2 (
333 This
->SupportedLanguages
,
334 gIScsiControllerNameTable
,
336 (BOOLEAN
)(This
== &gIScsiComponentName
)