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