summaryrefslogtreecommitdiff
path: root/Board/EM/MeWrapper/MePlatformPolicy/Pei/MePeiPolicyInit.c
blob: f5343034c72680645bf4a813c95e38a7739d3121 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*++
  This file contains a 'Sample Driver' and is licensed as such  
  under the terms of your license agreement with Intel or your  
  vendor.  This file may be modified by the user, subject to    
  the additional terms of the license agreement                 
--*/

/*++

Copyright (c)  1999 - 2010 Intel Corporation. All rights reserved
This software and associated documentation (if any) is furnished
under a license and may only be used or copied in accordance
with the terms of the license. Except as permitted by such
license, no part of this software or documentation may be
reproduced, stored in a retrieval system, or transmitted in any
form or by any means without the express written consent of
Intel Corporation.

Module Name:

  MePeiPolicyInit.c
  
Abstract: 
  
  This file is SampleCode for Intel ME PEI Platform Policy initialzation.

--*/
#include <Token.h>
#include "MePeiPolicyInit.h"
#include <Ppi\PchPlatformPolicy\PchPlatformPolicy.h>
#include <SetupDataDefinition.h>

#define SETUP_GUID { 0xEC87D643, 0xEBA4, 0x4BB5, 0xA1, 0xE5, 0x3F, 0x3E, 0x36, 0xB2, 0x0D, 0xA9 }
static EFI_GUID	   gSetupGuid = SETUP_GUID;


//
// Function implementations
//
VOID
PrepareThermalHob (
  IN EFI_PEI_SERVICES          **PeiServices
)
{
  EFI_STATUS                 Status;
  EFI_HOB_GUID_TYPE          *Hob;
  UINT8                      TsOnDimm[4];
  EFI_GUID                   gPchPolicyPpiGuid = PCH_PLATFORM_POLICY_PPI_GUID;
  PCH_PLATFORM_POLICY_PPI    *PchPlatformPolicy;
  EFI_GUID                   gDimmTsInfoGuid = DIMM_TS_INFO_GUID;

  Status = (**PeiServices).LocatePpi (PeiServices, &gPchPolicyPpiGuid, 0,
                      NULL, (VOID **)&PchPlatformPolicy);

  if(EFI_ERROR(Status))
  {
    return;
  }
  // Build the GUID'd HOB for DXE
  Status = (*PeiServices)->CreateHob (
                             PeiServices,
                             EFI_HOB_TYPE_GUID_EXTENSION,
                             (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + 4),
                             &Hob
                             );

  if (EFI_ERROR (Status))return;

  ((EFI_HOB_GUID_TYPE *)(Hob))->Name = gDimmTsInfoGuid;

  Hob++;

//-   TsOnDimm[0] = PchPlatformPolicy->ThermalReportConfig->ThermalReportControl->Dimm1TempReadEnable;
//-   TsOnDimm[1] = PchPlatformPolicy->ThermalReportConfig->ThermalReportControl->Dimm2TempReadEnable;
//-   TsOnDimm[2] = PchPlatformPolicy->ThermalReportConfig->ThermalReportControl->Dimm3TempReadEnable;
//-   TsOnDimm[3] = PchPlatformPolicy->ThermalReportConfig->ThermalReportControl->Dimm4TempReadEnable;

  GlueCopyMem (Hob, TsOnDimm, sizeof(TsOnDimm));

}

EFI_STATUS
MePeiPolicyInitEntryPoint (
  IN EFI_FFS_FILE_HEADER       *FfsHeader,
  IN EFI_PEI_SERVICES          **PeiServices
  )
/*++

Routine Description:

  Initilize Intel ME PEI Platform Policy
  
Arguments:

  FfsHeader               Pointer to Firmware File System file header.
  PeiServices             General purpose services available to every PEIM.

Returns:

  EFI_STATUS
  
--*/
{
  EFI_STATUS                  Status;
  PEI_ME_PLATFORM_POLICY_PPI  *MePlatformPolicyPpi;
  EFI_PEI_PPI_DESCRIPTOR      *MePlatformPolicyPpiDesc;
  EFI_PEI_READ_ONLY_VARIABLE_PPI       *VariableServices;
  UINTN                                 VariableSize;
  SETUP_DATA                            SetupData;

  //
  // Allocate descriptor and PPI structures
  //
  MePlatformPolicyPpi = (PEI_ME_PLATFORM_POLICY_PPI *) AllocateZeroPool (sizeof (PEI_ME_PLATFORM_POLICY_PPI));
  ASSERT (MePlatformPolicyPpi != NULL);
  if (MePlatformPolicyPpi == NULL) {
    return EFI_OUT_OF_RESOURCES;
  }

  MePlatformPolicyPpiDesc = (EFI_PEI_PPI_DESCRIPTOR *) AllocateZeroPool (sizeof (EFI_PEI_PPI_DESCRIPTOR));
  ASSERT (MePlatformPolicyPpiDesc != NULL);
  if (MePlatformPolicyPpiDesc == NULL) {
    return EFI_OUT_OF_RESOURCES;
  }

  //
  // Locate Variable Ppi
  //
  Status = (*PeiServices)->LocatePpi(PeiServices,
                                     &gPeiReadOnlyVariablePpiGuid,
                                     0,
                                     NULL,
                                     &VariableServices);

  //
  // Make sure we have a PPI, if not, just return.
  //
  if (!VariableServices) {
   	return EFI_UNSUPPORTED;
  }
  VariableSize = sizeof(SETUP_DATA);
  //
  // Get Setup Variable
  //
  Status = VariableServices->PeiGetVariable (
                    PeiServices,
                    L"Setup",
                    &gSetupGuid,
                    NULL,
                    &VariableSize,
                    &SetupData);

  //
  // Update Itnel PPT 
  // 
  if ( !EFI_ERROR(Status) ) {
#if IntelPTT_SUPPORT
    MePlatformPolicyPpi->FTpmSwitch = SetupData.FTpmSwitch;
#else
    MePlatformPolicyPpi->FTpmSwitch = 0;
#endif
  } else {
    MePlatformPolicyPpi->FTpmSwitch = 0;
  }

  //
  // Initialize the PPI
  //
  MePlatformPolicyPpiDesc->Flags  = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
  MePlatformPolicyPpiDesc->Guid   = &gPeiMePlatformPolicyPpiGuid;

  //
  // Update the REVISION number
  //
  MePlatformPolicyPpi->Revision = PEI_ME_PLATFORM_POLICY_PPI_REVISION_2;


  //
  // Initialize the Platform Configuration
  //
// Debug  UpdatePeiMePlatformPolicy (PeiServices, MePlatformPolicyPpi);

  MePlatformPolicyPpiDesc->Ppi = MePlatformPolicyPpi;

  ///
  /// TBD put initialize codes in here if needs
  ///
  ///
  /// Install the ME PEI Platform Policy PPI
  ///
  Status = (**PeiServices).InstallPpi (PeiServices, MePlatformPolicyPpiDesc);
  ASSERT_PEI_ERROR (PeiServices, Status);
  DEBUG ((EFI_D_INFO, "ME PEI Platform Policy PPI Installed\n"));

  return Status;
}