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