2 Cirrus Logic 5430 Controller Driver
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 // Cirrus Logic 5430 Controller Driver
19 #ifndef _CIRRUS_LOGIC_5430_H_
20 #define _CIRRUS_LOGIC_5430_H_
24 #include <Protocol/UgaDraw.h>
25 #include <Protocol/GraphicsOutput.h>
26 #include <Protocol/PciIo.h>
27 #include <Protocol/DriverSupportedEfiVersion.h>
29 #include <Library/DebugLib.h>
30 #include <Library/UefiDriverEntryPoint.h>
31 #include <Library/UefiLib.h>
32 #include <Library/PcdLib.h>
33 #include <Library/MemoryAllocationLib.h>
34 #include <Library/UefiBootServicesTableLib.h>
36 #include <IndustryStandard/pci22.h>
38 // Cirrus Logic 5430 PCI Configuration Header values
40 #define CIRRUS_LOGIC_VENDOR_ID 0x1013
41 #define CIRRUS_LOGIC_5430_DEVICE_ID 0x00a8
42 #define CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID 0x00a0
43 #define CIRRUS_LOGIC_5446_DEVICE_ID 0x00b8
46 // Cirrus Logic Graphical Mode Data
48 #define CIRRUS_LOGIC_5430_MODE_COUNT 3
51 UINT32 HorizontalResolution
;
52 UINT32 VerticalResolution
;
55 } CIRRUS_LOGIC_5430_MODE_DATA
;
57 #define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
60 // Cirrus Logic 5440 Private Data Structure
62 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('C', 'L', '5', '4')
67 EFI_PCI_IO_PROTOCOL
*PciIo
;
68 EFI_UGA_DRAW_PROTOCOL UgaDraw
;
69 EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput
;
72 CIRRUS_LOGIC_5430_MODE_DATA ModeData
[CIRRUS_LOGIC_5430_MODE_COUNT
];
74 BOOLEAN HardwareNeedsStarting
;
75 } CIRRUS_LOGIC_5430_PRIVATE_DATA
;
78 /// Video Mode structure
88 } CIRRUS_LOGIC_5430_VIDEO_MODES
;
90 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS(a) \
91 CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, UgaDraw, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)
93 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS(a) \
94 CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, GraphicsOutput, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)
100 extern UINT8 AttributeController
[];
101 extern UINT8 GraphicsController
[];
102 extern UINT8 Crtc_640_480_256_60
[];
103 extern UINT16 Seq_640_480_256_60
[];
104 extern UINT8 Crtc_800_600_256_60
[];
105 extern UINT16 Seq_800_600_256_60
[];
106 extern UINT8 Crtc_1024_768_256_60
[];
107 extern UINT16 Seq_1024_768_256_60
[];
108 extern CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes
[];
109 extern EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding
;
110 extern EFI_COMPONENT_NAME_PROTOCOL gCirrusLogic5430ComponentName
;
111 extern EFI_COMPONENT_NAME2_PROTOCOL gCirrusLogic5430ComponentName2
;
112 extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gCirrusLogic5430DriverSupportedEfiVersion
;
115 // Io Registers defined by VGA
117 #define CRTC_ADDRESS_REGISTER 0x3d4
118 #define CRTC_DATA_REGISTER 0x3d5
119 #define SEQ_ADDRESS_REGISTER 0x3c4
120 #define SEQ_DATA_REGISTER 0x3c5
121 #define GRAPH_ADDRESS_REGISTER 0x3ce
122 #define GRAPH_DATA_REGISTER 0x3cf
123 #define ATT_ADDRESS_REGISTER 0x3c0
124 #define MISC_OUTPUT_REGISTER 0x3c2
125 #define INPUT_STATUS_1_REGISTER 0x3da
126 #define DAC_PIXEL_MASK_REGISTER 0x3c6
127 #define PALETTE_INDEX_REGISTER 0x3c8
128 #define PALETTE_DATA_REGISTER 0x3c9
131 // UGA Draw Hardware abstraction internal worker functions
134 CirrusLogic5430UgaDrawConstructor (
135 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
140 CirrusLogic5430UgaDrawDestructor (
141 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
146 // Graphics Output Hardware abstraction internal worker functions
149 CirrusLogic5430GraphicsOutputConstructor (
150 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
155 CirrusLogic5430GraphicsOutputDestructor (
156 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
162 // EFI_DRIVER_BINDING_PROTOCOL Protocol Interface
165 TODO: Add function description
167 @param This TODO: add argument description
168 @param Controller TODO: add argument description
169 @param RemainingDevicePath TODO: add argument description
171 TODO: add return values
176 CirrusLogic5430ControllerDriverSupported (
177 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
178 IN EFI_HANDLE Controller
,
179 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
184 TODO: Add function description
186 @param This TODO: add argument description
187 @param Controller TODO: add argument description
188 @param RemainingDevicePath TODO: add argument description
190 TODO: add return values
195 CirrusLogic5430ControllerDriverStart (
196 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
197 IN EFI_HANDLE Controller
,
198 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
203 TODO: Add function description
205 @param This TODO: add argument description
206 @param Controller TODO: add argument description
207 @param NumberOfChildren TODO: add argument description
208 @param ChildHandleBuffer TODO: add argument description
210 TODO: add return values
215 CirrusLogic5430ControllerDriverStop (
216 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
217 IN EFI_HANDLE Controller
,
218 IN UINTN NumberOfChildren
,
219 IN EFI_HANDLE
*ChildHandleBuffer
224 // EFI Component Name Functions
227 Retrieves a Unicode string that is the user readable name of the driver.
229 This function retrieves the user readable name of a driver in the form of a
230 Unicode string. If the driver specified by This has a user readable name in
231 the language specified by Language, then a pointer to the driver name is
232 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
233 by This does not support the language specified by Language,
234 then EFI_UNSUPPORTED is returned.
236 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
237 EFI_COMPONENT_NAME_PROTOCOL instance.
239 @param Language[in] A pointer to a Null-terminated ASCII string
240 array indicating the language. This is the
241 language of the driver name that the caller is
242 requesting, and it must match one of the
243 languages specified in SupportedLanguages. The
244 number of languages supported by a driver is up
245 to the driver writer. Language is specified
246 in RFC 3066 or ISO 639-2 language code format.
248 @param DriverName[out] A pointer to the Unicode string to return.
249 This Unicode string is the name of the
250 driver specified by This in the language
251 specified by Language.
253 @retval EFI_SUCCESS The Unicode string for the Driver specified by
254 This and the language specified by Language was
255 returned in DriverName.
257 @retval EFI_INVALID_PARAMETER Language is NULL.
259 @retval EFI_INVALID_PARAMETER DriverName is NULL.
261 @retval EFI_UNSUPPORTED The driver specified by This does not support
262 the language specified by Language.
267 CirrusLogic5430ComponentNameGetDriverName (
268 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
270 OUT CHAR16
**DriverName
275 Retrieves a Unicode string that is the user readable name of the controller
276 that is being managed by a driver.
278 This function retrieves the user readable name of the controller specified by
279 ControllerHandle and ChildHandle in the form of a Unicode string. If the
280 driver specified by This has a user readable name in the language specified by
281 Language, then a pointer to the controller name is returned in ControllerName,
282 and EFI_SUCCESS is returned. If the driver specified by This is not currently
283 managing the controller specified by ControllerHandle and ChildHandle,
284 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
285 support the language specified by Language, then EFI_UNSUPPORTED is returned.
287 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
288 EFI_COMPONENT_NAME_PROTOCOL instance.
290 @param ControllerHandle[in] The handle of a controller that the driver
291 specified by This is managing. This handle
292 specifies the controller whose name is to be
295 @param ChildHandle[in] The handle of the child controller to retrieve
296 the name of. This is an optional parameter that
297 may be NULL. It will be NULL for device
298 drivers. It will also be NULL for a bus drivers
299 that wish to retrieve the name of the bus
300 controller. It will not be NULL for a bus
301 driver that wishes to retrieve the name of a
304 @param Language[in] A pointer to a Null-terminated ASCII string
305 array indicating the language. This is the
306 language of the driver name that the caller is
307 requesting, and it must match one of the
308 languages specified in SupportedLanguages. The
309 number of languages supported by a driver is up
310 to the driver writer. Language is specified in
311 RFC 3066 or ISO 639-2 language code format.
313 @param ControllerName[out] A pointer to the Unicode string to return.
314 This Unicode string is the name of the
315 controller specified by ControllerHandle and
316 ChildHandle in the language specified by
317 Language from the point of view of the driver
320 @retval EFI_SUCCESS The Unicode string for the user readable name in
321 the language specified by Language for the
322 driver specified by This was returned in
325 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
327 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
330 @retval EFI_INVALID_PARAMETER Language is NULL.
332 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
334 @retval EFI_UNSUPPORTED The driver specified by This is not currently
335 managing the controller specified by
336 ControllerHandle and ChildHandle.
338 @retval EFI_UNSUPPORTED The driver specified by This does not support
339 the language specified by Language.
344 CirrusLogic5430ComponentNameGetControllerName (
345 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
346 IN EFI_HANDLE ControllerHandle
,
347 IN EFI_HANDLE ChildHandle OPTIONAL
,
349 OUT CHAR16
**ControllerName
354 // Local Function Prototypes
357 InitializeGraphicsMode (
358 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
359 CIRRUS_LOGIC_5430_VIDEO_MODES
*ModeData
364 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
373 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
378 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
385 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
392 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
399 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
405 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,