]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | UEFI Component Name(2) protocol implementation for EHCI driver.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions\r | |
8 | of the BSD License which accompanies this distribution. The\r | |
9 | full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #include "Ehci.h"\r | |
18 | \r | |
19 | \r | |
20 | //\r | |
21 | // EFI Component Name Protocol\r | |
22 | //\r | |
23 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName = {\r | |
24 | EhciComponentNameGetDriverName,\r | |
25 | EhciComponentNameGetControllerName,\r | |
26 | "eng"\r | |
27 | };\r | |
28 | \r | |
29 | //\r | |
30 | // EFI Component Name 2 Protocol\r | |
31 | //\r | |
32 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2 = {\r | |
33 | (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EhciComponentNameGetDriverName,\r | |
34 | (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EhciComponentNameGetControllerName,\r | |
35 | "en"\r | |
36 | };\r | |
37 | \r | |
38 | \r | |
39 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEhciDriverNameTable[] = {\r | |
40 | { "eng;en", L"Usb Ehci Driver" },\r | |
41 | { NULL , NULL }\r | |
42 | };\r | |
43 | \r | |
44 | \r | |
45 | /**\r | |
46 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
47 | \r | |
48 | This function retrieves the user readable name of a driver in the form of a\r | |
49 | Unicode string. If the driver specified by This has a user readable name in\r | |
50 | the language specified by Language, then a pointer to the driver name is\r | |
51 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
52 | by This does not support the language specified by Language,\r | |
53 | then EFI_UNSUPPORTED is returned.\r | |
54 | \r | |
55 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
56 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
57 | \r | |
58 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
59 | array indicating the language. This is the\r | |
60 | language of the driver name that the caller is\r | |
61 | requesting, and it must match one of the\r | |
62 | languages specified in SupportedLanguages. The\r | |
63 | number of languages supported by a driver is up\r | |
64 | to the driver writer. Language is specified\r | |
65 | in RFC 4646 or ISO 639-2 language code format.\r | |
66 | \r | |
67 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
68 | This Unicode string is the name of the\r | |
69 | driver specified by This in the language\r | |
70 | specified by Language.\r | |
71 | \r | |
72 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
73 | This and the language specified by Language was\r | |
74 | returned in DriverName.\r | |
75 | \r | |
76 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
77 | \r | |
78 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
79 | \r | |
80 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
81 | the language specified by Language.\r | |
82 | \r | |
83 | **/\r | |
84 | EFI_STATUS\r | |
85 | EFIAPI\r | |
86 | EhciComponentNameGetDriverName (\r | |
87 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
88 | IN CHAR8 *Language,\r | |
89 | OUT CHAR16 **DriverName\r | |
90 | )\r | |
91 | {\r | |
92 | return LookupUnicodeString2 (\r | |
93 | Language,\r | |
94 | This->SupportedLanguages,\r | |
95 | mEhciDriverNameTable,\r | |
96 | DriverName,\r | |
97 | (BOOLEAN)(This == &gEhciComponentName)\r | |
98 | );\r | |
99 | }\r | |
100 | \r | |
101 | /**\r | |
102 | Retrieves a Unicode string that is the user readable name of the controller\r | |
103 | that is being managed by a driver.\r | |
104 | \r | |
105 | This function retrieves the user readable name of the controller specified by\r | |
106 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
107 | driver specified by This has a user readable name in the language specified by\r | |
108 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
109 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
110 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
111 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
112 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
113 | \r | |
114 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
115 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
116 | \r | |
117 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
118 | specified by This is managing. This handle\r | |
119 | specifies the controller whose name is to be\r | |
120 | returned.\r | |
121 | \r | |
122 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
123 | the name of. This is an optional parameter that\r | |
124 | may be NULL. It will be NULL for device\r | |
125 | drivers. It will also be NULL for a bus drivers\r | |
126 | that wish to retrieve the name of the bus\r | |
127 | controller. It will not be NULL for a bus\r | |
128 | driver that wishes to retrieve the name of a\r | |
129 | child controller.\r | |
130 | \r | |
131 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
132 | array indicating the language. This is the\r | |
133 | language of the driver name that the caller is\r | |
134 | requesting, and it must match one of the\r | |
135 | languages specified in SupportedLanguages. The\r | |
136 | number of languages supported by a driver is up\r | |
137 | to the driver writer. Language is specified in\r | |
138 | RFC 4646 or ISO 639-2 language code format.\r | |
139 | \r | |
140 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
141 | This Unicode string is the name of the\r | |
142 | controller specified by ControllerHandle and\r | |
143 | ChildHandle in the language specified by\r | |
144 | Language from the point of view of the driver\r | |
145 | specified by This.\r | |
146 | \r | |
147 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
148 | the language specified by Language for the\r | |
149 | driver specified by This was returned in\r | |
150 | DriverName.\r | |
151 | \r | |
152 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
153 | \r | |
154 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
155 | EFI_HANDLE.\r | |
156 | \r | |
157 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
158 | \r | |
159 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
160 | \r | |
161 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
162 | managing the controller specified by\r | |
163 | ControllerHandle and ChildHandle.\r | |
164 | \r | |
165 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
166 | the language specified by Language.\r | |
167 | \r | |
168 | **/\r | |
169 | EFI_STATUS\r | |
170 | EFIAPI\r | |
171 | EhciComponentNameGetControllerName (\r | |
172 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
173 | IN EFI_HANDLE ControllerHandle,\r | |
174 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
175 | IN CHAR8 *Language,\r | |
176 | OUT CHAR16 **ControllerName\r | |
177 | )\r | |
178 | {\r | |
179 | EFI_STATUS Status;\r | |
180 | USB2_HC_DEV *EhciDev;\r | |
181 | EFI_USB2_HC_PROTOCOL *Usb2Hc;\r | |
182 | \r | |
183 | //\r | |
184 | // This is a device driver, so ChildHandle must be NULL.\r | |
185 | //\r | |
186 | if (ChildHandle != NULL) {\r | |
187 | return EFI_UNSUPPORTED;\r | |
188 | }\r | |
189 | //\r | |
190 | // Make sure this driver is currently managing ControllerHandle\r | |
191 | //\r | |
192 | Status = EfiTestManagedDevice (\r | |
193 | ControllerHandle,\r | |
194 | gEhciDriverBinding.DriverBindingHandle,\r | |
195 | &gEfiPciIoProtocolGuid\r | |
196 | );\r | |
197 | if (EFI_ERROR (Status)) {\r | |
198 | return Status;\r | |
199 | }\r | |
200 | //\r | |
201 | // Get the device context\r | |
202 | //\r | |
203 | Status = gBS->OpenProtocol (\r | |
204 | ControllerHandle,\r | |
205 | &gEfiUsb2HcProtocolGuid,\r | |
206 | (VOID **) &Usb2Hc,\r | |
207 | gEhciDriverBinding.DriverBindingHandle,\r | |
208 | ControllerHandle,\r | |
209 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
210 | );\r | |
211 | if (EFI_ERROR (Status)) {\r | |
212 | return Status;\r | |
213 | }\r | |
214 | \r | |
215 | EhciDev = EHC_FROM_THIS (Usb2Hc);\r | |
216 | \r | |
217 | return LookupUnicodeString2 (\r | |
218 | Language,\r | |
219 | This->SupportedLanguages,\r | |
220 | EhciDev->ControllerNameTable,\r | |
221 | ControllerName,\r | |
222 | (BOOLEAN)(This == &gEhciComponentName)\r | |
223 | );\r | |
224 | \r | |
225 | }\r |