3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
23 // EFI Component Name Protocol
25 EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName
= {
26 TerminalComponentNameGetDriverName
,
27 TerminalComponentNameGetControllerName
,
31 static EFI_UNICODE_STRING_TABLE mTerminalDriverNameTable
[] = {
34 (CHAR16
*) L
"Serial Terminal Driver"
44 TerminalComponentNameGetDriverName (
45 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
47 OUT CHAR16
**DriverName
52 Retrieves a Unicode string that is the user readable name of the EFI Driver.
55 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
56 Language - A pointer to a three character ISO 639-2 language identifier.
57 This is the language of the driver name that that the caller
58 is requesting, and it must match one of the languages specified
59 in SupportedLanguages. The number of languages supported by a
60 driver is up to the driver writer.
61 DriverName - A pointer to the Unicode string to return. This Unicode string
62 is the name of the driver specified by This in the language
63 specified by Language.
66 EFI_SUCCESS - The Unicode string for the Driver specified by This
67 and the language specified by Language was returned
69 EFI_INVALID_PARAMETER - Language is NULL.
70 EFI_INVALID_PARAMETER - DriverName is NULL.
71 EFI_UNSUPPORTED - The driver specified by This does not support the
72 language specified by Language.
76 return LookupUnicodeString (
78 gTerminalComponentName
.SupportedLanguages
,
79 mTerminalDriverNameTable
,
86 TerminalComponentNameGetControllerName (
87 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
88 IN EFI_HANDLE ControllerHandle
,
89 IN EFI_HANDLE ChildHandle OPTIONAL
,
91 OUT CHAR16
**ControllerName
96 Retrieves a Unicode string that is the user readable name of the controller
97 that is being managed by an EFI Driver.
100 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
101 ControllerHandle - The handle of a controller that the driver specified by
102 This is managing. This handle specifies the controller
103 whose name is to be returned.
104 ChildHandle - The handle of the child controller to retrieve the name
105 of. This is an optional parameter that may be NULL. It
106 will be NULL for device drivers. It will also be NULL
107 for a bus drivers that wish to retrieve the name of the
108 bus controller. It will not be NULL for a bus driver
109 that wishes to retrieve the name of a child controller.
110 Language - A pointer to a three character ISO 639-2 language
111 identifier. This is the language of the controller name
112 that that the caller is requesting, and it must match one
113 of the languages specified in SupportedLanguages. The
114 number of languages supported by a driver is up to the
116 ControllerName - A pointer to the Unicode string to return. This Unicode
117 string is the name of the controller specified by
118 ControllerHandle and ChildHandle in the language
119 specified by Language from the point of view of the
120 driver specified by This.
123 EFI_SUCCESS - The Unicode string for the user readable name in the
124 language specified by Language for the driver
125 specified by This was returned in DriverName.
126 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
127 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
129 EFI_INVALID_PARAMETER - Language is NULL.
130 EFI_INVALID_PARAMETER - ControllerName is NULL.
131 EFI_UNSUPPORTED - The driver specified by This is not currently
132 managing the controller specified by
133 ControllerHandle and ChildHandle.
134 EFI_UNSUPPORTED - The driver specified by This does not support the
135 language specified by Language.
140 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*SimpleTextOutput
;
141 TERMINAL_DEV
*TerminalDevice
;
144 // Make sure this driver is currently managing ControllHandle
146 Status
= EfiTestManagedDevice (
148 gTerminalDriverBinding
.DriverBindingHandle
,
149 &gEfiSerialIoProtocolGuid
151 if (EFI_ERROR (Status
)) {
156 // This is a bus driver, so ChildHandle can not be NULL.
158 if (ChildHandle
== NULL
) {
159 return EFI_UNSUPPORTED
;
162 Status
= EfiTestChildHandle (
165 &gEfiSerialIoProtocolGuid
167 if (EFI_ERROR (Status
)) {
172 // Get our context back
174 Status
= gBS
->OpenProtocol (
176 &gEfiSimpleTextOutProtocolGuid
,
177 (VOID
**) &SimpleTextOutput
,
178 gTerminalDriverBinding
.DriverBindingHandle
,
180 EFI_OPEN_PROTOCOL_GET_PROTOCOL
182 if (EFI_ERROR (Status
)) {
183 return EFI_UNSUPPORTED
;
186 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (SimpleTextOutput
);
188 return LookupUnicodeString (
190 gTerminalComponentName
.SupportedLanguages
,
191 TerminalDevice
->ControllerNameTable
,