]> git.proxmox.com Git - mirror_edk2.git/blob - OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.h
Apply library to test controller handle.
[mirror_edk2.git] / OptionRomPkg / CirrusLogic5430Dxe / CirrusLogic5430.h
1 /** @file
2 Cirrus Logic 5430 Controller Driver
3
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
9
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.
12
13 **/
14
15 //
16 // Cirrus Logic 5430 Controller Driver
17 //
18
19 #ifndef _CIRRUS_LOGIC_5430_H_
20 #define _CIRRUS_LOGIC_5430_H_
21
22
23 #include <Uefi.h>
24 #include <Protocol/UgaDraw.h>
25 #include <Protocol/GraphicsOutput.h>
26 #include <Protocol/PciIo.h>
27 #include <Protocol/DriverSupportedEfiVersion.h>
28
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>
35
36 #include <IndustryStandard/pci22.h>
37 //
38 // Cirrus Logic 5430 PCI Configuration Header values
39 //
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
44
45 //
46 // Cirrus Logic Graphical Mode Data
47 //
48 #define CIRRUS_LOGIC_5430_MODE_COUNT 3
49
50 typedef struct {
51 UINT32 HorizontalResolution;
52 UINT32 VerticalResolution;
53 UINT32 ColorDepth;
54 UINT32 RefreshRate;
55 } CIRRUS_LOGIC_5430_MODE_DATA;
56
57 #define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
58
59 //
60 // Cirrus Logic 5440 Private Data Structure
61 //
62 #define CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('C', 'L', '5', '4')
63
64 typedef struct {
65 UINT64 Signature;
66 EFI_HANDLE Handle;
67 EFI_PCI_IO_PROTOCOL *PciIo;
68 EFI_UGA_DRAW_PROTOCOL UgaDraw;
69 EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
70 UINTN CurrentMode;
71 UINTN MaxMode;
72 CIRRUS_LOGIC_5430_MODE_DATA ModeData[CIRRUS_LOGIC_5430_MODE_COUNT];
73 UINT8 *LineBuffer;
74 BOOLEAN HardwareNeedsStarting;
75 } CIRRUS_LOGIC_5430_PRIVATE_DATA;
76
77 ///
78 /// Video Mode structure
79 ///
80 typedef struct {
81 UINT32 Width;
82 UINT32 Height;
83 UINT32 ColorDepth;
84 UINT32 RefreshRate;
85 UINT8 *CrtcSettings;
86 UINT16 *SeqSettings;
87 UINT8 MiscSetting;
88 } CIRRUS_LOGIC_5430_VIDEO_MODES;
89
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)
92
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)
95
96
97 //
98 // Global Variables
99 //
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;
113
114 //
115 // Io Registers defined by VGA
116 //
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
129
130 //
131 // UGA Draw Hardware abstraction internal worker functions
132 //
133 EFI_STATUS
134 CirrusLogic5430UgaDrawConstructor (
135 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
136 )
137 ;
138
139 EFI_STATUS
140 CirrusLogic5430UgaDrawDestructor (
141 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
142 )
143 ;
144
145 //
146 // Graphics Output Hardware abstraction internal worker functions
147 //
148 EFI_STATUS
149 CirrusLogic5430GraphicsOutputConstructor (
150 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
151 )
152 ;
153
154 EFI_STATUS
155 CirrusLogic5430GraphicsOutputDestructor (
156 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
157 )
158 ;
159
160
161 //
162 // EFI_DRIVER_BINDING_PROTOCOL Protocol Interface
163 //
164 /**
165 TODO: Add function description
166
167 @param This TODO: add argument description
168 @param Controller TODO: add argument description
169 @param RemainingDevicePath TODO: add argument description
170
171 TODO: add return values
172
173 **/
174 EFI_STATUS
175 EFIAPI
176 CirrusLogic5430ControllerDriverSupported (
177 IN EFI_DRIVER_BINDING_PROTOCOL *This,
178 IN EFI_HANDLE Controller,
179 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
180 )
181 ;
182
183 /**
184 TODO: Add function description
185
186 @param This TODO: add argument description
187 @param Controller TODO: add argument description
188 @param RemainingDevicePath TODO: add argument description
189
190 TODO: add return values
191
192 **/
193 EFI_STATUS
194 EFIAPI
195 CirrusLogic5430ControllerDriverStart (
196 IN EFI_DRIVER_BINDING_PROTOCOL *This,
197 IN EFI_HANDLE Controller,
198 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
199 )
200 ;
201
202 /**
203 TODO: Add function description
204
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
209
210 TODO: add return values
211
212 **/
213 EFI_STATUS
214 EFIAPI
215 CirrusLogic5430ControllerDriverStop (
216 IN EFI_DRIVER_BINDING_PROTOCOL *This,
217 IN EFI_HANDLE Controller,
218 IN UINTN NumberOfChildren,
219 IN EFI_HANDLE *ChildHandleBuffer
220 )
221 ;
222
223 //
224 // EFI Component Name Functions
225 //
226 /**
227 Retrieves a Unicode string that is the user readable name of the driver.
228
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.
235
236 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
237 EFI_COMPONENT_NAME_PROTOCOL instance.
238
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.
247
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.
252
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.
256
257 @retval EFI_INVALID_PARAMETER Language is NULL.
258
259 @retval EFI_INVALID_PARAMETER DriverName is NULL.
260
261 @retval EFI_UNSUPPORTED The driver specified by This does not support
262 the language specified by Language.
263
264 **/
265 EFI_STATUS
266 EFIAPI
267 CirrusLogic5430ComponentNameGetDriverName (
268 IN EFI_COMPONENT_NAME_PROTOCOL *This,
269 IN CHAR8 *Language,
270 OUT CHAR16 **DriverName
271 );
272
273
274 /**
275 Retrieves a Unicode string that is the user readable name of the controller
276 that is being managed by a driver.
277
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.
286
287 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
288 EFI_COMPONENT_NAME_PROTOCOL instance.
289
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
293 returned.
294
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
302 child controller.
303
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.
312
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
318 specified by This.
319
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
323 DriverName.
324
325 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
326
327 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
328 EFI_HANDLE.
329
330 @retval EFI_INVALID_PARAMETER Language is NULL.
331
332 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
333
334 @retval EFI_UNSUPPORTED The driver specified by This is not currently
335 managing the controller specified by
336 ControllerHandle and ChildHandle.
337
338 @retval EFI_UNSUPPORTED The driver specified by This does not support
339 the language specified by Language.
340
341 **/
342 EFI_STATUS
343 EFIAPI
344 CirrusLogic5430ComponentNameGetControllerName (
345 IN EFI_COMPONENT_NAME_PROTOCOL *This,
346 IN EFI_HANDLE ControllerHandle,
347 IN EFI_HANDLE ChildHandle OPTIONAL,
348 IN CHAR8 *Language,
349 OUT CHAR16 **ControllerName
350 );
351
352
353 //
354 // Local Function Prototypes
355 //
356 VOID
357 InitializeGraphicsMode (
358 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
359 CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData
360 );
361
362 VOID
363 SetPaletteColor (
364 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
365 UINTN Index,
366 UINT8 Red,
367 UINT8 Green,
368 UINT8 Blue
369 );
370
371 VOID
372 SetDefaultPalette (
373 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
374 );
375
376 VOID
377 DrawLogo (
378 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
379 UINTN ScreenWidth,
380 UINTN ScreenHeight
381 );
382
383 VOID
384 outb (
385 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
386 UINTN Address,
387 UINT8 Data
388 );
389
390 VOID
391 outw (
392 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
393 UINTN Address,
394 UINT16 Data
395 );
396
397 UINT8
398 inb (
399 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
400 UINTN Address
401 );
402
403 UINT16
404 inw (
405 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
406 UINTN Address
407 );
408
409 #endif