OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
ComponentName.c
Go to the documentation of this file.
1
9#include "KeyBoard.h"
10
11//
12// EFI Component Name Protocol
13//
14GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName = {
17 "eng"
18};
19
20//
21// EFI Component Name 2 Protocol
22//
23GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2 = {
24 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)UsbKeyboardComponentNameGetDriverName,
25 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)UsbKeyboardComponentNameGetControllerName,
26 "en"
27};
28
29GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTable[] = {
30 { "eng;en", L"Usb Keyboard Driver" },
31 { NULL, NULL }
32};
33
68EFI_STATUS
69EFIAPI
71 IN EFI_COMPONENT_NAME_PROTOCOL *This,
72 IN CHAR8 *Language,
73 OUT CHAR16 **DriverName
74 )
75{
76 return LookupUnicodeString2 (
77 Language,
78 This->SupportedLanguages,
80 DriverName,
81 (BOOLEAN)(This == &gUsbKeyboardComponentName)
82 );
83}
84
143EFI_STATUS
144EFIAPI
146 IN EFI_COMPONENT_NAME_PROTOCOL *This,
147 IN EFI_HANDLE ControllerHandle,
148 IN EFI_HANDLE ChildHandle OPTIONAL,
149 IN CHAR8 *Language,
150 OUT CHAR16 **ControllerName
151 )
152{
153 EFI_STATUS Status;
154 USB_KB_DEV *UsbKbDev;
155 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTxtIn;
156 EFI_USB_IO_PROTOCOL *UsbIoProtocol;
157
158 //
159 // This is a device driver, so ChildHandle must be NULL.
160 //
161 if (ChildHandle != NULL) {
162 return EFI_UNSUPPORTED;
163 }
164
165 //
166 // Check Controller's handle
167 //
168 Status = gBS->OpenProtocol (
169 ControllerHandle,
170 &gEfiUsbIoProtocolGuid,
171 (VOID **)&UsbIoProtocol,
172 gUsbKeyboardDriverBinding.DriverBindingHandle,
173 ControllerHandle,
174 EFI_OPEN_PROTOCOL_BY_DRIVER
175 );
176 if (!EFI_ERROR (Status)) {
177 gBS->CloseProtocol (
178 ControllerHandle,
179 &gEfiUsbIoProtocolGuid,
180 gUsbKeyboardDriverBinding.DriverBindingHandle,
181 ControllerHandle
182 );
183
184 return EFI_UNSUPPORTED;
185 }
186
187 if (Status != EFI_ALREADY_STARTED) {
188 return EFI_UNSUPPORTED;
189 }
190
191 //
192 // Get the device context
193 //
194 Status = gBS->OpenProtocol (
195 ControllerHandle,
196 &gEfiSimpleTextInProtocolGuid,
197 (VOID **)&SimpleTxtIn,
198 gUsbKeyboardDriverBinding.DriverBindingHandle,
199 ControllerHandle,
200 EFI_OPEN_PROTOCOL_GET_PROTOCOL
201 );
202
203 if (EFI_ERROR (Status)) {
204 return Status;
205 }
206
207 UsbKbDev = USB_KB_DEV_FROM_THIS (SimpleTxtIn);
208
209 return LookupUnicodeString2 (
210 Language,
211 This->SupportedLanguages,
212 UsbKbDev->ControllerNameTable,
213 ControllerName,
214 (BOOLEAN)(This == &gUsbKeyboardComponentName)
215 );
216}
EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding
Definition EfiKey.c:20
#define USB_KB_DEV_FROM_THIS(a)
Definition EfiKey.h:171
EFI_BOOT_SERVICES * gBS
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName
EFI_STATUS EFIAPI UsbKeyboardComponentNameGetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTable[]
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2
EFI_STATUS EFIAPI UsbKeyboardComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
EFI_UNICODE_STRING_TABLE * ControllerNameTable
Definition EfiKey.h:125