From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.38.112; helo=nam02-bl2-obe.outbound.protection.outlook.com; envelope-from=christopher.co@microsoft.com; receiver=edk2-devel@lists.01.org Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0112.outbound.protection.outlook.com [104.47.38.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CA1D02115412E for ; Fri, 21 Sep 2018 01:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XdaVIRvJEDKGIUn0CWfc05nxr0iKUnChXpo4jlHvORE=; b=U87tIwdtgG0eoAradrbaJ3pWZ9DRZnwJ+LutZqluvOduWBaHgJg469208UP6uFVa7NU8/ftE1uRm5zWbsRNmFzRib5GIv/SaZScZ02t776yDCqJjQnevR6h8G+9DosDHBsMT5IdFjYA1KAIRH9VcqEUZVCqof816AtuiY3IhKLE= Received: from DM5PR2101MB1128.namprd21.prod.outlook.com (52.132.133.20) by DM5PR2101MB0727.namprd21.prod.outlook.com (10.167.110.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.6; Fri, 21 Sep 2018 08:26:18 +0000 Received: from DM5PR2101MB1128.namprd21.prod.outlook.com ([fe80::81f8:300e:d90:d49]) by DM5PR2101MB1128.namprd21.prod.outlook.com ([fe80::81f8:300e:d90:d49%3]) with mapi id 15.20.1164.008; Fri, 21 Sep 2018 08:26:18 +0000 From: Chris Co To: "edk2-devel@lists.01.org" CC: Ard Biesheuvel , Leif Lindholm , Michael D Kinney Thread-Topic: [PATCH edk2-platforms 23/27] Silicon/NXP: Add i.MX6 Smbios Driver Thread-Index: AQHUUYTDxDtoZqi2LUuF+5GhGJCKwg== Date: Fri, 21 Sep 2018 08:26:15 +0000 Message-ID: <20180921082542.35768-24-christopher.co@microsoft.com> References: <20180921082542.35768-1-christopher.co@microsoft.com> In-Reply-To: <20180921082542.35768-1-christopher.co@microsoft.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MWHPR17CA0054.namprd17.prod.outlook.com (2603:10b6:300:93::16) To DM5PR2101MB1128.namprd21.prod.outlook.com (2603:10b6:4:a8::20) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2001:4898:80e8:8:388a:edc9:7085:c18] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB0727; 6:oBR0kO2hI86S7QHu4pwYOsxugUZCf3GkW7Fyn+Fj7NwjtRkbOnX+aMyOHEIrSx+28muhSixmUmfNGeGyy073gG95bPe68vYVUFXf843E13qicq2Pah7Y8iN6Us2hF5kPaVQlM7q0+5gTx8oL52q6jtrcH6BgT6ebt0p40inlAlimjq0T/hd4ifZpmkaWPKXAwYEyb+APUlHTn5KkPZXTqIOJ+T3GVa2zo2M4VTPK41gksnwhvqjRT/SkEq2T48/1ZfVkbGNEbWJmh0H/8wD03Nh/WdM+DTm76Id2xouMDFMYIfzEq8l6rvOyCqPkKKVYLKKnZNrorWQIXk+tFoqJJ+ptRxtEqOOEeJBppQ2DMZWVIJToDdGQGbF3rA5GdeJ7hqxuVb0CX43b096fSw8W6rpQGdV158BQXHqo2chg0PKRzfKTo2S+pzmSu4vamtF86VKFO1E6ldoB3xxLNYMZlQ==; 5:DsWsGEkJz8QmBGDUDLahvrRr1vTOqvSXUZxbXPAux0YoLnPl+lCKRDD/1S2C0/NL0c8wZYQzmdymVd5+8g2JuG/ukuGWR97/Kc+ae0qSG5PnLfGhUKpr1cx5a/lPySYbRokVj3yA8wiFBw4OXiqNTEaQAHHpsOWm4SMD4+7jim4=; 7:dxkcpWttPq5pE1O0r2t7zm7I3ORzbsFlHqKOtqAJlPgmN/04zvvwUY4VzekGYf3z9G7idLdeA/9T0j+qgG8G6Xv44rZ4SZgrus9NmC6saYKfn3dJtBSNuRXT0CKyEC2li1VuBnE7hcVW6du/0CfjWwXAuamD5/3VDymSSonPqa4g30UKBevYoUMWDfkv5FEXLacmXzdpXQMQWE+aV0IMtlQmtP3Y7q+4SVmIYNr879E9uPAxHA5lMnKL9T+U+FGO x-ms-office365-filtering-correlation-id: bb21dbe6-a0c4-4dea-ce6d-08d61f9be5c7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7193020); SRVR:DM5PR2101MB0727; x-ms-traffictypediagnostic: DM5PR2101MB0727: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(105169848403564)(12401385986421)(28532068793085)(89211679590171)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(2280164)(944501410)(52105095)(2018427008)(93006095)(93001095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201708071742011)(7699051)(76991041); SRVR:DM5PR2101MB0727; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0727; x-forefront-prvs: 0802ADD973 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(1496009)(39860400002)(396003)(136003)(376002)(366004)(346002)(40224003)(199004)(189003)(8676002)(81156014)(25786009)(446003)(2900100001)(102836004)(46003)(52116002)(6346003)(81166006)(11346002)(105586002)(2351001)(8936002)(386003)(4326008)(76176011)(6506007)(10090500001)(5250100002)(7736002)(2616005)(486006)(305945005)(53376002)(6116002)(186003)(16799955002)(1076002)(2501003)(476003)(6916009)(6666003)(99286004)(22452003)(97736004)(45954006)(71200400001)(71190400001)(72206003)(478600001)(966005)(6306002)(10290500003)(5640700003)(14454004)(36756003)(86362001)(19627235002)(575784001)(6436002)(16200700003)(15188155005)(2906002)(53946003)(86612001)(106356001)(54906003)(316002)(6486002)(256004)(6512007)(14444005)(68736007)(5660300001)(53936002)(60540400001)(579004)(569006); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0727; H:DM5PR2101MB1128.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Christopher.Co@microsoft.com; x-microsoft-antispam-message-info: HmUUcfQLMkv4PyGuH7ezFXiJWoR1sohCUhPrIZnk9veTmYWOcLvrKQ7kMBu6SyEbGAxh6nCRmw4LSUH8ohEuF4XPiHre6wVoEFpp2uWLAuanjstnAfoOxB2luzPKuYJEKgEUl/5jXVJvC650IIyfk8HJhZNeBBaJeWqS+G7qbxLwH02UCk3ESCtowQBQXWOSuhyxeJAcYt/3TpqD1HInJYk814BXOllPeHQ1FmFksMT3xuq1FckywOOKLdZzaRvmeMzoXriW2C0bl8dkFpoBb9AzHTZKos458daQOs2adZzM/HP/FwIW1pyAuNHHms7EuplPvOsBl1fMSK8a/aSfQTvLHnj8b9Clqq218y8Ch3dlr+G83XxoZcUBvart7Oy2OueOinHEtz8xXm9FhqpPryw+yDjtg0bf7K6f479++/7Ea7u33wu8wunmO0mH4ugAU0UIIvY6I/T1NbQhLJ2GBDZx/YhIJstpBnPJQ7l4G0RVzqHa23mEQAZ9Vm/ZsbRsysbnVjFgZeXJskX77hRh3WRglbYhWhejTZdn8D0OsYqtdqPJWNkNpXGQs4B6ubA+ spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb21dbe6-a0c4-4dea-ce6d-08d61f9be5c7 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Sep 2018 08:26:16.0129 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0727 Subject: [PATCH edk2-platforms 23/27] Silicon/NXP: Add i.MX6 Smbios Driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Sep 2018 08:26:21 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This adds support populating the SMBIOS tables on an i.MX6 SoC. Platforms just need to define the relevant PCDs in their dsc file and this driver will fill out the SMBIOS table structures. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Christopher Co Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Michael D Kinney --- Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | 1774= ++++++++++++++++++++ Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.h | 44= + Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf | 84= + 3 files changed, 1902 insertions(+) diff --git a/Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDx= e.c b/Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c new file mode 100644 index 000000000000..93c56dec254b --- /dev/null +++ b/Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c @@ -0,0 +1,1774 @@ +/** @file + + Static SMBIOS Table for the SolidRun HummingBoard-Edge iMX6 Quad platfor= m + Derived from EmulatorPkg package + + Note SMBIOS 2.7.1 Required structures: + BIOS Information (Type 0) + System Information (Type 1) + Board Information (Type 2) + System Enclosure (Type 3) + Processor Information (Type 4) - CPU Driver + Cache Information (Type 7) - For cache that is external to processor + Physical Memory Array (Type 16) + Memory Device (Type 17) - For each socketed system-memory Device + Memory Array Mapped Address (Type 19) - One per contiguous block per P= hysical Memroy Array + System Boot Information (Type 32) + + Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2012, Apple Inc. All rights reserved.
+ Copyright (c) 2015, Linaro Limited. All rights reserved.
+ Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+ Copyright (c) 2015, ARM Limited. All rights reserved. + Copyright (c) 2018 Microsoft Corporation. All rights reserved. + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "PlatformSmbiosDxe.h" + +// Default SMBIOS Tables for i.MX6 +SMBIOS_TABLE_TYPE0 mBiosInfoType0 =3D { + { + EFI_SMBIOS_TYPE_BIOS_INFORMATION, + sizeof (SMBIOS_TABLE_TYPE0), + SMBIOS_HANDLE_PI_RESERVED + }, + 1, // Vendor String + 2, // BiosVersion String + 0xE000, // BiosSegment + 3, // BiosReleaseDate String + (FixedPcdGet32 (PcdFdSize) - 1) / SIZE_64KB, // BiosSize + { // BiosCharacteristics + 0, // Reserved :2; + 0, // Unknown :1; + 0, // BiosCharacteristicsNotSupported :1; + 0, // IsaIsSupported :1; + 0, // McaIsSupported :1; + 0, // EisaIsSupported :1; + 1, // PciIsSupported :1; + 0, // PcmciaIsSupported :1; + 0, // PlugAndPlayIsSupported :1; + 0, // ApmIsSupported :1; + 1, // BiosIsUpgradable :1; + 0, // BiosShadowingAllowed :1; + 0, // VlVesaIsSupported :1; + 0, // EscdSupportIsAvailable :1; + 0, // BootFromCdIsSupported :1; + 1, // SelectableBootIsSupported :1; + 0, // RomBiosIsSocketed :1; + 0, // BootFromPcmciaIsSupported :1; + 0, // EDDSpecificationIsSupported :1; + 0, // JapaneseNecFloppyIsSupported :1; + 0, // JapaneseToshibaFloppyIsSupported :1; + 0, // Floppy525_360IsSupported :1; + 0, // Floppy525_12IsSupported :1; + 0, // Floppy35_720IsSupported :1; + 0, // Floppy35_288IsSupported :1; + 0, // PrintScreenIsSupported :1; + 0, // Keyboard8042IsSupported :1; + 0, // SerialIsSupported :1; + 0, // PrinterIsSupported :1; + 0, // CgaMonoIsSupported :1; + 0, // NecPc98 :1; + 0 // ReservedForVendor :32; + }, + { // BIOSCharacteristicsExtensionBytes[] + 0x01, // AcpiIsSupported :1; + // UsbLegacyIsSupported :1; + // AgpIsSupported :1; + // I2OBootIsSupported :1; + // Ls120BootIsSupported :1; + // AtapiZipDriveBootIsSupported :1; + // Boot1394IsSupported :1; + // SmartBatteryIsSupported :1; + 0x0C, // BiosBootSpecIsSupported :1; + // FunctionKeyNetworkBootIsSupported :1; + // TargetContentDistributionEnabled :1; + // UefiSpecificationSupported :1; + // VirtualMachineSupported :1; + // ExtensionByte2Reserved :3; + }, + FixedPcdGet32 (PcdFirmwareRevision) >> 16, // SystemBiosMajorRelease + FixedPcdGet32 (PcdFirmwareRevision) & 0xff, // SystemBiosMinorRelease + 0xFF, // EmbeddedControllerFirmwareMajorRelease + 0xFF, // EmbeddedControllerFirmwareMinorRelease +}; + +SMBIOS_TABLE_TYPE1 mSysInfoType1 =3D { + { + EFI_SMBIOS_TYPE_SYSTEM_INFORMATION, + sizeof (SMBIOS_TABLE_TYPE1), + SMBIOS_HANDLE_PI_RESERVED + }, + 1, // Manufacturer String + 2, // ProductName String + 3, // Version String + 4, // SerialNumber String + { 0xFFFFFFFF, 0xFFFF, 0xFFFF, { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF= , 0xFF } }, + SystemWakeupTypePowerSwitch, // WakeUp Type + 5, // SKUNumber String + 6, // Family String +}; + +SMBIOS_TABLE_TYPE2 mBoardInfoType2 =3D { + { + EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION, + sizeof (SMBIOS_TABLE_TYPE2), + SMBIOS_HANDLE_BOARD + }, + 1, // Manufacturer String + 2, // ProductName String + 3, // Version String + 4, // SerialNumber String + 5, // AssetTag String + { // FeatureFlag + 1, // Motherboard :1; + 0, // RequiresDaughterCard :1; + 0, // Removable :1; + 0, // Replaceable :1; + 0, // HotSwappable :1; + 0, // Reserved :3; + }, + 6, // LocationInChassis String + SMBIOS_HANDLE_CHASSIS, // ChassisHandle; + BaseBoardTypeMotherBoard, // BoardType; + 1, // NumberOfContainedObjectHandles; + { SMBIOS_HANDLE_PROCESSOR } // ContainedObjectHandles[1]; +}; + +SMBIOS_TABLE_TYPE3 mEnclosureInfoType3 =3D { + { + EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE, + sizeof (SMBIOS_TABLE_TYPE3), + SMBIOS_HANDLE_CHASSIS + }, + 1, // Manufacturer String + MiscChassisTypeOther, // Type; + 2, // Version String + 3, // SerialNumber String + 4, // AssetTag String + ChassisStateSafe, // BootupState; + ChassisStateSafe, // PowerSupplyState; + ChassisStateSafe, // ThermalState; + ChassisSecurityStatusNone, // SecurityStatus; + { 0, 0, 0, 0 }, // OemDefined[4]; + 0, // Height; + 0, // NumberofPowerCords; + 0, // ContainedElementCount; + 0, // ContainedElementRecordLength; + { { 0 } }, // ContainedElements[1]; +}; + +SMBIOS_TABLE_TYPE4 mProcessorInfoType4 =3D { + { + EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, + sizeof (SMBIOS_TABLE_TYPE4), + SMBIOS_HANDLE_PROCESSOR + }, + 1, // Socket String; + CentralProcessor, // ProcessorType; + ProcessorFamilyIndicatorFamily2, // ProcessorFamily; + 2, // ProcessorManufacture String; + {{0,},{0.}}, // ProcessorId; + 3, // ProcessorVersion String; + { // Voltage; + 1, // ProcessorVoltageCapability5V :1; + 1, // ProcessorVoltageCapability3_3V :1; + 1, // ProcessorVoltageCapability2_9V :1; + 0, // ProcessorVoltageCapabilityReserved :1; + 0, // ProcessorVoltageReserved :3; + 0 // ProcessorVoltageIndicateLegacy :1; + }, + 0, // ExternalClock; + 0, // MaxSpeed; + 0, // CurrentSpeed; + 0x41, // Status; + ProcessorUpgradeOther, // ProcessorUpgrade; + SMBIOS_HANDLE_L1I, // L1CacheHandle; + SMBIOS_HANDLE_L2U, // L2CacheHandle; + 0xFFFF, // L3CacheHandle; + 4, // SerialNumber; + 5, // AssetTag; + 6, // PartNumber; + 0, // CoreCount; + 0, // EnabledCoreCount; + 0, // ThreadCount; + 0, // ProcessorCharacteristics; + ProcessorFamilyARMv7, // ProcessorFamily2; +}; + +SMBIOS_TABLE_TYPE7 mCacheInfoType7L1I =3D { + { + EFI_SMBIOS_TYPE_CACHE_INFORMATION, + sizeof (SMBIOS_TABLE_TYPE7), + SMBIOS_HANDLE_L1I + }, + 1, // SocketDesignation String + 0x0180, // Cache Configuration + 0x0020, // Maximum Size 32k + 0x0020, // Install Size 32k + { // Supported SRAM Type + 0, //Other :1 + 0, //Unknown :1 + 0, //NonBurst :1 + 1, //Burst :1 + 0, //PiplelineBurst :1 + 1, //Synchronous :1 + 0, //Asynchronous :1 + 0 //Reserved :9 + }, + { // Current SRAM Type + 0, //Other :1 + 0, //Unknown :1 + 0, //NonBurst :1 + 1, //Burst :1 + 0, //PiplelineBurst :1 + 1, //Synchronous :1 + 0, //Asynchronous :1 + 0 //Reserved :9 + }, + 0, // Cache Speed unknown + CacheErrorMultiBit, // Error Correction Multi + CacheTypeInstruction, // System Cache Type + CacheAssociativity2Way // Associativity +}; + +SMBIOS_TABLE_TYPE7 mCacheInfoType7L1D =3D { + { + EFI_SMBIOS_TYPE_CACHE_INFORMATION, + sizeof (SMBIOS_TABLE_TYPE7), + SMBIOS_HANDLE_L1D + }, + 1, // SocketDesignation String + 0x0180, // Cache Configuration + 0x0020, // Maximum Size 32k + 0x0020, // Install Size 32k + { // Supported SRAM Type + 0, //Other :1 + 0, //Unknown :1 + 0, //NonBurst :1 + 1, //Burst :1 + 0, //PiplelineBurst :1 + 1, //Synchronous :1 + 0, //Asynchronous :1 + 0 //Reserved :9 + }, + { // Current SRAM Type + 0, //Other :1 + 0, //Unknown :1 + 0, //NonBurst :1 + 1, //Burst :1 + 0, //PiplelineBurst :1 + 1, //Synchronous :1 + 0, //Asynchronous :1 + 0 //Reserved :9 + }, + 0, // Cache Speed unknown + CacheErrorMultiBit, // Error Correction Multi + CacheTypeData, // System Cache Type + CacheAssociativity2Way // Associativity +}; + +SMBIOS_TABLE_TYPE7 mCacheInfoType7L2U =3D { + { + EFI_SMBIOS_TYPE_CACHE_INFORMATION, + sizeof (SMBIOS_TABLE_TYPE7), + SMBIOS_HANDLE_L2U + }, + 1, // SocketDesignation String + 0x0181, // Cache Configuration + 0, // Maximum Size + 0, // Install Size + { // Supported SRAM Type + 0, //Other :1 + 0, //Unknown :1 + 0, //NonBurst :1 + 1, //Burst :1 + 0, //PiplelineBurst :1 + 1, //Synchronous :1 + 0, //Asynchronous :1 + 0 //Reserved :9 + }, + { // Current SRAM Type + 0, //Other :1 + 0, //Unknown :1 + 0, //NonBurst :1 + 1, //Burst :1 + 0, //PiplelineBurst :1 + 1, //Synchronous :1 + 0, //Asynchronous :1 + 0 //Reserved :9 + }, + 0, // Cache Speed unknown + CacheErrorMultiBit, // Error Correction Multi + CacheTypeUnified, // System Cache Type + CacheAssociativity2Way // Associativity +}; + +SMBIOS_TABLE_TYPE16 mPhysicalMemoryArrayInfoType16 =3D { + { + EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, + sizeof (SMBIOS_TABLE_TYPE16), + SMBIOS_HANDLE_MEMORY_ARRAY + }, + MemoryArrayLocationSystemBoard, // Location; + MemoryArrayUseSystemMemory, // Use; + MemoryErrorCorrectionNone, // MemoryErrorCorrection; + 0x80000000, // MaximumCapacity + 0xFFFE, // MemoryErrorInformationHandle; + 1, // NumberOfMemoryDevices; + 0x80000000ULL, // ExtendedMaximumCapacity +}; + +SMBIOS_TABLE_TYPE17 mMemoryDeviceInfoType17 =3D { + { + EFI_SMBIOS_TYPE_MEMORY_DEVICE, + sizeof (SMBIOS_TABLE_TYPE17), + SMBIOS_HANDLE_MEMORY_DEVICE + }, + SMBIOS_HANDLE_MEMORY_ARRAY, // MemoryArrayHandle; + 0xFFFE, // MemoryErrorInformationHandle; + 0xFFFF, // TotalWidth; + 0xFFFF, // DataWidth; + 0xFFFF, // Size; When bit 15 is 0: Size in MB + // When bit 15 is 1: Size in KB, and continues in ExtendedSi= ze + MemoryFormFactorRowOfChips, // FormFactor; + 0, // DeviceSet; + 1, // DeviceLocator String + 2, // BankLocator String + MemoryTypeDdr3, // MemoryType; + { // TypeDetail; + 0, // Reserved :1; + 0, // Other :1; + 0, // Unknown :1; + 0, // FastPaged :1; + 0, // StaticColumn :1; + 0, // PseudoStatic :1; + 0, // Rambus :1; + 0, // Synchronous :1; + 0, // Cmos :1; + 0, // Edo :1; + 0, // WindowDram :1; + 0, // CacheDram :1; + 0, // Nonvolatile :1; + 0, // Registered :1; + 1, // Unbuffered :1; + 0, // Reserved1 :1; + }, + 0, // Speed; + 0, // Manufacturer String + 0, // SerialNumber String + 0, // AssetTag String + 0, // PartNumber String + 0, // Attributes; + 0, // ExtendedSize; + 0, // ConfiguredMemoryClockSpeed; +}; + +SMBIOS_TABLE_TYPE19 mMemoryArrayMappedInfoType19 =3D { + { + EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, + sizeof (SMBIOS_TABLE_TYPE19), + SMBIOS_HANDLE_PI_RESERVED + }, + 0xFFFFFFFF, // StartingAddress; + 0xFFFFFFFF, // EndingAddress; + SMBIOS_HANDLE_MEMORY_ARRAY, // MemoryArrayHandle; + 1, // PartitionWidth; + 0xFFFFFFFF, // ExtendedStartingAddress; + 0xFFFFFFFF, // ExtendedEndingAddress; +}; + +SMBIOS_TABLE_TYPE32 mBootInfoType32 =3D { + { + EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, + sizeof (SMBIOS_TABLE_TYPE32), + SMBIOS_HANDLE_PI_RESERVED + }, + { 0, 0, 0, 0, 0, 0 }, // Reserved[6]; + BootInformationStatusNoError // BootStatus +}; + +struct MonthDescription { + CONST CHAR8* MonthStr; + UINT32 MonthInt; +} gMonthDescription[] =3D { + { "Jan", 1 }, + { "Feb", 2 }, + { "Mar", 3 }, + { "Apr", 4 }, + { "May", 5 }, + { "Jun", 6 }, + { "Jul", 7 }, + { "Aug", 8 }, + { "Sep", 9 }, + { "Oct", 10 }, + { "Nov", 11 }, + { "Dec", 12 }, + { "???", 1 }, // Use 1 as default month +}; + +EFI_STATUS +LogSmbiosData ( + IN UINT8 *Buffer, + IN OUT EFI_SMBIOS_HANDLE *SmbiosHandle + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_PROTOCOL *Smbios; + + *SmbiosHandle =3D ((EFI_SMBIOS_TABLE_HEADER *)Buffer)->Handle; + Status =3D gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)= &Smbios); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D Smbios->Add ( + Smbios, + NULL, + SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *)Buffer + ); + + return Status; +} + +VOID +GetReleaseTime ( + EFI_TIME *Time + ) +{ + CONST CHAR8 *ReleaseDate =3D __DATE__; + CONST CHAR8 *ReleaseTime =3D __TIME__; + UINTN i; + + for (i =3D 0; i < 12; i++) { + if (0 =3D=3D AsciiStrnCmp (ReleaseDate, gMonthDescription[i].MonthStr,= 3)) { + break; + } + } + Time->Month =3D gMonthDescription[i].MonthInt; + Time->Day =3D AsciiStrDecimalToUintn (ReleaseDate + 4); + Time->Year =3D AsciiStrDecimalToUintn (ReleaseDate + 7); + Time->Hour =3D AsciiStrDecimalToUintn (ReleaseTime); + Time->Minute =3D AsciiStrDecimalToUintn (ReleaseTime + 3); + Time->Second =3D AsciiStrDecimalToUintn (ReleaseTime + 6); + + return; +} + +UINT64 +GetImx6SerialNumber ( + VOID + ) +{ + UINT64 ProcessorSerialNumber; + + ProcessorSerialNumber =3D ((UINT64)MmioRead32 (OCOTP_BANK_0_WORD_2)) << = 32; + ProcessorSerialNumber |=3D(UINT64)MmioRead32 (OCOTP_BANK_0_WORD_1); + + DEBUG ((DEBUG_INFO, "iMX6 Serial Number %08X%08Xh \r\n", + (UINT32) (ProcessorSerialNumber >> 32), (UINT32)ProcessorSerialN= umber)); + return ProcessorSerialNumber; +} + +EFI_STATUS +BiosInfoUpdateSmbiosType0 ( + VOID + ) +{ + CHAR8 *OptionalStrStart; + CHAR16 *ReleaseDate; + SMBIOS_TABLE_TYPE0 *SmbiosRecord; + CHAR16 *Vendor; + CHAR16 *Version; + UINTN ReleaseDateLen; + UINT32 Revision; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + EFI_STATUS Status; + UINTN VendorLen; + UINTN VersionLen; + EFI_TIME Time; + + Version =3D NULL; + ReleaseDate =3D NULL; + SmbiosRecord =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE0); + + // 04h - Vendor Name String + Vendor =3D (CHAR16 *)FixedPcdGetPtr (PcdFirmwareVendor); + VendorLen =3D StrLen (Vendor); + if (VendorLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdFirmwareVendor not filled\n", __FUNCTION_= _)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D VendorLen + 1; + + // 05h - BIOS Version string + Revision =3D FixedPcdGet32 (PcdFirmwareRevision); + if (Revision =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdFirmwareRevision not filled\n", __FUNCTIO= N__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + GetReleaseTime (&Time); + + Version =3D AllocateZeroPool ((sizeof (CHAR16)) * SMBIOS_STRING_MAX_LENG= TH); + if (Version =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + (VOID)UnicodeSPrintAsciiFormat ( + Version, + (sizeof (CHAR16)) * SMBIOS_STRING_MAX_LENGTH, + "\nBoot firmware (version %x built on %t)\n", + Revision, + &Time + ); + VersionLen =3D StrLen(Version); + SmbiosRecordLen +=3D VersionLen + 1; + + // 08h - BIOS Release Date must be in mm/dd/yyyy format + ReleaseDate =3D AllocateZeroPool ((sizeof (CHAR16)) * SMBIOS_STRING_MAX_= LENGTH); + if (ReleaseDate =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + (VOID)UnicodeSPrintAsciiFormat ( ReleaseDate, + (sizeof (CHAR16)) * SMBIOS_STRING_MAX_LENGTH, + "%02d/%02d/%4d", + Time.Month, + Time.Day, + Time.Year + ); + ReleaseDateLen =3D StrLen(ReleaseDate); + SmbiosRecordLen +=3D ReleaseDateLen + 1; + + // Record must end in double NULL + SmbiosRecordLen +=3D 1; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mBiosInfoType0, sizeof (SMBIOS_TABLE_TYPE0)); + + // Populate optional string area at the end of the entry + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStr (Vendor, OptionalStrStart); + OptionalStrStart +=3D VendorLen + 1; + UnicodeStrToAsciiStr (Version, OptionalStrStart); + OptionalStrStart +=3D VersionLen + 1; + UnicodeStrToAsciiStr (ReleaseDate, OptionalStrStart); + + // Commit SMBIOS entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (Version !=3D NULL) { + FreePool (Version); + } + if (ReleaseDate !=3D NULL) { + FreePool (ReleaseDate); + } + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +SysInfoUpdateSmbiosType1 ( + VOID + ) +{ + CHAR16 *Family; + GLOBAL_PAGE_DATA *GlobalDataAddress; + CHAR16 *Manufacturer; + CHAR8 *OptionalStrStart; + CHAR16 *ProductName; + CHAR16 *SerialNumber; + CHAR16 *SkuNumber; + SMBIOS_TABLE_TYPE1 *SmbiosRecord; + EFI_GUID *SystemUuidFromPcd; + EFI_GUID *SystemUuid; + CHAR16 *Version; + UINT64 ProcessorSerialNumber; + UINTN FamilyLen; + UINT32 i; + UINTN ManufacturerLen; + UINTN ProductNameLen; + UINTN SerialNumberLen; + UINTN SkuNumberLen; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + EFI_STATUS Status; + UINTN VersionLen; + + SerialNumber =3D NULL; + SmbiosRecord =3D NULL; + SystemUuid =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE1); + + // 04h - Manufacturer String + Manufacturer =3D (CHAR16 *)FixedPcdGetPtr (PcdSystemManufacturer); + ManufacturerLen =3D StrLen (Manufacturer); + if (ManufacturerLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdSystemManufacturer not filled\n", __FUNCT= ION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D ManufacturerLen + 1; + + // 05h - Product Name String + ProductName =3D (CHAR16 *)FixedPcdGetPtr (PcdSystemProductName); + ProductNameLen =3D StrLen (ProductName); + if (ProductNameLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdSystemProductName not filled\n", __FUNCTI= ON__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D ProductNameLen + 1; + + // 06h - Version String + Version =3D (CHAR16 *)FixedPcdGetPtr (PcdSystemVersionNumber); + VersionLen =3D StrLen (Version); + if (VersionLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdSystemVersionNumber not filled\n", __FUNC= TION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D VersionLen + 1; + + // 07h - Serial Number String + ProcessorSerialNumber =3D GetImx6SerialNumber (); + SerialNumber =3D AllocateZeroPool (sizeof (CHAR16) * SMBIOS_STRING_MAX_L= ENGTH); + if (SerialNumber =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + (VOID)UnicodeSPrintAsciiFormat (SerialNumber, + sizeof (CHAR16) * SMBIOS_STRING_MAX_LENG= TH, + "%08X%08X", + (UINT32)(ProcessorSerialNumber >> 32), + (UINT32)ProcessorSerialNumber + ); + SerialNumberLen =3D StrLen (SerialNumber); + SmbiosRecordLen +=3D SerialNumberLen + 1; + + // 08h - UUID + // RFC4122 - Initial UUID must be the same across all boards of the same= type + // And the last 6 bytes are to be populated with system's MAC Address + SystemUuidFromPcd =3D (EFI_GUID *)FixedPcdGetPtr (PcdSystemUuid); + SystemUuid =3D AllocateZeroPool (sizeof (EFI_GUID)); + if (SystemUuid =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + CopyMem (SystemUuid, SystemUuidFromPcd, sizeof (EFI_GUID)); + + GlobalDataAddress =3D (GLOBAL_PAGE_DATA *)FixedPcdGet32 (PcdGlobalDataBa= seAddress); + if (GlobalDataAddress =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: PcdGlobalDataBaseAddress not filled\n", __FU= NCTION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + // Verify signature and version of global page + if (GlobalDataAddress->Signature !=3D GLOBAL_PAGE_SIGNATURE) { + DEBUG ((DEBUG_ERROR, "%a: Global Page Signature mismatch.\n", __FUNCTI= ON__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + if (GlobalDataAddress->Revision > 1) { + DEBUG ((DEBUG_ERROR, "%a: Global Page Revision mismatch.\n", __FUNCTIO= N__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + // Check validity of Mac address and assign to UUID + if (GlobalDataAddress->Mac0Valid =3D=3D TRUE) { + for (i =3D 0; i < 6; i++) { + SystemUuid->Data4[i + 2] =3D GlobalDataAddress->MacAddress[i]; + } + } else { + DEBUG ((DEBUG_ERROR, "%a: Mac Address not present.\n", __FUNCTION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + + mSysInfoType1.Uuid =3D *SystemUuid; + + // 19h - SKU Number String + SkuNumber =3D (CHAR16 *)FixedPcdGetPtr (PcdSystemSkuNumber); + SkuNumberLen =3D StrLen (SkuNumber); + if (SkuNumberLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdSystemSkuNumber not filled\n", __FUNCTION= __)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D SkuNumberLen + 1; + + // 1Ah - Family String + Family =3D (CHAR16 *)FixedPcdGetPtr (PcdSystemFamily); + FamilyLen =3D StrLen (Family); + if (FamilyLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdSystemFamily not filled\n", __FUNCTION__)= ); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D FamilyLen + 1; + + // Record must end in double NULL + SmbiosRecordLen +=3D 1; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mSysInfoType1, sizeof (SMBIOS_TABLE_TYPE1)); + + // Populate optional string area at the end of the entry + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStr (Manufacturer, OptionalStrStart); + OptionalStrStart +=3D ManufacturerLen + 1; + UnicodeStrToAsciiStr (ProductName, OptionalStrStart); + OptionalStrStart +=3D ProductNameLen + 1; + UnicodeStrToAsciiStr (Version, OptionalStrStart); + OptionalStrStart +=3D VersionLen + 1; + UnicodeStrToAsciiStr (SerialNumber, OptionalStrStart); + OptionalStrStart +=3D SerialNumberLen + 1; + UnicodeStrToAsciiStr (SkuNumber, OptionalStrStart); + OptionalStrStart +=3D SkuNumberLen + 1; + UnicodeStrToAsciiStr (Family, OptionalStrStart); + + // Commit SMBIOS Entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (SerialNumber !=3D NULL) { + FreePool (SerialNumber); + } + if (SystemUuid !=3D NULL) { + FreePool (SystemUuid); + } + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +BoardInfoUpdateSmbiosType2 ( + VOID + ) +{ + CHAR16 *AssetTag; + CHAR16 *Location; + CHAR16 *Manufacturer; + CHAR8 *OptionalStrStart; + CHAR16 *ProductName; + CHAR16 *SerialNumber; + SMBIOS_TABLE_TYPE2 *SmbiosRecord; + CHAR16 *Version; + UINTN AssetTagLen; + UINT64 ProcessorSerialNumber; + UINTN LocationLen; + UINTN ManufacturerLen; + UINTN ProductNameLen; + UINTN SerialNumberLen; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + EFI_STATUS Status; + UINTN VersionLen; + + SerialNumber =3D NULL; + SmbiosRecord =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE2); + + // 04h - Manufacturer String + Manufacturer =3D (CHAR16 *)FixedPcdGetPtr (PcdBoardManufacturer); + ManufacturerLen =3D StrLen (Manufacturer); + if (ManufacturerLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdBoardManufacturer not filled\n", __FUNCTI= ON__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D ManufacturerLen + 1; + + // 05h - Product Name String + ProductName =3D (CHAR16 *)FixedPcdGetPtr (PcdBoardProductName); + ProductNameLen =3D StrLen (ProductName); + if (ProductNameLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdBoardProductName not filled\n", __FUNCTIO= N__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D ProductNameLen + 1; + + // 06h - Version String + Version =3D (CHAR16 *)FixedPcdGetPtr (PcdBoardVersionNumber); + VersionLen =3D StrLen (Version); + if (VersionLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdBoardVersionNumber not filled\n", __FUNCT= ION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D VersionLen + 1; + + // 07h - Serial Number String + ProcessorSerialNumber =3D GetImx6SerialNumber (); + SerialNumber =3D AllocateZeroPool (sizeof (CHAR16) * SMBIOS_STRING_MAX_L= ENGTH); + if (SerialNumber =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + (VOID)UnicodeSPrintAsciiFormat (SerialNumber, + sizeof (CHAR16) * SMBIOS_STRING_MAX_LENG= TH, + "%08X%08X", + (UINT32)(ProcessorSerialNumber >> 32), + (UINT32)ProcessorSerialNumber + ); + SerialNumberLen =3D StrLen (SerialNumber); + SmbiosRecordLen +=3D SerialNumberLen + 1; + + // 08h - Asset Tag String + AssetTag =3D (CHAR16 *)FixedPcdGetPtr (PcdBoardAssetTag); + AssetTagLen =3D StrLen (AssetTag); + if (AssetTagLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdBoardAssetTag not filled\n", __FUNCTION__= )); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D AssetTagLen + 1; + + // 0Ah - Location in Chassis String + Location =3D (CHAR16 *)FixedPcdGetPtr (PcdBoardLocationInChassis); + LocationLen =3D StrLen (Location); + if (LocationLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdBoardLocationInChassis not filled\n", __F= UNCTION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D LocationLen + 1; + + // Record must end in double NULL + SmbiosRecordLen +=3D 1; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mBoardInfoType2, sizeof (SMBIOS_TABLE_TYPE2)); + + // Populate optional string area at the end of the entry + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStr (Manufacturer, OptionalStrStart); + OptionalStrStart +=3D ManufacturerLen + 1; + UnicodeStrToAsciiStr (ProductName, OptionalStrStart); + OptionalStrStart +=3D ProductNameLen + 1; + UnicodeStrToAsciiStr (Version, OptionalStrStart); + OptionalStrStart +=3D VersionLen + 1; + UnicodeStrToAsciiStr (SerialNumber, OptionalStrStart); + OptionalStrStart +=3D SerialNumberLen + 1; + UnicodeStrToAsciiStr (AssetTag, OptionalStrStart); + OptionalStrStart +=3D AssetTagLen + 1; + UnicodeStrToAsciiStr (Location, OptionalStrStart); + + // Commit SMBIOS Entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (SerialNumber !=3D NULL) { + FreePool (SerialNumber); + } + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +EnclosureInfoUpdateSmbiosType3 ( + VOID + ) +{ + CHAR16 *AssetTag; + CHAR16 *Manufacturer; + CHAR8 *OptionalStrStart; + CHAR16 *SerialNumber; + SMBIOS_TABLE_TYPE3 *SmbiosRecord; + CHAR16 *Version; + UINTN AssetTagLen; + UINT64 ProcessorSerialNumber; + UINTN ManufacturerLen; + UINTN SerialNumberLen; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + EFI_STATUS Status; + UINTN VersionLen; + + SerialNumber =3D NULL; + SmbiosRecord =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE3); + + // 04h - Manufacturer String + Manufacturer =3D (CHAR16 *)FixedPcdGetPtr (PcdChassisManufacturer); + ManufacturerLen =3D StrLen (Manufacturer); + if (ManufacturerLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdChassisManufacturer not filled\n", __FUNC= TION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D ManufacturerLen + 1; + + // 06h - Version String + Version =3D (CHAR16 *)FixedPcdGetPtr (PcdChassisVersionNumber); + VersionLen =3D StrLen (Version); + if (VersionLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdChassisVersionNumber not filled\n", __FUN= CTION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D VersionLen + 1; + + // 07h - Serial Number String + ProcessorSerialNumber =3D GetImx6SerialNumber (); + SerialNumber =3D AllocateZeroPool (sizeof (CHAR16) * SMBIOS_STRING_MAX_L= ENGTH); + if (SerialNumber =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + (VOID)UnicodeSPrintAsciiFormat (SerialNumber, + sizeof (CHAR16) * SMBIOS_STRING_MAX_LENG= TH, + "%08X%08X", + (UINT32)(ProcessorSerialNumber >> 32), + (UINT32)ProcessorSerialNumber + ); + SerialNumberLen =3D StrLen (SerialNumber); + SmbiosRecordLen +=3D SerialNumberLen + 1; + + // 08h - Asset Tag String + AssetTag =3D (CHAR16 *)FixedPcdGetPtr (PcdChassisAssetTag); + AssetTagLen =3D StrLen (AssetTag); + if (AssetTagLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdChassisAssetTag not filled\n", __FUNCTION= __)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D AssetTagLen + 1; + + // Record must end in double NULL + SmbiosRecordLen +=3D 1; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mEnclosureInfoType3, sizeof (SMBIOS_TABLE_TYPE3)= ); + + // Populate optional string area at the end of the entry + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStr (Manufacturer, OptionalStrStart); + OptionalStrStart +=3D ManufacturerLen + 1; + UnicodeStrToAsciiStr (Version, OptionalStrStart); + OptionalStrStart +=3D VersionLen + 1; + UnicodeStrToAsciiStr (SerialNumber, OptionalStrStart); + OptionalStrStart +=3D SerialNumberLen + 1; + UnicodeStrToAsciiStr (AssetTag, OptionalStrStart); + + // Commit SMBIOS Entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (SerialNumber !=3D NULL) { + FreePool (SerialNumber); + } + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +ProcessorInfoUpdateSmbiosType4 ( + IN UINTN MaxCpus + ) +{ + CHAR16 *AssetTag; + CHAR16 *Manufacturer; + CHAR8 *OptionalStrStart; + CHAR16 *PartNumber; + CHAR16 *SerialNumber; + SMBIOS_TABLE_TYPE4 *SmbiosRecord; + CHAR16 *SocketDesignation; + CHAR16 *Version; + UINT32 ArmMidr; + UINTN AssetTagLen; + UINTN i; + UINT32 Midr; + UINT64 ProcessorSerialNumber; + UINTN ManufacturerLen; + UINTN PartNumberLen; + UINTN SerialNumberLen; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + UINTN SocketDesignationLen; + EFI_STATUS Status; + UINTN VersionLen; + + SerialNumber =3D NULL; + SmbiosRecord =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE4); + Midr =3D 0; + + // 04h - Socket Designation String + SocketDesignation =3D (CHAR16 *)FixedPcdGetPtr (PcdProcessorSocketDesign= ation); + SocketDesignationLen =3D StrLen (SocketDesignation); + if (SocketDesignationLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdProcessorSocketDesignation not filled\n",= __FUNCTION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D SocketDesignationLen + 1; + + // 07h - Processor Manufacturer String + Manufacturer =3D (CHAR16 *)FixedPcdGetPtr (PcdProcessorManufacturer); + ManufacturerLen =3D StrLen (Manufacturer); + if (ManufacturerLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdProcessorManufacturer not filled\n", __FU= NCTION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D ManufacturerLen + 1; + + // 08h - Processor ID - On ARM32, first DWORD is MIDR value. Second DWOR= D is 0 + ArmMidr =3D (UINT32)ArmReadMidr (); + DEBUG ((DEBUG_INFO, "%a: ArmMidr =3D %x\n", __FUNCTION__, ArmMidr)); + // Need to reverse byte order so the value is populated correctly + for (i =3D 0; i < 32; i +=3D 8) { + Midr |=3D ((ArmMidr >> i) & 0xFF) << (24-i); + } + CopyMem(&mProcessorInfoType4.ProcessorId.Signature, &Midr, sizeof (UINT3= 2)); + + // 10h - Processor Version String + Version =3D (CHAR16 *)FixedPcdGetPtr (PcdProcessorVersionNumber); + VersionLen =3D StrLen (Version); + if (VersionLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdProcessorVersionNumber not filled\n", __F= UNCTION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D VersionLen + 1; + + // 14h - Max Speed +#if defined(CPU_IMX6DQ) || defined(CPU_IMX6DQP) + mProcessorInfoType4.MaxSpeed =3D 1200; + mProcessorInfoType4.CurrentSpeed =3D 1200; +#elif defined(CPU_IMX6SDL) || defined(CPU_IMX6SX) + mProcessorInfoType4.MaxSpeed =3D 1000; + mProcessorInfoType4.CurrentSpeed =3D 1000; +#else + #error iMX6 CPU Type not defined +#endif + + // 20h - Processor Serial Number String + ProcessorSerialNumber =3D GetImx6SerialNumber (); + SerialNumber =3D AllocateZeroPool (sizeof (CHAR16) * SMBIOS_STRING_MAX_L= ENGTH); + if (SerialNumber =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + (VOID)UnicodeSPrintAsciiFormat (SerialNumber, + sizeof (CHAR16) * SMBIOS_STRING_MAX_LENG= TH, + "%08X%08X", + (UINT32)(ProcessorSerialNumber >> 32), + (UINT32)ProcessorSerialNumber + ); + SerialNumberLen =3D StrLen (SerialNumber); + SmbiosRecordLen +=3D SerialNumberLen + 1; + + // 21h - Asset Tag String + AssetTag =3D (CHAR16 *)FixedPcdGetPtr (PcdProcessorAssetTag); + AssetTagLen =3D StrLen (AssetTag); + if (AssetTagLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdProcessorAssetTag not filled\n", __FUNCTI= ON__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D AssetTagLen + 1; + + // 22h - Part Number String + PartNumber =3D (CHAR16 *)FixedPcdGetPtr (PcdProcessorPartNumber); + PartNumberLen =3D StrLen (PartNumber); + if (PartNumberLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdProcessorPartNumber not filled\n", __FUNC= TION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D PartNumberLen + 1; + + // 23h - Core Count + // 24h - Core Enabled + // 25h - Thread Count + mProcessorInfoType4.CoreCount =3D (UINT8) MaxCpus; + mProcessorInfoType4.EnabledCoreCount =3D (UINT8) MaxCpus; + mProcessorInfoType4.ThreadCount =3D (UINT8) MaxCpus; + + // Record must end in double NULL + SmbiosRecordLen +=3D 1; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mProcessorInfoType4, sizeof (SMBIOS_TABLE_TYPE4)= ); + + // Populate optional string area at the end of the entry + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStr (SocketDesignation, OptionalStrStart); + OptionalStrStart +=3D SocketDesignationLen + 1; + UnicodeStrToAsciiStr (Manufacturer, OptionalStrStart); + OptionalStrStart +=3D ManufacturerLen + 1; + UnicodeStrToAsciiStr (Version, OptionalStrStart); + OptionalStrStart +=3D VersionLen + 1; + UnicodeStrToAsciiStr (SerialNumber, OptionalStrStart); + OptionalStrStart +=3D SerialNumberLen + 1; + UnicodeStrToAsciiStr (AssetTag, OptionalStrStart); + OptionalStrStart +=3D AssetTagLen + 1; + UnicodeStrToAsciiStr (PartNumber, OptionalStrStart); + + // Commit SMBIOS Entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (SerialNumber !=3D NULL) { + FreePool (SerialNumber); + } + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +CacheInfoUpdateSmbiosType7L1I ( + VOID + ) +{ + CHAR8 *OptionalStrStart; + SMBIOS_TABLE_TYPE7 *SmbiosRecord; + CHAR16 *SocketDesignation; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + UINTN SocketDesignationLen; + EFI_STATUS Status; + + SocketDesignation =3D NULL; + SmbiosRecord =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE7); + + // 04h - Socket Designation String + SocketDesignation =3D AllocateZeroPool (sizeof (CHAR16) * SMBIOS_STRING_= MAX_LENGTH); + if (SocketDesignation =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + (VOID)UnicodeSPrintAsciiFormat (SocketDesignation, + sizeof (CHAR16) * SMBIOS_STRING_MAX_LENG= TH, + "L1 ICache" + ); + SocketDesignationLen =3D StrLen (SocketDesignation); + SmbiosRecordLen +=3D SocketDesignationLen + 1; + + // Record must end in double NULL + SmbiosRecordLen +=3D 1; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mCacheInfoType7L1I, sizeof (SMBIOS_TABLE_TYPE7))= ; + + // Populate optional string area at the end of the entry + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStr (SocketDesignation, OptionalStrStart); + + // Commit SMBIOS Entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (SocketDesignation !=3D NULL) { + FreePool (SocketDesignation); + } + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +CacheInfoUpdateSmbiosType7L1D ( + VOID + ) +{ + CHAR8 *OptionalStrStart; + SMBIOS_TABLE_TYPE7 *SmbiosRecord; + CHAR16 *SocketDesignation; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + UINTN SocketDesignationLen; + EFI_STATUS Status; + + SocketDesignation =3D NULL; + SmbiosRecord =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE7); + + // 04h - Socket Designation String + SocketDesignation =3D AllocateZeroPool (sizeof (CHAR16) * SMBIOS_STRING_= MAX_LENGTH); + if (SocketDesignation =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + (VOID)UnicodeSPrintAsciiFormat (SocketDesignation, + sizeof (CHAR16) * SMBIOS_STRING_MAX_LENG= TH, + "L1 DCache" + ); + SocketDesignationLen =3D StrLen (SocketDesignation); + SmbiosRecordLen +=3D SocketDesignationLen + 1; + + // Record must end in double NULL + SmbiosRecordLen +=3D 1; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mCacheInfoType7L1D, sizeof (SMBIOS_TABLE_TYPE7))= ; + + // Populate optional string area at the end of the entry + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStr (SocketDesignation, OptionalStrStart); + + // Commit SMBIOS Entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (SocketDesignation !=3D NULL) { + FreePool (SocketDesignation); + } + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +CacheInfoUpdateSmbiosType7L2U ( + VOID + ) +{ + CHAR8 *OptionalStrStart; + SMBIOS_TABLE_TYPE7 *SmbiosRecord; + CHAR16 *SocketDesignation; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + UINTN SocketDesignationLen; + EFI_STATUS Status; + + SocketDesignation =3D NULL; + SmbiosRecord =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE7); + + // 04h - Socket Designation String + SocketDesignation =3D AllocateZeroPool (sizeof (CHAR16) * SMBIOS_STRING_= MAX_LENGTH); + if (SocketDesignation =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + (VOID)UnicodeSPrintAsciiFormat (SocketDesignation, + sizeof (CHAR16) * SMBIOS_STRING_MAX_LENG= TH, + "L2 UCache (PL310)" + ); + SocketDesignationLen =3D StrLen (SocketDesignation); + SmbiosRecordLen +=3D SocketDesignationLen + 1; + + // 07h - Maximum Cache Size + // 09h - Installed Size +#if defined(CPU_IMX6DQ) || defined(CPU_IMX6DQP) + mCacheInfoType7L2U.MaximumCacheSize =3D 0x400; // 1MB + mCacheInfoType7L2U.InstalledSize =3D 0x400; // 1MB +#elif defined(CPU_IMX6SDL) + mCacheInfoType7L2U.MaximumCacheSize =3D 0x200; // 512KB + mCacheInfoType7L2U.InstalledSize =3D 0x200; // 512KB +#elif defined(CPU_IMX6SX) + mCacheInfoType7L2U.MaximumCacheSize =3D 0x100; // 256KB + mCacheInfoType7L2U.InstalledSize =3D 0x100; // 256KB +#else + #error iMX6 CPU Type not defined +#endif + + // Record must end in double NULL + SmbiosRecordLen +=3D 1; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mCacheInfoType7L2U, sizeof (SMBIOS_TABLE_TYPE7))= ; + + // Populate optional string area at the end of the entry + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStr (SocketDesignation, OptionalStrStart); + + // Commit SMBIOS Entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (SocketDesignation !=3D NULL) { + FreePool (SocketDesignation); + } + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +CacheInfoUpdateSmbiosType7 ( + VOID + ) +{ + EFI_STATUS Status; + + // L1I Table + Status =3D CacheInfoUpdateSmbiosType7L1I (); + if (EFI_ERROR (Status)) { + goto Exit; + } + + // L1D Table + Status =3D CacheInfoUpdateSmbiosType7L1D (); + if (EFI_ERROR (Status)) { + goto Exit; + } + + // L2U Table + Status =3D CacheInfoUpdateSmbiosType7L2U (); + if (EFI_ERROR (Status)) { + goto Exit; + } + +Exit: + return Status; +} + +EFI_STATUS +PhysicalMemoryArrayInfoUpdateSmbiosType16 ( + VOID + ) +{ + SMBIOS_TABLE_TYPE16 *SmbiosRecord; + UINT32 MaximumCapacity; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + EFI_STATUS Status; + + SmbiosRecord =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE16); + + // 07h - Maximum Capacity + MaximumCapacity =3D FixedPcdGet32 (PcdPhysicalMemoryMaximumCapacity); + if (MaximumCapacity =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdPhysicalMemoryMaximumCapacity not filled\= n", __FUNCTION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + mPhysicalMemoryArrayInfoType16.MaximumCapacity =3D MaximumCapacity; + + // 0Fh - Extended Maximum Capacity + mPhysicalMemoryArrayInfoType16.ExtendedMaximumCapacity =3D 0; + + // Since there are no strings, need to add one extra to the record lengt= h + // in order to have the record end with double NULL. + SmbiosRecordLen +=3D 2; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mPhysicalMemoryArrayInfoType16, sizeof (SMBIOS_T= ABLE_TYPE16)); + + // Commit SMBIOS Entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +MemoryDeviceInfoUpdateSmbiosType17 ( + VOID + ) +{ + CHAR16 *BankLocation; + CHAR16 *DeviceLocation; + CHAR8 *OptionalStrStart; + SMBIOS_TABLE_TYPE17 *SmbiosRecord; + UINTN BankLocationLen; + UINTN DeviceLocationLen; + UINT32 MaximumCapacity; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + EFI_STATUS Status; + + SmbiosRecord =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE17); + + // 08h - Total Width + // 0Ah - Data Width +#if defined(CPU_IMX6DQ) || defined(CPU_IMX6DQP) || defined(SOCTYPE_DUALLIT= E) + mMemoryDeviceInfoType17.TotalWidth =3D 64; + mMemoryDeviceInfoType17.DataWidth =3D 64; +#elif defined(CPU_IMX6SX) || defined(SOCTYPE_SOLO) + mMemoryDeviceInfoType17.TotalWidth =3D 32; + mMemoryDeviceInfoType17.DataWidth =3D 32; +#else + #error iMX6 CPU Type not defined +#endif + + // 0Ch - Size - in MB + MaximumCapacity =3D FixedPcdGet32 (PcdPhysicalMemoryMaximumCapacity); + if (MaximumCapacity =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdPhysicalMemoryMaximumCapacity not filled\= n", __FUNCTION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + MaximumCapacity =3D MaximumCapacity / 1024; + mMemoryDeviceInfoType17.Size =3D MaximumCapacity; + + // 10h - Device Locator String + DeviceLocation =3D (CHAR16 *)FixedPcdGetPtr (PcdMemoryDeviceLocation); + DeviceLocationLen =3D StrLen (DeviceLocation); + if (DeviceLocationLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdMemoryDeviceLocation not filled\n", __FUN= CTION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D DeviceLocationLen + 1; + + // 11h - Bank Locator String + BankLocation =3D (CHAR16 *)FixedPcdGetPtr (PcdMemoryBankLocation); + BankLocationLen =3D StrLen (BankLocation); + if (BankLocationLen =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdMemoryBankLocation not filled\n", __FUNCT= ION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + SmbiosRecordLen +=3D BankLocationLen + 1; + + // 15h - Speed +#if defined(CPU_IMX6DQ) || defined(CPU_IMX6DQP) + mMemoryDeviceInfoType17.Speed =3D 533; // 533 MHz DDR3 +#elif defined(CPU_IMX6SDL) || defined(CPU_IMX6SX) + mMemoryDeviceInfoType17.Speed =3D 400; // 400 MHz DDR3 +#else + #error iMX6 CPU Type not defined +#endif + + // Record must end in double NULL + SmbiosRecordLen +=3D 1; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mMemoryDeviceInfoType17, sizeof (SMBIOS_TABLE_TY= PE17)); + + // Populate optional string area at the end of the entry + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStr (DeviceLocation, OptionalStrStart); + OptionalStrStart +=3D DeviceLocationLen + 1; + UnicodeStrToAsciiStr (BankLocation, OptionalStrStart); + + // Commit SMBIOS Entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +MemoryArrayMappingInfoUpdateSmbiosType19 ( + VOID + ) +{ + SMBIOS_TABLE_TYPE19 *SmbiosRecord; + UINT32 EndAddress; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + UINT32 StartAddress; + EFI_STATUS Status; + + SmbiosRecord =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE19); + + // 04h - Starting Address + StartAddress =3D FixedPcdGet32 (PcdMemoryStartAddress); + if (StartAddress =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdMemoryStartAddress not filled\n", __FUNCT= ION__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + mMemoryArrayMappedInfoType19.StartingAddress =3D StartAddress; + mMemoryArrayMappedInfoType19.ExtendedStartingAddress =3D 0; + + // 08h - Ending Address + EndAddress =3D FixedPcdGet32 (PcdMemoryEndAddress); + if (EndAddress =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: PcdMemoryEndAddress not filled\n", __FUNCTIO= N__)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + if (EndAddress <=3D StartAddress) { + DEBUG ((DEBUG_ERROR, + "%a: Start/End addresses invalid. Start =3D %x, End =3D %x\n", + __FUNCTION__, + StartAddress, + EndAddress)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + mMemoryArrayMappedInfoType19.EndingAddress =3D EndAddress; + mMemoryArrayMappedInfoType19.ExtendedEndingAddress =3D 0; + + // Since there are no strings, need to add one extra to the record lengt= h + // in order to have the record end with double NULL. + SmbiosRecordLen +=3D 2; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mMemoryArrayMappedInfoType19, sizeof (SMBIOS_TAB= LE_TYPE19)); + + // Commit SMBIOS Entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +BootInfoUpdateSmbiosType32 ( + VOID + ) +{ + SMBIOS_TABLE_TYPE19 *SmbiosRecord; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT32 SmbiosRecordLen; + EFI_STATUS Status; + + SmbiosRecord =3D NULL; + SmbiosRecordLen =3D sizeof (SMBIOS_TABLE_TYPE32); + + // Since there are no strings, need to add one extra to the record lengt= h + // in order to have the record end with double NULL. + SmbiosRecordLen +=3D 2; + + // Create new SMBIOS record entry + SmbiosRecord =3D AllocateZeroPool (SmbiosRecordLen); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Populate entry with default values + CopyMem (SmbiosRecord, &mBootInfoType32, sizeof (SMBIOS_TABLE_TYPE32)); + + // Commit SMBIOS Entry + Status =3D LogSmbiosData ((UINT8*)SmbiosRecord, &SmbiosHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Smbios Table Log Failed %x\n", __FUNCTION__,= Status)); + } + +Exit: + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + return Status; +} + +EFI_STATUS +EFIAPI +PlatformSmbiosDriverEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D BiosInfoUpdateSmbiosType0 (); + if (EFI_ERROR (Status)) { + goto Exit; + } + + Status =3D SysInfoUpdateSmbiosType1 (); + if (EFI_ERROR (Status)) { + goto Exit; + } + + Status =3D BoardInfoUpdateSmbiosType2 (); + if (EFI_ERROR (Status)) { + goto Exit; + } + + Status =3D EnclosureInfoUpdateSmbiosType3 (); + if (EFI_ERROR (Status)) { + goto Exit; + } + + Status =3D ProcessorInfoUpdateSmbiosType4 (FixedPcdGet32 (PcdCoreCount))= ; + if (EFI_ERROR (Status)) { + goto Exit; + } + + Status =3D CacheInfoUpdateSmbiosType7 (); + if (EFI_ERROR (Status)) { + goto Exit; + } + + Status =3D PhysicalMemoryArrayInfoUpdateSmbiosType16 (); + if (EFI_ERROR (Status)) { + goto Exit; + } + + Status =3D MemoryDeviceInfoUpdateSmbiosType17 (); + if (EFI_ERROR (Status)) { + goto Exit; + } + + Status =3D MemoryArrayMappingInfoUpdateSmbiosType19 (); + if (EFI_ERROR (Status)) { + goto Exit; + } + + Status =3D BootInfoUpdateSmbiosType32 (); + if (EFI_ERROR (Status)) { + goto Exit; + } + +Exit: + return Status; +} diff --git a/Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDx= e.h b/Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.h new file mode 100644 index 000000000000..4842015afcdf --- /dev/null +++ b/Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.h @@ -0,0 +1,44 @@ +/** @file +* +* Copyright (c) 2015, ARM Limited. All rights reserved. +* Copyright (c) 2018 Microsoft Corporation. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD License +* which accompanies this distribution. The full text of the license may = be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +* +**/ + +#ifndef _PLATFORM_SMBIOS_DXE_H_ +#define _PLATFORM_SMBIOS_DXE_H_ + +#define OCOTP_BANK_0_WORD_1 0x021BC410 +#define OCOTP_BANK_0_WORD_2 0x021BC420 + +#define GLOBAL_PAGE_SIGNATURE 0x474C424C // 'GLBL' + +enum SMBIOS_REFRENCE_HANDLES { + SMBIOS_HANDLE_BOARD =3D 0x1000, + SMBIOS_HANDLE_CHASSIS, + SMBIOS_HANDLE_PROCESSOR, + SMBIOS_HANDLE_L1I, + SMBIOS_HANDLE_L1D, + SMBIOS_HANDLE_L2U, + SMBIOS_HANDLE_MEMORY_ARRAY, + SMBIOS_HANDLE_MEMORY_DEVICE +}; + +typedef struct { + UINT32 Signature; + UINT8 Revision; + UINT8 reserved[3]; + UINT8 Mac0Id; + UINT8 Mac0Valid; + UINT8 MacAddress[6]; +} GLOBAL_PAGE_DATA; + +#endif /* _PLATFORM_SMBIOS_DXE_H_ */ diff --git a/Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDx= e.inf b/Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf new file mode 100644 index 000000000000..9e9b386f1b08 --- /dev/null +++ b/Silicon/NXP/iMX6Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf @@ -0,0 +1,84 @@ +#/** @file +# +# Copyright (c) 2013 Linaro.org +# Copyright (c) 2018 Microsoft Corporation. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +#**/ + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D PlatformSmbiosDxe + FILE_GUID =3D 3847D23F-1D95-4772-B60C-4BBFBC4D532F + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D PlatformSmbiosDriverEntryPoint + +[Sources] + PlatformSmbiosDxe.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/NXP/iMX6Pkg/iMX6Pkg.dec + Silicon/NXP/iMXPlatformPkg/iMXPlatformPkg.dec + +[LibraryClasses] + ArmLib + BaseLib + BaseMemoryLib + DebugLib + IoLib + MemoryAllocationLib + PrintLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + +[Protocols] + gEfiSmbiosProtocolGuid # PROTOCOL SOMETIMES_CONSU= MED + +[Guids] + +[FixedPcd] + gArmPlatformTokenSpaceGuid.PcdCoreCount + gArmTokenSpaceGuid.PcdFdSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor + giMXPlatformTokenSpaceGuid.PcdGlobalDataBaseAddress + giMX6TokenSpaceGuid.PcdSystemFamily + giMX6TokenSpaceGuid.PcdSystemManufacturer + giMX6TokenSpaceGuid.PcdSystemProductName + giMX6TokenSpaceGuid.PcdSystemSkuNumber + giMX6TokenSpaceGuid.PcdSystemUuid + giMX6TokenSpaceGuid.PcdSystemVersionNumber + giMX6TokenSpaceGuid.PcdBoardAssetTag + giMX6TokenSpaceGuid.PcdBoardLocationInChassis + giMX6TokenSpaceGuid.PcdBoardManufacturer + giMX6TokenSpaceGuid.PcdBoardProductName + giMX6TokenSpaceGuid.PcdBoardVersionNumber + giMX6TokenSpaceGuid.PcdChassisAssetTag + giMX6TokenSpaceGuid.PcdChassisManufacturer + giMX6TokenSpaceGuid.PcdChassisVersionNumber + giMX6TokenSpaceGuid.PcdProcessorAssetTag + giMX6TokenSpaceGuid.PcdProcessorManufacturer + giMX6TokenSpaceGuid.PcdProcessorPartNumber + giMX6TokenSpaceGuid.PcdProcessorSocketDesignation + giMX6TokenSpaceGuid.PcdProcessorVersionNumber + giMX6TokenSpaceGuid.PcdPhysicalMemoryMaximumCapacity + giMX6TokenSpaceGuid.PcdMemoryBankLocation + giMX6TokenSpaceGuid.PcdMemoryDeviceLocation + giMX6TokenSpaceGuid.PcdMemoryEndAddress + giMX6TokenSpaceGuid.PcdMemoryStartAddress + +[Depex] + gEfiSmbiosProtocolGuid --=20 2.16.2.gvfs.1.33.gf5370f1