VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxVgaDxe/VBoxVga.h@ 33110

Last change on this file since 33110 was 33086, checked in by vboxsync, 14 years ago

EFI: Introduces Video Mode 1920x1200.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette