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