VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVga.h@ 69498

Last change on this file since 69498 was 69498, checked in by vboxsync, 7 years ago

backed out r118835 as it incorrectly updated the 'This file is based on' file headers.

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