]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/EmuBusDriverDxe/ComponentName.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / EmulatorPkg / EmuBusDriverDxe / ComponentName.c
1 /** @file
2
3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5
6 **/
7
8 #include "EmuBusDriverDxe.h"
9
10 //
11 // EFI Component Name Functions
12 //
13 EFI_STATUS
14 EFIAPI
15 EmuBusDriverComponentNameGetDriverName (
16 IN EFI_COMPONENT_NAME_PROTOCOL *This,
17 IN CHAR8 *Language,
18 OUT CHAR16 **DriverName
19 );
20
21 EFI_STATUS
22 EFIAPI
23 EmuBusDriverComponentNameGetControllerName (
24 IN EFI_COMPONENT_NAME_PROTOCOL *This,
25 IN EFI_HANDLE ControllerHandle,
26 IN EFI_HANDLE ChildHandle OPTIONAL,
27 IN CHAR8 *Language,
28 OUT CHAR16 **ControllerName
29 );
30
31 //
32 // EFI Component Name Protocol
33 //
34 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuBusDriverComponentName = {
35 EmuBusDriverComponentNameGetDriverName,
36 EmuBusDriverComponentNameGetControllerName,
37 "eng"
38 };
39
40 //
41 // EFI Component Name 2 Protocol
42 //
43 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2 = {
44 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuBusDriverComponentNameGetDriverName,
45 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuBusDriverComponentNameGetControllerName,
46 "en"
47 };
48
49 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuBusDriverNameTable[] = {
50 { "eng", L"Emu Bus Driver" },
51 { NULL , NULL }
52 };
53
54 /**
55 Retrieves a Unicode string that is the user readable name of the driver.
56
57 This function retrieves the user readable name of a driver in the form of a
58 Unicode string. If the driver specified by This has a user readable name in
59 the language specified by Language, then a pointer to the driver name is
60 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
61 by This does not support the language specified by Language,
62 then EFI_UNSUPPORTED is returned.
63
64 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
65 EFI_COMPONENT_NAME_PROTOCOL instance.
66
67 @param Language[in] A pointer to a Null-terminated ASCII string
68 array indicating the language. This is the
69 language of the driver name that the caller is
70 requesting, and it must match one of the
71 languages specified in SupportedLanguages. The
72 number of languages supported by a driver is up
73 to the driver writer. Language is specified
74 in RFC 4646 or ISO 639-2 language code format.
75
76 @param DriverName[out] A pointer to the Unicode string to return.
77 This Unicode string is the name of the
78 driver specified by This in the language
79 specified by Language.
80
81 @retval EFI_SUCCESS The Unicode string for the Driver specified by
82 This and the language specified by Language was
83 returned in DriverName.
84
85 @retval EFI_INVALID_PARAMETER Language is NULL.
86
87 @retval EFI_INVALID_PARAMETER DriverName is NULL.
88
89 @retval EFI_UNSUPPORTED The driver specified by This does not support
90 the language specified by Language.
91
92 **/
93 EFI_STATUS
94 EFIAPI
95 EmuBusDriverComponentNameGetDriverName (
96 IN EFI_COMPONENT_NAME_PROTOCOL *This,
97 IN CHAR8 *Language,
98 OUT CHAR16 **DriverName
99 )
100 {
101 return LookupUnicodeString2 (
102 Language,
103 This->SupportedLanguages,
104 mEmuBusDriverNameTable,
105 DriverName,
106 (BOOLEAN)(This == &gEmuBusDriverComponentName)
107 );
108 }
109
110 /**
111 Retrieves a Unicode string that is the user readable name of the controller
112 that is being managed by a driver.
113
114 This function retrieves the user readable name of the controller specified by
115 ControllerHandle and ChildHandle in the form of a Unicode string. If the
116 driver specified by This has a user readable name in the language specified by
117 Language, then a pointer to the controller name is returned in ControllerName,
118 and EFI_SUCCESS is returned. If the driver specified by This is not currently
119 managing the controller specified by ControllerHandle and ChildHandle,
120 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
121 support the language specified by Language, then EFI_UNSUPPORTED is returned.
122
123 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
124 EFI_COMPONENT_NAME_PROTOCOL instance.
125
126 @param ControllerHandle[in] The handle of a controller that the driver
127 specified by This is managing. This handle
128 specifies the controller whose name is to be
129 returned.
130
131 @param ChildHandle[in] The handle of the child controller to retrieve
132 the name of. This is an optional parameter that
133 may be NULL. It will be NULL for device
134 drivers. It will also be NULL for a bus drivers
135 that wish to retrieve the name of the bus
136 controller. It will not be NULL for a bus
137 driver that wishes to retrieve the name of a
138 child controller.
139
140 @param Language[in] A pointer to a Null-terminated ASCII string
141 array indicating the language. This is the
142 language of the driver name that the caller is
143 requesting, and it must match one of the
144 languages specified in SupportedLanguages. The
145 number of languages supported by a driver is up
146 to the driver writer. Language is specified in
147 RFC 4646 or ISO 639-2 language code format.
148
149 @param ControllerName[out] A pointer to the Unicode string to return.
150 This Unicode string is the name of the
151 controller specified by ControllerHandle and
152 ChildHandle in the language specified by
153 Language from the point of view of the driver
154 specified by This.
155
156 @retval EFI_SUCCESS The Unicode string for the user readable name in
157 the language specified by Language for the
158 driver specified by This was returned in
159 DriverName.
160
161 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
162
163 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
164 EFI_HANDLE.
165
166 @retval EFI_INVALID_PARAMETER Language is NULL.
167
168 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
169
170 @retval EFI_UNSUPPORTED The driver specified by This is not currently
171 managing the controller specified by
172 ControllerHandle and ChildHandle.
173
174 @retval EFI_UNSUPPORTED The driver specified by This does not support
175 the language specified by Language.
176
177 **/
178 EFI_STATUS
179 EFIAPI
180 EmuBusDriverComponentNameGetControllerName (
181 IN EFI_COMPONENT_NAME_PROTOCOL *This,
182 IN EFI_HANDLE ControllerHandle,
183 IN EFI_HANDLE ChildHandle OPTIONAL,
184 IN CHAR8 *Language,
185 OUT CHAR16 **ControllerName
186 )
187 {
188 EFI_STATUS Status;
189 EMU_IO_THUNK_PROTOCOL *EmuIo;
190 EMU_IO_DEVICE *Private;
191
192 //
193 // Make sure this driver is currently managing ControllHandle
194 //
195 Status = EfiTestManagedDevice (
196 ControllerHandle,
197 gEmuBusDriverBinding.DriverBindingHandle,
198 &gEmuThunkProtocolGuid
199 );
200 if (EFI_ERROR (Status)) {
201 return Status;
202 }
203
204 //
205 // This is a bus driver, so ChildHandle can not be NULL.
206 //
207 if (ChildHandle == NULL) {
208 return EFI_UNSUPPORTED;
209 }
210
211 Status = EfiTestChildHandle (
212 ControllerHandle,
213 ChildHandle,
214 &gEmuThunkProtocolGuid
215 );
216 if (EFI_ERROR (Status)) {
217 return Status;
218 }
219
220 //
221 // Get our context back
222 //
223 Status = gBS->OpenProtocol (
224 ChildHandle,
225 &gEmuIoThunkProtocolGuid,
226 (VOID**)&EmuIo,
227 gEmuBusDriverBinding.DriverBindingHandle,
228 ChildHandle,
229 EFI_OPEN_PROTOCOL_GET_PROTOCOL
230 );
231 if (EFI_ERROR (Status)) {
232 return EFI_UNSUPPORTED;
233 }
234
235 Private = EMU_IO_DEVICE_FROM_THIS (EmuIo);
236
237 return LookupUnicodeString2 (
238 Language,
239 This->SupportedLanguages,
240 Private->ControllerNameTable,
241 ControllerName,
242 (BOOLEAN)(This == &gEmuBusDriverComponentName)
243 );
244 }