2 UEFI Component Name and Name2 protocol for Isa serial driver.
4 Copyright (c) 2006 - 2015, 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 gIsaSerialComponentName
= {
15 IsaSerialComponentNameGetDriverName
,
16 IsaSerialComponentNameGetControllerName
,
21 // EFI Component Name 2 Protocol
23 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaSerialComponentName2
= {
24 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) IsaSerialComponentNameGetDriverName
,
25 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) IsaSerialComponentNameGetControllerName
,
30 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaSerialDriverNameTable
[] = {
41 GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 mSerialPortName
[] = L
"ISA Serial Port # ";
44 Retrieves a Unicode string that is the user readable name of the driver.
46 This function retrieves the user readable name of a driver in the form of a
47 Unicode string. If the driver specified by This has a user readable name in
48 the language specified by Language, then a pointer to the driver name is
49 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
50 by This does not support the language specified by Language,
51 then EFI_UNSUPPORTED is returned.
53 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
54 EFI_COMPONENT_NAME_PROTOCOL instance.
56 @param Language[in] A pointer to a Null-terminated ASCII string
57 array indicating the language. This is the
58 language of the driver name that the caller is
59 requesting, and it must match one of the
60 languages specified in SupportedLanguages. The
61 number of languages supported by a driver is up
62 to the driver writer. Language is specified
63 in RFC 4646 or ISO 639-2 language code format.
65 @param DriverName[out] A pointer to the Unicode string to return.
66 This Unicode string is the name of the
67 driver specified by This in the language
68 specified by Language.
70 @retval EFI_SUCCESS The Unicode string for the Driver specified by
71 This and the language specified by Language was
72 returned in DriverName.
74 @retval EFI_INVALID_PARAMETER Language is NULL.
76 @retval EFI_INVALID_PARAMETER DriverName is NULL.
78 @retval EFI_UNSUPPORTED The driver specified by This does not support
79 the language specified by Language.
84 IsaSerialComponentNameGetDriverName (
85 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
87 OUT CHAR16
**DriverName
90 return LookupUnicodeString2 (
92 This
->SupportedLanguages
,
93 mIsaSerialDriverNameTable
,
95 (BOOLEAN
)(This
== &gIsaSerialComponentName
)
100 Retrieves a Unicode string that is the user readable name of the controller
101 that is being managed by a driver.
103 This function retrieves the user readable name of the controller specified by
104 ControllerHandle and ChildHandle in the form of a Unicode string. If the
105 driver specified by This has a user readable name in the language specified by
106 Language, then a pointer to the controller name is returned in ControllerName,
107 and EFI_SUCCESS is returned. If the driver specified by This is not currently
108 managing the controller specified by ControllerHandle and ChildHandle,
109 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
110 support the language specified by Language, then EFI_UNSUPPORTED is returned.
112 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
113 EFI_COMPONENT_NAME_PROTOCOL instance.
115 @param ControllerHandle[in] The handle of a controller that the driver
116 specified by This is managing. This handle
117 specifies the controller whose name is to be
120 @param ChildHandle[in] The handle of the child controller to retrieve
121 the name of. This is an optional parameter that
122 may be NULL. It will be NULL for device
123 drivers. It will also be NULL for a bus drivers
124 that wish to retrieve the name of the bus
125 controller. It will not be NULL for a bus
126 driver that wishes to retrieve the name of a
129 @param Language[in] A pointer to a Null-terminated ASCII string
130 array indicating the language. This is the
131 language of the driver name that the caller is
132 requesting, and it must match one of the
133 languages specified in SupportedLanguages. The
134 number of languages supported by a driver is up
135 to the driver writer. Language is specified in
136 RFC 4646 or ISO 639-2 language code format.
138 @param ControllerName[out] A pointer to the Unicode string to return.
139 This Unicode string is the name of the
140 controller specified by ControllerHandle and
141 ChildHandle in the language specified by
142 Language from the point of view of the driver
145 @retval EFI_SUCCESS The Unicode string for the user readable name in
146 the language specified by Language for the
147 driver specified by This was returned in
150 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
152 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
155 @retval EFI_INVALID_PARAMETER Language is NULL.
157 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
159 @retval EFI_UNSUPPORTED The driver specified by This is not currently
160 managing the controller specified by
161 ControllerHandle and ChildHandle.
163 @retval EFI_UNSUPPORTED The driver specified by This does not support
164 the language specified by Language.
169 IsaSerialComponentNameGetControllerName (
170 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
171 IN EFI_HANDLE ControllerHandle
,
172 IN EFI_HANDLE ChildHandle OPTIONAL
,
174 OUT CHAR16
**ControllerName
178 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
179 SERIAL_DEV
*SerialDevice
;
180 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
183 // Make sure this driver is currently managing ControllerHandle
185 Status
= EfiTestManagedDevice (
187 gSerialControllerDriver
.DriverBindingHandle
,
188 &gEfiIsaIoProtocolGuid
190 if (EFI_ERROR (Status
)) {
194 ControllerNameTable
= NULL
;
195 if (ChildHandle
!= NULL
) {
196 Status
= EfiTestChildHandle (
199 &gEfiIsaIoProtocolGuid
201 if (EFI_ERROR (Status
)) {
206 // Get the Serial I/O Protocol from the child handle
208 Status
= gBS
->OpenProtocol (
210 &gEfiSerialIoProtocolGuid
,
212 gSerialControllerDriver
.DriverBindingHandle
,
214 EFI_OPEN_PROTOCOL_GET_PROTOCOL
216 if (EFI_ERROR (Status
)) {
221 // Get the Serial Controller's Device structure
223 SerialDevice
= SERIAL_DEV_FROM_THIS (SerialIo
);
224 ControllerNameTable
= SerialDevice
->ControllerNameTable
;
227 return LookupUnicodeString2 (
229 This
->SupportedLanguages
,
232 (BOOLEAN
)(This
== &gIsaSerialComponentName
)
237 Add the ISO639-2 and RFC4646 component name both for the Serial IO device
239 @param SerialDevice A pointer to the SERIAL_DEV instance.
241 @param IsaIo A pointer to the EFI_ISA_IO_PROTOCOL instance.
246 IN SERIAL_DEV
*SerialDevice
,
247 IN EFI_ISA_IO_PROTOCOL
*IsaIo
250 mSerialPortName
[(sizeof (mSerialPortName
) / 2) - 2] = (CHAR16
) (L
'0' + (UINT8
) IsaIo
->ResourceList
->Device
.UID
);
253 gIsaSerialComponentName
.SupportedLanguages
,
254 &SerialDevice
->ControllerNameTable
,
260 gIsaSerialComponentName2
.SupportedLanguages
,
261 &SerialDevice
->ControllerNameTable
,