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