]> git.proxmox.com Git - mirror_edk2.git/blame - OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.h
UefiCpuPkg/MpService: move settimer out to InitMpSystemData
[mirror_edk2.git] / OptionRomPkg / CirrusLogic5430Dxe / CirrusLogic5430.h
CommitLineData
87f8ccbe 1/** @file\r
2 Cirrus Logic 5430 Controller Driver\r
3\r
b28b274d 4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
ac1ca104 5 This program and the accompanying materials\r
94b73c24 6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
87f8ccbe 9\r
94b73c24 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
87f8ccbe 12\r
13**/\r
14\r
15//\r
16// Cirrus Logic 5430 Controller Driver\r
17//\r
18\r
19#ifndef _CIRRUS_LOGIC_5430_H_\r
20#define _CIRRUS_LOGIC_5430_H_\r
21\r
22\r
23#include <Uefi.h>\r
24#include <Protocol/UgaDraw.h>\r
25#include <Protocol/GraphicsOutput.h>\r
26#include <Protocol/PciIo.h>\r
27#include <Protocol/DriverSupportedEfiVersion.h>\r
31f9e631 28#include <Protocol/EdidOverride.h>\r
29#include <Protocol/EdidDiscovered.h>\r
30#include <Protocol/EdidActive.h>\r
31#include <Protocol/DevicePath.h>\r
87f8ccbe 32\r
33#include <Library/DebugLib.h>\r
34#include <Library/UefiDriverEntryPoint.h>\r
35#include <Library/UefiLib.h>\r
36#include <Library/PcdLib.h>\r
37#include <Library/MemoryAllocationLib.h>\r
38#include <Library/UefiBootServicesTableLib.h>\r
31f9e631 39#include <Library/BaseMemoryLib.h>\r
40#include <Library/DevicePathLib.h>\r
2e293897 41#include <Library/TimerLib.h>\r
87f8ccbe 42\r
5781db08 43#include <IndustryStandard/Pci.h>\r
87f8ccbe 44//\r
45// Cirrus Logic 5430 PCI Configuration Header values\r
46//\r
47#define CIRRUS_LOGIC_VENDOR_ID 0x1013\r
48#define CIRRUS_LOGIC_5430_DEVICE_ID 0x00a8\r
49#define CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID 0x00a0\r
50#define CIRRUS_LOGIC_5446_DEVICE_ID 0x00b8\r
51\r
52//\r
53// Cirrus Logic Graphical Mode Data\r
54//\r
55#define CIRRUS_LOGIC_5430_MODE_COUNT 3\r
56\r
57typedef struct {\r
31f9e631 58 UINT32 ModeNumber;\r
87f8ccbe 59 UINT32 HorizontalResolution;\r
60 UINT32 VerticalResolution;\r
61 UINT32 ColorDepth;\r
62 UINT32 RefreshRate;\r
63} CIRRUS_LOGIC_5430_MODE_DATA;\r
64\r
110d3a9a 65#define PIXEL_RED_SHIFT 0\r
66#define PIXEL_GREEN_SHIFT 3\r
67#define PIXEL_BLUE_SHIFT 6\r
68\r
69#define PIXEL_RED_MASK (BIT7 | BIT6 | BIT5)\r
70#define PIXEL_GREEN_MASK (BIT4 | BIT3 | BIT2)\r
71#define PIXEL_BLUE_MASK (BIT1 | BIT0)\r
72\r
73#define PIXEL_TO_COLOR_BYTE(pixel, mask, shift) ((UINT8) ((pixel & mask) << shift))\r
74#define PIXEL_TO_RED_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_RED_MASK, PIXEL_RED_SHIFT)\r
75#define PIXEL_TO_GREEN_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_GREEN_MASK, PIXEL_GREEN_SHIFT)\r
76#define PIXEL_TO_BLUE_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_BLUE_MASK, PIXEL_BLUE_SHIFT)\r
77\r
78#define RGB_BYTES_TO_PIXEL(Red, Green, Blue) \\r
79 (UINT8) ( (((Red) >> PIXEL_RED_SHIFT) & PIXEL_RED_MASK) | \\r
80 (((Green) >> PIXEL_GREEN_SHIFT) & PIXEL_GREEN_MASK) | \\r
81 (((Blue) >> PIXEL_BLUE_SHIFT) & PIXEL_BLUE_MASK) )\r
82\r
87f8ccbe 83#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff\r
84\r
85//\r
86// Cirrus Logic 5440 Private Data Structure\r
87//\r
32438080 88#define CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('C', 'L', '5', '4')\r
87f8ccbe 89\r
90typedef struct {\r
91 UINT64 Signature;\r
92 EFI_HANDLE Handle;\r
93 EFI_PCI_IO_PROTOCOL *PciIo;\r
94b73c24 94 UINT64 OriginalPciAttributes;\r
87f8ccbe 95 EFI_UGA_DRAW_PROTOCOL UgaDraw;\r
96 EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;\r
31f9e631 97 EFI_EDID_DISCOVERED_PROTOCOL EdidDiscovered;\r
98 EFI_EDID_ACTIVE_PROTOCOL EdidActive;\r
99 EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;\r
100 EFI_DEVICE_PATH_PROTOCOL *UgaDevicePath;\r
87f8ccbe 101 UINTN CurrentMode;\r
102 UINTN MaxMode;\r
103 CIRRUS_LOGIC_5430_MODE_DATA ModeData[CIRRUS_LOGIC_5430_MODE_COUNT];\r
104 UINT8 *LineBuffer;\r
105 BOOLEAN HardwareNeedsStarting;\r
106} CIRRUS_LOGIC_5430_PRIVATE_DATA;\r
107\r
108///\r
109/// Video Mode structure\r
110///\r
111typedef struct {\r
112 UINT32 Width;\r
113 UINT32 Height;\r
114 UINT32 ColorDepth;\r
115 UINT32 RefreshRate;\r
116 UINT8 *CrtcSettings;\r
117 UINT16 *SeqSettings;\r
118 UINT8 MiscSetting;\r
119} CIRRUS_LOGIC_5430_VIDEO_MODES;\r
120\r
121#define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS(a) \\r
122 CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, UgaDraw, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)\r
123\r
124#define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS(a) \\r
125 CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, GraphicsOutput, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)\r
126\r
127\r
128//\r
129// Global Variables\r
130//\r
131extern UINT8 AttributeController[];\r
132extern UINT8 GraphicsController[];\r
133extern UINT8 Crtc_640_480_256_60[];\r
134extern UINT16 Seq_640_480_256_60[];\r
135extern UINT8 Crtc_800_600_256_60[];\r
136extern UINT16 Seq_800_600_256_60[];\r
137extern UINT8 Crtc_1024_768_256_60[];\r
138extern UINT16 Seq_1024_768_256_60[];\r
139extern CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes[];\r
140extern EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding;\r
141extern EFI_COMPONENT_NAME_PROTOCOL gCirrusLogic5430ComponentName;\r
142extern EFI_COMPONENT_NAME2_PROTOCOL gCirrusLogic5430ComponentName2;\r
143extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gCirrusLogic5430DriverSupportedEfiVersion;\r
144\r
145//\r
146// Io Registers defined by VGA\r
147//\r
148#define CRTC_ADDRESS_REGISTER 0x3d4\r
149#define CRTC_DATA_REGISTER 0x3d5\r
150#define SEQ_ADDRESS_REGISTER 0x3c4\r
151#define SEQ_DATA_REGISTER 0x3c5\r
152#define GRAPH_ADDRESS_REGISTER 0x3ce\r
153#define GRAPH_DATA_REGISTER 0x3cf\r
154#define ATT_ADDRESS_REGISTER 0x3c0\r
155#define MISC_OUTPUT_REGISTER 0x3c2\r
156#define INPUT_STATUS_1_REGISTER 0x3da\r
157#define DAC_PIXEL_MASK_REGISTER 0x3c6\r
158#define PALETTE_INDEX_REGISTER 0x3c8\r
159#define PALETTE_DATA_REGISTER 0x3c9\r
160\r
161//\r
162// UGA Draw Hardware abstraction internal worker functions\r
163//\r
164EFI_STATUS\r
165CirrusLogic5430UgaDrawConstructor (\r
166 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
ed66e1bc 167 );\r
87f8ccbe 168\r
169EFI_STATUS\r
170CirrusLogic5430UgaDrawDestructor (\r
171 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
ed66e1bc 172 );\r
87f8ccbe 173\r
174//\r
175// Graphics Output Hardware abstraction internal worker functions\r
176//\r
177EFI_STATUS\r
178CirrusLogic5430GraphicsOutputConstructor (\r
179 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
ed66e1bc 180 );\r
87f8ccbe 181\r
182EFI_STATUS\r
183CirrusLogic5430GraphicsOutputDestructor (\r
184 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
ed66e1bc 185 );\r
87f8ccbe 186\r
187\r
188//\r
189// EFI_DRIVER_BINDING_PROTOCOL Protocol Interface\r
190//\r
191/**\r
192 TODO: Add function description\r
193\r
194 @param This TODO: add argument description\r
195 @param Controller TODO: add argument description\r
196 @param RemainingDevicePath TODO: add argument description\r
197\r
198 TODO: add return values\r
199\r
200**/\r
201EFI_STATUS\r
202EFIAPI\r
203CirrusLogic5430ControllerDriverSupported (\r
204 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
205 IN EFI_HANDLE Controller,\r
206 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
ed66e1bc 207 );\r
87f8ccbe 208\r
209/**\r
210 TODO: Add function description\r
211\r
212 @param This TODO: add argument description\r
213 @param Controller TODO: add argument description\r
214 @param RemainingDevicePath TODO: add argument description\r
215\r
216 TODO: add return values\r
217\r
218**/\r
219EFI_STATUS\r
220EFIAPI\r
221CirrusLogic5430ControllerDriverStart (\r
222 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
223 IN EFI_HANDLE Controller,\r
224 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
ed66e1bc 225 );\r
87f8ccbe 226\r
227/**\r
228 TODO: Add function description\r
229\r
230 @param This TODO: add argument description\r
231 @param Controller TODO: add argument description\r
232 @param NumberOfChildren TODO: add argument description\r
233 @param ChildHandleBuffer TODO: add argument description\r
234\r
235 TODO: add return values\r
236\r
237**/\r
238EFI_STATUS\r
239EFIAPI\r
240CirrusLogic5430ControllerDriverStop (\r
241 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
242 IN EFI_HANDLE Controller,\r
243 IN UINTN NumberOfChildren,\r
244 IN EFI_HANDLE *ChildHandleBuffer\r
ed66e1bc 245 );\r
87f8ccbe 246\r
247//\r
248// EFI Component Name Functions\r
249//\r
250/**\r
251 Retrieves a Unicode string that is the user readable name of the driver.\r
252\r
253 This function retrieves the user readable name of a driver in the form of a\r
254 Unicode string. If the driver specified by This has a user readable name in\r
255 the language specified by Language, then a pointer to the driver name is\r
256 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
257 by This does not support the language specified by Language,\r
258 then EFI_UNSUPPORTED is returned.\r
259\r
260 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
261 EFI_COMPONENT_NAME_PROTOCOL instance.\r
262\r
263 @param Language[in] A pointer to a Null-terminated ASCII string\r
264 array indicating the language. This is the\r
265 language of the driver name that the caller is\r
266 requesting, and it must match one of the\r
267 languages specified in SupportedLanguages. The\r
268 number of languages supported by a driver is up\r
269 to the driver writer. Language is specified\r
8469b662 270 in RFC 4646 or ISO 639-2 language code format.\r
87f8ccbe 271\r
272 @param DriverName[out] A pointer to the Unicode string to return.\r
273 This Unicode string is the name of the\r
274 driver specified by This in the language\r
275 specified by Language.\r
276\r
277 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
278 This and the language specified by Language was\r
279 returned in DriverName.\r
280\r
281 @retval EFI_INVALID_PARAMETER Language is NULL.\r
282\r
283 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
284\r
285 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
286 the language specified by Language.\r
287\r
288**/\r
289EFI_STATUS\r
290EFIAPI\r
291CirrusLogic5430ComponentNameGetDriverName (\r
292 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
293 IN CHAR8 *Language,\r
294 OUT CHAR16 **DriverName\r
295 );\r
296\r
297\r
298/**\r
299 Retrieves a Unicode string that is the user readable name of the controller\r
300 that is being managed by a driver.\r
301\r
302 This function retrieves the user readable name of the controller specified by\r
303 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
304 driver specified by This has a user readable name in the language specified by\r
305 Language, then a pointer to the controller name is returned in ControllerName,\r
306 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
307 managing the controller specified by ControllerHandle and ChildHandle,\r
308 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
309 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
310\r
311 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
312 EFI_COMPONENT_NAME_PROTOCOL instance.\r
313\r
314 @param ControllerHandle[in] The handle of a controller that the driver\r
315 specified by This is managing. This handle\r
316 specifies the controller whose name is to be\r
317 returned.\r
318\r
319 @param ChildHandle[in] The handle of the child controller to retrieve\r
320 the name of. This is an optional parameter that\r
321 may be NULL. It will be NULL for device\r
322 drivers. It will also be NULL for a bus drivers\r
323 that wish to retrieve the name of the bus\r
324 controller. It will not be NULL for a bus\r
325 driver that wishes to retrieve the name of a\r
326 child controller.\r
327\r
328 @param Language[in] A pointer to a Null-terminated ASCII string\r
329 array indicating the language. This is the\r
330 language of the driver name that the caller is\r
331 requesting, and it must match one of the\r
332 languages specified in SupportedLanguages. The\r
333 number of languages supported by a driver is up\r
334 to the driver writer. Language is specified in\r
8469b662 335 RFC 4646 or ISO 639-2 language code format.\r
87f8ccbe 336\r
337 @param ControllerName[out] A pointer to the Unicode string to return.\r
338 This Unicode string is the name of the\r
339 controller specified by ControllerHandle and\r
340 ChildHandle in the language specified by\r
341 Language from the point of view of the driver\r
342 specified by This.\r
343\r
344 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
345 the language specified by Language for the\r
346 driver specified by This was returned in\r
347 DriverName.\r
348\r
b28b274d 349 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
87f8ccbe 350\r
351 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
352 EFI_HANDLE.\r
353\r
354 @retval EFI_INVALID_PARAMETER Language is NULL.\r
355\r
356 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
357\r
358 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
359 managing the controller specified by\r
360 ControllerHandle and ChildHandle.\r
361\r
362 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
363 the language specified by Language.\r
364\r
365**/\r
366EFI_STATUS\r
367EFIAPI\r
368CirrusLogic5430ComponentNameGetControllerName (\r
369 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
370 IN EFI_HANDLE ControllerHandle,\r
371 IN EFI_HANDLE ChildHandle OPTIONAL,\r
372 IN CHAR8 *Language,\r
373 OUT CHAR16 **ControllerName\r
374 );\r
375\r
376\r
377//\r
378// Local Function Prototypes\r
379//\r
380VOID\r
381InitializeGraphicsMode (\r
382 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
383 CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData\r
384 );\r
385\r
386VOID\r
387SetPaletteColor (\r
388 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
389 UINTN Index,\r
390 UINT8 Red,\r
391 UINT8 Green,\r
392 UINT8 Blue\r
393 );\r
394\r
395VOID\r
396SetDefaultPalette (\r
397 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
398 );\r
399\r
400VOID\r
401DrawLogo (\r
402 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
403 UINTN ScreenWidth,\r
404 UINTN ScreenHeight\r
405 );\r
406\r
407VOID\r
408outb (\r
409 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
410 UINTN Address,\r
411 UINT8 Data\r
412 );\r
413\r
414VOID\r
415outw (\r
416 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
417 UINTN Address,\r
418 UINT16 Data\r
419 );\r
420\r
421UINT8\r
422inb (\r
423 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
424 UINTN Address\r
425 );\r
426\r
427UINT16\r
428inw (\r
429 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
430 UINTN Address\r
431 );\r
432\r
31f9e631 433EFI_STATUS\r
434CirrusLogic5430VideoModeSetup (\r
435 CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
436 );\r
437\r
87f8ccbe 438#endif\r