]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/PlatformDxe/ExI.c
UefiCpuPkg/PiSmmCpuDxeSmm: patch "gSmiCr3" with PatchInstructionX86()
[mirror_edk2.git] / Vlv2TbltDevicePkg / PlatformDxe / ExI.c
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14 Module Name:
15
16
17 ExI.c
18
19 Abstract:
20
21 ExI configuration based on setup option
22
23
24 --*/
25
26
27 #include "PlatformDxe.h"
28
29 #define PchLpcPciCfg32(Register) MmioRead32 (MmPciAddress (0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_LPC, 0, Register))
30
31 //
32 // Procedure: GetPmcBase
33 //
34 // Description: This function read content of B:D:F 0:31:0, offset 44h (for
35 // PmcBase)
36 //
37 // Input: None
38 //
39 // Output: 32 bit PmcBase
40 //
41 UINT32
42 GetPmcBase (
43 VOID
44 )
45 {
46 return (PchLpcPciCfg32 (R_PCH_LPC_PMC_BASE) & B_PCH_LPC_PMC_BASE_BAR);
47 }
48
49 /**
50 Configure ExI.
51
52 @param ImageHandle Pointer to the loaded image protocol for this driver
53 @param SystemTable Pointer to the EFI System Table
54
55 @retval EFI_SUCCESS The driver initializes correctly.
56 **/
57 VOID
58 InitExI (
59 )
60 {
61 EFI_STATUS Status;
62
63 SYSTEM_CONFIGURATION SystemConfiguration;
64 UINTN VarSize;
65
66 VarSize = sizeof(SYSTEM_CONFIGURATION);
67
68 Status = gRT->GetVariable(
69 L"Setup",
70 &gEfiNormalSetupGuid,
71 NULL,
72 &VarSize,
73 &SystemConfiguration
74 );
75
76 if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
77 //The setup variable is corrupted
78 VarSize = sizeof(SYSTEM_CONFIGURATION);
79 Status = gRT->GetVariable(
80 L"SetupRecovery",
81 &gEfiNormalSetupGuid,
82 NULL,
83 &VarSize,
84 &SystemConfiguration
85 );
86 ASSERT_EFI_ERROR (Status);
87 }
88
89 if (SystemConfiguration.ExISupport == 1) {
90 MmioOr32 ((UINTN) (GetPmcBase() + R_PCH_PMC_MTPMC1), (UINT32) BIT0+BIT1+BIT2);
91 } else if (SystemConfiguration.ExISupport == 0) {
92 MmioAnd32 ((UINTN) (GetPmcBase() + R_PCH_PMC_MTPMC1), ~((UINT32) BIT0+BIT1+BIT2)); //clear bit 0,1,2
93 }
94 }