]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Bus/Pci/CirrusLogic/Dxe/ComponentName.c
Make EdkModulePkg pass Intel IPF compiler with /W4 /WX switches, solving warning...
[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 Protocol
17 //
18 EFI_COMPONENT_NAME_PROTOCOL gCirrusLogic5430ComponentName = {
19 CirrusLogic5430ComponentNameGetDriverName,
20 CirrusLogic5430ComponentNameGetControllerName,
21 "eng"
22 };
23
24 static EFI_UNICODE_STRING_TABLE mCirrusLogic5430DriverNameTable[] = {
25 { "eng", (CHAR16 *) L"Cirrus Logic 5430 UGA Driver" },
26 { NULL , NULL }
27 };
28
29 static EFI_UNICODE_STRING_TABLE mCirrusLogic5430ControllerNameTable[] = {
30 { "eng", (CHAR16 *) L"Cirrus Logic 5430 PCI Adapter" },
31 { NULL , NULL }
32 };
33
34 /**
35 Retrieves a Unicode string that is the user readable name of the EFI Driver.
36
37 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
38 @param Language A pointer to a three character ISO 639-2 language identifier.
39 This is the language of the driver name that that the caller
40 is requesting, and it must match one of the languages specified
41 in SupportedLanguages. The number of languages supported by a
42 driver is up to the driver writer.
43 @param DriverName A pointer to the Unicode string to return. This Unicode string
44 is the name of the driver specified by This in the language
45 specified by Language.
46
47 @retval EFI_SUCCESS The Unicode string for the Driver specified by This
48 and the language specified by Language was returned
49 in DriverName.
50 @retval EFI_INVALID_PARAMETER Language is NULL.
51 @retval EFI_INVALID_PARAMETER DriverName is NULL.
52 @retval EFI_UNSUPPORTED The driver specified by This does not support the
53 language specified by Language.
54
55 **/
56 EFI_STATUS
57 EFIAPI
58 CirrusLogic5430ComponentNameGetDriverName (
59 IN EFI_COMPONENT_NAME_PROTOCOL *This,
60 IN CHAR8 *Language,
61 OUT CHAR16 **DriverName
62 )
63 {
64 return LookupUnicodeString (
65 Language,
66 gCirrusLogic5430ComponentName.SupportedLanguages,
67 mCirrusLogic5430DriverNameTable,
68 DriverName
69 );
70 }
71
72 /**
73 Retrieves a Unicode string that is the user readable name of the controller
74 that is being managed by an EFI Driver.
75
76 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
77 @param ControllerHandle The handle of a controller that the driver specified by
78 This is managing. This handle specifies the controller
79 whose name is to be returned.
80 @param ChildHandle The handle of the child controller to retrieve the name
81 of. This is an optional parameter that may be NULL. It
82 will be NULL for device drivers. It will also be NULL
83 for a bus drivers that wish to retrieve the name of the
84 bus controller. It will not be NULL for a bus driver
85 that wishes to retrieve the name of a child controller.
86 @param Language A pointer to a three character ISO 639-2 language
87 identifier. This is the language of the controller name
88 that that the caller is requesting, and it must match one
89 of the languages specified in SupportedLanguages. The
90 number of languages supported by a driver is up to the
91 driver writer.
92 @param ControllerName A pointer to the Unicode string to return. This Unicode
93 string is the name of the controller specified by
94 ControllerHandle and ChildHandle in the language specified
95 by Language from the point of view of the driver specified
96 by This.
97
98 @retval EFI_SUCCESS The Unicode string for the user readable name in the
99 language specified by Language for the driver
100 specified by This was returned in DriverName.
101 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
102 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
103 @retval EFI_INVALID_PARAMETER Language is NULL.
104 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
105 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing
106 the controller specified by ControllerHandle and
107 ChildHandle.
108 @retval EFI_UNSUPPORTED The driver specified by This does not support the
109 language specified by Language.
110
111 **/
112 EFI_STATUS
113 EFIAPI
114 CirrusLogic5430ComponentNameGetControllerName (
115 IN EFI_COMPONENT_NAME_PROTOCOL *This,
116 IN EFI_HANDLE ControllerHandle,
117 IN EFI_HANDLE ChildHandle OPTIONAL,
118 IN CHAR8 *Language,
119 OUT CHAR16 **ControllerName
120 )
121 {
122 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
123 EFI_STATUS Status;
124 EFI_PCI_IO_PROTOCOL *PciIoProtocol;
125
126 //
127 // This is a device driver, so ChildHandle must be NULL.
128 //
129 if (ChildHandle != NULL) {
130 return EFI_UNSUPPORTED;
131 }
132
133 //
134 // Check Controller's handle
135 //
136 Status = gBS->OpenProtocol (
137 ControllerHandle,
138 &gEfiPciIoProtocolGuid,
139 (VOID **) &PciIoProtocol,
140 gCirrusLogic5430DriverBinding.DriverBindingHandle,
141 ControllerHandle,
142 EFI_OPEN_PROTOCOL_BY_DRIVER
143 );
144 if (!EFI_ERROR (Status)) {
145 gBS->CloseProtocol (
146 ControllerHandle,
147 &gEfiPciIoProtocolGuid,
148 gCirrusLogic5430DriverBinding.DriverBindingHandle,
149 ControllerHandle
150 );
151
152 return EFI_UNSUPPORTED;
153 }
154
155 if (Status != EFI_ALREADY_STARTED) {
156 return EFI_UNSUPPORTED;
157 }
158
159 //
160 // Get the UGA Draw Protocol on Controller
161 //
162 Status = gBS->OpenProtocol (
163 ControllerHandle,
164 &gEfiUgaDrawProtocolGuid,
165 (VOID **) &UgaDraw,
166 gCirrusLogic5430DriverBinding.DriverBindingHandle,
167 ControllerHandle,
168 EFI_OPEN_PROTOCOL_GET_PROTOCOL
169 );
170 if (EFI_ERROR (Status)) {
171 return Status;
172 }
173
174 //
175 // Get the Cirrus Logic 5430's Device structure
176 //
177 return LookupUnicodeString (
178 Language,
179 gCirrusLogic5430ComponentName.SupportedLanguages,
180 mCirrusLogic5430ControllerNameTable,
181 ControllerName
182 );
183 }