+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
- MiscSubclassDriverEntryPoint.c\r
-\r
-Abstract:\r
-\r
- This driver parses the mMiscSubclassDataTable structure and reports\r
- any generated data to the DataHub.\r
-\r
---*/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-EFI_HII_HANDLE mHiiHandle;\r
-\r
-/**\r
- This is the standard EFI driver point that detects whether there is a\r
- MemoryConfigurationData Variable and, if so, reports memory configuration info\r
- to the DataHub.\r
-\r
- @param ImageHandle Handle for the image of this driver\r
- @param SystemTable Pointer to the EFI System Table\r
-\r
- @return EFI_SUCCESS if the data is successfully reported\r
- @return EFI_NOT_FOUND if the HOB list could not be located.\r
-\r
-**/\r
-EFI_STATUS\r
-LogMemorySmbiosRecord (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT64 TotalMemorySize;\r
- UINT8 NumSlots;\r
- SMBIOS_TABLE_TYPE19 *Type19Record;\r
- EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle;\r
- EFI_SMBIOS_PROTOCOL *Smbios;\r
- CHAR16 *UnixMemString;\r
-\r
- Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
- ASSERT_EFI_ERROR (Status);\r
- \r
- NumSlots = 1;\r
-\r
- //\r
- // Process Memory String in form size!size ...\r
- // So 64!64 is 128 MB\r
- //\r
- UnixMemString = PcdGetPtr (PcdUnixMemorySize);\r
- for (TotalMemorySize = 0; *UnixMemString != '\0';) {\r
- TotalMemorySize += StrDecimalToUint64 (UnixMemString);\r
- while (*UnixMemString != '\0') {\r
- if (*UnixMemString == '!') {\r
- UnixMemString++; \r
- break;\r
- }\r
- UnixMemString++;\r
- }\r
- }\r
-\r
- //\r
- // Convert Total Memory Size to based on KiloByte\r
- //\r
- TotalMemorySize = LShiftU64 (TotalMemorySize, 20);\r
- //\r
- // Generate Memory Array Mapped Address info\r
- //\r
- Type19Record = AllocateZeroPool(sizeof (SMBIOS_TABLE_TYPE19) + 2);\r
- Type19Record->Hdr.Type = EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS;\r
- Type19Record->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE19);\r
- Type19Record->Hdr.Handle = 0;\r
- Type19Record->StartingAddress = 0;\r
- Type19Record->EndingAddress = (UINT32)RShiftU64(TotalMemorySize, 10) - 1;\r
- Type19Record->MemoryArrayHandle = 0;\r
- Type19Record->PartitionWidth = (UINT8)(NumSlots); \r
-\r
- //\r
- // Generate Memory Array Mapped Address info (TYPE 19)\r
- //\r
- Status = AddSmbiosRecord (Smbios, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record);\r
-\r
- FreePool(Type19Record);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-MiscSubclassDriverEntryPoint (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-/*++\r
-Description:\r
-\r
- Standard EFI driver point. This driver parses the mMiscSubclassDataTable\r
- structure and reports any generated data to the DataHub.\r
-\r
-Arguments:\r
-\r
- ImageHandle\r
- Handle for the image of this driver\r
-\r
- SystemTable\r
- Pointer to the EFI System Table\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS\r
- The data was successfully reported to the Data Hub.\r
-\r
---*/\r
-{\r
- UINTN Index;\r
- EFI_STATUS EfiStatus;\r
- EFI_SMBIOS_PROTOCOL *Smbios; \r
-\r
- EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
-\r
- if (EFI_ERROR(EfiStatus)) {\r
- DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));\r
- return EfiStatus;\r
- }\r
-\r
- mHiiHandle = HiiAddPackages (\r
- &gEfiCallerIdGuid,\r
- NULL,\r
- MiscSubclassStrings,\r
- NULL\r
- );\r
- ASSERT (mHiiHandle != NULL);\r
-\r
- for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r
- //\r
- // If the entry have a function pointer, just log the data.\r
- //\r
- if (mMiscSubclassDataTable[Index].Function != NULL) {\r
- EfiStatus = (*mMiscSubclassDataTable[Index].Function)(\r
- mMiscSubclassDataTable[Index].RecordData,\r
- Smbios\r
- );\r
-\r
- if (EFI_ERROR(EfiStatus)) {\r
- DEBUG((EFI_D_ERROR, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index, EfiStatus));\r
- return EfiStatus;\r
- }\r
- }\r
- }\r
-\r
- //\r
- // Log Memory SMBIOS Record\r
- //\r
- EfiStatus = LogMemorySmbiosRecord();\r
- return EfiStatus;\r
-}\r
-\r
-/**\r
- Add an SMBIOS record.\r
-\r
- @param Smbios The EFI_SMBIOS_PROTOCOL instance.\r
- @param SmbiosHandle A unique handle will be assigned to the SMBIOS record.\r
- @param Record The data for the fixed portion of the SMBIOS record. The format of the record is\r
- determined by EFI_SMBIOS_TABLE_HEADER.Type. The size of the formatted area is defined \r
- by EFI_SMBIOS_TABLE_HEADER.Length and either followed by a double-null (0x0000) or \r
- a set of null terminated strings and a null.\r
-\r
- @retval EFI_SUCCESS Record was added.\r
- @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system resources.\r
-\r
-**/\r
-EFI_STATUS\r
-AddSmbiosRecord (\r
- IN EFI_SMBIOS_PROTOCOL *Smbios,\r
- OUT EFI_SMBIOS_HANDLE *SmbiosHandle,\r
- IN EFI_SMBIOS_TABLE_HEADER *Record\r
- )\r
-{\r
- *SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
- return Smbios->Add (\r
- Smbios,\r
- NULL,\r
- SmbiosHandle,\r
- Record\r
- );\r
-}\r
-\r