]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Bus/Usb/UsbKb/Dxe/ComponentName.c
3e139f9d9a025d047a2327fb3b3ca4fa14c8b5bc
[mirror_edk2.git] / EdkModulePkg / Bus / Usb / UsbKb / Dxe / ComponentName.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 ComponentName.c
15
16 Abstract:
17
18 --*/
19
20 #include "keyboard.h"
21
22 //
23 // EFI Component Name Functions
24 //
25 EFI_STATUS
26 EFIAPI
27 UsbKeyboardComponentNameGetDriverName (
28 IN EFI_COMPONENT_NAME_PROTOCOL *This,
29 IN CHAR8 *Language,
30 OUT CHAR16 **DriverName
31 );
32
33 EFI_STATUS
34 EFIAPI
35 UsbKeyboardComponentNameGetControllerName (
36 IN EFI_COMPONENT_NAME_PROTOCOL *This,
37 IN EFI_HANDLE ControllerHandle,
38 IN EFI_HANDLE ChildHandle OPTIONAL,
39 IN CHAR8 *Language,
40 OUT CHAR16 **ControllerName
41 );
42
43 //
44 // EFI Component Name Protocol
45 //
46 EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName = {
47 UsbKeyboardComponentNameGetDriverName,
48 UsbKeyboardComponentNameGetControllerName,
49 "eng"
50 };
51
52 STATIC EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTable[] = {
53 { "eng", (CHAR16 *) L"Usb Keyboard Driver" },
54 { NULL , NULL }
55 };
56
57
58 EFI_STATUS
59 EFIAPI
60 UsbKeyboardComponentNameGetDriverName (
61 IN EFI_COMPONENT_NAME_PROTOCOL *This,
62 IN CHAR8 *Language,
63 OUT CHAR16 **DriverName
64 )
65 /*++
66
67 Routine Description:
68 Retrieves a Unicode string that is the user readable name of the EFI Driver.
69
70 Arguments:
71 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
72 Language - A pointer to a three character ISO 639-2 language identifier.
73 This is the language of the driver name that that the caller
74 is requesting, and it must match one of the languages specified
75 in SupportedLanguages. The number of languages supported by a
76 driver is up to the driver writer.
77 DriverName - A pointer to the Unicode string to return. This Unicode string
78 is the name of the driver specified by This in the language
79 specified by Language.
80
81 Returns:
82 EFI_SUCCESS - The Unicode string for the Driver specified by This
83 and the language specified by Language was returned
84 in DriverName.
85 EFI_INVALID_PARAMETER - Language is NULL.
86 EFI_INVALID_PARAMETER - DriverName is NULL.
87 EFI_UNSUPPORTED - The driver specified by This does not support the
88 language specified by Language.
89
90 --*/
91 {
92 return LookupUnicodeString (
93 Language,
94 gUsbKeyboardComponentName.SupportedLanguages,
95 mUsbKeyboardDriverNameTable,
96 DriverName
97 );
98 }
99
100 EFI_STATUS
101 EFIAPI
102 UsbKeyboardComponentNameGetControllerName (
103 IN EFI_COMPONENT_NAME_PROTOCOL *This,
104 IN EFI_HANDLE ControllerHandle,
105 IN EFI_HANDLE ChildHandle OPTIONAL,
106 IN CHAR8 *Language,
107 OUT CHAR16 **ControllerName
108 )
109 /*++
110
111 Routine Description:
112 Retrieves a Unicode string that is the user readable name of the controller
113 that is being managed by an EFI Driver.
114
115 Arguments:
116 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
117 ControllerHandle - The handle of a controller that the driver specified by
118 This is managing. This handle specifies the controller
119 whose name is to be returned.
120 ChildHandle - The handle of the child controller to retrieve the name
121 of. This is an optional parameter that may be NULL. It
122 will be NULL for device drivers. It will also be NULL
123 for a bus drivers that wish to retrieve the name of the
124 bus controller. It will not be NULL for a bus driver
125 that wishes to retrieve the name of a child controller.
126 Language - A pointer to a three character ISO 639-2 language
127 identifier. This is the language of the controller name
128 that that the caller is requesting, and it must match one
129 of the languages specified in SupportedLanguages. The
130 number of languages supported by a driver is up to the
131 driver writer.
132 ControllerName - A pointer to the Unicode string to return. This Unicode
133 string is the name of the controller specified by
134 ControllerHandle and ChildHandle in the language specified
135 by Language from the point of view of the driver specified
136 by This.
137
138 Returns:
139 EFI_SUCCESS - The Unicode string for the user readable name in the
140 language specified by Language for the driver
141 specified by This was returned in DriverName.
142 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
143 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
144 EFI_INVALID_PARAMETER - Language is NULL.
145 EFI_INVALID_PARAMETER - ControllerName is NULL.
146 EFI_UNSUPPORTED - The driver specified by This is not currently managing
147 the controller specified by ControllerHandle and
148 ChildHandle.
149 EFI_UNSUPPORTED - The driver specified by This does not support the
150 language specified by Language.
151
152 --*/
153 {
154 EFI_STATUS Status;
155 USB_KB_DEV *UsbKbDev;
156 EFI_SIMPLE_TEXT_IN_PROTOCOL *SimpleTxtIn;
157 EFI_USB_IO_PROTOCOL *UsbIoProtocol;
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 // Get the device context
192 //
193 Status = gBS->OpenProtocol (
194 ControllerHandle,
195 &gEfiSimpleTextInProtocolGuid,
196 (VOID **) &SimpleTxtIn,
197 gUsbKeyboardDriverBinding.DriverBindingHandle,
198 ControllerHandle,
199 EFI_OPEN_PROTOCOL_GET_PROTOCOL
200 );
201
202 if (EFI_ERROR (Status)) {
203 return Status;
204 }
205
206 UsbKbDev = USB_KB_DEV_FROM_THIS (SimpleTxtIn);
207
208 return LookupUnicodeString (
209 Language,
210 gUsbKeyboardComponentName.SupportedLanguages,
211 UsbKbDev->ControllerNameTable,
212 ControllerName
213 );
214
215 }