]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscPhysicalArrayFunction.c
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / SmBiosMiscDxe / MiscPhysicalArrayFunction.c
1 /*++
2
3 Copyright (c) 2012 - 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
15 Module Name:
16
17 MiscPhysicalArrayFunction.c
18
19 Abstract:
20
21 BIOS system Physical Array boot time changes.
22 SMBIOS type 16.
23
24 --*/
25
26
27 #include "CommonHeader.h"
28 #include "MiscSubclassDriver.h"
29
30
31
32 /**
33 This function makes boot time changes to the contents of the
34 MiscPhysicalArrayFunction (Type 16).
35
36 @param RecordData Pointer to copy of RecordData from the Data Table.
37
38 @retval EFI_SUCCESS All parameters were valid.
39 @retval EFI_UNSUPPORTED Unexpected RecordType value.
40 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
41
42 **/
43
44 MISC_SMBIOS_TABLE_FUNCTION(MiscPhysicalMemoryArray)
45 {
46 EFI_STATUS Status;
47 EFI_SMBIOS_HANDLE SmbiosHandle;
48 SMBIOS_TABLE_TYPE16 *SmbiosRecord;
49 EFI_MEMORY_ARRAY_LOCATION_DATA *ForType16InputData;
50 UINT32 TopOfMemory = 8 * 1024 * 1024;
51
52 //
53 // First check for invalid parameters.
54 //
55 if (RecordData == NULL) {
56 return EFI_INVALID_PARAMETER;
57 }
58
59 ForType16InputData = (EFI_MEMORY_ARRAY_LOCATION_DATA *)RecordData;
60
61 //
62 // Two zeros following the last string.
63 //
64 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE16) + 1);
65 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE16) + 1);
66
67 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY;
68 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE16);
69
70 //
71 // Make handle chosen by smbios protocol.add automatically.
72 //
73 SmbiosRecord->Hdr.Handle = 0;
74
75 //
76 // ReleaseDate will be the 3rd optional string following the formatted structure.
77 //
78 SmbiosRecord->Location = *(UINT8 *) &ForType16InputData ->MemoryArrayLocation;
79 SmbiosRecord->Use = *(UINT8 *) &ForType16InputData ->MemoryArrayUse;
80 SmbiosRecord->MemoryErrorCorrection = *(UINT8 *) &ForType16InputData->MemoryErrorCorrection;
81
82 //
83 // System does not provide the error information structure
84 //
85 SmbiosRecord->MemoryErrorInformationHandle = 0xFFFE;
86
87 //
88 // Maximum memory capacity
89 //
90 SmbiosRecord-> MaximumCapacity = TopOfMemory;
91 SmbiosRecord-> NumberOfMemoryDevices= 0x02;
92
93 //
94 // Now we have got the full smbios record, call smbios protocol to add this record.
95 //
96 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
97 Status = Smbios-> Add(
98 Smbios,
99 NULL,
100 &SmbiosHandle,
101 (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
102 );
103 FreePool(SmbiosRecord);
104 return Status;
105
106 }