]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c
Clean up the Isa related DXE in IntelFrameworkMoudlePkg.
[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 #include "Ps2Keyboard.h"
21
22 //
23 // EFI Component Name Functions
24 //
25 EFI_STATUS
26 EFIAPI
27 Ps2KeyboardComponentNameGetDriverName (
28 IN EFI_COMPONENT_NAME_PROTOCOL *This,
29 IN CHAR8 *Language,
30 OUT CHAR16 **DriverName
31 );
32
33 EFI_STATUS
34 EFIAPI
35 Ps2KeyboardComponentNameGetControllerName (
36 IN EFI_COMPONENT_NAME_PROTOCOL *This,
37 IN EFI_HANDLE ControllerHandle,
38 IN EFI_HANDLE ChildHandle OPTIONAL,
39 IN CHAR8 *Language,
40 OUT CHAR16 **ControllerName
41 );
42
43 //
44 // EFI Component Name Protocol
45 //
46 EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName = {
47 Ps2KeyboardComponentNameGetDriverName,
48 Ps2KeyboardComponentNameGetControllerName,
49 "eng"
50 };
51
52 static EFI_UNICODE_STRING_TABLE mPs2KeyboardDriverNameTable[] = {
53 {
54 "eng",
55 L"PS/2 Keyboard Driver"
56 },
57 {
58 NULL,
59 NULL
60 }
61 };
62
63 EFI_STATUS
64 EFIAPI
65 Ps2KeyboardComponentNameGetDriverName (
66 IN EFI_COMPONENT_NAME_PROTOCOL *This,
67 IN CHAR8 *Language,
68 OUT CHAR16 **DriverName
69 )
70 /*++
71
72 Routine Description:
73
74 Retrieves a Unicode string that is the user readable name of the EFI Driver.
75
76 Arguments:
77
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.
87
88 Returns:
89
90 EFI_SUCCESS - The Unicode string for the Driver specified by This
91 and the language specified by Language was returned
92 in DriverName.
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.
97
98 --*/
99 {
100 return LookupUnicodeString (
101 Language,
102 gPs2KeyboardComponentName.SupportedLanguages,
103 mPs2KeyboardDriverNameTable,
104 DriverName
105 );
106 }
107
108 EFI_STATUS
109 EFIAPI
110 Ps2KeyboardComponentNameGetControllerName (
111 IN EFI_COMPONENT_NAME_PROTOCOL *This,
112 IN EFI_HANDLE ControllerHandle,
113 IN EFI_HANDLE ChildHandle OPTIONAL,
114 IN CHAR8 *Language,
115 OUT CHAR16 **ControllerName
116 )
117 /*++
118
119 Routine Description:
120
121 Retrieves a Unicode string that is the user readable name of the controller
122 that is being managed by an EFI Driver.
123
124 Arguments:
125
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
141 driver writer.
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
146 by This.
147
148 Returns:
149
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
159 ChildHandle.
160 EFI_UNSUPPORTED - The driver specified by This does not support the
161 language specified by Language.
162
163 --*/
164 {
165 EFI_STATUS Status;
166 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
167 KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
168 EFI_ISA_IO_PROTOCOL *IsaIoProtocol;
169
170 //
171 // This is a device driver, so ChildHandle must be NULL.
172 //
173 if (ChildHandle != NULL) {
174 return EFI_UNSUPPORTED;
175 }
176 //
177 // Check Controller's handle
178 //
179 Status = gBS->OpenProtocol (
180 ControllerHandle,
181 &gEfiIsaIoProtocolGuid,
182 (VOID **) &IsaIoProtocol,
183 gKeyboardControllerDriver.DriverBindingHandle,
184 ControllerHandle,
185 EFI_OPEN_PROTOCOL_BY_DRIVER
186 );
187
188 if (!EFI_ERROR (Status)) {
189 gBS->CloseProtocol (
190 ControllerHandle,
191 &gEfiIsaIoProtocolGuid,
192 gKeyboardControllerDriver.DriverBindingHandle,
193 ControllerHandle
194 );
195
196 return EFI_UNSUPPORTED;
197 }
198
199 if (Status != EFI_ALREADY_STARTED) {
200 return EFI_UNSUPPORTED;
201 }
202 //
203 // Get the device context
204 //
205 Status = gBS->OpenProtocol (
206 ControllerHandle,
207 &gEfiSimpleTextInProtocolGuid,
208 (VOID **) &ConIn,
209 gKeyboardControllerDriver.DriverBindingHandle,
210 ControllerHandle,
211 EFI_OPEN_PROTOCOL_GET_PROTOCOL
212 );
213 if (EFI_ERROR (Status)) {
214 return Status;
215 }
216
217 ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
218
219 return LookupUnicodeString (
220 Language,
221 gPs2KeyboardComponentName.SupportedLanguages,
222 ConsoleIn->ControllerNameTable,
223 ControllerName
224 );
225 }