3 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
8 MiscSubclassDriverEntryPoint.c
12 This driver parses the mMiscSubclassDataTable structure and reports
13 any generated data to the DataHub.
17 #include "MiscSubclassDriver.h"
19 EFI_HII_HANDLE mHiiHandle
;
22 This is the standard EFI driver point that detects whether there is a
23 MemoryConfigurationData Variable and, if so, reports memory configuration info
26 @param ImageHandle Handle for the image of this driver
27 @param SystemTable Pointer to the EFI System Table
29 @return EFI_SUCCESS if the data is successfully reported
30 @return EFI_NOT_FOUND if the HOB list could not be located.
34 LogMemorySmbiosRecord (
39 UINT64 TotalMemorySize
;
41 SMBIOS_TABLE_TYPE19
*Type19Record
;
42 EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle
;
43 EFI_SMBIOS_PROTOCOL
*Smbios
;
44 CHAR16
*Nt32MemString
;
46 Status
= gBS
->LocateProtocol (&gEfiSmbiosProtocolGuid
, NULL
, (VOID
**)&Smbios
);
47 ASSERT_EFI_ERROR (Status
);
52 // Process Memory String in form size!size ...
55 Nt32MemString
= PcdGetPtr (PcdWinNtMemorySize
);
56 for (TotalMemorySize
= 0; *Nt32MemString
!= '\0';) {
57 TotalMemorySize
+= StrDecimalToUint64 (Nt32MemString
);
58 while (*Nt32MemString
!= '\0') {
59 if (*Nt32MemString
== '!') {
68 // Convert Total Memory Size to based on KiloByte
70 TotalMemorySize
= LShiftU64 (TotalMemorySize
, 20);
72 // Generate Memory Array Mapped Address info
74 Type19Record
= AllocateZeroPool(sizeof (SMBIOS_TABLE_TYPE19
) + 2);
75 Type19Record
->Hdr
.Type
= EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS
;
76 Type19Record
->Hdr
.Length
= sizeof(SMBIOS_TABLE_TYPE19
);
77 Type19Record
->Hdr
.Handle
= 0;
78 Type19Record
->StartingAddress
= 0;
79 Type19Record
->EndingAddress
= (UINT32
)RShiftU64(TotalMemorySize
, 10) - 1;
80 Type19Record
->MemoryArrayHandle
= 0;
81 Type19Record
->PartitionWidth
= (UINT8
)(NumSlots
);
84 // Generate Memory Array Mapped Address info (TYPE 19)
86 Status
= AddSmbiosRecord (Smbios
, &MemArrayMappedAddrSmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) Type19Record
);
88 FreePool(Type19Record
);
89 ASSERT_EFI_ERROR (Status
);
97 MiscSubclassDriverEntryPoint (
98 IN EFI_HANDLE ImageHandle
,
99 IN EFI_SYSTEM_TABLE
*SystemTable
104 Standard EFI driver point. This driver parses the mMiscSubclassDataTable
105 structure and reports any generated data to the DataHub.
110 Handle for the image of this driver
113 Pointer to the EFI System Table
118 The data was successfully reported to the Data Hub.
123 EFI_STATUS EfiStatus
;
124 EFI_SMBIOS_PROTOCOL
*Smbios
;
126 EfiStatus
= gBS
->LocateProtocol(&gEfiSmbiosProtocolGuid
, NULL
, (VOID
**)&Smbios
);
128 if (EFI_ERROR(EfiStatus
)) {
129 DEBUG((EFI_D_ERROR
, "Could not locate SMBIOS protocol. %r\n", EfiStatus
));
133 mHiiHandle
= HiiAddPackages (
139 ASSERT (mHiiHandle
!= NULL
);
141 for (Index
= 0; Index
< mMiscSubclassDataTableEntries
; ++Index
) {
143 // If the entry have a function pointer, just log the data.
145 if (mMiscSubclassDataTable
[Index
].Function
!= NULL
) {
146 EfiStatus
= (*mMiscSubclassDataTable
[Index
].Function
)(
147 mMiscSubclassDataTable
[Index
].RecordData
,
151 if (EFI_ERROR(EfiStatus
)) {
152 DEBUG((EFI_D_ERROR
, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index
, EfiStatus
));
159 // Log Memory SMBIOS Record
161 EfiStatus
= LogMemorySmbiosRecord();
166 Add an SMBIOS record.
168 @param Smbios The EFI_SMBIOS_PROTOCOL instance.
169 @param SmbiosHandle A unique handle will be assigned to the SMBIOS record.
170 @param Record The data for the fixed portion of the SMBIOS record. The format of the record is
171 determined by EFI_SMBIOS_TABLE_HEADER.Type. The size of the formatted area is defined
172 by EFI_SMBIOS_TABLE_HEADER.Length and either followed by a double-null (0x0000) or
173 a set of null terminated strings and a null.
175 @retval EFI_SUCCESS Record was added.
176 @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system resources.
181 IN EFI_SMBIOS_PROTOCOL
*Smbios
,
182 OUT EFI_SMBIOS_HANDLE
*SmbiosHandle
,
183 IN EFI_SMBIOS_TABLE_HEADER
*Record
186 *SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;