Update to BSD license header.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2KeyboardDxe / ComponentName.c
1 /*++
2
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
8
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.
11
12 Module Name:
13
14 ComponentName.c
15
16 Abstract:
17
18 --*/
19
20 //
21 // Include common header file for this module.
22 //
23 #include "CommonHeader.h"
24
25 #include "Ps2Keyboard.h"
26
27 //
28 // EFI Component Name Functions
29 //
30 EFI_STATUS
31 EFIAPI
32 Ps2KeyboardComponentNameGetDriverName (
33 IN EFI_COMPONENT_NAME_PROTOCOL *This,
34 IN CHAR8 *Language,
35 OUT CHAR16 **DriverName
36 );
37
38 EFI_STATUS
39 EFIAPI
40 Ps2KeyboardComponentNameGetControllerName (
41 IN EFI_COMPONENT_NAME_PROTOCOL *This,
42 IN EFI_HANDLE ControllerHandle,
43 IN EFI_HANDLE ChildHandle OPTIONAL,
44 IN CHAR8 *Language,
45 OUT CHAR16 **ControllerName
46 );
47
48 //
49 // EFI Component Name Protocol
50 //
51 EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName = {
52 Ps2KeyboardComponentNameGetDriverName,
53 Ps2KeyboardComponentNameGetControllerName,
54 "eng"
55 };
56
57 static EFI_UNICODE_STRING_TABLE mPs2KeyboardDriverNameTable[] = {
58 {
59 "eng",
60 L"PS/2 Keyboard Driver"
61 },
62 {
63 NULL,
64 NULL
65 }
66 };
67
68 EFI_STATUS
69 EFIAPI
70 Ps2KeyboardComponentNameGetDriverName (
71 IN EFI_COMPONENT_NAME_PROTOCOL *This,
72 IN CHAR8 *Language,
73 OUT CHAR16 **DriverName
74 )
75 /*++
76
77 Routine Description:
78
79 Retrieves a Unicode string that is the user readable name of the EFI Driver.
80
81 Arguments:
82
83 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
84 Language - A pointer to a three character ISO 639-2 language identifier.
85 This is the language of the driver name that that the caller
86 is requesting, and it must match one of the languages specified
87 in SupportedLanguages. The number of languages supported by a
88 driver is up to the driver writer.
89 DriverName - A pointer to the Unicode string to return. This Unicode string
90 is the name of the driver specified by This in the language
91 specified by Language.
92
93 Returns:
94
95 EFI_SUCCESS - The Unicode string for the Driver specified by This
96 and the language specified by Language was returned
97 in DriverName.
98 EFI_INVALID_PARAMETER - Language is NULL.
99 EFI_INVALID_PARAMETER - DriverName is NULL.
100 EFI_UNSUPPORTED - The driver specified by This does not support the
101 language specified by Language.
102
103 --*/
104 {
105 return LookupUnicodeString (
106 Language,
107 gPs2KeyboardComponentName.SupportedLanguages,
108 mPs2KeyboardDriverNameTable,
109 DriverName
110 );
111 }
112
113 EFI_STATUS
114 EFIAPI
115 Ps2KeyboardComponentNameGetControllerName (
116 IN EFI_COMPONENT_NAME_PROTOCOL *This,
117 IN EFI_HANDLE ControllerHandle,
118 IN EFI_HANDLE ChildHandle OPTIONAL,
119 IN CHAR8 *Language,
120 OUT CHAR16 **ControllerName
121 )
122 /*++
123
124 Routine Description:
125
126 Retrieves a Unicode string that is the user readable name of the controller
127 that is being managed by an EFI Driver.
128
129 Arguments:
130
131 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
132 ControllerHandle - The handle of a controller that the driver specified by
133 This is managing. This handle specifies the controller
134 whose name is to be returned.
135 ChildHandle - The handle of the child controller to retrieve the name
136 of. This is an optional parameter that may be NULL. It
137 will be NULL for device drivers. It will also be NULL
138 for a bus drivers that wish to retrieve the name of the
139 bus controller. It will not be NULL for a bus driver
140 that wishes to retrieve the name of a child controller.
141 Language - A pointer to a three character ISO 639-2 language
142 identifier. This is the language of the controller name
143 that that the caller is requesting, and it must match one
144 of the languages specified in SupportedLanguages. The
145 number of languages supported by a driver is up to the
146 driver writer.
147 ControllerName - A pointer to the Unicode string to return. This Unicode
148 string is the name of the controller specified by
149 ControllerHandle and ChildHandle in the language specified
150 by Language from the point of view of the driver specified
151 by This.
152
153 Returns:
154
155 EFI_SUCCESS - The Unicode string for the user readable name in the
156 language specified by Language for the driver
157 specified by This was returned in DriverName.
158 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
159 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
160 EFI_INVALID_PARAMETER - Language is NULL.
161 EFI_INVALID_PARAMETER - ControllerName is NULL.
162 EFI_UNSUPPORTED - The driver specified by This is not currently managing
163 the controller specified by ControllerHandle and
164 ChildHandle.
165 EFI_UNSUPPORTED - The driver specified by This does not support the
166 language specified by Language.
167
168 --*/
169 {
170 EFI_STATUS Status;
171 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
172 KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
173 EFI_ISA_IO_PROTOCOL *IsaIoProtocol;
174
175 //
176 // This is a device driver, so ChildHandle must be NULL.
177 //
178 if (ChildHandle != NULL) {
179 return EFI_UNSUPPORTED;
180 }
181 //
182 // Check Controller's handle
183 //
184 Status = gBS->OpenProtocol (
185 ControllerHandle,
186 &gEfiIsaIoProtocolGuid,
187 (VOID **) &IsaIoProtocol,
188 gKeyboardControllerDriver.DriverBindingHandle,
189 ControllerHandle,
190 EFI_OPEN_PROTOCOL_BY_DRIVER
191 );
192 if (!EFI_ERROR (Status)) {
193 gBS->CloseProtocol (
194 ControllerHandle,
195 &gEfiIsaIoProtocolGuid,
196 gKeyboardControllerDriver.DriverBindingHandle,
197 ControllerHandle
198 );
199
200 return EFI_UNSUPPORTED;
201 }
202
203 if (Status != EFI_ALREADY_STARTED) {
204 return EFI_UNSUPPORTED;
205 }
206 //
207 // Get the device context
208 //
209 Status = gBS->OpenProtocol (
210 ControllerHandle,
211 &gEfiSimpleTextInProtocolGuid,
212 (VOID **) &ConIn,
213 gKeyboardControllerDriver.DriverBindingHandle,
214 ControllerHandle,
215 EFI_OPEN_PROTOCOL_GET_PROTOCOL
216 );
217 if (EFI_ERROR (Status)) {
218 return Status;
219 }
220
221 ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
222
223 return LookupUnicodeString (
224 Language,
225 gPs2KeyboardComponentName.SupportedLanguages,
226 ConsoleIn->ControllerNameTable,
227 ControllerName
228 );
229 }