]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Bus/Pci/CirrusLogic/Dxe/ComponentName.c
Partially make EdkModulePkg pass intel IPF compiler with /W4 /WX switched on.
[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 EFI_PCI_IO_PROTOCOL *PciIoProtocol;
146
147 //
148 // This is a device driver, so ChildHandle must be NULL.
149 //
150 if (ChildHandle != NULL) {
151 return EFI_UNSUPPORTED;
152 }
153
154 //
155 // Check Controller's handle
156 //
157 Status = gBS->OpenProtocol (
158 ControllerHandle,
159 &gEfiPciIoProtocolGuid,
160 (VOID **) &PciIoProtocol,
161 gCirrusLogic5430DriverBinding.DriverBindingHandle,
162 ControllerHandle,
163 EFI_OPEN_PROTOCOL_BY_DRIVER
164 );
165 if (!EFI_ERROR (Status)) {
166 gBS->CloseProtocol (
167 ControllerHandle,
168 &gEfiPciIoProtocolGuid,
169 gCirrusLogic5430DriverBinding.DriverBindingHandle,
170 ControllerHandle
171 );
172
173 return EFI_UNSUPPORTED;
174 }
175
176 if (Status != EFI_ALREADY_STARTED) {
177 return EFI_UNSUPPORTED;
178 }
179
180 //
181 // Get the UGA Draw Protocol on Controller
182 //
183 Status = gBS->OpenProtocol (
184 ControllerHandle,
185 &gEfiUgaDrawProtocolGuid,
186 (VOID **) &UgaDraw,
187 gCirrusLogic5430DriverBinding.DriverBindingHandle,
188 ControllerHandle,
189 EFI_OPEN_PROTOCOL_GET_PROTOCOL
190 );
191 if (EFI_ERROR (Status)) {
192 return Status;
193 }
194
195 //
196 // Get the Cirrus Logic 5430's Device structure
197 //
198 return LookupUnicodeString (
199 Language,
200 gCirrusLogic5430ComponentName.SupportedLanguages,
201 mCirrusLogic5430ControllerNameTable,
202 ControllerName
203 );
204 }