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