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