summaryrefslogtreecommitdiff
path: root/Platform/BroxtonPlatformPkg/Common/Library/DxePolicyUpdateLib/DxeSaPolicyUpdate.c
blob: 2b24a9a3b0dfb137fdcce193911b1de5fca056cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/** @file
  This file is the library for SA DXE Policy initialzation.

  Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>

  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php.

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#include <DxeSaPolicyUpdate.h>


/**
  Get data for platform policy from setup options.

  @param[in] DxeSaPolicy              The pointer to get SA Policy protocol instance
  @param[in] SystemConfiguration      The pointer to get System Setup

  @retval    EFI_SUCCESS              Operation success.

**/
EFI_STATUS
EFIAPI
UpdateDxeSaPolicy (
  IN OUT SA_POLICY_PROTOCOL *SaPolicy,
  IN SYSTEM_CONFIGURATION   *SystemConfiguration
  )
{
#if defined (ENBDT_PF_ENABLE) && (ENBDT_PF_ENABLE == 1) // For ApolloLake
  PLATFORM_GOP_POLICY_PROTOCOL *GopPolicy;
  VBT_INFO                     *VbtInfo = NULL;
  EFI_PHYSICAL_ADDRESS         VbtAddress;
  UINT32                       Size;
  EFI_PEI_HOB_POINTERS         GuidHob;
#endif
  EFI_STATUS                   Status;
  SA_DXE_MISC_CONFIG           *SaDxeMiscConfig = NULL;
  IGD_PANEL_CONFIG             *IgdPanelConfig = NULL;

  DEBUG ((DEBUG_INFO, "UpdateDxeSaPolicy\n"));

  Status = GetConfigBlock ((CONFIG_BLOCK_TABLE_HEADER *) SaPolicy, &gIgdPanelConfigGuid, (VOID *) &IgdPanelConfig);
  ASSERT_EFI_ERROR (Status);

  Status = GetConfigBlock ((CONFIG_BLOCK_TABLE_HEADER *) SaPolicy, &gSaDxeMiscConfigGuid, (VOID *) &SaDxeMiscConfig);
  ASSERT_EFI_ERROR (Status);
#if defined (ENBDT_PF_ENABLE) && (ENBDT_PF_ENABLE == 1) // For ApolloLake
  DEBUG ((DEBUG_INFO, "Locate GopPolicy and GetVbtData\n"));

  //
  // Locate the GOP Policy Protocol.
  //
  GopPolicy = NULL;
  Status = gBS->LocateProtocol (
                  &gPlatformGOPPolicyGuid,
                  NULL,
                  (VOID **)&GopPolicy
                  );

  if (EFI_ERROR (Status) || (GopPolicy == NULL)) {
    return Status;
  }

  //
  // Get VBT data
  //
  VbtAddress      = 0;
  Size            = 0;
  DEBUG ((DEBUG_INFO, "GetVbtData\n"));
  Status          = GopPolicy->GetVbtData (&VbtAddress, &Size);
  if (EFI_ERROR (Status)) {
    return Status;
  }

  GuidHob.Raw = GetHobList ();
  if (GuidHob.Raw != NULL) {
    if ((GuidHob.Raw = GetNextGuidHob (&gVbtInfoGuid, GuidHob.Raw)) != NULL) {
      VbtInfo = GET_GUID_HOB_DATA (GuidHob.Guid);
      VbtInfo->VbtAddress = VbtAddress;
      VbtInfo->VbtSize = Size;
      Status = EFI_SUCCESS;
    }
  } else {
    Status = EFI_NOT_FOUND;
    return Status;
  }
#endif

  IgdPanelConfig->PFITStatus     = SystemConfiguration->PanelScaling;
  SaDxeMiscConfig->S0ixSupported = SystemConfiguration->LowPowerS0Idle;
  IgdPanelConfig->PanelSelect    = SystemConfiguration->VbtSelect;

  return EFI_SUCCESS;
}