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