3 Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR>
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
24 // EFI Component Name Protocol
26 EFI_COMPONENT_NAME_PROTOCOL gIsaSerialComponentName
= {
27 IsaSerialComponentNameGetDriverName
,
28 IsaSerialComponentNameGetControllerName
,
32 STATIC EFI_UNICODE_STRING_TABLE mIsaSerialDriverNameTable
[] = {
45 IsaSerialComponentNameGetDriverName (
46 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
48 OUT CHAR16
**DriverName
54 Retrieves a Unicode string that is the user readable name of the EFI Driver.
58 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
59 Language - A pointer to a three character ISO 639-2 language identifier.
60 This is the language of the driver name that that the caller
61 is requesting, and it must match one of the languages specified
62 in SupportedLanguages. The number of languages supported by a
63 driver is up to the driver writer.
64 DriverName - A pointer to the Unicode string to return. This Unicode string
65 is the name of the driver specified by This in the language
66 specified by Language.
70 EFI_SUCCESS - The Unicode string for the Driver specified by This
71 and the language specified by Language was returned
73 EFI_INVALID_PARAMETER - Language is NULL.
74 EFI_INVALID_PARAMETER - DriverName is NULL.
75 EFI_UNSUPPORTED - The driver specified by This does not support the
76 language specified by Language.
80 return LookupUnicodeString (
82 gIsaSerialComponentName
.SupportedLanguages
,
83 mIsaSerialDriverNameTable
,
90 IsaSerialComponentNameGetControllerName (
91 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
92 IN EFI_HANDLE ControllerHandle
,
93 IN EFI_HANDLE ChildHandle OPTIONAL
,
95 OUT CHAR16
**ControllerName
101 Retrieves a Unicode string that is the user readable name of the controller
102 that is being managed by an EFI Driver.
106 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
107 ControllerHandle - The handle of a controller that the driver specified by
108 This is managing. This handle specifies the controller
109 whose name is to be returned.
110 ChildHandle - The handle of the child controller to retrieve the name
111 of. This is an optional parameter that may be NULL. It
112 will be NULL for device drivers. It will also be NULL
113 for a bus drivers that wish to retrieve the name of the
114 bus controller. It will not be NULL for a bus driver
115 that wishes to retrieve the name of a child controller.
116 Language - A pointer to a three character ISO 639-2 language
117 identifier. This is the language of the controller name
118 that that the caller is requesting, and it must match one
119 of the languages specified in SupportedLanguages. The
120 number of languages supported by a driver is up to the
122 ControllerName - A pointer to the Unicode string to return. This Unicode
123 string is the name of the controller specified by
124 ControllerHandle and ChildHandle in the language
125 specified by Language from the point of view of the
126 driver specified by This.
130 EFI_SUCCESS - The Unicode string for the user readable name in the
131 language specified by Language for the driver
132 specified by This was returned in DriverName.
133 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
134 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
136 EFI_INVALID_PARAMETER - Language is NULL.
137 EFI_INVALID_PARAMETER - ControllerName is NULL.
138 EFI_UNSUPPORTED - The driver specified by This is not currently
139 managing the controller specified by
140 ControllerHandle and ChildHandle.
141 EFI_UNSUPPORTED - The driver specified by This does not support the
142 language specified by Language.
147 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
148 SERIAL_DEV
*SerialDevice
;
151 // This is a device driver, so ChildHandle must be NULL.
153 if (ChildHandle
!= NULL
) {
154 return EFI_UNSUPPORTED
;
157 // Make sure this driver is currently managing ControllerHandle
159 Status
= EfiTestManagedDevice (
161 gSerialControllerDriver
.DriverBindingHandle
,
162 &gEfiIsaIoProtocolGuid
164 if (EFI_ERROR (Status
)) {
168 // Get the Block I/O Protocol on Controller
170 Status
= gBS
->OpenProtocol (
172 &gEfiSerialIoProtocolGuid
,
174 gSerialControllerDriver
.DriverBindingHandle
,
176 EFI_OPEN_PROTOCOL_GET_PROTOCOL
178 if (EFI_ERROR (Status
)) {
182 // Get the Serial Controller's Device structure
184 SerialDevice
= SERIAL_DEV_FROM_THIS (SerialIo
);
186 return LookupUnicodeString (
188 gIsaSerialComponentName
.SupportedLanguages
,
189 SerialDevice
->ControllerNameTable
,
196 IN SERIAL_DEV
*SerialDevice
,
197 IN EFI_ISA_IO_PROTOCOL
*IsaIo
203 Add the component name for the serial io device
207 SerialDevice - A pointer to the SERIAL_DEV instance.
208 IsaIo - A pointer to the EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL instance.
216 CHAR16 SerialPortName
[sizeof (SERIAL_PORT_NAME
)];
218 StrCpy (SerialPortName
, L
"ISA Serial Port # ");
219 SerialPortName
[sizeof (SERIAL_PORT_NAME
) - 2] = (CHAR16
) (L
'0' + (UINT8
) IsaIo
->ResourceList
->Device
.UID
);
222 gIsaSerialComponentName
.SupportedLanguages
,
223 &SerialDevice
->ControllerNameTable
,
224 (CHAR16
*) SerialPortName