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
21 Retrieves a Unicode string that is the user readable name of the driver.
23 This function retrieves the user readable name of a driver in the form of a
24 Unicode string. If the driver specified by This has a user readable name in
25 the language specified by Language, then a pointer to the driver name is
26 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
27 by This does not support the language specified by Language,
28 then EFI_UNSUPPORTED is returned.
30 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
31 EFI_COMPONENT_NAME_PROTOCOL instance.
33 @param Language[in] A pointer to a Null-terminated ASCII string
34 array indicating the language. This is the
35 language of the driver name that the caller is
36 requesting, and it must match one of the
37 languages specified in SupportedLanguages. The
38 number of languages supported by a driver is up
39 to the driver writer. Language is specified
40 in RFC 4646 or ISO 639-2 language code format.
42 @param DriverName[out] A pointer to the Unicode string to return.
43 This Unicode string is the name of the
44 driver specified by This in the language
45 specified by Language.
47 @retval EFI_SUCCESS The Unicode string for the Driver specified by
48 This and the language specified by Language was
49 returned in DriverName.
51 @retval EFI_INVALID_PARAMETER Language is NULL.
53 @retval EFI_INVALID_PARAMETER DriverName is NULL.
55 @retval EFI_UNSUPPORTED The driver specified by This does not support
56 the language specified by Language.
61 EmuBlockIoComponentNameGetDriverName (
62 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
64 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
,
163 EFI_UNICODE_STRING_TABLE mEmuBlockIoDriverNameTable
[] = {
164 { "eng;en", L
"Emu Block I/O Driver" },
169 Retrieves a Unicode string that is the user readable name of the driver.
171 This function retrieves the user readable name of a driver in the form of a
172 Unicode string. If the driver specified by This has a user readable name in
173 the language specified by Language, then a pointer to the driver name is
174 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
175 by This does not support the language specified by Language,
176 then EFI_UNSUPPORTED is returned.
178 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
179 EFI_COMPONENT_NAME_PROTOCOL instance.
181 @param Language[in] A pointer to a Null-terminated ASCII string
182 array indicating the language. This is the
183 language of the driver name that the caller is
184 requesting, and it must match one of the
185 languages specified in SupportedLanguages. The
186 number of languages supported by a driver is up
187 to the driver writer. Language is specified
188 in RFC 4646 or ISO 639-2 language code format.
190 @param DriverName[out] A pointer to the Unicode string to return.
191 This Unicode string is the name of the
192 driver specified by This in the language
193 specified by Language.
195 @retval EFI_SUCCESS The Unicode string for the Driver specified by
196 This and the language specified by Language was
197 returned in DriverName.
199 @retval EFI_INVALID_PARAMETER Language is NULL.
201 @retval EFI_INVALID_PARAMETER DriverName is NULL.
203 @retval EFI_UNSUPPORTED The driver specified by This does not support
204 the language specified by Language.
209 EmuBlockIoComponentNameGetDriverName (
210 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
212 OUT CHAR16
**DriverName
215 return LookupUnicodeString2 (
217 This
->SupportedLanguages
,
218 mEmuBlockIoDriverNameTable
,
220 (BOOLEAN
)(This
== &gEmuBlockIoComponentName
)
225 Retrieves a Unicode string that is the user readable name of the controller
226 that is being managed by a driver.
228 This function retrieves the user readable name of the controller specified by
229 ControllerHandle and ChildHandle in the form of a Unicode string. If the
230 driver specified by This has a user readable name in the language specified by
231 Language, then a pointer to the controller name is returned in ControllerName,
232 and EFI_SUCCESS is returned. If the driver specified by This is not currently
233 managing the controller specified by ControllerHandle and ChildHandle,
234 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
235 support the language specified by Language, then EFI_UNSUPPORTED is returned.
237 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
238 EFI_COMPONENT_NAME_PROTOCOL instance.
240 @param ControllerHandle[in] The handle of a controller that the driver
241 specified by This is managing. This handle
242 specifies the controller whose name is to be
245 @param ChildHandle[in] The handle of the child controller to retrieve
246 the name of. This is an optional parameter that
247 may be NULL. It will be NULL for device
248 drivers. It will also be NULL for a bus drivers
249 that wish to retrieve the name of the bus
250 controller. It will not be NULL for a bus
251 driver that wishes to retrieve the name of a
254 @param Language[in] A pointer to a Null-terminated ASCII string
255 array indicating the language. This is the
256 language of the driver name that the caller is
257 requesting, and it must match one of the
258 languages specified in SupportedLanguages. The
259 number of languages supported by a driver is up
260 to the driver writer. Language is specified in
261 RFC 4646 or ISO 639-2 language code format.
263 @param ControllerName[out] A pointer to the Unicode string to return.
264 This Unicode string is the name of the
265 controller specified by ControllerHandle and
266 ChildHandle in the language specified by
267 Language from the point of view of the driver
270 @retval EFI_SUCCESS The Unicode string for the user readable name in
271 the language specified by Language for the
272 driver specified by This was returned in
275 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
277 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
280 @retval EFI_INVALID_PARAMETER Language is NULL.
282 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
284 @retval EFI_UNSUPPORTED The driver specified by This is not currently
285 managing the controller specified by
286 ControllerHandle and ChildHandle.
288 @retval EFI_UNSUPPORTED The driver specified by This does not support
289 the language specified by Language.
294 EmuBlockIoComponentNameGetControllerName (
295 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
296 IN EFI_HANDLE ControllerHandle
,
297 IN EFI_HANDLE ChildHandle OPTIONAL
,
299 OUT CHAR16
**ControllerName
303 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
304 EMU_BLOCK_IO_PRIVATE
*Private
;
307 // This is a device driver, so ChildHandle must be NULL.
309 if (ChildHandle
!= NULL
) {
310 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
;
326 // Get our context back
328 Status
= gBS
->OpenProtocol (
330 &gEfiBlockIoProtocolGuid
,
332 gEmuBlockIoDriverBinding
.DriverBindingHandle
,
334 EFI_OPEN_PROTOCOL_GET_PROTOCOL
336 if (EFI_ERROR (Status
)) {
337 return EFI_UNSUPPORTED
;
340 Private
= EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo
);
342 return LookupUnicodeString2 (
344 This
->SupportedLanguages
,
345 Private
->ControllerNameTable
,
347 (BOOLEAN
)(This
== &gEmuBlockIoComponentName
)