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