]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/XhciDxe/ComponentName.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / XhciDxe / ComponentName.c
CommitLineData
92870c98 1/** @file\r
2 UEFI Component Name(2) protocol implementation for XHCI driver.\r
3\r
4Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
5\r
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
92870c98 7\r
8**/\r
9\r
10#include "Xhci.h"\r
11\r
12//\r
13// EFI Component Name Protocol\r
14//\r
15GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gXhciComponentName = {\r
16 XhciComponentNameGetDriverName,\r
17 XhciComponentNameGetControllerName,\r
18 "eng"\r
19};\r
20\r
21//\r
22// EFI Component Name 2 Protocol\r
23//\r
24GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gXhciComponentName2 = {\r
25 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) XhciComponentNameGetDriverName,\r
26 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) XhciComponentNameGetControllerName,\r
27 "en"\r
28};\r
29\r
30GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mXhciDriverNameTable[] = {\r
31 { "eng;en", L"Usb Xhci Driver" },\r
32 { NULL , NULL }\r
33};\r
34\r
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
55 in RFC 4646 or ISO 639-2 language code format.\r
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
74EFI_STATUS\r
75EFIAPI\r
76XhciComponentNameGetDriverName (\r
77 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
78 IN CHAR8 *Language,\r
79 OUT CHAR16 **DriverName\r
80 )\r
81{\r
82 return LookupUnicodeString2 (\r
83 Language,\r
84 This->SupportedLanguages,\r
85 mXhciDriverNameTable,\r
86 DriverName,\r
87 (BOOLEAN)(This == &gXhciComponentName)\r
88 );\r
89}\r
90\r
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
128 RFC 4646 or ISO 639-2 language code format.\r
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
142 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
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
159EFI_STATUS\r
160EFIAPI\r
161XhciComponentNameGetControllerName (\r
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
167 )\r
168{\r
169 EFI_STATUS Status;\r
170 EFI_USB2_HC_PROTOCOL *Usb2Hc;\r
a9292c13 171 USB_XHCI_INSTANCE *XhciDev;\r
92870c98 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
179\r
180 //\r
181 // Make sure this driver is currently managing ControllerHandle\r
182 //\r
183 Status = EfiTestManagedDevice (\r
184 ControllerHandle,\r
185 gXhciDriverBinding.DriverBindingHandle,\r
186 &gEfiPciIoProtocolGuid\r
187 );\r
188 if (EFI_ERROR (Status)) {\r
189 return Status;\r
190 }\r
191\r
192 //\r
193 // Get the device context\r
194 //\r
195 Status = gBS->OpenProtocol (\r
196 ControllerHandle,\r
197 &gEfiUsb2HcProtocolGuid,\r
198 (VOID **) &Usb2Hc,\r
199 gXhciDriverBinding.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 XhciDev = XHC_FROM_THIS (Usb2Hc);\r
208\r
209 return LookupUnicodeString2 (\r
210 Language,\r
211 This->SupportedLanguages,\r
212 XhciDev->ControllerNameTable,\r
213 ControllerName,\r
214 (BOOLEAN)(This == &gXhciComponentName)\r
215 );\r
216\r
217}\r