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
|
/** @file
Copies the memory related timing and configuration information into the
Compatible BIOS data (BDAT) table.
@copyright
Copyright (c) 2010 - 2012 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.
This file contains an 'Intel Peripheral Driver' and uniquely
identified as "Intel Reference Module" and is
licensed for Intel CPUs and chipsets under the terms of your
license agreement with Intel or your vendor. This file may
be modified by the user, subject to additional terms of the
license agreement.
**/
#include "BdatAccessHandler.h"
#include "McMain.h"
#ifdef BDAT_SUPPORT
///
/// Data definitions & structures
///
EFI_GUID gMemoryInitHobGuid = EFI_MEMORY_RESTORE_DATA_GUID;
///
/// Bdat Access Handler instance data structure
///
STATIC EFI_BDAT_ACPI_DESCRIPTION_TABLE mRmtAcpiTable = {
EFI_BDAT_TABLE_SIGNATURE, ///< Signature
sizeof (EFI_BDAT_ACPI_DESCRIPTION_TABLE), ///< Length
0x01, ///< Revision [01]
0, ///< Checksum
' ', ///< OEM ID
' ', ///< .
' ', ///< .
' ', ///< .
' ', ///< .
' ', ///< .
0, ///< OEM Table ID
0, ///< OEM Revision [0x00000000]
0, ///< Creator ID
0, ///< Creator Revision
0, ///< System Memory Address Space ID
0,
0,
0,
EFI_BDAT_ACPI_POINTER,
};
#endif
/**
Entry point of the Bdat RMT Access Handler.
@param[in] DxePlatformSaPolicy : A pointer to Dxe platform policy
@param[in] HobList : A pointer to the HOB list
@param[in] AcpiTable : A pointer to ACPI table
@retval EFI_SUCCESS: Driver initialized successfully
@exception EFI_UNSUPPORTED: A needed driver was not located
@retval EFI_OUT_OF_RESOURCES: Could not allocate needed resources
**/
EFI_STATUS
BdatRmtHandler (
IN DXE_PLATFORM_SA_POLICY_PROTOCOL *DxePlatformSaPolicy,
IN VOID *HobList,
IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable
)
{
#ifdef BDAT_SUPPORT
EFI_STATUS Status;
VOID *Buffer;
RmtData *rmtBdat;
HOB_SAVE_MEMORY_DATA *RmtHobData;
UINTN AcpiTableKey;
UINT64 TempBuffer;
UINT16 BufferSize;
UINT32 *ScratchPad;
Buffer = NULL;
rmtBdat = NULL;
BufferSize = 0;
Status = EFI_SUCCESS;
if (!DxePlatformSaPolicy->MemoryConfig->RmtBdatEnable) {
return EFI_UNSUPPORTED;
}
///
/// Get the Compatible BIOS structure PMT BDAT from the HOB.
///
RmtHobData = GetNextGuidHob (&gMemoryInitHobGuid, HobList);
if (RmtHobData == NULL) {
return EFI_UNSUPPORTED;
}
///
/// Allocate and clear memory, in 4kb pages
///
BufferSize = sizeof (RmtData);
Status = (gBS->AllocatePages) (AllocateAnyPages, EfiReservedMemoryType, EFI_SIZE_TO_PAGES (BufferSize), (EFI_PHYSICAL_ADDRESS *) &Buffer);
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
ZeroMem (Buffer, BufferSize);
///
/// Copy BDAT structure to Reserved memory
///
CopyMem (Buffer, &RmtHobData->MrcData.Rmt, BufferSize);
TempBuffer = EFI_SIGNATURE_64 ('I', 'N', 'T', 'E', 'L', 0, 0, 0);
///
/// RMT ACPI table
///
DEBUG ((EFI_D_INFO, "In RMT ACPI table\n"));
CopyMem (&mRmtAcpiTable.Header.OemId, &TempBuffer, sizeof (mRmtAcpiTable.Header.OemId));
mRmtAcpiTable.Header.OemTableId = EFI_SIGNATURE_64 ('H', 'S', 'W', '-', 'L', 'P', 'T', 0);
mRmtAcpiTable.Header.CreatorId = CREATOR_ID_INTEL;
mRmtAcpiTable.Header.CreatorRevision = CREATOR_REV_INTEL;
mRmtAcpiTable.Header.OemRevision = ACPI_BDAT_OEM_REV;
///
/// Copy pointer to RMT ACPI BDAT structure and protocol.
///
mRmtAcpiTable.BdatGas.Address = (EFI_PHYSICAL_ADDRESS) Buffer;
///
/// Install RMT BDAT into RMT ACPI table
///
AcpiTableKey = 0;
Status = AcpiTable->InstallAcpiTable (
AcpiTable,
&mRmtAcpiTable,
sizeof (EFI_BDAT_ACPI_DESCRIPTION_TABLE),
&AcpiTableKey
);
ASSERT_EFI_ERROR (Status);
///
/// Write scratchpad register in MCHBAR space with address of the RMT ACPI BDAT structure.
///
ScratchPad = (UINT32 *) ((UINT64) (RmtHobData->MrcData.SysIn.Inputs.MchBarBaseAddress) + NCDECS_CR_SCRATCHPAD_NCU_2_REG);
*ScratchPad = (UINT32) ((UINT64) Buffer);
return Status;
#else
return EFI_UNSUPPORTED;
#endif
}
|