3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
8 #include "EmuBusDriverDxe.h"
11 // EFI Component Name Functions
15 EmuBusDriverComponentNameGetDriverName (
16 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
18 OUT CHAR16
**DriverName
23 EmuBusDriverComponentNameGetControllerName (
24 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
25 IN EFI_HANDLE ControllerHandle
,
26 IN EFI_HANDLE ChildHandle OPTIONAL
,
28 OUT CHAR16
**ControllerName
32 // EFI Component Name Protocol
34 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuBusDriverComponentName
= {
35 EmuBusDriverComponentNameGetDriverName
,
36 EmuBusDriverComponentNameGetControllerName
,
41 // EFI Component Name 2 Protocol
43 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2
= {
44 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)EmuBusDriverComponentNameGetDriverName
,
45 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)EmuBusDriverComponentNameGetControllerName
,
49 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuBusDriverNameTable
[] = {
50 { "eng", L
"Emu Bus Driver" },
55 Retrieves a Unicode string that is the user readable name of the driver.
57 This function retrieves the user readable name of a driver in the form of a
58 Unicode string. If the driver specified by This has a user readable name in
59 the language specified by Language, then a pointer to the driver name is
60 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
61 by This does not support the language specified by Language,
62 then EFI_UNSUPPORTED is returned.
64 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
65 EFI_COMPONENT_NAME_PROTOCOL instance.
67 @param Language[in] A pointer to a Null-terminated ASCII string
68 array indicating the language. This is the
69 language of the driver name that the caller is
70 requesting, and it must match one of the
71 languages specified in SupportedLanguages. The
72 number of languages supported by a driver is up
73 to the driver writer. Language is specified
74 in RFC 4646 or ISO 639-2 language code format.
76 @param DriverName[out] A pointer to the Unicode string to return.
77 This Unicode string is the name of the
78 driver specified by This in the language
79 specified by Language.
81 @retval EFI_SUCCESS The Unicode string for the Driver specified by
82 This and the language specified by Language was
83 returned in DriverName.
85 @retval EFI_INVALID_PARAMETER Language is NULL.
87 @retval EFI_INVALID_PARAMETER DriverName is NULL.
89 @retval EFI_UNSUPPORTED The driver specified by This does not support
90 the language specified by Language.
95 EmuBusDriverComponentNameGetDriverName (
96 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
98 OUT CHAR16
**DriverName
101 return LookupUnicodeString2 (
103 This
->SupportedLanguages
,
104 mEmuBusDriverNameTable
,
106 (BOOLEAN
)(This
== &gEmuBusDriverComponentName
)
111 Retrieves a Unicode string that is the user readable name of the controller
112 that is being managed by a driver.
114 This function retrieves the user readable name of the controller specified by
115 ControllerHandle and ChildHandle in the form of a Unicode string. If the
116 driver specified by This has a user readable name in the language specified by
117 Language, then a pointer to the controller name is returned in ControllerName,
118 and EFI_SUCCESS is returned. If the driver specified by This is not currently
119 managing the controller specified by ControllerHandle and ChildHandle,
120 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
121 support the language specified by Language, then EFI_UNSUPPORTED is returned.
123 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
124 EFI_COMPONENT_NAME_PROTOCOL instance.
126 @param ControllerHandle[in] The handle of a controller that the driver
127 specified by This is managing. This handle
128 specifies the controller whose name is to be
131 @param ChildHandle[in] The handle of the child controller to retrieve
132 the name of. This is an optional parameter that
133 may be NULL. It will be NULL for device
134 drivers. It will also be NULL for a bus drivers
135 that wish to retrieve the name of the bus
136 controller. It will not be NULL for a bus
137 driver that wishes to retrieve the name of a
140 @param Language[in] A pointer to a Null-terminated ASCII string
141 array indicating the language. This is the
142 language of the driver name that the caller is
143 requesting, and it must match one of the
144 languages specified in SupportedLanguages. The
145 number of languages supported by a driver is up
146 to the driver writer. Language is specified in
147 RFC 4646 or ISO 639-2 language code format.
149 @param ControllerName[out] A pointer to the Unicode string to return.
150 This Unicode string is the name of the
151 controller specified by ControllerHandle and
152 ChildHandle in the language specified by
153 Language from the point of view of the driver
156 @retval EFI_SUCCESS The Unicode string for the user readable name in
157 the language specified by Language for the
158 driver specified by This was returned in
161 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
163 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
166 @retval EFI_INVALID_PARAMETER Language is NULL.
168 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
170 @retval EFI_UNSUPPORTED The driver specified by This is not currently
171 managing the controller specified by
172 ControllerHandle and ChildHandle.
174 @retval EFI_UNSUPPORTED The driver specified by This does not support
175 the language specified by Language.
180 EmuBusDriverComponentNameGetControllerName (
181 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
182 IN EFI_HANDLE ControllerHandle
,
183 IN EFI_HANDLE ChildHandle OPTIONAL
,
185 OUT CHAR16
**ControllerName
189 EMU_IO_THUNK_PROTOCOL
*EmuIo
;
190 EMU_IO_DEVICE
*Private
;
193 // Make sure this driver is currently managing ControllHandle
195 Status
= EfiTestManagedDevice (
197 gEmuBusDriverBinding
.DriverBindingHandle
,
198 &gEmuThunkProtocolGuid
200 if (EFI_ERROR (Status
)) {
205 // This is a bus driver, so ChildHandle can not be NULL.
207 if (ChildHandle
== NULL
) {
208 return EFI_UNSUPPORTED
;
211 Status
= EfiTestChildHandle (
214 &gEmuThunkProtocolGuid
216 if (EFI_ERROR (Status
)) {
221 // Get our context back
223 Status
= gBS
->OpenProtocol (
225 &gEmuIoThunkProtocolGuid
,
227 gEmuBusDriverBinding
.DriverBindingHandle
,
229 EFI_OPEN_PROTOCOL_GET_PROTOCOL
231 if (EFI_ERROR (Status
)) {
232 return EFI_UNSUPPORTED
;
235 Private
= EMU_IO_DEVICE_FROM_THIS (EmuIo
);
237 return LookupUnicodeString2 (
239 This
->SupportedLanguages
,
240 Private
->ControllerNameTable
,
242 (BOOLEAN
)(This
== &gEmuBusDriverComponentName
)