3 Copyright (c) 2006 - 2007, 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.
20 #include "Ps2Keyboard.h"
23 // EFI Component Name Functions
27 Ps2KeyboardComponentNameGetDriverName (
28 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
30 OUT CHAR16
**DriverName
35 Ps2KeyboardComponentNameGetControllerName (
36 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
37 IN EFI_HANDLE ControllerHandle
,
38 IN EFI_HANDLE ChildHandle OPTIONAL
,
40 OUT CHAR16
**ControllerName
44 // EFI Component Name Protocol
46 EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName
= {
47 Ps2KeyboardComponentNameGetDriverName
,
48 Ps2KeyboardComponentNameGetControllerName
,
52 static EFI_UNICODE_STRING_TABLE mPs2KeyboardDriverNameTable
[] = {
55 L
"PS/2 Keyboard Driver"
65 Ps2KeyboardComponentNameGetDriverName (
66 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
68 OUT CHAR16
**DriverName
74 Retrieves a Unicode string that is the user readable name of the EFI Driver.
78 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
79 Language - A pointer to a three character ISO 639-2 language identifier.
80 This is the language of the driver name that that the caller
81 is requesting, and it must match one of the languages specified
82 in SupportedLanguages. The number of languages supported by a
83 driver is up to the driver writer.
84 DriverName - A pointer to the Unicode string to return. This Unicode string
85 is the name of the driver specified by This in the language
86 specified by Language.
90 EFI_SUCCESS - The Unicode string for the Driver specified by This
91 and the language specified by Language was returned
93 EFI_INVALID_PARAMETER - Language is NULL.
94 EFI_INVALID_PARAMETER - DriverName is NULL.
95 EFI_UNSUPPORTED - The driver specified by This does not support the
96 language specified by Language.
100 return LookupUnicodeString (
102 gPs2KeyboardComponentName
.SupportedLanguages
,
103 mPs2KeyboardDriverNameTable
,
110 Ps2KeyboardComponentNameGetControllerName (
111 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
112 IN EFI_HANDLE ControllerHandle
,
113 IN EFI_HANDLE ChildHandle OPTIONAL
,
115 OUT CHAR16
**ControllerName
121 Retrieves a Unicode string that is the user readable name of the controller
122 that is being managed by an EFI Driver.
126 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
127 ControllerHandle - The handle of a controller that the driver specified by
128 This is managing. This handle specifies the controller
129 whose name is to be returned.
130 ChildHandle - The handle of the child controller to retrieve the name
131 of. This is an optional parameter that may be NULL. It
132 will be NULL for device drivers. It will also be NULL
133 for a bus drivers that wish to retrieve the name of the
134 bus controller. It will not be NULL for a bus driver
135 that wishes to retrieve the name of a child controller.
136 Language - A pointer to a three character ISO 639-2 language
137 identifier. This is the language of the controller name
138 that that the caller is requesting, and it must match one
139 of the languages specified in SupportedLanguages. The
140 number of languages supported by a driver is up to the
142 ControllerName - A pointer to the Unicode string to return. This Unicode
143 string is the name of the controller specified by
144 ControllerHandle and ChildHandle in the language specified
145 by Language from the point of view of the driver specified
150 EFI_SUCCESS - The Unicode string for the user readable name in the
151 language specified by Language for the driver
152 specified by This was returned in DriverName.
153 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
154 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
155 EFI_INVALID_PARAMETER - Language is NULL.
156 EFI_INVALID_PARAMETER - ControllerName is NULL.
157 EFI_UNSUPPORTED - The driver specified by This is not currently managing
158 the controller specified by ControllerHandle and
160 EFI_UNSUPPORTED - The driver specified by This does not support the
161 language specified by Language.
166 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*ConIn
;
167 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
168 EFI_ISA_IO_PROTOCOL
*IsaIoProtocol
;
171 // This is a device driver, so ChildHandle must be NULL.
173 if (ChildHandle
!= NULL
) {
174 return EFI_UNSUPPORTED
;
177 // Check Controller's handle
179 Status
= gBS
->OpenProtocol (
181 &gEfiIsaIoProtocolGuid
,
182 (VOID
**) &IsaIoProtocol
,
183 gKeyboardControllerDriver
.DriverBindingHandle
,
185 EFI_OPEN_PROTOCOL_BY_DRIVER
187 if (!EFI_ERROR (Status
)) {
190 &gEfiIsaIoProtocolGuid
,
191 gKeyboardControllerDriver
.DriverBindingHandle
,
195 return EFI_UNSUPPORTED
;
198 if (Status
!= EFI_ALREADY_STARTED
) {
199 return EFI_UNSUPPORTED
;
202 // Get the device context
204 Status
= gBS
->OpenProtocol (
206 &gEfiSimpleTextInProtocolGuid
,
208 gKeyboardControllerDriver
.DriverBindingHandle
,
210 EFI_OPEN_PROTOCOL_GET_PROTOCOL
212 if (EFI_ERROR (Status
)) {
216 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn
);
218 return LookupUnicodeString (
220 gPs2KeyboardComponentName
.SupportedLanguages
,
221 ConsoleIn
->ControllerNameTable
,