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
|
/** @file
This library will determine memory configuration information from the chipset
and memory and create SMBIOS memory structures appropriately.
Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "SmbiosMemory.h"
//
// Physical Memory Array (Type 16) data
//
GLOBAL_REMOVE_IF_UNREFERENCED SMBIOS_TABLE_TYPE16 SmbiosTableType16Data = {
{ EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, sizeof (SMBIOS_TABLE_TYPE16), 0 },
MemoryArrayLocationSystemBoard, ///< Location
MemoryArrayUseSystemMemory, ///< Use
TO_BE_FILLED, ///< MemoryErrorCorrection
TO_BE_FILLED, ///< MaximumCapacity
0xFFFE, ///< MemoryErrorInformationHandle
TO_BE_FILLED, ///< NumberOfMemoryDevices
0, ///< ExtendedMaximumCapacity
};
/**
This function installs SMBIOS Table Type 16 (Physical Memory Array).
@param[in] SmbiosProtocol Instance of Smbios Protocol.
@retval EFI_SUCCESS If the data is successfully reported.
@retval EFI_OUT_OF_RESOURCES If not able to get resources.
**/
EFI_STATUS
InstallSmbiosType16 (
VOID
)
{
EFI_STATUS Status;
UINT8 ChannelASlotMap;
UINT8 ChannelBSlotMap;
UINT8 BitIndex;
UINT16 MaxSockets;
UINT8 ChannelASlotNum;
UINT8 ChannelBSlotNum;
//
// Get Memory size parameters for each rank from the chipset registers
//
Status = gBS->LocateProtocol (&gMemInfoProtocolGuid, NULL, (VOID **) &mMemInfoHob);
//
// Configure the data for TYPE 16 SMBIOS Structure
//
//
// Create physical array and associated data for all mainboard memory
//
SmbiosTableType16Data.MemoryErrorCorrection = MemoryErrorCorrectionNone;
//
// Get the Memory DIMM info from policy protocols
//
ChannelASlotMap = 0x01;
ChannelBSlotMap = 0x01;
ChannelASlotNum = 0;
ChannelBSlotNum = 0;
for (BitIndex = 0; BitIndex < 8; BitIndex++) {
if ((ChannelASlotMap >> BitIndex) & BIT0) {
ChannelASlotNum++;
}
if ((ChannelBSlotMap >> BitIndex) & BIT0) {
ChannelBSlotNum++;
}
}
MaxSockets = ChannelASlotNum + ChannelBSlotNum;
if (mMemInfoHob->MemInfoData.ddrType == 0) {
if ((MAX_RANK_CAPACITY_DDR4 * SA_MC_MAX_SIDES * MaxSockets) < SMBIOS_TYPE16_USE_EXTENDED_MAX_CAPACITY) {
SmbiosTableType16Data.MaximumCapacity = MAX_RANK_CAPACITY_DDR4 * SA_MC_MAX_SIDES * MaxSockets;
} else {
SmbiosTableType16Data.MaximumCapacity = SMBIOS_TYPE16_USE_EXTENDED_MAX_CAPACITY;
SmbiosTableType16Data.ExtendedMaximumCapacity = ((UINT64) MAX_RANK_CAPACITY_DDR4) * SA_MC_MAX_SIDES * MaxSockets * 1024; // Convert from KB to Byte
}
} else {
if ((MAX_RANK_CAPACITY * SA_MC_MAX_SIDES * MaxSockets) < SMBIOS_TYPE16_USE_EXTENDED_MAX_CAPACITY) {
SmbiosTableType16Data.MaximumCapacity = MAX_RANK_CAPACITY * SA_MC_MAX_SIDES * MaxSockets;
} else {
SmbiosTableType16Data.MaximumCapacity = SMBIOS_TYPE16_USE_EXTENDED_MAX_CAPACITY;
SmbiosTableType16Data.ExtendedMaximumCapacity = ((UINT64) MAX_RANK_CAPACITY) * SA_MC_MAX_SIDES * MaxSockets * 1024; // Convert from KB to Byte
}
}
SmbiosTableType16Data.NumberOfMemoryDevices = MaxSockets;
//
// Install SMBIOS Table Type 16
//
Status = AddSmbiosEntry ((EFI_SMBIOS_TABLE_HEADER *) &SmbiosTableType16Data, NULL, 0, &mSmbiosType16Handle);
DEBUG ((DEBUG_INFO, "\nInstall SMBIOS Table Type 16"));
return Status;
}
|