]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c
e88587a4bbc8d15f13c904e381dd7a535128cb1a
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / ComponentName.c
1 /** @file
2 UEFI Component Name(2) protocol implementation for iSCSI.
3
4 Copyright (c) 2004 - 2012, 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
9
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.
12
13 **/
14
15 #include "IScsiImpl.h"
16
17 //
18 // EFI Component Name Protocol
19 //
20 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName = {
21 IScsiComponentNameGetDriverName,
22 IScsiComponentNameGetControllerName,
23 "eng"
24 };
25
26 //
27 // EFI Component Name 2 Protocol
28 //
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,
32 "en"
33 };
34
35 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIScsiDriverNameTable[] = {
36 {"eng;en", L"iSCSI Driver"},
37 {NULL, NULL}
38 };
39
40 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIScsiControllerNameTable[] = {
41 {"eng;en", L"iSCSI (IPv4)"},
42 {NULL, NULL}
43 };
44
45 /**
46 Retrieves a Unicode string that is the user readable name of the EFI Driver.
47
48 This function retrieves the user readable name of a driver in the form of a
49 Unicode string. If the driver specified by This has a user readable name in
50 the language specified by Language, then a pointer to the driver name is
51 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
52 by This does not support the language specified by Language,
53 then EFI_UNSUPPORTED is returned.
54
55 @param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
56 @param[in] Language A pointer to a three character ISO 639-2 language identifier.
57 This is the language of the driver name that that the caller
58 is requesting, and it must match one of the languages specified
59 in SupportedLanguages. The number of languages supported by a
60 driver is up to the driver writer.
61 @param[out] DriverName A pointer to the Unicode string to return. This Unicode string
62 is the name of the driver specified by This in the language
63 specified by Language.
64
65 @retval EFI_SUCCESS The Unicode string for the Driver specified by This
66 and the language specified by Language was returned
67 in DriverName.
68 @retval EFI_INVALID_PARAMETER Language is NULL.
69 @retval EFI_INVALID_PARAMETER DriverName is NULL.
70 @retval EFI_UNSUPPORTED The driver specified by This does not support the
71 language specified by Language.
72 **/
73 EFI_STATUS
74 EFIAPI
75 IScsiComponentNameGetDriverName (
76 IN EFI_COMPONENT_NAME_PROTOCOL *This,
77 IN CHAR8 *Language,
78 OUT CHAR16 **DriverName
79 )
80 {
81 return LookupUnicodeString2 (
82 Language,
83 This->SupportedLanguages,
84 mIScsiDriverNameTable,
85 DriverName,
86 (BOOLEAN)(This == &gIScsiComponentName)
87 );
88 }
89
90 /**
91 Retrieves a Unicode string that is the user readable name of the controller
92 that is being managed by an EFI Driver.Currently not implemented.
93
94 @param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
95 @param[in] ControllerHandle The handle of a controller that the driver specified by
96 This is managing. This handle specifies the controller
97 whose name is to be returned.
98 @param[in] ChildHandle The handle of the child controller to retrieve the name
99 of. This is an optional parameter that may be NULL. It
100 will be NULL for device drivers. It will also be NULL
101 for a bus drivers that wish to retrieve the name of the
102 bus controller. It will not be NULL for a bus driver
103 that wishes to retrieve the name of a child controller.
104 @param[in] Language A pointer to a three character ISO 639-2 language
105 identifier. This is the language of the controller name
106 that that the caller is requesting, and it must match one
107 of the languages specified in SupportedLanguages. The
108 number of languages supported by a driver is up to the
109 driver writer.
110 @param[out] ControllerName A pointer to the Unicode string to return. This Unicode
111 string is the name of the controller specified by
112 ControllerHandle and ChildHandle in the language specified
113 by Language from the point of view of the driver specified
114 by This.
115
116 @retval EFI_SUCCESS The Unicode string for the user readable name in the
117 language specified by Language for the driver
118 specified by This was returned in DriverName.
119 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
120 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
121 @retval EFI_INVALID_PARAMETER Language is NULL.
122 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
123 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing
124 the controller specified by ControllerHandle and
125 ChildHandle.
126 @retval EFI_UNSUPPORTED The driver specified by This does not support the
127 language specified by Language.
128 **/
129 EFI_STATUS
130 EFIAPI
131 IScsiComponentNameGetControllerName (
132 IN EFI_COMPONENT_NAME_PROTOCOL *This,
133 IN EFI_HANDLE ControllerHandle,
134 IN EFI_HANDLE ChildHandle OPTIONAL,
135 IN CHAR8 *Language,
136 OUT CHAR16 **ControllerName
137 )
138 {
139 EFI_HANDLE IScsiController;
140 ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier;
141 EFI_STATUS Status;
142
143 //
144 // Get the handle of the controller we are controling.
145 //
146 IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid);
147 if (IScsiController == NULL) {
148 return EFI_UNSUPPORTED;
149 }
150
151 Status = gBS->OpenProtocol (
152 IScsiController,
153 &gEfiCallerIdGuid,
154 (VOID **)&IScsiIdentifier,
155 NULL,
156 NULL,
157 EFI_OPEN_PROTOCOL_GET_PROTOCOL
158 );
159 if (EFI_ERROR (Status)) {
160 return Status;
161 }
162
163 return LookupUnicodeString2 (
164 Language,
165 This->SupportedLanguages,
166 mIScsiControllerNameTable,
167 ControllerName,
168 (BOOLEAN)(This == &gIScsiComponentName)
169 );
170 }
171