]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/PlatformDxe/Platform.c
OvmfPkg: PlatformDxe: set preferred video resolution from platform config
[mirror_edk2.git] / OvmfPkg / PlatformDxe / Platform.c
1 /** @file
2 This driver effectuates OVMF's platform configuration settings and exposes
3 them via HII.
4
5 Copyright (C) 2014, Red Hat, Inc.
6 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
7
8 This program and the accompanying materials are licensed and made available
9 under the terms and conditions of the BSD License which accompanies this
10 distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 **/
16
17 #include <Library/DebugLib.h>
18 #include <Library/UefiBootServicesTableLib.h>
19
20 #include "PlatformConfig.h"
21
22 /**
23 Load and execute the platform configuration.
24
25 @retval EFI_SUCCESS Configuration loaded and executed.
26 @return Status codes from PlatformConfigLoad().
27 **/
28 STATIC
29 EFI_STATUS
30 EFIAPI
31 ExecutePlatformConfig (
32 VOID
33 )
34 {
35 EFI_STATUS Status;
36 PLATFORM_CONFIG PlatformConfig;
37 UINT64 OptionalElements;
38
39 Status = PlatformConfigLoad (&PlatformConfig, &OptionalElements);
40 if (EFI_ERROR (Status)) {
41 DEBUG (((Status == EFI_NOT_FOUND) ? EFI_D_VERBOSE : EFI_D_ERROR,
42 "%a: failed to load platform config: %r\n", __FUNCTION__, Status));
43 return Status;
44 }
45
46 if (OptionalElements & PLATFORM_CONFIG_F_GRAPHICS_RESOLUTION) {
47 //
48 // Pass the preferred resolution to GraphicsConsoleDxe via dynamic PCDs.
49 //
50 PcdSet32 (PcdVideoHorizontalResolution,
51 PlatformConfig.HorizontalResolution);
52 PcdSet32 (PcdVideoVerticalResolution,
53 PlatformConfig.VerticalResolution);
54 }
55
56 return EFI_SUCCESS;
57 }
58
59
60 /**
61 Entry point for this driver.
62
63 @param[in] ImageHandle Image handle of this driver.
64 @param[in] SystemTable Pointer to SystemTable.
65
66 @retval EFI_SUCESS Driver has loaded successfully.
67
68 **/
69 EFI_STATUS
70 EFIAPI
71 PlatformInit (
72 IN EFI_HANDLE ImageHandle,
73 IN EFI_SYSTEM_TABLE *SystemTable
74 )
75 {
76 ExecutePlatformConfig ();
77 return EFI_SUCCESS;
78 }
79
80 /**
81 Unload the driver.
82
83 @param[in] ImageHandle Handle that identifies the image to evict.
84
85 @retval EFI_SUCCESS The image has been unloaded.
86 **/
87 EFI_STATUS
88 EFIAPI
89 PlatformUnload (
90 IN EFI_HANDLE ImageHandle
91 )
92 {
93 return EFI_SUCCESS;
94 }