3 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 MiscSubclassDriverEntryPoint.c
18 This driver parses the mMiscSubclassDataTable structure and reports
19 any generated data to the DataHub.
23 #include "MiscSubclassDriver.h"
25 EFI_HII_HANDLE mHiiHandle
;
28 This is the standard EFI driver point that detects whether there is a
29 MemoryConfigurationData Variable and, if so, reports memory configuration info
32 @param ImageHandle Handle for the image of this driver
33 @param SystemTable Pointer to the EFI System Table
35 @return EFI_SUCCESS if the data is successfully reported
36 @return EFI_NOT_FOUND if the HOB list could not be located.
40 LogMemorySmbiosRecord (
45 UINT64 TotalMemorySize
;
47 SMBIOS_TABLE_TYPE19
*Type19Record
;
48 EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle
;
49 EFI_SMBIOS_PROTOCOL
*Smbios
;
50 CHAR16
*Nt32MemString
;
52 Status
= gBS
->LocateProtocol (&gEfiSmbiosProtocolGuid
, NULL
, (VOID
**)&Smbios
);
53 ASSERT_EFI_ERROR (Status
);
58 // Process Memory String in form size!size ...
61 Nt32MemString
= PcdGetPtr (PcdWinNtMemorySize
);
62 for (TotalMemorySize
= 0; *Nt32MemString
!= '\0';) {
63 TotalMemorySize
+= StrDecimalToUint64 (Nt32MemString
);
64 while (*Nt32MemString
!= '\0') {
65 if (*Nt32MemString
== '!') {
74 // Convert Total Memory Size to based on KiloByte
76 TotalMemorySize
= LShiftU64 (TotalMemorySize
, 20);
78 // Generate Memory Array Mapped Address info
80 Type19Record
= AllocateZeroPool(sizeof (SMBIOS_TABLE_TYPE19
) + 2);
81 Type19Record
->Hdr
.Type
= EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS
;
82 Type19Record
->Hdr
.Length
= sizeof(SMBIOS_TABLE_TYPE19
);
83 Type19Record
->Hdr
.Handle
= 0;
84 Type19Record
->StartingAddress
= 0;
85 Type19Record
->EndingAddress
= (UINT32
)RShiftU64(TotalMemorySize
, 10) - 1;
86 Type19Record
->MemoryArrayHandle
= 0;
87 Type19Record
->PartitionWidth
= (UINT8
)(NumSlots
);
90 // Generate Memory Array Mapped Address info (TYPE 19)
92 Status
= AddSmbiosRecord (Smbios
, &MemArrayMappedAddrSmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) Type19Record
);
94 FreePool(Type19Record
);
95 ASSERT_EFI_ERROR (Status
);
103 MiscSubclassDriverEntryPoint (
104 IN EFI_HANDLE ImageHandle
,
105 IN EFI_SYSTEM_TABLE
*SystemTable
110 Standard EFI driver point. This driver parses the mMiscSubclassDataTable
111 structure and reports any generated data to the DataHub.
116 Handle for the image of this driver
119 Pointer to the EFI System Table
124 The data was successfully reported to the Data Hub.
129 EFI_STATUS EfiStatus
;
130 EFI_SMBIOS_PROTOCOL
*Smbios
;
132 EfiStatus
= gBS
->LocateProtocol(&gEfiSmbiosProtocolGuid
, NULL
, (VOID
**)&Smbios
);
134 if (EFI_ERROR(EfiStatus
)) {
135 DEBUG((EFI_D_ERROR
, "Could not locate SMBIOS protocol. %r\n", EfiStatus
));
139 mHiiHandle
= HiiAddPackages (
145 ASSERT (mHiiHandle
!= NULL
);
147 for (Index
= 0; Index
< mMiscSubclassDataTableEntries
; ++Index
) {
149 // If the entry have a function pointer, just log the data.
151 if (mMiscSubclassDataTable
[Index
].Function
!= NULL
) {
152 EfiStatus
= (*mMiscSubclassDataTable
[Index
].Function
)(
153 mMiscSubclassDataTable
[Index
].RecordData
,
157 if (EFI_ERROR(EfiStatus
)) {
158 DEBUG((EFI_D_ERROR
, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index
, EfiStatus
));
165 // Log Memory SMBIOS Record
167 EfiStatus
= LogMemorySmbiosRecord();
172 Add an SMBIOS record.
174 @param Smbios The EFI_SMBIOS_PROTOCOL instance.
175 @param SmbiosHandle A unique handle will be assigned to the SMBIOS record.
176 @param Record The data for the fixed portion of the SMBIOS record. The format of the record is
177 determined by EFI_SMBIOS_TABLE_HEADER.Type. The size of the formatted area is defined
178 by EFI_SMBIOS_TABLE_HEADER.Length and either followed by a double-null (0x0000) or
179 a set of null terminated strings and a null.
181 @retval EFI_SUCCESS Record was added.
182 @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system resources.
187 IN EFI_SMBIOS_PROTOCOL
*Smbios
,
188 OUT EFI_SMBIOS_HANDLE
*SmbiosHandle
,
189 IN EFI_SMBIOS_TABLE_HEADER
*Record
192 *SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;