2 UEFI Component Name and Name2 protocol for Isa serial driver.
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 // EFI Component Name Protocol
14 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPciSioSerialComponentName
= {
15 SerialComponentNameGetDriverName
,
16 SerialComponentNameGetControllerName
,
21 // EFI Component Name 2 Protocol
23 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPciSioSerialComponentName2
= {
24 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)SerialComponentNameGetDriverName
,
25 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)SerialComponentNameGetControllerName
,
29 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSerialDriverNameTable
[] = {
32 L
"PCI SIO Serial Driver"
41 Retrieves a Unicode string that is the user readable name of the driver.
43 This function retrieves the user readable name of a driver in the form of a
44 Unicode string. If the driver specified by This has a user readable name in
45 the language specified by Language, then a pointer to the driver name is
46 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
47 by This does not support the language specified by Language,
48 then EFI_UNSUPPORTED is returned.
50 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
51 EFI_COMPONENT_NAME_PROTOCOL instance.
53 @param Language[in] A pointer to a Null-terminated ASCII string
54 array indicating the language. This is the
55 language of the driver name that the caller is
56 requesting, and it must match one of the
57 languages specified in SupportedLanguages. The
58 number of languages supported by a driver is up
59 to the driver writer. Language is specified
60 in RFC 4646 or ISO 639-2 language code format.
62 @param DriverName[out] A pointer to the Unicode string to return.
63 This Unicode string is the name of the
64 driver specified by This in the language
65 specified by Language.
67 @retval EFI_SUCCESS The Unicode string for the Driver specified by
68 This and the language specified by Language was
69 returned in DriverName.
71 @retval EFI_INVALID_PARAMETER Language is NULL.
73 @retval EFI_INVALID_PARAMETER DriverName is NULL.
75 @retval EFI_UNSUPPORTED The driver specified by This does not support
76 the language specified by Language.
81 SerialComponentNameGetDriverName (
82 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
84 OUT CHAR16
**DriverName
87 return LookupUnicodeString2 (
89 This
->SupportedLanguages
,
90 mSerialDriverNameTable
,
92 (BOOLEAN
)(This
== &gPciSioSerialComponentName
)
97 Retrieves a Unicode string that is the user readable name of the controller
98 that is being managed by a driver.
100 This function retrieves the user readable name of the controller specified by
101 ControllerHandle and ChildHandle in the form of a Unicode string. If the
102 driver specified by This has a user readable name in the language specified by
103 Language, then a pointer to the controller name is returned in ControllerName,
104 and EFI_SUCCESS is returned. If the driver specified by This is not currently
105 managing the controller specified by ControllerHandle and ChildHandle,
106 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
107 support the language specified by Language, then EFI_UNSUPPORTED is returned.
109 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
110 EFI_COMPONENT_NAME_PROTOCOL instance.
112 @param ControllerHandle[in] The handle of a controller that the driver
113 specified by This is managing. This handle
114 specifies the controller whose name is to be
117 @param ChildHandle[in] The handle of the child controller to retrieve
118 the name of. This is an optional parameter that
119 may be NULL. It will be NULL for device
120 drivers. It will also be NULL for a bus drivers
121 that wish to retrieve the name of the bus
122 controller. It will not be NULL for a bus
123 driver that wishes to retrieve the name of a
126 @param Language[in] A pointer to a Null-terminated ASCII string
127 array indicating the language. This is the
128 language of the driver name that the caller is
129 requesting, and it must match one of the
130 languages specified in SupportedLanguages. The
131 number of languages supported by a driver is up
132 to the driver writer. Language is specified in
133 RFC 4646 or ISO 639-2 language code format.
135 @param ControllerName[out] A pointer to the Unicode string to return.
136 This Unicode string is the name of the
137 controller specified by ControllerHandle and
138 ChildHandle in the language specified by
139 Language from the point of view of the driver
142 @retval EFI_SUCCESS The Unicode string for the user readable name in
143 the language specified by Language for the
144 driver specified by This was returned in
147 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
149 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
152 @retval EFI_INVALID_PARAMETER Language is NULL.
154 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
156 @retval EFI_UNSUPPORTED The driver specified by This is not currently
157 managing the controller specified by
158 ControllerHandle and ChildHandle.
160 @retval EFI_UNSUPPORTED The driver specified by This does not support
161 the language specified by Language.
166 SerialComponentNameGetControllerName (
167 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
168 IN EFI_HANDLE ControllerHandle
,
169 IN EFI_HANDLE ChildHandle OPTIONAL
,
171 OUT CHAR16
**ControllerName
175 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
176 SERIAL_DEV
*SerialDevice
;
177 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
178 EFI_GUID
*IoProtocolGuid
;
181 // Make sure this driver is currently managing ControllerHandle
183 IoProtocolGuid
= &gEfiSioProtocolGuid
;
184 Status
= EfiTestManagedDevice (
186 gSerialControllerDriver
.DriverBindingHandle
,
189 if (EFI_ERROR (Status
)) {
190 IoProtocolGuid
= &gEfiPciIoProtocolGuid
;
191 Status
= EfiTestManagedDevice (
193 gSerialControllerDriver
.DriverBindingHandle
,
198 if (EFI_ERROR (Status
)) {
202 ControllerNameTable
= NULL
;
203 if (ChildHandle
!= NULL
) {
204 Status
= EfiTestChildHandle (
209 if (EFI_ERROR (Status
)) {
214 // Get the Serial I/O Protocol from the child handle
216 Status
= gBS
->OpenProtocol (
218 &gEfiSerialIoProtocolGuid
,
220 gSerialControllerDriver
.DriverBindingHandle
,
222 EFI_OPEN_PROTOCOL_GET_PROTOCOL
224 if (EFI_ERROR (Status
)) {
229 // Get the Serial Controller's Device structure
231 SerialDevice
= SERIAL_DEV_FROM_THIS (SerialIo
);
232 ControllerNameTable
= SerialDevice
->ControllerNameTable
;
235 return LookupUnicodeString2 (
237 This
->SupportedLanguages
,
240 (BOOLEAN
)(This
== &gPciSioSerialComponentName
)
245 Add the ISO639-2 and RFC4646 component name both for the Serial IO device
247 @param SerialDevice A pointer to the SERIAL_DEV instance.
248 @param Instance Instance ID for the serial device.
252 IN SERIAL_DEV
*SerialDevice
,
256 CHAR16 SerialPortName
[SERIAL_PORT_NAME_LEN
];
260 sizeof (SerialPortName
),
261 (SerialDevice
->PciDeviceInfo
!= NULL
) ? PCI_SERIAL_PORT_NAME
: SIO_SERIAL_PORT_NAME
,
266 gPciSioSerialComponentName
.SupportedLanguages
,
267 &SerialDevice
->ControllerNameTable
,
273 gPciSioSerialComponentName2
.SupportedLanguages
,
274 &SerialDevice
->ControllerNameTable
,