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