]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/HttpBootDxe/HttpBootComponentName.c
UefiCpuPkg/Application/Cpuid: Remove unnecessary code check
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootComponentName.c
CommitLineData
d933e70a
JW
1/** @file\r
2 Implementation of EFI_COMPONENT_NAME_PROTOCOL and EFI_COMPONENT_NAME2_PROTOCOL protocol.\r
3\r
4Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials are licensed and made available under \r
6the terms and conditions of the BSD License that accompanies this distribution. \r
7The 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
12\r
13**/\r
14\r
15#include "HttpBootDxe.h"\r
16\r
17///\r
18/// Component Name Protocol instance\r
19///\r
20GLOBAL_REMOVE_IF_UNREFERENCED \r
21EFI_COMPONENT_NAME_PROTOCOL gHttpBootDxeComponentName = {\r
22 (EFI_COMPONENT_NAME_GET_DRIVER_NAME) HttpBootDxeComponentNameGetDriverName,\r
23 (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)HttpBootDxeComponentNameGetControllerName,\r
24 "eng"\r
25};\r
26\r
27///\r
28/// Component Name 2 Protocol instance\r
29///\r
30GLOBAL_REMOVE_IF_UNREFERENCED \r
31EFI_COMPONENT_NAME2_PROTOCOL gHttpBootDxeComponentName2 = {\r
32 HttpBootDxeComponentNameGetDriverName,\r
33 HttpBootDxeComponentNameGetControllerName,\r
34 "en"\r
35};\r
36\r
37///\r
38/// Table of driver names\r
39///\r
40GLOBAL_REMOVE_IF_UNREFERENCED \r
41EFI_UNICODE_STRING_TABLE mHttpBootDxeDriverNameTable[] = {\r
42 { "eng;en", (CHAR16 *)L"UEFI HTTP Boot Driver" },\r
43 { NULL, NULL }\r
44};\r
45\r
46///\r
47/// Table of controller names\r
48///\r
49GLOBAL_REMOVE_IF_UNREFERENCED \r
50EFI_UNICODE_STRING_TABLE mHttpBootDxeControllerNameTable[] = {\r
51 { "eng;en", (CHAR16 *)L"UEFI Http Boot Controller" },\r
52 { NULL, NULL }\r
53};\r
54\r
55/**\r
56 Retrieves a Unicode string that is the user-readable name of the EFI Driver.\r
57\r
58 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
59 @param Language A pointer to a three-character ISO 639-2 language identifier.\r
60 This is the language of the driver name that that the caller\r
61 is requesting, and it must match one of the languages specified\r
62 in SupportedLanguages. The number of languages supported by a\r
63 driver is up to the driver writer.\r
64 @param DriverName A pointer to the Unicode string to return. This Unicode string\r
65 is the name of the driver specified by This in the language\r
66 specified by Language.\r
67\r
68 @retval EFI_SUCCESS The Unicode string for the Driver specified by This\r
69 and the language specified by Language was returned\r
70 in DriverName.\r
71 @retval EFI_INVALID_PARAMETER Language is NULL.\r
72 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
73 @retval EFI_UNSUPPORTED The driver specified by This does not support the\r
74 language specified by Language.\r
75\r
76**/\r
77EFI_STATUS\r
78EFIAPI\r
79HttpBootDxeComponentNameGetDriverName (\r
80 IN EFI_COMPONENT_NAME2_PROTOCOL *This,\r
81 IN CHAR8 *Language,\r
82 OUT CHAR16 **DriverName\r
83 )\r
84{\r
85 return LookupUnicodeString2 (\r
86 Language,\r
87 This->SupportedLanguages,\r
88 mHttpBootDxeDriverNameTable,\r
89 DriverName,\r
90 (BOOLEAN) (This != &gHttpBootDxeComponentName2)\r
91 );\r
92}\r
93\r
94/**\r
95 Retrieves a Unicode string that is the user readable name of the controller\r
96 that is being managed by an EFI Driver.\r
97\r
98 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
99 @param ControllerHandle The handle of a controller that the driver specified by\r
100 This is managing. This handle specifies the controller\r
101 whose name is to be returned.\r
102 @param ChildHandle The handle of the child controller to retrieve the name\r
103 of. This is an optional parameter that may be NULL. It\r
104 will be NULL for device drivers. It will also be NULL\r
105 for a bus drivers that wish to retrieve the name of the\r
106 bus controller. It will not be NULL for a bus driver\r
107 that wishes to retrieve the name of a child controller.\r
108 @param Language A pointer to a three character ISO 639-2 language\r
109 identifier. This is the language of the controller name\r
110 that the caller is requesting, and it must match one\r
111 of the languages specified in SupportedLanguages. The\r
112 number of languages supported by a driver is up to the\r
113 driver writer.\r
114 @param ControllerName A pointer to the Unicode string to return. This Unicode\r
115 string is the name of the controller specified by\r
116 ControllerHandle and ChildHandle in the language specified\r
117 by Language, from the point of view of the driver specified\r
118 by This.\r
119\r
120 @retval EFI_SUCCESS The Unicode string for the user-readable name in the\r
121 language specified by Language for the driver\r
122 specified by This was returned in DriverName.\r
123 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
124 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
125 @retval EFI_INVALID_PARAMETER Language is NULL.\r
126 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
127 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing\r
128 the controller specified by ControllerHandle and\r
129 ChildHandle.\r
130 @retval EFI_UNSUPPORTED The driver specified by This does not support the\r
131 language specified by Language.\r
132\r
133**/\r
134EFI_STATUS\r
135EFIAPI\r
136HttpBootDxeComponentNameGetControllerName (\r
137 IN EFI_COMPONENT_NAME2_PROTOCOL *This,\r
138 IN EFI_HANDLE ControllerHandle,\r
139 IN EFI_HANDLE ChildHandle OPTIONAL,\r
140 IN CHAR8 *Language,\r
141 OUT CHAR16 **ControllerName\r
142 )\r
143{\r
144 EFI_STATUS Status;\r
145 EFI_HANDLE NicHandle;\r
146 UINT32 *Id;\r
147\r
148 if (ControllerHandle == NULL || ChildHandle != NULL) {\r
149 return EFI_UNSUPPORTED;\r
150 }\r
151 \r
152 NicHandle = HttpBootGetNicByIp4Children (ControllerHandle);\r
153 if (NicHandle == NULL) {\r
b659408b
ZL
154 NicHandle = HttpBootGetNicByIp6Children(ControllerHandle);\r
155 if (NicHandle == NULL) {\r
156 return EFI_UNSUPPORTED;\r
157 }\r
d933e70a
JW
158 }\r
159\r
160 //\r
161 // Try to retrieve the private data by caller ID GUID.\r
162 //\r
163 Status = gBS->OpenProtocol (\r
164 NicHandle,\r
165 &gEfiCallerIdGuid,\r
166 (VOID **) &Id,\r
167 NULL,\r
168 NULL,\r
169 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
170 );\r
171 if (EFI_ERROR (Status)) {\r
172 return Status;\r
173 }\r
174\r
175 return LookupUnicodeString2 (\r
176 Language,\r
177 This->SupportedLanguages,\r
178 mHttpBootDxeControllerNameTable,\r
179 ControllerName,\r
180 (BOOLEAN)(This != &gHttpBootDxeComponentName2)\r
181 );\r
182\r
183}\r