]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c
1. Add EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName() support.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / ComponentName.c
CommitLineData
12618416 1/** @file\r
f69bf3f5 2 UEFI Component Name(2) protocol implementation for iSCSI.\r
6a690e23 3\r
216f7970 4Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5This program and the accompanying materials\r
7a444476 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
6a690e23 12\r
12618416 13**/\r
6a690e23 14\r
15#include "IScsiImpl.h"\r
16\r
17//\r
18// EFI Component Name Protocol\r
19//\r
20GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName = {\r
21 IScsiComponentNameGetDriverName,\r
22 IScsiComponentNameGetControllerName,\r
23 "eng"\r
24};\r
25\r
26//\r
27// EFI Component Name 2 Protocol\r
28//\r
29GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2 = {\r
30 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IScsiComponentNameGetDriverName,\r
31 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IScsiComponentNameGetControllerName,\r
32 "en"\r
33};\r
34\r
35GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIScsiDriverNameTable[] = {\r
12618416 36 {"eng;en", L"iSCSI Driver"}, \r
37 {NULL, NULL}\r
6a690e23 38};\r
39\r
216f7970 40GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIScsiControllerNameTable[] = {\r
41 {"eng;en", L"iSCSI (IPv4)"},\r
42 {NULL, NULL}\r
43};\r
44\r
12618416 45/**\r
46 Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
47\r
48 This function retrieves the user readable name of a driver in the form of a\r
49 Unicode string. If the driver specified by This has a user readable name in\r
50 the language specified by Language, then a pointer to the driver name is\r
51 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
52 by This does not support the language specified by Language,\r
53 then EFI_UNSUPPORTED is returned.\r
f69bf3f5 54 \r
55 @param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
56 @param[in] Language A pointer to a three character ISO 639-2 language identifier.\r
57 This is the language of the driver name that that the caller\r
58 is requesting, and it must match one of the languages specified\r
59 in SupportedLanguages. The number of languages supported by a\r
60 driver is up to the driver writer.\r
61 @param[out] DriverName A pointer to the Unicode string to return. This Unicode string\r
62 is the name of the driver specified by This in the language\r
63 specified by Language.\r
64\r
65 @retval EFI_SUCCESS The Unicode string for the Driver specified by This\r
66 and the language specified by Language was returned\r
67 in DriverName.\r
12618416 68 @retval EFI_INVALID_PARAMETER Language is NULL.\r
12618416 69 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
f69bf3f5 70 @retval EFI_UNSUPPORTED The driver specified by This does not support the\r
71 language specified by Language.\r
12618416 72**/\r
6a690e23 73EFI_STATUS\r
74EFIAPI\r
75IScsiComponentNameGetDriverName (\r
76 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
77 IN CHAR8 *Language,\r
78 OUT CHAR16 **DriverName\r
79 )\r
6a690e23 80{\r
81 return LookupUnicodeString2 (\r
82 Language,\r
83 This->SupportedLanguages,\r
84 mIScsiDriverNameTable,\r
85 DriverName,\r
86 (BOOLEAN)(This == &gIScsiComponentName)\r
87 );\r
88}\r
89\r
12618416 90/**\r
91 Retrieves a Unicode string that is the user readable name of the controller\r
f69bf3f5 92 that is being managed by an EFI Driver.Currently not implemented.\r
93\r
94 @param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
95 @param[in] ControllerHandle The handle of a controller that the driver specified by\r
96 This is managing. This handle specifies the controller\r
97 whose name is to be returned.\r
98 @param[in] ChildHandle The handle of the child controller to retrieve the name\r
99 of. This is an optional parameter that may be NULL. It\r
100 will be NULL for device drivers. It will also be NULL\r
101 for a bus drivers that wish to retrieve the name of the\r
102 bus controller. It will not be NULL for a bus driver\r
103 that wishes to retrieve the name of a child controller.\r
104 @param[in] Language A pointer to a three character ISO 639-2 language\r
105 identifier. This is the language of the controller name\r
106 that that the caller is requesting, and it must match one\r
107 of the languages specified in SupportedLanguages. The\r
108 number of languages supported by a driver is up to the\r
109 driver writer.\r
110 @param[out] ControllerName A pointer to the Unicode string to return. This Unicode\r
111 string is the name of the controller specified by\r
112 ControllerHandle and ChildHandle in the language specified\r
113 by Language from the point of view of the driver specified\r
114 by This.\r
115\r
116 @retval EFI_SUCCESS The Unicode string for the user readable name in the\r
117 language specified by Language for the driver\r
118 specified by This was returned in DriverName. \r
284ee2e8 119 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
12618416 120 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
12618416 121 @retval EFI_INVALID_PARAMETER Language is NULL.\r
12618416 122 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
12618416 123 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing\r
f69bf3f5 124 the controller specified by ControllerHandle and\r
125 ChildHandle.\r
126 @retval EFI_UNSUPPORTED The driver specified by This does not support the\r
12618416 127 language specified by Language.\r
12618416 128**/\r
6a690e23 129EFI_STATUS\r
130EFIAPI\r
131IScsiComponentNameGetControllerName (\r
132 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
133 IN EFI_HANDLE ControllerHandle,\r
134 IN EFI_HANDLE ChildHandle OPTIONAL,\r
135 IN CHAR8 *Language,\r
136 OUT CHAR16 **ControllerName\r
137 )\r
6a690e23 138{\r
216f7970 139 EFI_HANDLE IScsiController;\r
140 ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier;\r
141 EFI_STATUS Status;\r
142 \r
143 //\r
144 // Get the handle of the controller we are controling.\r
145 //\r
146 IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid);\r
147 if (IScsiController == NULL) {\r
148 return EFI_UNSUPPORTED;\r
149 }\r
150\r
151 Status = gBS->OpenProtocol (\r
152 IScsiController,\r
153 &gEfiCallerIdGuid,\r
154 (VOID **)&IScsiIdentifier,\r
155 NULL,\r
156 NULL,\r
157 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
158 );\r
159 if (EFI_ERROR (Status)) {\r
160 return Status;\r
161 }\r
162 \r
163 return LookupUnicodeString2 (\r
164 Language,\r
165 This->SupportedLanguages,\r
166 mIScsiControllerNameTable,\r
167 ControllerName,\r
168 (BOOLEAN)(This == &gIScsiComponentName)\r
169 );\r
6a690e23 170}\r
216f7970 171\r