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