2 UEFI Component Name(2) protocol implementation for USB Mouse Absolute Pointer Driver.
4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "UsbMouseAbsolutePointer.h"
12 // EFI Component Name Protocol
14 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbMouseAbsolutePointerComponentName
= {
15 UsbMouseAbsolutePointerComponentNameGetDriverName
,
16 UsbMouseAbsolutePointerComponentNameGetControllerName
,
21 // EFI Component Name 2 Protocol
23 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbMouseAbsolutePointerComponentName2
= {
24 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)UsbMouseAbsolutePointerComponentNameGetDriverName
,
25 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)UsbMouseAbsolutePointerComponentNameGetControllerName
,
29 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbMouseAbsolutePointerDriverNameTable
[] = {
30 { "eng;en", L
"Usb Mouse Absolute Pointer Driver" },
35 Retrieves a Unicode string that is the user readable name of the driver.
37 This function retrieves the user readable name of a driver in the form of a
38 Unicode string. If the driver specified by This has a user readable name in
39 the language specified by Language, then a pointer to the driver name is
40 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
41 by This does not support the language specified by Language,
42 then EFI_UNSUPPORTED is returned.
44 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
45 EFI_COMPONENT_NAME_PROTOCOL instance.
46 @param Language A pointer to a Null-terminated ASCII string
47 array indicating the language. This is the
48 language of the driver name that the caller is
49 requesting, and it must match one of the
50 languages specified in SupportedLanguages. The
51 number of languages supported by a driver is up
52 to the driver writer. Language is specified
53 in RFC 4646 or ISO 639-2 language code format.
54 @param DriverName A pointer to the Unicode string to return.
55 This Unicode string is the name of the
56 driver specified by This in the language
57 specified by Language.
59 @retval EFI_SUCCESS The Unicode string for the Driver specified by
60 This and the language specified by Language was
61 returned in DriverName.
62 @retval EFI_INVALID_PARAMETER Language is NULL.
63 @retval EFI_INVALID_PARAMETER DriverName is NULL.
64 @retval EFI_UNSUPPORTED The driver specified by This does not support
65 the language specified by Language.
70 UsbMouseAbsolutePointerComponentNameGetDriverName (
71 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
73 OUT CHAR16
**DriverName
76 return LookupUnicodeString2 (
78 This
->SupportedLanguages
,
79 mUsbMouseAbsolutePointerDriverNameTable
,
81 (BOOLEAN
)(This
== &gUsbMouseAbsolutePointerComponentName
)
86 Retrieves a Unicode string that is the user readable name of the controller
87 that is being managed by a driver.
89 This function retrieves the user readable name of the controller specified by
90 ControllerHandle and ChildHandle in the form of a Unicode string. If the
91 driver specified by This has a user readable name in the language specified by
92 Language, then a pointer to the controller name is returned in ControllerName,
93 and EFI_SUCCESS is returned. If the driver specified by This is not currently
94 managing the controller specified by ControllerHandle and ChildHandle,
95 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
96 support the language specified by Language, then EFI_UNSUPPORTED is returned.
98 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
99 EFI_COMPONENT_NAME_PROTOCOL instance.
100 @param ControllerHandle The handle of a controller that the driver
101 specified by This is managing. This handle
102 specifies the controller whose name is to be
104 @param ChildHandle The handle of the child controller to retrieve
105 the name of. This is an optional parameter that
106 may be NULL. It will be NULL for device
107 drivers. It will also be NULL for a bus drivers
108 that wish to retrieve the name of the bus
109 controller. It will not be NULL for a bus
110 driver that wishes to retrieve the name of a
112 @param Language A pointer to a Null-terminated ASCII string
113 array indicating the language. This is the
114 language of the driver name that the caller is
115 requesting, and it must match one of the
116 languages specified in SupportedLanguages. The
117 number of languages supported by a driver is up
118 to the driver writer. Language is specified in
119 RFC 4646 or ISO 639-2 language code format.
120 @param ControllerName A pointer to the Unicode string to return.
121 This Unicode string is the name of the
122 controller specified by ControllerHandle and
123 ChildHandle in the language specified by
124 Language from the point of view of the driver
127 @retval EFI_SUCCESS The Unicode string for the user readable name in
128 the language specified by Language for the
129 driver specified by This was returned in
131 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
132 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
134 @retval EFI_INVALID_PARAMETER Language is NULL.
135 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
136 @retval EFI_UNSUPPORTED The driver specified by This is not currently
137 managing the controller specified by
138 ControllerHandle and ChildHandle.
139 @retval EFI_UNSUPPORTED The driver specified by This does not support
140 the language specified by Language.
145 UsbMouseAbsolutePointerComponentNameGetControllerName (
146 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
147 IN EFI_HANDLE ControllerHandle
,
148 IN EFI_HANDLE ChildHandle OPTIONAL
,
150 OUT CHAR16
**ControllerName
154 USB_MOUSE_ABSOLUTE_POINTER_DEV
*UsbMouseAbsolutePointerDev
;
155 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointerProtocol
;
156 EFI_USB_IO_PROTOCOL
*UsbIoProtocol
;
159 // This is a device driver, so ChildHandle must be NULL.
161 if (ChildHandle
!= NULL
) {
162 return EFI_UNSUPPORTED
;
166 // Check Controller's handle
168 Status
= gBS
->OpenProtocol (
170 &gEfiUsbIoProtocolGuid
,
171 (VOID
**)&UsbIoProtocol
,
172 gUsbMouseAbsolutePointerDriverBinding
.DriverBindingHandle
,
174 EFI_OPEN_PROTOCOL_BY_DRIVER
176 if (!EFI_ERROR (Status
)) {
179 &gEfiUsbIoProtocolGuid
,
180 gUsbMouseAbsolutePointerDriverBinding
.DriverBindingHandle
,
184 return EFI_UNSUPPORTED
;
187 if (Status
!= EFI_ALREADY_STARTED
) {
188 return EFI_UNSUPPORTED
;
192 // Get the device context
194 Status
= gBS
->OpenProtocol (
196 &gEfiAbsolutePointerProtocolGuid
,
197 (VOID
**)&AbsolutePointerProtocol
,
198 gUsbMouseAbsolutePointerDriverBinding
.DriverBindingHandle
,
200 EFI_OPEN_PROTOCOL_GET_PROTOCOL
203 if (EFI_ERROR (Status
)) {
207 UsbMouseAbsolutePointerDev
= USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (AbsolutePointerProtocol
);
209 return LookupUnicodeString2 (
211 This
->SupportedLanguages
,
212 UsbMouseAbsolutePointerDev
->ControllerNameTable
,
214 (BOOLEAN
)(This
== &gUsbMouseAbsolutePointerComponentName
)