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