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