Update License header.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / ComponentName.c
CommitLineData
913cb9dc 1/** @file\r
2\r
824b03ce 3Copyright (c) 2006 - 2007, Intel Corporation \r
4 \r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions\r
7of the BSD License which accompanies this distribution. The\r
8full text of the license may be found at\r
913cb9dc 9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14Module Name:\r
15\r
16 ComponentName.c\r
17\r
18Abstract:\r
19\r
20\r
21**/\r
22\r
23#include "Ehci.h"\r
24\r
25//\r
26// EFI Component Name Functions\r
27//\r
28EFI_STATUS\r
29EFIAPI\r
30EhciComponentNameGetDriverName (\r
31 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
32 IN CHAR8 *Language,\r
33 OUT CHAR16 **DriverName\r
34 );\r
35\r
36EFI_STATUS\r
37EFIAPI\r
38EhciComponentNameGetControllerName (\r
39 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
40 IN EFI_HANDLE ControllerHandle,\r
41 IN EFI_HANDLE ChildHandle, OPTIONAL\r
42 IN CHAR8 *Language,\r
43 OUT CHAR16 **ControllerName\r
44 );\r
45\r
46//\r
47// EFI Component Name Protocol\r
48//\r
49EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName = {\r
50 EhciComponentNameGetDriverName,\r
51 EhciComponentNameGetControllerName,\r
52 "eng"\r
53};\r
54\r
55static EFI_UNICODE_STRING_TABLE mEhciDriverNameTable[] = {\r
56 { "eng", L"Usb Ehci Driver" },\r
57 { NULL , NULL }\r
58};\r
59\r
60EFI_STATUS\r
61EFIAPI\r
62EhciComponentNameGetDriverName (\r
63 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
64 IN CHAR8 *Language,\r
65 OUT CHAR16 **DriverName\r
66 )\r
67/*++\r
68\r
69 Routine Description:\r
70 Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
71\r
72 Arguments:\r
73 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
74 Language - A pointer to a three character ISO 639-2 language identifier.\r
75 This is the language of the driver name that that the caller\r
76 is requesting, and it must match one of the languages specified\r
77 in SupportedLanguages. The number of languages supported by a\r
78 driver is up to the driver writer.\r
79 DriverName - A pointer to the Unicode string to return. This Unicode string\r
80 is the name of the driver specified by This in the language\r
81 specified by Language.\r
82\r
83 Returns:\r
84 EFI_SUCCESS - The Unicode string for the Driver specified by This\r
85 and the language specified by Language was returned\r
86 in DriverName.\r
87 EFI_INVALID_PARAMETER - Language is NULL.\r
88 EFI_INVALID_PARAMETER - DriverName is NULL.\r
89 EFI_UNSUPPORTED - The driver specified by This does not support the\r
90 language specified by Language.\r
91\r
92--*/\r
93{\r
94 return LookupUnicodeString (\r
95 Language,\r
96 gEhciComponentName.SupportedLanguages,\r
97 mEhciDriverNameTable,\r
98 DriverName\r
99 );\r
100}\r
101\r
102EFI_STATUS\r
103EFIAPI\r
104EhciComponentNameGetControllerName (\r
105 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
106 IN EFI_HANDLE ControllerHandle,\r
107 IN EFI_HANDLE ChildHandle, OPTIONAL\r
108 IN CHAR8 *Language,\r
109 OUT CHAR16 **ControllerName\r
110 )\r
111/*++\r
112\r
113 Routine Description:\r
114 Retrieves a Unicode string that is the user readable name of the controller\r
115 that is being managed by an EFI Driver.\r
116\r
117 Arguments:\r
118 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
119 ControllerHandle - The handle of a controller that the driver specified by\r
120 This is managing. This handle specifies the controller\r
121 whose name is to be returned.\r
122 ChildHandle - The handle of the child controller to retrieve the name\r
123 of. This is an optional parameter that may be NULL. It\r
124 will be NULL for device drivers. It will also be NULL\r
125 for a bus drivers that wish to retrieve the name of the\r
126 bus controller. It will not be NULL for a bus driver\r
127 that wishes to retrieve the name of a child controller.\r
128 Language - A pointer to a three character ISO 639-2 language\r
129 identifier. This is the language of the controller name\r
130 that that the caller is requesting, and it must match one\r
131 of the languages specified in SupportedLanguages. The\r
132 number of languages supported by a driver is up to the\r
133 driver writer.\r
134 ControllerName - A pointer to the Unicode string to return. This Unicode\r
135 string is the name of the controller specified by\r
136 ControllerHandle and ChildHandle in the language\r
137 specified by Language from the point of view of the\r
138 driver specified by This.\r
139\r
140 Returns:\r
141 EFI_SUCCESS - The Unicode string for the user readable name in the\r
142 language specified by Language for the driver\r
143 specified by This was returned in DriverName.\r
144 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
145 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid\r
146 EFI_HANDLE.\r
147 EFI_INVALID_PARAMETER - Language is NULL.\r
148 EFI_INVALID_PARAMETER - ControllerName is NULL.\r
149 EFI_UNSUPPORTED - The driver specified by This is not currently\r
150 managing the controller specified by\r
151 ControllerHandle and ChildHandle.\r
152 EFI_UNSUPPORTED - The driver specified by This does not support the\r
153 language specified by Language.\r
154\r
155--*/\r
156{\r
157 EFI_STATUS Status;\r
158 USB2_HC_DEV *EhciDev;\r
159 EFI_USB2_HC_PROTOCOL *Usb2Hc;\r
160\r
161 //\r
162 // This is a device driver, so ChildHandle must be NULL.\r
163 //\r
164 if (ChildHandle != NULL) {\r
165 return EFI_UNSUPPORTED;\r
166 }\r
167 //\r
168 // Make sure this driver is currently managing ControllerHandle\r
169 //\r
170 Status = EfiTestManagedDevice (\r
171 ControllerHandle,\r
172 gEhciDriverBinding.DriverBindingHandle,\r
173 &gEfiPciIoProtocolGuid\r
174 );\r
175 if (EFI_ERROR (Status)) {\r
176 return Status;\r
177 }\r
178 //\r
179 // Get the device context\r
180 //\r
181 Status = gBS->OpenProtocol (\r
182 ControllerHandle,\r
183 &gEfiUsb2HcProtocolGuid,\r
184 (VOID **) &Usb2Hc,\r
185 gEhciDriverBinding.DriverBindingHandle,\r
186 ControllerHandle,\r
187 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
188 );\r
189 if (EFI_ERROR (Status)) {\r
190 return Status;\r
191 }\r
192\r
193 EhciDev = EHC_FROM_THIS (Usb2Hc);\r
194\r
195 return LookupUnicodeString (\r
196 Language,\r
197 gEhciComponentName.SupportedLanguages,\r
198 EhciDev->ControllerNameTable,\r
199 ControllerName\r
200 );\r
201\r
202}\r