3 Copyright (c) 2006 - 2009, 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
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE19
));
81 ZeroMem(Type19Record
, sizeof(SMBIOS_TABLE_TYPE19
));
82 Type19Record
->Hdr
.Type
= EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS
;
83 Type19Record
->Hdr
.Length
= sizeof(SMBIOS_TABLE_TYPE19
);
84 Type19Record
->Hdr
.Handle
= 0;
85 Type19Record
->StartingAddress
= 0;
86 Type19Record
->EndingAddress
= (UINT32
)RShiftU64(TotalMemorySize
, 10) - 1;
87 Type19Record
->MemoryArrayHandle
= 0;
88 Type19Record
->PartitionWidth
= (UINT8
)(NumSlots
);
91 // Generate Memory Array Mapped Address info (TYPE 19)
93 MemArrayMappedAddrSmbiosHandle
= 0;
94 Status
= Smbios
->Add (Smbios
, NULL
, &MemArrayMappedAddrSmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) Type19Record
);
95 FreePool(Type19Record
);
96 ASSERT_EFI_ERROR (Status
);
104 MiscSubclassDriverEntryPoint (
105 IN EFI_HANDLE ImageHandle
,
106 IN EFI_SYSTEM_TABLE
*SystemTable
111 Standard EFI driver point. This driver parses the mMiscSubclassDataTable
112 structure and reports any generated data to the DataHub.
117 Handle for the image of this driver
120 Pointer to the EFI System Table
125 The data was successfully reported to the Data Hub.
130 EFI_STATUS EfiStatus
;
131 EFI_SMBIOS_PROTOCOL
*Smbios
;
133 EfiStatus
= gBS
->LocateProtocol(&gEfiSmbiosProtocolGuid
, NULL
, (VOID
**)&Smbios
);
135 if (EFI_ERROR(EfiStatus
)) {
136 DEBUG((EFI_D_ERROR
, "Could not locate SMBIOS protocol. %r\n", EfiStatus
));
140 mHiiHandle
= HiiAddPackages (
146 ASSERT (mHiiHandle
!= NULL
);
148 for (Index
= 0; Index
< mMiscSubclassDataTableEntries
; ++Index
) {
150 // If the entry have a function pointer, just log the data.
152 if (mMiscSubclassDataTable
[Index
].Function
!= NULL
) {
153 EfiStatus
= (*mMiscSubclassDataTable
[Index
].Function
)(
154 mMiscSubclassDataTable
[Index
].RecordData
,
158 if (EFI_ERROR(EfiStatus
)) {
159 DEBUG((EFI_D_ERROR
, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index
, EfiStatus
));
166 // Log Memory SMBIOS Record
168 EfiStatus
= LogMemorySmbiosRecord();