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