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
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.
13 #include "CirrusLogic5430.h"
16 // EFI Component Name Protocol
18 EFI_COMPONENT_NAME_PROTOCOL gCirrusLogic5430ComponentName
= {
19 CirrusLogic5430ComponentNameGetDriverName
,
20 CirrusLogic5430ComponentNameGetControllerName
,
24 static EFI_UNICODE_STRING_TABLE mCirrusLogic5430DriverNameTable
[] = {
25 { "eng", (CHAR16
*) L
"Cirrus Logic 5430 UGA Driver" },
29 static EFI_UNICODE_STRING_TABLE mCirrusLogic5430ControllerNameTable
[] = {
30 { "eng", (CHAR16
*) L
"Cirrus Logic 5430 PCI Adapter" },
35 Retrieves a Unicode string that is the user readable name of the EFI Driver.
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.
47 @retval EFI_SUCCESS The Unicode string for the Driver specified by This
48 and the language specified by Language was returned
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.
58 CirrusLogic5430ComponentNameGetDriverName (
59 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
61 OUT CHAR16
**DriverName
64 return LookupUnicodeString (
66 gCirrusLogic5430ComponentName
.SupportedLanguages
,
67 mCirrusLogic5430DriverNameTable
,
73 Retrieves a Unicode string that is the user readable name of the controller
74 that is being managed by an EFI Driver.
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
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
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
108 @retval EFI_UNSUPPORTED The driver specified by This does not support the
109 language specified by Language.
114 CirrusLogic5430ComponentNameGetControllerName (
115 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
116 IN EFI_HANDLE ControllerHandle
,
117 IN EFI_HANDLE ChildHandle OPTIONAL
,
119 OUT CHAR16
**ControllerName
122 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
124 EFI_PCI_IO_PROTOCOL
*PciIoProtocol
;
127 // This is a device driver, so ChildHandle must be NULL.
129 if (ChildHandle
!= NULL
) {
130 return EFI_UNSUPPORTED
;
134 // Check Controller's handle
136 Status
= gBS
->OpenProtocol (
138 &gEfiPciIoProtocolGuid
,
139 (VOID
**) &PciIoProtocol
,
140 gCirrusLogic5430DriverBinding
.DriverBindingHandle
,
142 EFI_OPEN_PROTOCOL_BY_DRIVER
144 if (!EFI_ERROR (Status
)) {
147 &gEfiPciIoProtocolGuid
,
148 gCirrusLogic5430DriverBinding
.DriverBindingHandle
,
152 return EFI_UNSUPPORTED
;
155 if (Status
!= EFI_ALREADY_STARTED
) {
156 return EFI_UNSUPPORTED
;
160 // Get the UGA Draw Protocol on Controller
162 Status
= gBS
->OpenProtocol (
164 &gEfiUgaDrawProtocolGuid
,
166 gCirrusLogic5430DriverBinding
.DriverBindingHandle
,
168 EFI_OPEN_PROTOCOL_GET_PROTOCOL
170 if (EFI_ERROR (Status
)) {
175 // Get the Cirrus Logic 5430's Device structure
177 return LookupUnicodeString (
179 gCirrusLogic5430ComponentName
.SupportedLanguages
,
180 mCirrusLogic5430ControllerNameTable
,