]> git.proxmox.com Git - mirror_edk2.git/blame - QuarkSocPkg/QuarkSouthCluster/Usb/Ohci/Dxe/ComponentName.c
QuarkSocPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / QuarkSocPkg / QuarkSouthCluster / Usb / Ohci / Dxe / ComponentName.c
CommitLineData
9b6bbcdb
MK
1/** @file\r
2UEFI Component Name and Name2 protocol for OHCI driver.\r
3\r
4Copyright (c) 2013-2015 Intel Corporation.\r
5\r
c9f231d0 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
9b6bbcdb
MK
7\r
8**/\r
9\r
10\r
11#include "Ohci.h"\r
12\r
13\r
14//\r
15// EFI Component Name Protocol\r
16//\r
17GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gOhciComponentName = {\r
18 OhciComponentNameGetDriverName,\r
19 OhciComponentNameGetControllerName,\r
20 "eng"\r
21};\r
22\r
23//\r
24// EFI Component Name 2 Protocol\r
25//\r
26GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gOhciComponentName2 = {\r
27 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) OhciComponentNameGetDriverName,\r
28 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) OhciComponentNameGetControllerName,\r
29 "en"\r
30};\r
31\r
32\r
33GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mOhciDriverNameTable[] = {\r
34 { "eng;en", L"Usb Ohci Driver" },\r
35 { NULL, NULL }\r
36};\r
37\r
38\r
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
59 in RFC 4646 or ISO 639-2 language code format.\r
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
78EFI_STATUS\r
79EFIAPI\r
80OhciComponentNameGetDriverName (\r
81 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
82 IN CHAR8 *Language,\r
83 OUT CHAR16 **DriverName\r
84 )\r
85{\r
86 return LookupUnicodeString2 (\r
87 Language,\r
88 This->SupportedLanguages,\r
89 mOhciDriverNameTable,\r
90 DriverName,\r
91 (BOOLEAN)(This == &gOhciComponentName)\r
92 );\r
93}\r
94\r
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
132 RFC 4646 or ISO 639-2 language code format.\r
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
146 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
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
163EFI_STATUS\r
164EFIAPI\r
165OhciComponentNameGetControllerName (\r
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
171 )\r
172{\r
173 EFI_STATUS Status;\r
174 USB_OHCI_HC_DEV *OhciDev;\r
175 EFI_USB_HC_PROTOCOL *UsbHc;\r
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 // Make sure this driver is currently managing ControllerHandle\r
185 //\r
186 Status = EfiTestManagedDevice (\r
187 ControllerHandle,\r
188 gOhciDriverBinding.DriverBindingHandle,\r
189 &gEfiPciIoProtocolGuid\r
190 );\r
191 if (EFI_ERROR (Status)) {\r
192 return Status;\r
193 }\r
194 //\r
195 // Get the device context\r
196 //\r
197 Status = gBS->OpenProtocol (\r
198 ControllerHandle,\r
199 &gEfiUsbHcProtocolGuid,\r
200 (VOID **) &UsbHc,\r
201 gOhciDriverBinding.DriverBindingHandle,\r
202 ControllerHandle,\r
203 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
204 );\r
205 if (EFI_ERROR (Status)) {\r
206 return Status;\r
207 }\r
208\r
209 OhciDev = USB_OHCI_HC_DEV_FROM_THIS (UsbHc);\r
210\r
211 return LookupUnicodeString2 (\r
212 Language,\r
213 This->SupportedLanguages,\r
214 OhciDev->ControllerNameTable,\r
215 ControllerName,\r
216 (BOOLEAN)(This == &gOhciComponentName)\r
217 );\r
218\r
219}\r