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