Add IncompatiblePciDeviceSupportDxe module in IntelFrameworkModulePkg.
[edk2.git] / Nt32Pkg / WinNtBlockIoDxe / ComponentName.c
blob5e13ada6d8dc538d34d2482a72dc528ad0412a1e
1 /**@file
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 Module Name:
14 ComponentName.c
16 Abstract:
18 **/
19 #include <Uefi.h>
20 #include <WinNtDxe.h>
21 #include <Protocol/ComponentName.h>
22 #include <Protocol/DriverBinding.h>
24 #include "WinNtBlockIo.h"
27 // EFI Component Name Functions
29 /**
30 Retrieves a Unicode string that is the user readable name of the driver.
32 This function retrieves the user readable name of a driver in the form of a
33 Unicode string. If the driver specified by This has a user readable name in
34 the language specified by Language, then a pointer to the driver name is
35 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
36 by This does not support the language specified by Language,
37 then EFI_UNSUPPORTED is returned.
39 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
40 EFI_COMPONENT_NAME_PROTOCOL instance.
42 @param Language[in] A pointer to a Null-terminated ASCII string
43 array indicating the language. This is the
44 language of the driver name that the caller is
45 requesting, and it must match one of the
46 languages specified in SupportedLanguages. The
47 number of languages supported by a driver is up
48 to the driver writer. Language is specified
49 in RFC 4646 or ISO 639-2 language code format.
51 @param DriverName[out] A pointer to the Unicode string to return.
52 This Unicode string is the name of the
53 driver specified by This in the language
54 specified by Language.
56 @retval EFI_SUCCESS The Unicode string for the Driver specified by
57 This and the language specified by Language was
58 returned in DriverName.
60 @retval EFI_INVALID_PARAMETER Language is NULL.
62 @retval EFI_INVALID_PARAMETER DriverName is NULL.
64 @retval EFI_UNSUPPORTED The driver specified by This does not support
65 the language specified by Language.
67 **/
68 EFI_STATUS
69 EFIAPI
70 WinNtBlockIoComponentNameGetDriverName (
71 IN EFI_COMPONENT_NAME_PROTOCOL *This,
72 IN CHAR8 *Language,
73 OUT CHAR16 **DriverName
77 /**
78 Retrieves a Unicode string that is the user readable name of the controller
79 that is being managed by a driver.
81 This function retrieves the user readable name of the controller specified by
82 ControllerHandle and ChildHandle in the form of a Unicode string. If the
83 driver specified by This has a user readable name in the language specified by
84 Language, then a pointer to the controller name is returned in ControllerName,
85 and EFI_SUCCESS is returned. If the driver specified by This is not currently
86 managing the controller specified by ControllerHandle and ChildHandle,
87 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
88 support the language specified by Language, then EFI_UNSUPPORTED is returned.
90 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
91 EFI_COMPONENT_NAME_PROTOCOL instance.
93 @param ControllerHandle[in] The handle of a controller that the driver
94 specified by This is managing. This handle
95 specifies the controller whose name is to be
96 returned.
98 @param ChildHandle[in] The handle of the child controller to retrieve
99 the name of. This is an optional parameter that
100 may be NULL. It will be NULL for device
101 drivers. It will also be NULL for a bus drivers
102 that wish to retrieve the name of the bus
103 controller. It will not be NULL for a bus
104 driver that wishes to retrieve the name of a
105 child controller.
107 @param Language[in] A pointer to a Null-terminated ASCII string
108 array indicating the language. This is the
109 language of the driver name that the caller is
110 requesting, and it must match one of the
111 languages specified in SupportedLanguages. The
112 number of languages supported by a driver is up
113 to the driver writer. Language is specified in
114 RFC 4646 or ISO 639-2 language code format.
116 @param ControllerName[out] A pointer to the Unicode string to return.
117 This Unicode string is the name of the
118 controller specified by ControllerHandle and
119 ChildHandle in the language specified by
120 Language from the point of view of the driver
121 specified by This.
123 @retval EFI_SUCCESS The Unicode string for the user readable name in
124 the language specified by Language for the
125 driver specified by This was returned in
126 DriverName.
128 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
130 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
131 EFI_HANDLE.
133 @retval EFI_INVALID_PARAMETER Language is NULL.
135 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
137 @retval EFI_UNSUPPORTED The driver specified by This is not currently
138 managing the controller specified by
139 ControllerHandle and ChildHandle.
141 @retval EFI_UNSUPPORTED The driver specified by This does not support
142 the language specified by Language.
145 EFI_STATUS
146 EFIAPI
147 WinNtBlockIoComponentNameGetControllerName (
148 IN EFI_COMPONENT_NAME_PROTOCOL *This,
149 IN EFI_HANDLE ControllerHandle,
150 IN EFI_HANDLE ChildHandle OPTIONAL,
151 IN CHAR8 *Language,
152 OUT CHAR16 **ControllerName
157 // EFI Component Name Protocol
159 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtBlockIoComponentName = {
160 WinNtBlockIoComponentNameGetDriverName,
161 WinNtBlockIoComponentNameGetControllerName,
162 "eng"
166 // EFI Component Name 2 Protocol
168 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtBlockIoComponentName2 = {
169 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) WinNtBlockIoComponentNameGetDriverName,
170 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) WinNtBlockIoComponentNameGetControllerName,
171 "en"
175 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtBlockIoDriverNameTable[] = {
176 { "eng;en", L"Windows Block I/O Driver" },
177 { NULL , NULL }
181 Retrieves a Unicode string that is the user readable name of the driver.
183 This function retrieves the user readable name of a driver in the form of a
184 Unicode string. If the driver specified by This has a user readable name in
185 the language specified by Language, then a pointer to the driver name is
186 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
187 by This does not support the language specified by Language,
188 then EFI_UNSUPPORTED is returned.
190 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
191 EFI_COMPONENT_NAME_PROTOCOL instance.
193 @param Language[in] A pointer to a Null-terminated ASCII string
194 array indicating the language. This is the
195 language of the driver name that the caller is
196 requesting, and it must match one of the
197 languages specified in SupportedLanguages. The
198 number of languages supported by a driver is up
199 to the driver writer. Language is specified
200 in RFC 4646 or ISO 639-2 language code format.
202 @param DriverName[out] A pointer to the Unicode string to return.
203 This Unicode string is the name of the
204 driver specified by This in the language
205 specified by Language.
207 @retval EFI_SUCCESS The Unicode string for the Driver specified by
208 This and the language specified by Language was
209 returned in DriverName.
211 @retval EFI_INVALID_PARAMETER Language is NULL.
213 @retval EFI_INVALID_PARAMETER DriverName is NULL.
215 @retval EFI_UNSUPPORTED The driver specified by This does not support
216 the language specified by Language.
219 EFI_STATUS
220 EFIAPI
221 WinNtBlockIoComponentNameGetDriverName (
222 IN EFI_COMPONENT_NAME_PROTOCOL *This,
223 IN CHAR8 *Language,
224 OUT CHAR16 **DriverName
227 return LookupUnicodeString2 (
228 Language,
229 This->SupportedLanguages,
230 mWinNtBlockIoDriverNameTable,
231 DriverName,
232 (BOOLEAN)(This == &gWinNtBlockIoComponentName)
237 Retrieves a Unicode string that is the user readable name of the controller
238 that is being managed by a driver.
240 This function retrieves the user readable name of the controller specified by
241 ControllerHandle and ChildHandle in the form of a Unicode string. If the
242 driver specified by This has a user readable name in the language specified by
243 Language, then a pointer to the controller name is returned in ControllerName,
244 and EFI_SUCCESS is returned. If the driver specified by This is not currently
245 managing the controller specified by ControllerHandle and ChildHandle,
246 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
247 support the language specified by Language, then EFI_UNSUPPORTED is returned.
249 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
250 EFI_COMPONENT_NAME_PROTOCOL instance.
252 @param ControllerHandle[in] The handle of a controller that the driver
253 specified by This is managing. This handle
254 specifies the controller whose name is to be
255 returned.
257 @param ChildHandle[in] The handle of the child controller to retrieve
258 the name of. This is an optional parameter that
259 may be NULL. It will be NULL for device
260 drivers. It will also be NULL for a bus drivers
261 that wish to retrieve the name of the bus
262 controller. It will not be NULL for a bus
263 driver that wishes to retrieve the name of a
264 child controller.
266 @param Language[in] A pointer to a Null-terminated ASCII string
267 array indicating the language. This is the
268 language of the driver name that the caller is
269 requesting, and it must match one of the
270 languages specified in SupportedLanguages. The
271 number of languages supported by a driver is up
272 to the driver writer. Language is specified in
273 RFC 4646 or ISO 639-2 language code format.
275 @param ControllerName[out] A pointer to the Unicode string to return.
276 This Unicode string is the name of the
277 controller specified by ControllerHandle and
278 ChildHandle in the language specified by
279 Language from the point of view of the driver
280 specified by This.
282 @retval EFI_SUCCESS The Unicode string for the user readable name in
283 the language specified by Language for the
284 driver specified by This was returned in
285 DriverName.
287 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
289 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
290 EFI_HANDLE.
292 @retval EFI_INVALID_PARAMETER Language is NULL.
294 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
296 @retval EFI_UNSUPPORTED The driver specified by This is not currently
297 managing the controller specified by
298 ControllerHandle and ChildHandle.
300 @retval EFI_UNSUPPORTED The driver specified by This does not support
301 the language specified by Language.
304 EFI_STATUS
305 EFIAPI
306 WinNtBlockIoComponentNameGetControllerName (
307 IN EFI_COMPONENT_NAME_PROTOCOL *This,
308 IN EFI_HANDLE ControllerHandle,
309 IN EFI_HANDLE ChildHandle OPTIONAL,
310 IN CHAR8 *Language,
311 OUT CHAR16 **ControllerName
314 EFI_STATUS Status;
315 EFI_BLOCK_IO_PROTOCOL *BlockIo;
316 WIN_NT_BLOCK_IO_PRIVATE *Private;
319 // This is a device driver, so ChildHandle must be NULL.
321 if (ChildHandle != NULL) {
322 return EFI_UNSUPPORTED;
325 // Make sure this driver is currently managing ControllerHandle
327 Status = EfiTestManagedDevice (
328 ControllerHandle,
329 gWinNtBlockIoDriverBinding.DriverBindingHandle,
330 &gEfiWinNtIoProtocolGuid
332 if (EFI_ERROR (Status)) {
333 return EFI_UNSUPPORTED;
336 // Get our context back
338 Status = gBS->OpenProtocol (
339 ControllerHandle,
340 &gEfiBlockIoProtocolGuid,
341 (VOID **) &BlockIo,
342 gWinNtBlockIoDriverBinding.DriverBindingHandle,
343 ControllerHandle,
344 EFI_OPEN_PROTOCOL_GET_PROTOCOL
346 if (EFI_ERROR (Status)) {
347 return EFI_UNSUPPORTED;
350 Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);
352 return LookupUnicodeString2 (
353 Language,
354 This->SupportedLanguages,
355 Private->ControllerNameTable,
356 ControllerName,
357 (BOOLEAN)(This == &gWinNtBlockIoComponentName)