3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include "EmuBlockIo.h"
17 // EFI Component Name Functions
20 Retrieves a Unicode string that is the user readable name of the driver.
22 This function retrieves the user readable name of a driver in the form of a
23 Unicode string. If the driver specified by This has a user readable name in
24 the language specified by Language, then a pointer to the driver name is
25 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
26 by This does not support the language specified by Language,
27 then EFI_UNSUPPORTED is returned.
29 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
30 EFI_COMPONENT_NAME_PROTOCOL instance.
32 @param Language[in] A pointer to a Null-terminated ASCII string
33 array indicating the language. This is the
34 language of the driver name that the caller is
35 requesting, and it must match one of the
36 languages specified in SupportedLanguages. The
37 number of languages supported by a driver is up
38 to the driver writer. Language is specified
39 in RFC 4646 or ISO 639-2 language code format.
41 @param DriverName[out] A pointer to the Unicode string to return.
42 This Unicode string is the name of the
43 driver specified by This in the language
44 specified by Language.
46 @retval EFI_SUCCESS The Unicode string for the Driver specified by
47 This and the language specified by Language was
48 returned in DriverName.
50 @retval EFI_INVALID_PARAMETER Language is NULL.
52 @retval EFI_INVALID_PARAMETER DriverName is NULL.
54 @retval EFI_UNSUPPORTED The driver specified by This does not support
55 the language specified by Language.
60 EmuBlockIoComponentNameGetDriverName (
61 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
63 OUT CHAR16
**DriverName
68 Retrieves a Unicode string that is the user readable name of the controller
69 that is being managed by a driver.
71 This function retrieves the user readable name of the controller specified by
72 ControllerHandle and ChildHandle in the form of a Unicode string. If the
73 driver specified by This has a user readable name in the language specified by
74 Language, then a pointer to the controller name is returned in ControllerName,
75 and EFI_SUCCESS is returned. If the driver specified by This is not currently
76 managing the controller specified by ControllerHandle and ChildHandle,
77 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
78 support the language specified by Language, then EFI_UNSUPPORTED is returned.
80 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
81 EFI_COMPONENT_NAME_PROTOCOL instance.
83 @param ControllerHandle[in] The handle of a controller that the driver
84 specified by This is managing. This handle
85 specifies the controller whose name is to be
88 @param ChildHandle[in] The handle of the child controller to retrieve
89 the name of. This is an optional parameter that
90 may be NULL. It will be NULL for device
91 drivers. It will also be NULL for a bus drivers
92 that wish to retrieve the name of the bus
93 controller. It will not be NULL for a bus
94 driver that wishes to retrieve the name of a
97 @param Language[in] A pointer to a Null-terminated ASCII string
98 array indicating the language. This is the
99 language of the driver name that the caller is
100 requesting, and it must match one of the
101 languages specified in SupportedLanguages. The
102 number of languages supported by a driver is up
103 to the driver writer. Language is specified in
104 RFC 4646 or ISO 639-2 language code format.
106 @param ControllerName[out] A pointer to the Unicode string to return.
107 This Unicode string is the name of the
108 controller specified by ControllerHandle and
109 ChildHandle in the language specified by
110 Language from the point of view of the driver
113 @retval EFI_SUCCESS The Unicode string for the user readable name in
114 the language specified by Language for the
115 driver specified by This was returned in
118 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
120 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
123 @retval EFI_INVALID_PARAMETER Language is NULL.
125 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
127 @retval EFI_UNSUPPORTED The driver specified by This is not currently
128 managing the controller specified by
129 ControllerHandle and ChildHandle.
131 @retval EFI_UNSUPPORTED The driver specified by This does not support
132 the language specified by Language.
137 EmuBlockIoComponentNameGetControllerName (
138 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
139 IN EFI_HANDLE ControllerHandle
,
140 IN EFI_HANDLE ChildHandle OPTIONAL
,
142 OUT CHAR16
**ControllerName
146 // EFI Component Name Protocol
148 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuBlockIoComponentName
= {
149 EmuBlockIoComponentNameGetDriverName
,
150 EmuBlockIoComponentNameGetControllerName
,
155 // EFI Component Name 2 Protocol
157 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBlockIoComponentName2
= {
158 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) EmuBlockIoComponentNameGetDriverName
,
159 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) EmuBlockIoComponentNameGetControllerName
,
164 EFI_UNICODE_STRING_TABLE mEmuBlockIoDriverNameTable
[] = {
165 { "eng;en", L
"Emu Block I/O Driver" },
170 Retrieves a Unicode string that is the user readable name of the driver.
172 This function retrieves the user readable name of a driver in the form of a
173 Unicode string. If the driver specified by This has a user readable name in
174 the language specified by Language, then a pointer to the driver name is
175 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
176 by This does not support the language specified by Language,
177 then EFI_UNSUPPORTED is returned.
179 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
180 EFI_COMPONENT_NAME_PROTOCOL instance.
182 @param Language[in] A pointer to a Null-terminated ASCII string
183 array indicating the language. This is the
184 language of the driver name that the caller is
185 requesting, and it must match one of the
186 languages specified in SupportedLanguages. The
187 number of languages supported by a driver is up
188 to the driver writer. Language is specified
189 in RFC 4646 or ISO 639-2 language code format.
191 @param DriverName[out] A pointer to the Unicode string to return.
192 This Unicode string is the name of the
193 driver specified by This in the language
194 specified by Language.
196 @retval EFI_SUCCESS The Unicode string for the Driver specified by
197 This and the language specified by Language was
198 returned in DriverName.
200 @retval EFI_INVALID_PARAMETER Language is NULL.
202 @retval EFI_INVALID_PARAMETER DriverName is NULL.
204 @retval EFI_UNSUPPORTED The driver specified by This does not support
205 the language specified by Language.
210 EmuBlockIoComponentNameGetDriverName (
211 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
213 OUT CHAR16
**DriverName
216 return LookupUnicodeString2 (
218 This
->SupportedLanguages
,
219 mEmuBlockIoDriverNameTable
,
221 (BOOLEAN
)(This
== &gEmuBlockIoComponentName
)
226 Retrieves a Unicode string that is the user readable name of the controller
227 that is being managed by a driver.
229 This function retrieves the user readable name of the controller specified by
230 ControllerHandle and ChildHandle in the form of a Unicode string. If the
231 driver specified by This has a user readable name in the language specified by
232 Language, then a pointer to the controller name is returned in ControllerName,
233 and EFI_SUCCESS is returned. If the driver specified by This is not currently
234 managing the controller specified by ControllerHandle and ChildHandle,
235 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
236 support the language specified by Language, then EFI_UNSUPPORTED is returned.
238 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
239 EFI_COMPONENT_NAME_PROTOCOL instance.
241 @param ControllerHandle[in] The handle of a controller that the driver
242 specified by This is managing. This handle
243 specifies the controller whose name is to be
246 @param ChildHandle[in] The handle of the child controller to retrieve
247 the name of. This is an optional parameter that
248 may be NULL. It will be NULL for device
249 drivers. It will also be NULL for a bus drivers
250 that wish to retrieve the name of the bus
251 controller. It will not be NULL for a bus
252 driver that wishes to retrieve the name of a
255 @param Language[in] A pointer to a Null-terminated ASCII string
256 array indicating the language. This is the
257 language of the driver name that the caller is
258 requesting, and it must match one of the
259 languages specified in SupportedLanguages. The
260 number of languages supported by a driver is up
261 to the driver writer. Language is specified in
262 RFC 4646 or ISO 639-2 language code format.
264 @param ControllerName[out] A pointer to the Unicode string to return.
265 This Unicode string is the name of the
266 controller specified by ControllerHandle and
267 ChildHandle in the language specified by
268 Language from the point of view of the driver
271 @retval EFI_SUCCESS The Unicode string for the user readable name in
272 the language specified by Language for the
273 driver specified by This was returned in
276 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
278 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
281 @retval EFI_INVALID_PARAMETER Language is NULL.
283 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
285 @retval EFI_UNSUPPORTED The driver specified by This is not currently
286 managing the controller specified by
287 ControllerHandle and ChildHandle.
289 @retval EFI_UNSUPPORTED The driver specified by This does not support
290 the language specified by Language.
295 EmuBlockIoComponentNameGetControllerName (
296 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
297 IN EFI_HANDLE ControllerHandle
,
298 IN EFI_HANDLE ChildHandle OPTIONAL
,
300 OUT CHAR16
**ControllerName
304 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
305 EMU_BLOCK_IO_PRIVATE
*Private
;
308 // This is a device driver, so ChildHandle must be NULL.
310 if (ChildHandle
!= NULL
) {
311 return EFI_UNSUPPORTED
;
314 // Make sure this driver is currently managing ControllerHandle
316 Status
= EfiTestManagedDevice (
318 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
319 &gEmuIoThunkProtocolGuid
321 if (EFI_ERROR (Status
)) {
322 return EFI_UNSUPPORTED
;
325 // Get our context back
327 Status
= gBS
->OpenProtocol (
329 &gEfiBlockIoProtocolGuid
,
331 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
333 EFI_OPEN_PROTOCOL_GET_PROTOCOL
335 if (EFI_ERROR (Status
)) {
336 return EFI_UNSUPPORTED
;
339 Private
= EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo
);
341 return LookupUnicodeString2 (
343 This
->SupportedLanguages
,
344 Private
->ControllerNameTable
,
346 (BOOLEAN
)(This
== &gEmuBlockIoComponentName
)