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