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