]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | ComponentName.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | --*/\r | |
19 | \r | |
20 | #include "usbmouse.h"\r | |
21 | \r | |
878ddf1f | 22 | //\r |
23 | // EFI Component Name Protocol\r | |
24 | //\r | |
25 | EFI_COMPONENT_NAME_PROTOCOL gUsbMouseComponentName = {\r | |
26 | UsbMouseComponentNameGetDriverName,\r | |
27 | UsbMouseComponentNameGetControllerName,\r | |
28 | "eng"\r | |
29 | };\r | |
30 | \r | |
31 | STATIC EFI_UNICODE_STRING_TABLE mUsbMouseDriverNameTable[] = {\r | |
32 | { "eng", (CHAR16 *) L"Usb Mouse Driver" },\r | |
33 | { NULL , NULL }\r | |
34 | };\r | |
35 | \r | |
36 | \r | |
37 | EFI_STATUS\r | |
38 | EFIAPI\r | |
39 | UsbMouseComponentNameGetDriverName (\r | |
40 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
41 | IN CHAR8 *Language,\r | |
42 | OUT CHAR16 **DriverName\r | |
43 | )\r | |
44 | /*++\r | |
45 | \r | |
46 | Routine Description:\r | |
47 | Retrieves a Unicode string that is the user readable name of the EFI Driver.\r | |
48 | \r | |
49 | Arguments:\r | |
50 | This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
51 | Language - A pointer to a three character ISO 639-2 language identifier.\r | |
52 | This is the language of the driver name that that the caller \r | |
53 | is requesting, and it must match one of the languages specified\r | |
54 | in SupportedLanguages. The number of languages supported by a \r | |
55 | driver is up to the driver writer.\r | |
56 | DriverName - A pointer to the Unicode string to return. This Unicode string\r | |
57 | is the name of the driver specified by This in the language \r | |
58 | specified by Language.\r | |
59 | \r | |
60 | Returns:\r | |
61 | EFI_SUCCESS - The Unicode string for the Driver specified by This\r | |
62 | and the language specified by Language was returned \r | |
63 | in DriverName.\r | |
64 | EFI_INVALID_PARAMETER - Language is NULL.\r | |
65 | EFI_INVALID_PARAMETER - DriverName is NULL.\r | |
66 | EFI_UNSUPPORTED - The driver specified by This does not support the \r | |
67 | language specified by Language.\r | |
68 | \r | |
69 | --*/\r | |
70 | {\r | |
71 | return LookupUnicodeString (\r | |
72 | Language,\r | |
73 | gUsbMouseComponentName.SupportedLanguages,\r | |
74 | mUsbMouseDriverNameTable,\r | |
75 | DriverName\r | |
76 | );\r | |
77 | }\r | |
78 | \r | |
79 | EFI_STATUS\r | |
80 | EFIAPI\r | |
81 | UsbMouseComponentNameGetControllerName (\r | |
82 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
83 | IN EFI_HANDLE ControllerHandle,\r | |
84 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
85 | IN CHAR8 *Language,\r | |
86 | OUT CHAR16 **ControllerName\r | |
87 | )\r | |
88 | /*++\r | |
89 | \r | |
90 | Routine Description:\r | |
91 | Retrieves a Unicode string that is the user readable name of the controller\r | |
92 | that is being managed by an EFI Driver.\r | |
93 | \r | |
94 | Arguments:\r | |
95 | This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
96 | ControllerHandle - The handle of a controller that the driver specified by \r | |
97 | This is managing. This handle specifies the controller \r | |
98 | whose name is to be returned.\r | |
99 | ChildHandle - The handle of the child controller to retrieve the name \r | |
100 | of. This is an optional parameter that may be NULL. It \r | |
101 | will be NULL for device drivers. It will also be NULL \r | |
102 | for a bus drivers that wish to retrieve the name of the \r | |
103 | bus controller. It will not be NULL for a bus driver \r | |
104 | that wishes to retrieve the name of a child controller.\r | |
105 | Language - A pointer to a three character ISO 639-2 language \r | |
106 | identifier. This is the language of the controller name \r | |
107 | that that the caller is requesting, and it must match one\r | |
108 | of the languages specified in SupportedLanguages. The \r | |
109 | number of languages supported by a driver is up to the \r | |
110 | driver writer.\r | |
111 | ControllerName - A pointer to the Unicode string to return. This Unicode\r | |
112 | string is the name of the controller specified by \r | |
113 | ControllerHandle and ChildHandle in the language specified\r | |
114 | by Language from the point of view of the driver specified\r | |
115 | by This. \r | |
116 | \r | |
117 | Returns:\r | |
118 | EFI_SUCCESS - The Unicode string for the user readable name in the \r | |
119 | language specified by Language for the driver \r | |
120 | specified by This was returned in DriverName.\r | |
121 | EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r | |
122 | EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r | |
123 | EFI_INVALID_PARAMETER - Language is NULL.\r | |
124 | EFI_INVALID_PARAMETER - ControllerName is NULL.\r | |
125 | EFI_UNSUPPORTED - The driver specified by This is not currently managing \r | |
126 | the controller specified by ControllerHandle and \r | |
127 | ChildHandle.\r | |
128 | EFI_UNSUPPORTED - The driver specified by This does not support the \r | |
129 | language specified by Language.\r | |
130 | \r | |
131 | --*/\r | |
132 | {\r | |
133 | EFI_STATUS Status;\r | |
134 | USB_MOUSE_DEV *UsbMouseDev;\r | |
135 | EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;\r | |
136 | EFI_USB_IO_PROTOCOL *UsbIoProtocol;\r | |
137 | \r | |
138 | //\r | |
139 | // This is a device driver, so ChildHandle must be NULL.\r | |
140 | //\r | |
141 | if (ChildHandle != NULL) {\r | |
142 | return EFI_UNSUPPORTED;\r | |
143 | }\r | |
144 | \r | |
145 | //\r | |
146 | // Check Controller's handle\r | |
147 | //\r | |
148 | Status = gBS->OpenProtocol (\r | |
149 | ControllerHandle,\r | |
150 | &gEfiUsbIoProtocolGuid,\r | |
151 | (VOID **) &UsbIoProtocol,\r | |
152 | gUsbMouseDriverBinding.DriverBindingHandle,\r | |
153 | ControllerHandle,\r | |
154 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
155 | );\r | |
156 | if (!EFI_ERROR (Status)) {\r | |
157 | gBS->CloseProtocol (\r | |
158 | ControllerHandle,\r | |
159 | &gEfiUsbIoProtocolGuid,\r | |
160 | gUsbMouseDriverBinding.DriverBindingHandle,\r | |
161 | ControllerHandle\r | |
162 | );\r | |
163 | \r | |
164 | return EFI_UNSUPPORTED;\r | |
165 | }\r | |
166 | \r | |
167 | if (Status != EFI_ALREADY_STARTED) {\r | |
168 | return EFI_UNSUPPORTED;\r | |
169 | }\r | |
170 | //\r | |
171 | // Get the device context\r | |
172 | //\r | |
173 | Status = gBS->OpenProtocol (\r | |
174 | ControllerHandle,\r | |
175 | &gEfiSimplePointerProtocolGuid,\r | |
176 | (VOID **) &SimplePointerProtocol,\r | |
177 | gUsbMouseDriverBinding.DriverBindingHandle,\r | |
178 | ControllerHandle,\r | |
179 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
180 | );\r | |
181 | \r | |
182 | if (EFI_ERROR (Status)) {\r | |
183 | return Status;\r | |
184 | }\r | |
185 | \r | |
186 | UsbMouseDev = USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (SimplePointerProtocol);\r | |
187 | \r | |
188 | return LookupUnicodeString (\r | |
189 | Language,\r | |
190 | gUsbMouseComponentName.SupportedLanguages,\r | |
191 | UsbMouseDev->ControllerNameTable,\r | |
192 | ControllerName\r | |
193 | );\r | |
194 | \r | |
195 | }\r |