]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/WinNtBlockIoDxe/ComponentName.c
UefiCpuPkg: Remove double \r
[mirror_edk2.git] / Nt32Pkg / WinNtBlockIoDxe / 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 Module Name:
7
8 ComponentName.c
9
10 Abstract:
11
12 **/
13 #include <Uefi.h>
14 #include <WinNtDxe.h>
15 #include <Protocol/ComponentName.h>
16 #include <Protocol/DriverBinding.h>
17
18 #include "WinNtBlockIo.h"
19
20 //
21 // EFI Component Name Functions
22 //
23 /**
24 Retrieves a Unicode string that is the user readable name of the driver.
25
26 This function retrieves the user readable name of a driver in the form of a
27 Unicode string. If the driver specified by This has a user readable name in
28 the language specified by Language, then a pointer to the driver name is
29 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
30 by This does not support the language specified by Language,
31 then EFI_UNSUPPORTED is returned.
32
33 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
34 EFI_COMPONENT_NAME_PROTOCOL instance.
35
36 @param Language[in] A pointer to a Null-terminated ASCII string
37 array indicating the language. This is the
38 language of the driver name that the caller is
39 requesting, and it must match one of the
40 languages specified in SupportedLanguages. The
41 number of languages supported by a driver is up
42 to the driver writer. Language is specified
43 in RFC 4646 or ISO 639-2 language code format.
44
45 @param DriverName[out] A pointer to the Unicode string to return.
46 This Unicode string is the name of the
47 driver specified by This in the language
48 specified by Language.
49
50 @retval EFI_SUCCESS The Unicode string for the Driver specified by
51 This and the language specified by Language was
52 returned in DriverName.
53
54 @retval EFI_INVALID_PARAMETER Language is NULL.
55
56 @retval EFI_INVALID_PARAMETER DriverName is NULL.
57
58 @retval EFI_UNSUPPORTED The driver specified by This does not support
59 the language specified by Language.
60
61 **/
62 EFI_STATUS
63 EFIAPI
64 WinNtBlockIoComponentNameGetDriverName (
65 IN EFI_COMPONENT_NAME_PROTOCOL *This,
66 IN CHAR8 *Language,
67 OUT CHAR16 **DriverName
68 );
69
70
71 /**
72 Retrieves a Unicode string that is the user readable name of the controller
73 that is being managed by a driver.
74
75 This function retrieves the user readable name of the controller specified by
76 ControllerHandle and ChildHandle in the form of a Unicode string. If the
77 driver specified by This has a user readable name in the language specified by
78 Language, then a pointer to the controller name is returned in ControllerName,
79 and EFI_SUCCESS is returned. If the driver specified by This is not currently
80 managing the controller specified by ControllerHandle and ChildHandle,
81 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
82 support the language specified by Language, then EFI_UNSUPPORTED is returned.
83
84 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
85 EFI_COMPONENT_NAME_PROTOCOL instance.
86
87 @param ControllerHandle[in] The handle of a controller that the driver
88 specified by This is managing. This handle
89 specifies the controller whose name is to be
90 returned.
91
92 @param ChildHandle[in] The handle of the child controller to retrieve
93 the name of. This is an optional parameter that
94 may be NULL. It will be NULL for device
95 drivers. It will also be NULL for a bus drivers
96 that wish to retrieve the name of the bus
97 controller. It will not be NULL for a bus
98 driver that wishes to retrieve the name of a
99 child controller.
100
101 @param Language[in] A pointer to a Null-terminated ASCII string
102 array indicating the language. This is the
103 language of the driver name that the caller is
104 requesting, and it must match one of the
105 languages specified in SupportedLanguages. The
106 number of languages supported by a driver is up
107 to the driver writer. Language is specified in
108 RFC 4646 or ISO 639-2 language code format.
109
110 @param ControllerName[out] A pointer to the Unicode string to return.
111 This Unicode string is the name of the
112 controller specified by ControllerHandle and
113 ChildHandle in the language specified by
114 Language from the point of view of the driver
115 specified by This.
116
117 @retval EFI_SUCCESS The Unicode string for the user readable name in
118 the language specified by Language for the
119 driver specified by This was returned in
120 DriverName.
121
122 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
123
124 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
125 EFI_HANDLE.
126
127 @retval EFI_INVALID_PARAMETER Language is NULL.
128
129 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
130
131 @retval EFI_UNSUPPORTED The driver specified by This is not currently
132 managing the controller specified by
133 ControllerHandle and ChildHandle.
134
135 @retval EFI_UNSUPPORTED The driver specified by This does not support
136 the language specified by Language.
137
138 **/
139 EFI_STATUS
140 EFIAPI
141 WinNtBlockIoComponentNameGetControllerName (
142 IN EFI_COMPONENT_NAME_PROTOCOL *This,
143 IN EFI_HANDLE ControllerHandle,
144 IN EFI_HANDLE ChildHandle OPTIONAL,
145 IN CHAR8 *Language,
146 OUT CHAR16 **ControllerName
147 );
148
149
150 //
151 // EFI Component Name Protocol
152 //
153 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtBlockIoComponentName = {
154 WinNtBlockIoComponentNameGetDriverName,
155 WinNtBlockIoComponentNameGetControllerName,
156 "eng"
157 };
158
159 //
160 // EFI Component Name 2 Protocol
161 //
162 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtBlockIoComponentName2 = {
163 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) WinNtBlockIoComponentNameGetDriverName,
164 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) WinNtBlockIoComponentNameGetControllerName,
165 "en"
166 };
167
168
169 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtBlockIoDriverNameTable[] = {
170 { "eng;en", L"Windows Block I/O Driver" },
171 { NULL , NULL }
172 };
173
174 /**
175 Retrieves a Unicode string that is the user readable name of the driver.
176
177 This function retrieves the user readable name of a driver in the form of a
178 Unicode string. If the driver specified by This has a user readable name in
179 the language specified by Language, then a pointer to the driver name is
180 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
181 by This does not support the language specified by Language,
182 then EFI_UNSUPPORTED is returned.
183
184 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
185 EFI_COMPONENT_NAME_PROTOCOL instance.
186
187 @param Language[in] A pointer to a Null-terminated ASCII string
188 array indicating the language. This is the
189 language of the driver name that the caller is
190 requesting, and it must match one of the
191 languages specified in SupportedLanguages. The
192 number of languages supported by a driver is up
193 to the driver writer. Language is specified
194 in RFC 4646 or ISO 639-2 language code format.
195
196 @param DriverName[out] A pointer to the Unicode string to return.
197 This Unicode string is the name of the
198 driver specified by This in the language
199 specified by Language.
200
201 @retval EFI_SUCCESS The Unicode string for the Driver specified by
202 This and the language specified by Language was
203 returned in DriverName.
204
205 @retval EFI_INVALID_PARAMETER Language is NULL.
206
207 @retval EFI_INVALID_PARAMETER DriverName is NULL.
208
209 @retval EFI_UNSUPPORTED The driver specified by This does not support
210 the language specified by Language.
211
212 **/
213 EFI_STATUS
214 EFIAPI
215 WinNtBlockIoComponentNameGetDriverName (
216 IN EFI_COMPONENT_NAME_PROTOCOL *This,
217 IN CHAR8 *Language,
218 OUT CHAR16 **DriverName
219 )
220 {
221 return LookupUnicodeString2 (
222 Language,
223 This->SupportedLanguages,
224 mWinNtBlockIoDriverNameTable,
225 DriverName,
226 (BOOLEAN)(This == &gWinNtBlockIoComponentName)
227 );
228 }
229
230 /**
231 Retrieves a Unicode string that is the user readable name of the controller
232 that is being managed by a driver.
233
234 This function retrieves the user readable name of the controller specified by
235 ControllerHandle and ChildHandle in the form of a Unicode string. If the
236 driver specified by This has a user readable name in the language specified by
237 Language, then a pointer to the controller name is returned in ControllerName,
238 and EFI_SUCCESS is returned. If the driver specified by This is not currently
239 managing the controller specified by ControllerHandle and ChildHandle,
240 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
241 support the language specified by Language, then EFI_UNSUPPORTED is returned.
242
243 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
244 EFI_COMPONENT_NAME_PROTOCOL instance.
245
246 @param ControllerHandle[in] The handle of a controller that the driver
247 specified by This is managing. This handle
248 specifies the controller whose name is to be
249 returned.
250
251 @param ChildHandle[in] The handle of the child controller to retrieve
252 the name of. This is an optional parameter that
253 may be NULL. It will be NULL for device
254 drivers. It will also be NULL for a bus drivers
255 that wish to retrieve the name of the bus
256 controller. It will not be NULL for a bus
257 driver that wishes to retrieve the name of a
258 child controller.
259
260 @param Language[in] A pointer to a Null-terminated ASCII string
261 array indicating the language. This is the
262 language of the driver name that the caller is
263 requesting, and it must match one of the
264 languages specified in SupportedLanguages. The
265 number of languages supported by a driver is up
266 to the driver writer. Language is specified in
267 RFC 4646 or ISO 639-2 language code format.
268
269 @param ControllerName[out] A pointer to the Unicode string to return.
270 This Unicode string is the name of the
271 controller specified by ControllerHandle and
272 ChildHandle in the language specified by
273 Language from the point of view of the driver
274 specified by This.
275
276 @retval EFI_SUCCESS The Unicode string for the user readable name in
277 the language specified by Language for the
278 driver specified by This was returned in
279 DriverName.
280
281 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
282
283 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
284 EFI_HANDLE.
285
286 @retval EFI_INVALID_PARAMETER Language is NULL.
287
288 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
289
290 @retval EFI_UNSUPPORTED The driver specified by This is not currently
291 managing the controller specified by
292 ControllerHandle and ChildHandle.
293
294 @retval EFI_UNSUPPORTED The driver specified by This does not support
295 the language specified by Language.
296
297 **/
298 EFI_STATUS
299 EFIAPI
300 WinNtBlockIoComponentNameGetControllerName (
301 IN EFI_COMPONENT_NAME_PROTOCOL *This,
302 IN EFI_HANDLE ControllerHandle,
303 IN EFI_HANDLE ChildHandle OPTIONAL,
304 IN CHAR8 *Language,
305 OUT CHAR16 **ControllerName
306 )
307 {
308 EFI_STATUS Status;
309 EFI_BLOCK_IO_PROTOCOL *BlockIo;
310 WIN_NT_BLOCK_IO_PRIVATE *Private;
311
312 //
313 // This is a device driver, so ChildHandle must be NULL.
314 //
315 if (ChildHandle != NULL) {
316 return EFI_UNSUPPORTED;
317 }
318 //
319 // Make sure this driver is currently managing ControllerHandle
320 //
321 Status = EfiTestManagedDevice (
322 ControllerHandle,
323 gWinNtBlockIoDriverBinding.DriverBindingHandle,
324 &gEfiWinNtIoProtocolGuid
325 );
326 if (EFI_ERROR (Status)) {
327 return EFI_UNSUPPORTED;
328 }
329 //
330 // Get our context back
331 //
332 Status = gBS->OpenProtocol (
333 ControllerHandle,
334 &gEfiBlockIoProtocolGuid,
335 (VOID **) &BlockIo,
336 gWinNtBlockIoDriverBinding.DriverBindingHandle,
337 ControllerHandle,
338 EFI_OPEN_PROTOCOL_GET_PROTOCOL
339 );
340 if (EFI_ERROR (Status)) {
341 return EFI_UNSUPPORTED;
342 }
343
344 Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);
345
346 return LookupUnicodeString2 (
347 Language,
348 This->SupportedLanguages,
349 Private->ControllerNameTable,
350 ControllerName,
351 (BOOLEAN)(This == &gWinNtBlockIoComponentName)
352 );
353 }