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