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