2 UEFI Component Name(2) protocol implementation for iSCSI.
4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "IScsiImpl.h"
18 // EFI Component Name Protocol
20 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName
= {
21 IScsiComponentNameGetDriverName
,
22 IScsiComponentNameGetControllerName
,
27 // EFI Component Name 2 Protocol
29 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2
= {
30 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) IScsiComponentNameGetDriverName
,
31 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) IScsiComponentNameGetControllerName
,
35 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIScsiDriverNameTable
[] = {
46 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
*gIScsiControllerNameTable
= NULL
;
49 Retrieves a Unicode string that is the user readable name of the driver.
51 This function retrieves the user readable name of a driver in the form of a
52 Unicode string. If the driver specified by This has a user readable name in
53 the language specified by Language, then a pointer to the driver name is
54 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
55 by This does not support the language specified by Language,
56 then EFI_UNSUPPORTED is returned.
58 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
59 EFI_COMPONENT_NAME_PROTOCOL instance.
61 @param[in] Language A pointer to a Null-terminated ASCII string
62 array indicating the language. This is the
63 language of the driver name that the caller is
64 requesting, and it must match one of the
65 languages specified in SupportedLanguages. The
66 number of languages supported by a driver is up
67 to the driver writer. Language is specified
68 in RFC 4646 or ISO 639-2 language code format.
70 @param[out] DriverName A pointer to the Unicode string to return.
71 This Unicode string is the name of the
72 driver specified by This in the language
73 specified by Language.
75 @retval EFI_SUCCESS The Unicode string for the Driver specified by
76 This and the language specified by Language was
77 returned in DriverName.
79 @retval EFI_INVALID_PARAMETER Language is NULL.
81 @retval EFI_INVALID_PARAMETER DriverName is NULL.
83 @retval EFI_UNSUPPORTED The driver specified by This does not support
84 the language specified by Language.
89 IScsiComponentNameGetDriverName (
90 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
92 OUT CHAR16
**DriverName
95 return LookupUnicodeString2 (
97 This
->SupportedLanguages
,
98 mIScsiDriverNameTable
,
100 (BOOLEAN
) (This
== &gIScsiComponentName
)
105 Update the component name for the iSCSI instance.
107 @param[in] IScsiExtScsiPassThru A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
108 @param[in] Ipv6Flag TRUE if IP6 network stack is used.
110 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully.
111 @retval EFI_INVALID_PARAMETER The input parameter is invalid.
112 @retval EFI_UNSUPPORTED Can't get the corresponding NIC info from the Controller handle.
117 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*IScsiExtScsiPassThru
,
122 CHAR16 HandleName
[80];
123 ISCSI_DRIVER_DATA
*Private
;
126 if (IScsiExtScsiPassThru
== NULL
) {
127 return EFI_INVALID_PARAMETER
;
130 Private
= ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (IScsiExtScsiPassThru
);
131 NicIndex
= Private
->Session
->ConfigData
->NicIndex
;
136 L
"iSCSI (%s, NicIndex=%d)",
137 Ipv6Flag
? L
"IPv6" : L
"IPv4",
141 if (gIScsiControllerNameTable
!= NULL
) {
142 FreeUnicodeStringTable (gIScsiControllerNameTable
);
143 gIScsiControllerNameTable
= NULL
;
146 Status
= AddUnicodeString2 (
148 gIScsiComponentName
.SupportedLanguages
,
149 &gIScsiControllerNameTable
,
153 if (EFI_ERROR (Status
)) {
157 return AddUnicodeString2 (
159 gIScsiComponentName2
.SupportedLanguages
,
160 &gIScsiControllerNameTable
,
167 Retrieves a Unicode string that is the user readable name of the controller
168 that is being managed by a driver.
170 This function retrieves the user readable name of the controller specified by
171 ControllerHandle and ChildHandle in the form of a Unicode string. If the
172 driver specified by This has a user readable name in the language specified by
173 Language, then a pointer to the controller name is returned in ControllerName,
174 and EFI_SUCCESS is returned. If the driver specified by This is not currently
175 managing the controller specified by ControllerHandle and ChildHandle,
176 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
177 support the language specified by Language, then EFI_UNSUPPORTED is returned.
179 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
180 EFI_COMPONENT_NAME_PROTOCOL instance.
182 @param[in] ControllerHandle The handle of a controller that the driver
183 specified by This is managing. This handle
184 specifies the controller whose name is to be
187 @param[in] ChildHandle The handle of the child controller to retrieve
188 the name of. This is an optional parameter that
189 may be NULL. It will be NULL for device
190 drivers. It will also be NULL for a bus drivers
191 that wish to retrieve the name of the bus
192 controller. It will not be NULL for a bus
193 driver that wishes to retrieve the name of a
196 @param[in] Language A pointer to a Null-terminated ASCII string
197 array indicating the language. This is the
198 language of the driver name that the caller is
199 requesting, and it must match one of the
200 languages specified in SupportedLanguages. The
201 number of languages supported by a driver is up
202 to the driver writer. Language is specified in
203 RFC 4646 or ISO 639-2 language code format.
205 @param[out] ControllerName A pointer to the Unicode string to return.
206 This Unicode string is the name of the
207 controller specified by ControllerHandle and
208 ChildHandle in the language specified by
209 Language, from the point of view of the driver
212 @retval EFI_SUCCESS The Unicode string for the user readable name in
213 the language specified by Language for the
214 driver specified by This was returned in
217 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
219 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
222 @retval EFI_INVALID_PARAMETER Language is NULL.
224 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
226 @retval EFI_UNSUPPORTED The driver specified by This is not currently
227 managing the controller specified by
228 ControllerHandle and ChildHandle.
230 @retval EFI_UNSUPPORTED The driver specified by This does not support
231 the language specified by Language.
236 IScsiComponentNameGetControllerName (
237 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
238 IN EFI_HANDLE ControllerHandle
,
239 IN EFI_HANDLE ChildHandle OPTIONAL
,
241 OUT CHAR16
**ControllerName
246 EFI_HANDLE IScsiController
;
248 EFI_GUID
*IScsiPrivateGuid
;
249 ISCSI_PRIVATE_PROTOCOL
*IScsiIdentifier
;
251 EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*IScsiExtScsiPassThru
;
253 if (ControllerHandle
== NULL
) {
254 return EFI_UNSUPPORTED
;
258 // Get the handle of the controller we are controling.
260 IScsiController
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp4ProtocolGuid
);
261 if (IScsiController
!= NULL
) {
262 IScsiPrivateGuid
= &gIScsiV4PrivateGuid
;
265 IScsiController
= NetLibGetNicHandle (ControllerHandle
, &gEfiTcp6ProtocolGuid
);
266 if (IScsiController
!= NULL
) {
267 IScsiPrivateGuid
= &gIScsiV6PrivateGuid
;
270 return EFI_UNSUPPORTED
;
274 Status
= gBS
->OpenProtocol (
277 (VOID
**) &IScsiIdentifier
,
280 EFI_OPEN_PROTOCOL_GET_PROTOCOL
282 if (EFI_ERROR (Status
)) {
286 if(ChildHandle
!= NULL
) {
289 // Make sure this driver produced ChildHandle
291 Status
= EfiTestChildHandle (
294 &gEfiTcp4ProtocolGuid
296 if (EFI_ERROR (Status
)) {
301 // Make sure this driver produced ChildHandle
303 Status
= EfiTestChildHandle (
306 &gEfiTcp6ProtocolGuid
308 if (EFI_ERROR (Status
)) {
314 // Retrieve an instance of a produced protocol from ChildHandle
316 Status
= gBS
->OpenProtocol (
318 &gEfiExtScsiPassThruProtocolGuid
,
319 (VOID
**)&IScsiExtScsiPassThru
,
322 EFI_OPEN_PROTOCOL_GET_PROTOCOL
324 if (EFI_ERROR (Status
)) {
329 // Update the component name for this child handle.
331 Status
= UpdateName (IScsiExtScsiPassThru
, Ipv6Flag
);
332 if (EFI_ERROR (Status
)) {
337 return LookupUnicodeString2 (
339 This
->SupportedLanguages
,
340 gIScsiControllerNameTable
,
342 (BOOLEAN
)(This
== &gIScsiComponentName
)