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