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