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