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