]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/PlatformDxe/ExI.c
ad667b0bd887c755a96e6b9044bbed407be4dab2
[mirror_edk2.git] / Vlv2TbltDevicePkg / PlatformDxe / ExI.c
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7
8
9 Module Name:
10
11
12 ExI.c
13
14 Abstract:
15
16 ExI configuration based on setup option
17
18
19 --*/
20
21
22 #include "PlatformDxe.h"
23
24 #define PchLpcPciCfg32(Register) MmioRead32 (MmPciAddress (0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_LPC, 0, Register))
25
26 //
27 // Procedure: GetPmcBase
28 //
29 // Description: This function read content of B:D:F 0:31:0, offset 44h (for
30 // PmcBase)
31 //
32 // Input: None
33 //
34 // Output: 32 bit PmcBase
35 //
36 UINT32
37 GetPmcBase (
38 VOID
39 )
40 {
41 return (PchLpcPciCfg32 (R_PCH_LPC_PMC_BASE) & B_PCH_LPC_PMC_BASE_BAR);
42 }
43
44 /**
45 Configure ExI.
46
47 @param ImageHandle Pointer to the loaded image protocol for this driver
48 @param SystemTable Pointer to the EFI System Table
49
50 @retval EFI_SUCCESS The driver initializes correctly.
51 **/
52 VOID
53 InitExI (
54 )
55 {
56 EFI_STATUS Status;
57
58 SYSTEM_CONFIGURATION SystemConfiguration;
59 UINTN VarSize;
60
61 VarSize = sizeof(SYSTEM_CONFIGURATION);
62
63 Status = gRT->GetVariable(
64 L"Setup",
65 &gEfiNormalSetupGuid,
66 NULL,
67 &VarSize,
68 &SystemConfiguration
69 );
70
71 if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
72 //The setup variable is corrupted
73 VarSize = sizeof(SYSTEM_CONFIGURATION);
74 Status = gRT->GetVariable(
75 L"SetupRecovery",
76 &gEfiNormalSetupGuid,
77 NULL,
78 &VarSize,
79 &SystemConfiguration
80 );
81 ASSERT_EFI_ERROR (Status);
82 }
83
84 if (SystemConfiguration.ExISupport == 1) {
85 MmioOr32 ((UINTN) (GetPmcBase() + R_PCH_PMC_MTPMC1), (UINT32) BIT0+BIT1+BIT2);
86 } else if (SystemConfiguration.ExISupport == 0) {
87 MmioAnd32 ((UINTN) (GetPmcBase() + R_PCH_PMC_MTPMC1), ~((UINT32) BIT0+BIT1+BIT2)); //clear bit 0,1,2
88 }
89 }