2 UEFI Component Name(2) protocol implementation for USB Serial driver.
4 Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "FtdiUsbSerialDriver.h"
12 // EFI Component Name Protocol
14 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbSerialComponentName
= {
15 (EFI_COMPONENT_NAME_GET_DRIVER_NAME
) UsbSerialComponentNameGetDriverName
,
16 (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME
) UsbSerialComponentNameGetControllerName
,
21 // EFI Component Name 2 Protocol
23 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbSerialComponentName2
= {
24 UsbSerialComponentNameGetDriverName
,
25 UsbSerialComponentNameGetControllerName
,
30 // Driver name string table
32 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbSerialDriverNameTable
[] = {
33 { "eng;en", L
"FTDI-232 USB Serial Driver" },
38 Retrieves a Unicode string that is the user readable name of the driver.
40 This function retrieves the user readable name of a driver in the form of a
41 Unicode string. If the driver specified by This has a user readable name in
42 the language specified by Language, then a pointer to the driver name is
43 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
44 by This does not support the language specified by Language,
45 then EFI_UNSUPPORTED is returned.
47 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
48 EFI_COMPONENT_NAME_PROTOCOL instance.
49 @param Language A pointer to a Null-terminated ASCII string
50 array indicating the language. This is the
51 language of the driver name that the caller is
52 requesting, and it must match one of the
53 languages specified in SupportedLanguages. The
54 number of languages supported by a driver is up
55 to the driver writer. Language is specified
56 in RFC 4646 or ISO 639-2 language code format.
57 @param DriverName A pointer to the Unicode string to return.
58 This Unicode string is the name of the
59 driver specified by This in the language
60 specified by Language.
62 @retval EFI_SUCCESS The Unicode string for the Driver specified by
63 This and the language specified by Language was
64 returned in DriverName.
65 @retval EFI_INVALID_PARAMETER Language is NULL.
66 @retval EFI_INVALID_PARAMETER DriverName is NULL.
67 @retval EFI_UNSUPPORTED The driver specified by This does not support
68 the language specified by Language.
73 UsbSerialComponentNameGetDriverName (
74 IN EFI_COMPONENT_NAME2_PROTOCOL
*This
,
76 OUT CHAR16
**DriverName
79 return LookupUnicodeString2 (
81 This
->SupportedLanguages
,
82 mUsbSerialDriverNameTable
,
84 (BOOLEAN
)(This
== &gUsbSerialComponentName2
)
90 Retrieves a Unicode string that is the user readable name of the controller
91 that is being managed by a driver.
93 This function retrieves the user readable name of the controller specified by
94 ControllerHandle and ChildHandle in the form of a Unicode string. If the
95 driver specified by This has a user readable name in the language specified by
96 Language, then a pointer to the controller name is returned in ControllerName,
97 and EFI_SUCCESS is returned. If the driver specified by This is not currently
98 managing the controller specified by ControllerHandle and ChildHandle,
99 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
100 support the language specified by Language, then EFI_UNSUPPORTED is returned.
102 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
103 EFI_COMPONENT_NAME_PROTOCOL instance.
104 @param ControllerHandle The handle of a controller that the driver
105 specified by This is managing. This handle
106 specifies the controller whose name is to be
108 @param ChildHandle The handle of the child controller to retrieve
109 the name of. This is an optional parameter that
110 may be NULL. It will be NULL for device
111 drivers. It will also be NULL for a bus drivers
112 that wish to retrieve the name of the bus
113 controller. It will not be NULL for a bus
114 driver that wishes to retrieve the name of a
116 @param Language A pointer to a Null-terminated ASCII string
117 array indicating the language. This is the
118 language of the driver name that the caller is
119 requesting, and it must match one of the
120 languages specified in SupportedLanguages. The
121 number of languages supported by a driver is up
122 to the driver writer. Language is specified in
123 RFC 4646 or ISO 639-2 language code format.
124 @param ControllerName A pointer to the Unicode string to return.
125 This Unicode string is the name of the
126 controller specified by ControllerHandle and
127 ChildHandle in the language specified by
128 Language from the point of view of the driver
131 @retval EFI_SUCCESS The Unicode string for the user readable name in
132 the language specified by Language for the
133 driver specified by This was returned in
135 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
136 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
138 @retval EFI_INVALID_PARAMETER Language is NULL.
139 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
140 @retval EFI_UNSUPPORTED The driver specified by This is not currently
141 managing the controller specified by
142 ControllerHandle and ChildHandle.
143 @retval EFI_UNSUPPORTED The driver specified by This does not support
144 the language specified by Language.
149 UsbSerialComponentNameGetControllerName (
150 IN EFI_COMPONENT_NAME2_PROTOCOL
*This
,
151 IN EFI_HANDLE ControllerHandle
,
152 IN EFI_HANDLE ChildHandle OPTIONAL
,
154 OUT CHAR16
**ControllerName
158 USB_SER_DEV
*UsbSerDev
;
159 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
160 EFI_USB_IO_PROTOCOL
*UsbIoProtocol
;
163 // This is a device driver, so ChildHandle must be NULL.
165 if (ChildHandle
!= NULL
) {
166 return EFI_UNSUPPORTED
;
170 // Check Controller's handle
172 Status
= gBS
->OpenProtocol (
174 &gEfiUsbIoProtocolGuid
,
175 (VOID
**) &UsbIoProtocol
,
176 gUsbSerialDriverBinding
.DriverBindingHandle
,
178 EFI_OPEN_PROTOCOL_BY_DRIVER
180 if (!EFI_ERROR (Status
)) {
183 &gEfiUsbIoProtocolGuid
,
184 gUsbSerialDriverBinding
.DriverBindingHandle
,
188 return EFI_UNSUPPORTED
;
191 if (Status
!= EFI_ALREADY_STARTED
) {
192 return EFI_UNSUPPORTED
;
195 // Get the device context
197 Status
= gBS
->OpenProtocol (
199 &gEfiSerialIoProtocolGuid
,
201 gUsbSerialDriverBinding
.DriverBindingHandle
,
203 EFI_OPEN_PROTOCOL_GET_PROTOCOL
205 if (EFI_ERROR (Status
)) {
209 UsbSerDev
= USB_SER_DEV_FROM_THIS (SerialIo
);
211 return LookupUnicodeString2 (
213 This
->SupportedLanguages
,
214 UsbSerDev
->ControllerNameTable
,
216 (BOOLEAN
)(This
== &gUsbSerialComponentName2
)