PlatformSmbiosDxe.c 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994
  1. /** @file
  2. Static SMBIOS Table for ARM platform
  3. Derived from EmulatorPkg package
  4. Note SMBIOS 2.7.1 Required structures:
  5. BIOS Information (Type 0)
  6. System Information (Type 1)
  7. Board Information (Type 2)
  8. System Enclosure (Type 3)
  9. Processor Information (Type 4) - CPU Driver
  10. Cache Information (Type 7) - For cache that is external to processor
  11. System Slots (Type 9) - If system has slots
  12. Physical Memory Array (Type 16)
  13. Memory Device (Type 17) - For each socketed system-memory Device
  14. Memory Array Mapped Address (Type 19) - One per contiguous block per Physical Memroy Array
  15. System Boot Information (Type 32)
  16. Copyright (c) 2012, Apple Inc. All rights reserved.<BR>
  17. Copyright (c) 2013, Linaro Ltd. All rights reserved.<BR>
  18. Copyright (c) 2014 - 2016, AMD Inc. All rights reserved.<BR>
  19. This program and the accompanying materials
  20. are licensed and made available under the terms and conditions of the BSD License
  21. which accompanies this distribution. The full text of the license may be found at
  22. http://opensource.org/licenses/bsd-license.php
  23. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  24. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  25. **/
  26. /*----------------------------------------------------------------------------------------
  27. * M O D U L E S U S E D
  28. *----------------------------------------------------------------------------------------
  29. */
  30. #include <Protocol/Smbios.h>
  31. #include <IndustryStandard/SmBios.h>
  32. #include <Guid/SmBios.h>
  33. #include <Library/DebugLib.h>
  34. #include <Library/UefiDriverEntryPoint.h>
  35. #include <Library/UefiLib.h>
  36. #include <Library/BaseLib.h>
  37. #include <Library/BaseMemoryLib.h>
  38. #include <Library/MemoryAllocationLib.h>
  39. #include <Library/UefiBootServicesTableLib.h>
  40. #include <Library/PcdLib.h>
  41. #include <Protocol/AmdIscpDxeProtocol.h>
  42. /*----------------------------------------------------------------------------------------
  43. * E X T E R N S
  44. *----------------------------------------------------------------------------------------
  45. */
  46. extern EFI_BOOT_SERVICES *gBS;
  47. /*----------------------------------------------------------------------------------------
  48. * G L O B A L S
  49. *----------------------------------------------------------------------------------------
  50. */
  51. STATIC EFI_SMBIOS_PROTOCOL *mSmbiosProtocol;
  52. STATIC AMD_ISCP_DXE_PROTOCOL *mIscpDxeProtocol;
  53. STATIC ISCP_SMBIOS_INFO mSmbiosInfo;
  54. /***********************************************************************
  55. SMBIOS data definition TYPE0 BIOS Information
  56. ************************************************************************/
  57. STATIC CONST SMBIOS_TABLE_TYPE0 mBIOSInfoType0 = {
  58. { EFI_SMBIOS_TYPE_BIOS_INFORMATION, sizeof (SMBIOS_TABLE_TYPE0), 0 },
  59. 1, // Vendor String
  60. 2, // BiosVersion String
  61. 0xE000, // BiosSegment
  62. 3, // BiosReleaseDate String
  63. 0x7F, // BiosSize
  64. { // BiosCharacteristics
  65. 0, // Reserved :2; ///< Bits 0-1.
  66. 0, // Unknown :1;
  67. 0, // BiosCharacteristicsNotSupported :1;
  68. 0, // IsaIsSupported :1;
  69. 0, // McaIsSupported :1;
  70. 0, // EisaIsSupported :1;
  71. 0, // PciIsSupported :1;
  72. 0, // PcmciaIsSupported :1;
  73. 0, // PlugAndPlayIsSupported :1;
  74. 0, // ApmIsSupported :1;
  75. 1, // BiosIsUpgradable :1;
  76. 1, // BiosShadowingAllowed :1;
  77. 0, // VlVesaIsSupported :1;
  78. 0, // EscdSupportIsAvailable :1;
  79. 0, // BootFromCdIsSupported :1;
  80. 1, // SelectableBootIsSupported :1;
  81. 0, // RomBiosIsSocketed :1;
  82. 0, // BootFromPcmciaIsSupported :1;
  83. 0, // EDDSpecificationIsSupported :1;
  84. 0, // JapaneseNecFloppyIsSupported :1;
  85. 0, // JapaneseToshibaFloppyIsSupported :1;
  86. 0, // Floppy525_360IsSupported :1;
  87. 0, // Floppy525_12IsSupported :1;
  88. 0, // Floppy35_720IsSupported :1;
  89. 0, // Floppy35_288IsSupported :1;
  90. 0, // PrintScreenIsSupported :1;
  91. 0, // Keyboard8042IsSupported :1;
  92. 0, // SerialIsSupported :1;
  93. 0, // PrinterIsSupported :1;
  94. 0, // CgaMonoIsSupported :1;
  95. 0, // NecPc98 :1;
  96. 0 // ReservedForVendor :32; ///< Bits 32-63. Bits 32-47 reserved for BIOS vendor
  97. ///< and bits 48-63 reserved for System Vendor.
  98. },
  99. { // BIOSCharacteristicsExtensionBytes[]
  100. 0x81, // AcpiIsSupported :1;
  101. // UsbLegacyIsSupported :1;
  102. // AgpIsSupported :1;
  103. // I2OBootIsSupported :1;
  104. // Ls120BootIsSupported :1;
  105. // AtapiZipDriveBootIsSupported :1;
  106. // Boot1394IsSupported :1;
  107. // SmartBatteryIsSupported :1;
  108. // BIOSCharacteristicsExtensionBytes[1]
  109. 0x0a, // BiosBootSpecIsSupported :1;
  110. // FunctionKeyNetworkBootIsSupported :1;
  111. // TargetContentDistributionEnabled :1;
  112. // UefiSpecificationSupported :1;
  113. // VirtualMachineSupported :1;
  114. // ExtensionByte2Reserved :3;
  115. },
  116. 0x00, // SystemBiosMajorRelease
  117. 0x01, // SystemBiosMinorRelease
  118. 0xFF, // EmbeddedControllerFirmwareMajorRelease
  119. 0xFF, // EmbeddedControllerFirmwareMinorRelease
  120. };
  121. STATIC CHAR8 CONST * CONST mBIOSInfoType0Strings[] = {
  122. "github.com/tianocore/", // Vendor String
  123. __TIME__, // BiosVersion String
  124. __DATE__, // BiosReleaseDate String
  125. NULL
  126. };
  127. /***********************************************************************
  128. SMBIOS data definition TYPE1 System Information
  129. ************************************************************************/
  130. STATIC CONST SMBIOS_TABLE_TYPE1 mSysInfoType1 = {
  131. { EFI_SMBIOS_TYPE_SYSTEM_INFORMATION, sizeof (SMBIOS_TABLE_TYPE1), 0 },
  132. 1, // Manufacturer String
  133. 2, // ProductName String
  134. 3, // Version String
  135. 4, // SerialNumber String
  136. { 0x25EF0280, 0xEC82, 0x42B0, { 0x8F, 0xB6, 0x10, 0xAD, 0xCC, 0xC6, 0x7C, 0x02 } },
  137. SystemWakeupTypePowerSwitch,
  138. 5, // SKUNumber String
  139. 6, // Family String
  140. };
  141. STATIC CHAR8 CONST * CONST mSysInfoType1Strings[] = {
  142. "AMD",
  143. "Seattle",
  144. "1.0",
  145. "System Serial#",
  146. "System SKU#",
  147. "edk2",
  148. NULL
  149. };
  150. /***********************************************************************
  151. SMBIOS data definition TYPE2 Board Information
  152. ************************************************************************/
  153. STATIC CONST SMBIOS_TABLE_TYPE2 mBoardInfoType2 = {
  154. { EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION, sizeof (SMBIOS_TABLE_TYPE2), 0 },
  155. 1, // Manufacturer String
  156. 2, // ProductName String
  157. 3, // Version String
  158. 4, // SerialNumber String
  159. 5, // AssetTag String
  160. { // FeatureFlag
  161. 1, // Motherboard :1;
  162. 0, // RequiresDaughterCard :1;
  163. 0, // Removable :1;
  164. 0, // Replaceable :1;
  165. 0, // HotSwappable :1;
  166. 0, // Reserved :3;
  167. },
  168. 6, // LocationInChassis String
  169. 0, // ChassisHandle;
  170. BaseBoardTypeMotherBoard, // BoardType;
  171. 0, // NumberOfContainedObjectHandles;
  172. { 0 } // ContainedObjectHandles[1];
  173. };
  174. STATIC CHAR8 CONST * CONST mBoardInfoType2Strings[] = {
  175. "AMD",
  176. "Seattle",
  177. "1.0",
  178. "Base Board Serial#",
  179. "Base Board Asset Tag#",
  180. "Part Component",
  181. NULL
  182. };
  183. /***********************************************************************
  184. SMBIOS data definition TYPE3 Enclosure Information
  185. ************************************************************************/
  186. STATIC CONST SMBIOS_TABLE_TYPE3 mEnclosureInfoType3 = {
  187. { EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE, sizeof (SMBIOS_TABLE_TYPE3), 0 },
  188. 1, // Manufacturer String
  189. MiscChassisTypeLapTop, // Type;
  190. 2, // Version String
  191. 3, // SerialNumber String
  192. 4, // AssetTag String
  193. ChassisStateSafe, // BootupState;
  194. ChassisStateSafe, // PowerSupplyState;
  195. ChassisStateSafe, // ThermalState;
  196. ChassisSecurityStatusNone,// SecurityStatus;
  197. { 0, 0, 0, 0 }, // OemDefined[4];
  198. 0, // Height;
  199. 0, // NumberofPowerCords;
  200. 0, // ContainedElementCount;
  201. 0, // ContainedElementRecordLength;
  202. { { 0 } }, // ContainedElements[1];
  203. };
  204. STATIC CHAR8 CONST * CONST mEnclosureInfoType3Strings[] = {
  205. "AMD",
  206. "1.0",
  207. "Chassis Board Serial#",
  208. "Chassis Board Asset Tag#",
  209. NULL
  210. };
  211. /***********************************************************************
  212. SMBIOS data definition TYPE4 Processor Information
  213. ************************************************************************/
  214. STATIC SMBIOS_TABLE_TYPE4 mProcessorInfoType4 = {
  215. { EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE4), 0},
  216. 1, // Socket String
  217. ProcessorOther, // ProcessorType; ///< The enumeration value from PROCESSOR_TYPE_DATA.
  218. ProcessorFamilyIndicatorFamily2, // ProcessorFamily; ///< The enumeration value from PROCESSOR_FAMILY2_DATA.
  219. 2, // ProcessorManufacture String;
  220. { // ProcessorId;
  221. { // PROCESSOR_SIGNATURE
  222. 0, // ProcessorSteppingId:4;
  223. 0, // ProcessorModel: 4;
  224. 0, // ProcessorFamily: 4;
  225. 0, // ProcessorType: 2;
  226. 0, // ProcessorReserved1: 2;
  227. 0, // ProcessorXModel: 4;
  228. 0, // ProcessorXFamily: 8;
  229. 0, // ProcessorReserved2: 4;
  230. },
  231. { // PROCESSOR_FEATURE_FLAGS
  232. 0, // ProcessorFpu :1;
  233. 0, // ProcessorVme :1;
  234. 0, // ProcessorDe :1;
  235. 0, // ProcessorPse :1;
  236. 0, // ProcessorTsc :1;
  237. 0, // ProcessorMsr :1;
  238. 0, // ProcessorPae :1;
  239. 0, // ProcessorMce :1;
  240. 0, // ProcessorCx8 :1;
  241. 0, // ProcessorApic :1;
  242. 0, // ProcessorReserved1 :1;
  243. 0, // ProcessorSep :1;
  244. 0, // ProcessorMtrr :1;
  245. 0, // ProcessorPge :1;
  246. 0, // ProcessorMca :1;
  247. 0, // ProcessorCmov :1;
  248. 0, // ProcessorPat :1;
  249. 0, // ProcessorPse36 :1;
  250. 0, // ProcessorPsn :1;
  251. 0, // ProcessorClfsh :1;
  252. 0, // ProcessorReserved2 :1;
  253. 0, // ProcessorDs :1;
  254. 0, // ProcessorAcpi :1;
  255. 0, // ProcessorMmx :1;
  256. 0, // ProcessorFxsr :1;
  257. 0, // ProcessorSse :1;
  258. 0, // ProcessorSse2 :1;
  259. 0, // ProcessorSs :1;
  260. 0, // ProcessorReserved3 :1;
  261. 0, // ProcessorTm :1;
  262. 0, // ProcessorReserved4 :2;
  263. }
  264. },
  265. 3, // ProcessorVersion String;
  266. { // Voltage;
  267. 1, // ProcessorVoltageCapability5V :1;
  268. 1, // ProcessorVoltageCapability3_3V :1;
  269. 1, // ProcessorVoltageCapability2_9V :1;
  270. 0, // ProcessorVoltageCapabilityReserved :1; ///< Bit 3, must be zero.
  271. 0, // ProcessorVoltageReserved :3; ///< Bits 4-6, must be zero.
  272. 0 // ProcessorVoltageIndicateLegacy :1;
  273. },
  274. 0, // ExternalClock;
  275. 0, // MaxSpeed;
  276. 0, // CurrentSpeed;
  277. 0x41, // Status;
  278. ProcessorUpgradeOther, // ProcessorUpgrade; ///< The enumeration value from PROCESSOR_UPGRADE.
  279. 0, // L1CacheHandle;
  280. 0, // L2CacheHandle;
  281. 0, // L3CacheHandle;
  282. 4, // SerialNumber;
  283. 5, // AssetTag;
  284. 6, // PartNumber;
  285. 0, // CoreCount;
  286. 0, // EnabledCoreCount;
  287. 0, // ThreadCount;
  288. 0, // ProcessorCharacteristics;
  289. ProcessorFamilyARM, // ARM Processor Family;
  290. };
  291. STATIC CHAR8 CONST * CONST mProcessorInfoType4Strings[] = {
  292. "Socket",
  293. "ARM",
  294. #ifdef ARM_CPU_AARCH64
  295. "v8",
  296. #else
  297. "v7",
  298. #endif
  299. "1.0",
  300. "1.0",
  301. "1.0",
  302. NULL
  303. };
  304. /***********************************************************************
  305. SMBIOS data definition TYPE7 Cache Information
  306. ************************************************************************/
  307. STATIC SMBIOS_TABLE_TYPE7 mCacheInfoType7 = {
  308. { EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof (SMBIOS_TABLE_TYPE7), 0 },
  309. 1, // SocketDesignation String
  310. 0x018A, // Cache Configuration
  311. 0x00FF, // Maximum Size 256k
  312. 0x00FF, // Install Size 256k
  313. { // Supported SRAM Type
  314. 0, //Other :1
  315. 0, //Unknown :1
  316. 0, //NonBurst :1
  317. 1, //Burst :1
  318. 0, //PiplelineBurst :1
  319. 1, //Synchronous :1
  320. 0, //Asynchronous :1
  321. 0 //Reserved :9
  322. },
  323. { // Current SRAM Type
  324. 0, //Other :1
  325. 0, //Unknown :1
  326. 0, //NonBurst :1
  327. 1, //Burst :1
  328. 0, //PiplelineBurst :1
  329. 1, //Synchronous :1
  330. 0, //Asynchronous :1
  331. 0 //Reserved :9
  332. },
  333. 0, // Cache Speed unknown
  334. CacheErrorMultiBit, // Error Correction Multi
  335. CacheTypeUnknown, // System Cache Type
  336. CacheAssociativity2Way // Associativity
  337. };
  338. STATIC CONST CHAR8 *mCacheInfoType7Strings[] = {
  339. "Cache1",
  340. NULL
  341. };
  342. /***********************************************************************
  343. SMBIOS data definition TYPE9 System Slot Information
  344. ************************************************************************/
  345. STATIC CONST SMBIOS_TABLE_TYPE9 mSysSlotInfoType9 = {
  346. { EFI_SMBIOS_TYPE_SYSTEM_SLOTS, sizeof (SMBIOS_TABLE_TYPE9), 0 },
  347. 1, // SlotDesignation String
  348. SlotTypeOther, // SlotType; ///< The enumeration value from MISC_SLOT_TYPE.
  349. SlotDataBusWidthOther, // SlotDataBusWidth; ///< The enumeration value from MISC_SLOT_DATA_BUS_WIDTH.
  350. SlotUsageAvailable, // CurrentUsage; ///< The enumeration value from MISC_SLOT_USAGE.
  351. SlotLengthOther, // SlotLength; ///< The enumeration value from MISC_SLOT_LENGTH.
  352. 0, // SlotID;
  353. { // SlotCharacteristics1;
  354. 1, // CharacteristicsUnknown :1;
  355. 0, // Provides50Volts :1;
  356. 0, // Provides33Volts :1;
  357. 0, // SharedSlot :1;
  358. 0, // PcCard16Supported :1;
  359. 0, // CardBusSupported :1;
  360. 0, // ZoomVideoSupported :1;
  361. 0, // ModemRingResumeSupported:1;
  362. },
  363. { // SlotCharacteristics2;
  364. 0, // PmeSignalSupported :1;
  365. 0, // HotPlugDevicesSupported :1;
  366. 0, // SmbusSignalSupported :1;
  367. 0, // Reserved :5; ///< Set to 0.
  368. },
  369. 0, // SegmentGroupNum;
  370. 0, // BusNum;
  371. 0, // DevFuncNum;
  372. };
  373. STATIC CHAR8 CONST * CONST mSysSlotInfoType9Strings[] = {
  374. "SD Card",
  375. NULL
  376. };
  377. /***********************************************************************
  378. SMBIOS data definition TYPE16 Physical Memory ArrayInformation
  379. ************************************************************************/
  380. STATIC SMBIOS_TABLE_TYPE16 mPhyMemArrayInfoType16 = {
  381. { EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, sizeof (SMBIOS_TABLE_TYPE16), 0 },
  382. MemoryArrayLocationSystemBoard, // Location; ///< The enumeration value from MEMORY_ARRAY_LOCATION.
  383. MemoryArrayUseSystemMemory, // Use; ///< The enumeration value from MEMORY_ARRAY_USE.
  384. MemoryErrorCorrectionUnknown, // MemoryErrorCorrection; ///< The enumeration value from MEMORY_ERROR_CORRECTION.
  385. 0x80000000, // MaximumCapacity;
  386. 0xFFFE, // MemoryErrorInformationHandle;
  387. 1, // NumberOfMemoryDevices;
  388. 0x3fffffffffffffffULL, // ExtendedMaximumCapacity;
  389. };
  390. STATIC CHAR8 CONST * CONST mPhyMemArrayInfoType16Strings[] = {
  391. NULL
  392. };
  393. /***********************************************************************
  394. SMBIOS data definition TYPE17 Memory Device Information
  395. ************************************************************************/
  396. STATIC SMBIOS_TABLE_TYPE17 mMemDevInfoType17 = {
  397. { EFI_SMBIOS_TYPE_MEMORY_DEVICE, sizeof (SMBIOS_TABLE_TYPE17), 0 },
  398. 0, // MemoryArrayHandle;
  399. 0xFFFE, // MemoryErrorInformationHandle;
  400. 0xFFFF, // TotalWidth;
  401. 0xFFFF, // DataWidth;
  402. 0xFFFF, // Size;
  403. MemoryFormFactorUnknown, // FormFactor; ///< The enumeration value from MEMORY_FORM_FACTOR.
  404. 0xff, // DeviceSet;
  405. 1, // DeviceLocator String
  406. 2, // BankLocator String
  407. MemoryTypeDram, // MemoryType; ///< The enumeration value from MEMORY_DEVICE_TYPE.
  408. { // TypeDetail;
  409. 0, // Reserved :1;
  410. 0, // Other :1;
  411. 1, // Unknown :1;
  412. 0, // FastPaged :1;
  413. 0, // StaticColumn :1;
  414. 0, // PseudoStatic :1;
  415. 0, // Rambus :1;
  416. 0, // Synchronous :1;
  417. 0, // Cmos :1;
  418. 0, // Edo :1;
  419. 0, // WindowDram :1;
  420. 0, // CacheDram :1;
  421. 0, // Nonvolatile :1;
  422. 0, // Registered :1;
  423. 0, // Unbuffered :1;
  424. 0, // Reserved1 :1;
  425. },
  426. 0, // Speed;
  427. 3, // Manufacturer String
  428. 0, // SerialNumber String
  429. 0, // AssetTag String
  430. 0, // PartNumber String
  431. 0, // Attributes;
  432. 0, // ExtendedSize;
  433. 0, // ConfiguredMemoryClockSpeed;
  434. };
  435. #if (FixedPcdGetBool (PcdIscpSupport))
  436. STATIC CHAR8 CONST *mMemDevInfoType17Strings[ 7 ] = {0};
  437. #else
  438. STATIC CHAR8 CONST * CONST mMemDevInfoType17Strings[] = {
  439. "OS Virtual Memory",
  440. "malloc",
  441. "OSV",
  442. NULL
  443. };
  444. #endif
  445. /***********************************************************************
  446. SMBIOS data definition TYPE19 Memory Array Mapped Address Information
  447. ************************************************************************/
  448. STATIC SMBIOS_TABLE_TYPE19 mMemArrMapInfoType19 = {
  449. { EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, sizeof (SMBIOS_TABLE_TYPE19), 0 },
  450. 0x80000000, // StartingAddress;
  451. 0xbfffffff, // EndingAddress;
  452. 0, // MemoryArrayHandle;
  453. 1, // PartitionWidth;
  454. 0, // ExtendedStartingAddress;
  455. 0, // ExtendedEndingAddress;
  456. };
  457. STATIC CHAR8 CONST * CONST mMemArrMapInfoType19Strings[] = {
  458. NULL
  459. };
  460. /***********************************************************************
  461. SMBIOS data definition TYPE32 Boot Information
  462. ************************************************************************/
  463. STATIC CONST SMBIOS_TABLE_TYPE32 mBootInfoType32 = {
  464. { EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, sizeof (SMBIOS_TABLE_TYPE32), 0 },
  465. { 0, 0, 0, 0, 0, 0 }, // Reserved[6];
  466. BootInformationStatusNoError // BootStatus
  467. };
  468. STATIC CHAR8 CONST * CONST mBootInfoType32Strings[] = {
  469. NULL
  470. };
  471. /**
  472. Create SMBIOS record.
  473. Converts a fixed SMBIOS structure and an array of pointers to strings into
  474. an SMBIOS record where the strings are cat'ed on the end of the fixed record
  475. and terminated via a double NULL and add to SMBIOS table.
  476. SMBIOS_TABLE_TYPE32 gSmbiosType12 = {
  477. { EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 },
  478. 1 // StringCount
  479. };
  480. CHAR8 *gSmbiosType12Strings[] = {
  481. "Not Found",
  482. NULL
  483. };
  484. ...
  485. LogSmbiosData (
  486. (EFI_SMBIOS_TABLE_HEADER*)&gSmbiosType12,
  487. gSmbiosType12Strings
  488. );
  489. @param Template Fixed SMBIOS structure, required.
  490. @param StringArray Array of strings to convert to an SMBIOS string pack.
  491. NULL is OK.
  492. **/
  493. STATIC
  494. EFI_STATUS
  495. EFIAPI
  496. LogSmbiosData (
  497. IN EFI_SMBIOS_TABLE_HEADER *Template,
  498. IN CONST CHAR8* CONST *StringPack
  499. )
  500. {
  501. EFI_STATUS Status;
  502. EFI_SMBIOS_HANDLE SmbiosHandle;
  503. EFI_SMBIOS_TABLE_HEADER *Record;
  504. UINTN Index;
  505. UINTN StringSize;
  506. UINTN Size;
  507. CHAR8 *Str;
  508. // Calculate the size of the fixed record and optional string pack
  509. Size = Template->Length;
  510. if (StringPack == NULL) {
  511. // At least a double null is required
  512. Size += 2;
  513. } else {
  514. for (Index = 0; StringPack[Index] != NULL; Index++) {
  515. StringSize = AsciiStrSize (StringPack[Index]);
  516. Size += StringSize;
  517. }
  518. if (StringPack[0] == NULL) {
  519. // At least a double null is required
  520. Size += 1;
  521. }
  522. // Don't forget the terminating double null
  523. Size += 1;
  524. }
  525. // Copy over Template
  526. Record = (EFI_SMBIOS_TABLE_HEADER *)AllocateZeroPool (Size);
  527. if (Record == NULL) {
  528. return EFI_OUT_OF_RESOURCES;
  529. }
  530. CopyMem (Record, Template, Template->Length);
  531. // Append string pack
  532. Str = ((CHAR8 *)Record) + Record->Length;
  533. for (Index = 0; StringPack[Index] != NULL; Index++) {
  534. StringSize = AsciiStrSize (StringPack[Index]);
  535. CopyMem (Str, StringPack[Index], StringSize);
  536. Str += StringSize;
  537. }
  538. *Str = 0;
  539. SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
  540. Status = mSmbiosProtocol->Add (
  541. mSmbiosProtocol,
  542. gImageHandle,
  543. &SmbiosHandle,
  544. Record
  545. );
  546. ASSERT_EFI_ERROR (Status);
  547. FreePool (Record);
  548. return Status;
  549. }
  550. /***********************************************************************
  551. SMBIOS data update TYPE0 BIOS Information
  552. ************************************************************************/
  553. STATIC
  554. VOID
  555. BIOSInfoUpdateSmbiosType0 (
  556. VOID
  557. )
  558. {
  559. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mBIOSInfoType0, mBIOSInfoType0Strings);
  560. }
  561. /***********************************************************************
  562. SMBIOS data update TYPE1 System Information
  563. ************************************************************************/
  564. STATIC
  565. VOID
  566. SysInfoUpdateSmbiosType1 (
  567. VOID
  568. )
  569. {
  570. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mSysInfoType1, mSysInfoType1Strings);
  571. }
  572. /***********************************************************************
  573. SMBIOS data update TYPE2 Board Information
  574. ************************************************************************/
  575. STATIC
  576. VOID
  577. BoardInfoUpdateSmbiosType2 (
  578. VOID
  579. )
  580. {
  581. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mBoardInfoType2, mBoardInfoType2Strings);
  582. }
  583. /***********************************************************************
  584. SMBIOS data update TYPE3 Enclosure Information
  585. ************************************************************************/
  586. STATIC
  587. VOID
  588. EnclosureInfoUpdateSmbiosType3 (
  589. VOID
  590. )
  591. {
  592. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mEnclosureInfoType3, mEnclosureInfoType3Strings);
  593. }
  594. /***********************************************************************
  595. SMBIOS data update TYPE4 Processor Information
  596. ************************************************************************/
  597. STATIC
  598. VOID
  599. ProcessorInfoUpdateSmbiosType4 (
  600. VOID
  601. )
  602. {
  603. #if (FixedPcdGetBool (PcdIscpSupport))
  604. ISCP_TYPE4_SMBIOS_INFO *SmbiosT4 = &mSmbiosInfo.SmbiosCpuBuffer.T4[0];
  605. DEBUG ((EFI_D_ERROR, "Logging SmbiosType4 from ISCP.\n"));
  606. mProcessorInfoType4.ProcessorType = SmbiosT4->T4ProcType;
  607. mProcessorInfoType4.ProcessorFamily = SmbiosT4->T4ProcFamily;
  608. mProcessorInfoType4.ProcessorFamily2 = SmbiosT4->T4ProcFamily2;
  609. mProcessorInfoType4.ProcessorCharacteristics = SmbiosT4->T4ProcCharacteristics;
  610. mProcessorInfoType4.MaxSpeed = SmbiosT4->T4MaxSpeed;
  611. mProcessorInfoType4.CurrentSpeed = SmbiosT4->T4CurrentSpeed;
  612. mProcessorInfoType4.CoreCount = SmbiosT4->T4CoreCount;
  613. mProcessorInfoType4.EnabledCoreCount = SmbiosT4->T4CoreEnabled;
  614. mProcessorInfoType4.ThreadCount = SmbiosT4->T4ThreadCount;
  615. mProcessorInfoType4.ProcessorUpgrade = SmbiosT4->T4ProcUpgrade;
  616. mProcessorInfoType4.Status= (UINT8)SmbiosT4->T4Status;
  617. mProcessorInfoType4.ExternalClock = SmbiosT4->T4ExternalClock;
  618. CopyMem (&mProcessorInfoType4.ProcessorId.Signature,
  619. &SmbiosT4->T4ProcId.ProcIDLsd, sizeof(UINT32));
  620. CopyMem (&mProcessorInfoType4.ProcessorId.FeatureFlags,
  621. &SmbiosT4->T4ProcId.ProcIDMsd, sizeof(UINT32));
  622. CopyMem (&mProcessorInfoType4.Voltage,
  623. &SmbiosT4->T4Voltage, sizeof(UINT8));
  624. #else
  625. mProcessorInfoType4.ProcessorType = CentralProcessor;
  626. mProcessorInfoType4.ProcessorFamily = ProcessorFamilyIndicatorFamily2;
  627. mProcessorInfoType4.ProcessorFamily2 = ProcessorFamilyARM;
  628. #ifdef ARM_CPU_AARCH64
  629. mProcessorInfoType4.ProcessorCharacteristics = 0x6C;
  630. #else
  631. mProcessorInfoType4.ProcessorCharacteristics = 0x68;
  632. #endif
  633. mProcessorInfoType4.MaxSpeed = PcdGet32(PcdArmArchTimerFreqInHz)/1000000; // In MHz
  634. mProcessorInfoType4.CurrentSpeed = PcdGet32(PcdArmArchTimerFreqInHz)/1000000; // In MHz
  635. mProcessorInfoType4.CoreCount = PcdGet32(PcdCoreCount);
  636. mProcessorInfoType4.EnabledCoreCount = PcdGet32(PcdCoreCount);
  637. mProcessorInfoType4.ThreadCount = PcdGet32(PcdCoreCount);
  638. mProcessorInfoType4.ProcessorUpgrade = ProcessorUpgradeDaughterBoard;
  639. #endif
  640. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mProcessorInfoType4, mProcessorInfoType4Strings);
  641. }
  642. /***********************************************************************
  643. SMBIOS data update TYPE7 Cache Information
  644. ************************************************************************/
  645. STATIC
  646. VOID
  647. CacheInfoUpdateSmbiosType7 (
  648. VOID
  649. )
  650. {
  651. #if (FixedPcdGetBool (PcdIscpSupport))
  652. ISCP_TYPE7_SMBIOS_INFO *SmbiosT7;
  653. SMBIOS_TABLE_TYPE7 dstType7 = {{0}};
  654. DEBUG ((EFI_D_ERROR, "Logging SmbiosType7 from ISCP.\n"));
  655. CopyMem ((VOID *) &dstType7.Hdr, (VOID *) &mCacheInfoType7.Hdr, sizeof (SMBIOS_STRUCTURE));
  656. dstType7.SocketDesignation = 1; // "L# Cache"
  657. // L1 cache settings
  658. mCacheInfoType7Strings[0] = "L1 Cache";
  659. SmbiosT7 = &mSmbiosInfo.SmbiosCpuBuffer.T7L1[0];
  660. dstType7.CacheConfiguration = SmbiosT7->T7CacheCfg;
  661. dstType7.MaximumCacheSize = SmbiosT7->T7MaxCacheSize;
  662. dstType7.InstalledSize = SmbiosT7->T7InstallSize;
  663. CopyMem (&dstType7.SupportedSRAMType,
  664. &SmbiosT7->T7SupportedSramType, sizeof(UINT16));
  665. CopyMem (&dstType7.CurrentSRAMType,
  666. &SmbiosT7->T7CurrentSramType, sizeof(UINT16));
  667. dstType7.CacheSpeed = SmbiosT7->T7CacheSpeed;
  668. dstType7.ErrorCorrectionType = SmbiosT7->T7ErrorCorrectionType;
  669. dstType7.SystemCacheType = SmbiosT7->T7SystemCacheType;
  670. dstType7.Associativity = SmbiosT7->T7Associativity;
  671. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&dstType7, mCacheInfoType7Strings);
  672. // L2 cache settings
  673. mCacheInfoType7Strings[0] = "L2 Cache";
  674. SmbiosT7 = &mSmbiosInfo.SmbiosCpuBuffer.T7L2[0];
  675. dstType7.CacheConfiguration = SmbiosT7->T7CacheCfg;
  676. dstType7.MaximumCacheSize = SmbiosT7->T7MaxCacheSize;
  677. dstType7.InstalledSize = SmbiosT7->T7InstallSize;
  678. CopyMem (&dstType7.SupportedSRAMType,
  679. &SmbiosT7->T7SupportedSramType, sizeof(UINT16));
  680. CopyMem (&dstType7.CurrentSRAMType,
  681. &SmbiosT7->T7CurrentSramType, sizeof(UINT16));
  682. dstType7.CacheSpeed = SmbiosT7->T7CacheSpeed;
  683. dstType7.ErrorCorrectionType = SmbiosT7->T7ErrorCorrectionType;
  684. dstType7.SystemCacheType = SmbiosT7->T7SystemCacheType;
  685. dstType7.Associativity = SmbiosT7->T7Associativity;
  686. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&dstType7, mCacheInfoType7Strings);
  687. // L3 cache settings
  688. mCacheInfoType7Strings[0] = "L3 Cache";
  689. SmbiosT7 = &mSmbiosInfo.SmbiosCpuBuffer.T7L3[0];
  690. dstType7.CacheConfiguration = SmbiosT7->T7CacheCfg;
  691. dstType7.MaximumCacheSize = SmbiosT7->T7MaxCacheSize;
  692. dstType7.InstalledSize = SmbiosT7->T7InstallSize;
  693. CopyMem (&dstType7.SupportedSRAMType,
  694. &SmbiosT7->T7SupportedSramType, sizeof(UINT16));
  695. CopyMem (&dstType7.CurrentSRAMType,
  696. &SmbiosT7->T7CurrentSramType, sizeof(UINT16));
  697. dstType7.CacheSpeed = SmbiosT7->T7CacheSpeed;
  698. dstType7.ErrorCorrectionType = SmbiosT7->T7ErrorCorrectionType;
  699. dstType7.SystemCacheType = SmbiosT7->T7SystemCacheType;
  700. dstType7.Associativity = SmbiosT7->T7Associativity;
  701. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&dstType7, mCacheInfoType7Strings);
  702. #else
  703. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mCacheInfoType7, mCacheInfoType7Strings);
  704. #endif
  705. }
  706. /***********************************************************************
  707. SMBIOS data update TYPE9 System Slot Information
  708. ************************************************************************/
  709. STATIC
  710. VOID
  711. SysSlotInfoUpdateSmbiosType9 (
  712. VOID
  713. )
  714. {
  715. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mSysSlotInfoType9, mSysSlotInfoType9Strings);
  716. }
  717. /***********************************************************************
  718. SMBIOS data update TYPE16 Physical Memory Array Information
  719. ************************************************************************/
  720. STATIC
  721. VOID
  722. PhyMemArrayInfoUpdateSmbiosType16 (
  723. VOID
  724. )
  725. {
  726. #if (FixedPcdGetBool (PcdIscpSupport))
  727. ISCP_TYPE16_SMBIOS_INFO *SmbiosT16 = &mSmbiosInfo.SmbiosMemBuffer.T16;
  728. DEBUG ((EFI_D_ERROR, "Logging SmbiosType16 from ISCP.\n"));
  729. mPhyMemArrayInfoType16.Location = SmbiosT16->Location;
  730. mPhyMemArrayInfoType16.Use = SmbiosT16->Use;
  731. mPhyMemArrayInfoType16.MemoryErrorCorrection = SmbiosT16->MemoryErrorCorrection;
  732. mPhyMemArrayInfoType16.NumberOfMemoryDevices = SmbiosT16->NumberOfMemoryDevices;
  733. #endif
  734. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mPhyMemArrayInfoType16, mPhyMemArrayInfoType16Strings);
  735. }
  736. /***********************************************************************
  737. SMBIOS data update TYPE17 Memory Device Information
  738. ************************************************************************/
  739. STATIC
  740. VOID
  741. MemDevInfoUpdatedstType17 (
  742. VOID
  743. )
  744. {
  745. #if (FixedPcdGetBool (PcdIscpSupport))
  746. SMBIOS_TABLE_TYPE17 dstType17 = {{0}};
  747. ISCP_TYPE17_SMBIOS_INFO *srcType17;
  748. UINTN i, j, StrIndex, LastIndex;
  749. DEBUG ((EFI_D_ERROR, "Logging SmbiosType17 from ISCP.\n"));
  750. LastIndex = (sizeof(mMemDevInfoType17Strings) / sizeof (CHAR8 *)) - 1;
  751. for (i = 0; i < 2; ++i) {
  752. for (j = 0; j < 2; ++j) {
  753. srcType17 = &mSmbiosInfo.SmbiosMemBuffer.T17[i][j];
  754. CopyMem ((VOID *) &dstType17.Hdr, (VOID *) &mMemDevInfoType17.Hdr, sizeof (SMBIOS_STRUCTURE));
  755. dstType17.MemoryArrayHandle = srcType17->Handle;
  756. dstType17.TotalWidth = srcType17->TotalWidth;
  757. dstType17.DataWidth = srcType17->DataWidth;
  758. dstType17.Size = srcType17->MemorySize;
  759. dstType17.FormFactor = srcType17->FormFactor;
  760. dstType17.DeviceSet = srcType17->DeviceSet;
  761. dstType17.MemoryType = srcType17->MemoryType;
  762. CopyMem ((VOID *) &dstType17.TypeDetail, (VOID *) &mMemDevInfoType17.TypeDetail, sizeof (UINT16));
  763. dstType17.Speed = srcType17->Speed;
  764. dstType17.Attributes = srcType17->Attributes;
  765. dstType17.ExtendedSize = srcType17->ExtSize;
  766. dstType17.ConfiguredMemoryClockSpeed = srcType17->ConfigSpeed;
  767. // Build table of TYPE17 strings
  768. StrIndex = 0;
  769. if (AsciiStrLen ((CHAR8 *)srcType17->DeviceLocator) && StrIndex < LastIndex) {
  770. mMemDevInfoType17Strings[StrIndex++] = (CHAR8 *)srcType17->DeviceLocator;
  771. dstType17.DeviceLocator = (SMBIOS_TABLE_STRING) StrIndex;
  772. } else {
  773. dstType17.DeviceLocator = 0;
  774. }
  775. if (AsciiStrLen ((CHAR8 *)srcType17->BankLocator) && StrIndex < LastIndex) {
  776. mMemDevInfoType17Strings[StrIndex++] = (CHAR8 *)srcType17->BankLocator;
  777. dstType17.BankLocator = (SMBIOS_TABLE_STRING) StrIndex;
  778. } else {
  779. dstType17.BankLocator = 0;
  780. }
  781. if (AsciiStrLen ((CHAR8 *)srcType17->ManufacturerIdCode) && StrIndex < LastIndex) {
  782. mMemDevInfoType17Strings[StrIndex++] = (CHAR8 *)srcType17->ManufacturerIdCode;
  783. dstType17.Manufacturer = (SMBIOS_TABLE_STRING) StrIndex;
  784. } else {
  785. dstType17.Manufacturer = 0;
  786. }
  787. if (AsciiStrLen ((CHAR8 *)srcType17->SerialNumber) && StrIndex < LastIndex) {
  788. mMemDevInfoType17Strings[StrIndex++] = (CHAR8 *)srcType17->SerialNumber;
  789. dstType17.SerialNumber = (SMBIOS_TABLE_STRING) StrIndex;
  790. } else {
  791. dstType17.SerialNumber = 0;
  792. }
  793. if (AsciiStrLen ((CHAR8 *)srcType17->PartNumber) && StrIndex < LastIndex) {
  794. mMemDevInfoType17Strings[StrIndex++] = (CHAR8 *)srcType17->PartNumber;
  795. dstType17.PartNumber = (SMBIOS_TABLE_STRING) StrIndex;
  796. } else {
  797. dstType17.PartNumber = 0;
  798. }
  799. mMemDevInfoType17Strings[StrIndex] = NULL;
  800. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&dstType17, mMemDevInfoType17Strings);
  801. }
  802. }
  803. #else
  804. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mMemDevInfoType17, mMemDevInfoType17Strings);
  805. #endif
  806. }
  807. /***********************************************************************
  808. SMBIOS data update TYPE19 Memory Array Map Information
  809. ************************************************************************/
  810. STATIC
  811. VOID
  812. MemArrMapInfoUpdateSmbiosType19 (
  813. VOID
  814. )
  815. {
  816. #if (FixedPcdGetBool (PcdIscpSupport))
  817. ISCP_TYPE19_SMBIOS_INFO *SmbiosT19 = &mSmbiosInfo.SmbiosMemBuffer.T19;
  818. DEBUG ((EFI_D_ERROR, "Logging SmbiosType19 from ISCP.\n"));
  819. mMemArrMapInfoType19.StartingAddress = SmbiosT19->StartingAddr;
  820. mMemArrMapInfoType19.EndingAddress = SmbiosT19->EndingAddr;
  821. mMemArrMapInfoType19.MemoryArrayHandle = SmbiosT19->MemoryArrayHandle;
  822. mMemArrMapInfoType19.PartitionWidth = SmbiosT19->PartitionWidth;
  823. mMemArrMapInfoType19.ExtendedStartingAddress = SmbiosT19->ExtStartingAddr;
  824. mMemArrMapInfoType19.ExtendedEndingAddress = SmbiosT19->ExtEndingAddr;
  825. #endif
  826. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mMemArrMapInfoType19, mMemArrMapInfoType19Strings);
  827. }
  828. /***********************************************************************
  829. SMBIOS data update TYPE32 Boot Information
  830. ************************************************************************/
  831. STATIC
  832. VOID
  833. BootInfoUpdateSmbiosType32 (
  834. VOID
  835. )
  836. {
  837. LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mBootInfoType32, mBootInfoType32Strings);
  838. }
  839. /***********************************************************************
  840. Driver Entry
  841. ************************************************************************/
  842. EFI_STATUS
  843. EFIAPI
  844. PlatformSmbiosDriverEntryPoint (
  845. IN EFI_HANDLE ImageHandle,
  846. IN EFI_SYSTEM_TABLE *SystemTable
  847. )
  848. {
  849. EFI_STATUS Status;
  850. DEBUG ((EFI_D_ERROR, "PlatformSmbiosDxe Loaded\n"));
  851. //
  852. // Locate Smbios protocol
  853. //
  854. Status = gBS->LocateProtocol (
  855. &gEfiSmbiosProtocolGuid,
  856. NULL,
  857. (VOID **)&mSmbiosProtocol
  858. );
  859. if (EFI_ERROR (Status)) {
  860. mSmbiosProtocol = NULL;
  861. DEBUG ((EFI_D_ERROR, "Failed to Locate SMBIOS Protocol"));
  862. return Status;
  863. }
  864. #if (FixedPcdGetBool (PcdIscpSupport))
  865. Status = gBS->LocateProtocol (
  866. &gAmdIscpDxeProtocolGuid,
  867. NULL,
  868. (VOID **)&mIscpDxeProtocol
  869. );
  870. if (EFI_ERROR (Status)) {
  871. mIscpDxeProtocol = NULL;
  872. DEBUG ((EFI_D_ERROR, "Failed to Locate ISCP DXE Protocol"));
  873. return Status;
  874. }
  875. Status = mIscpDxeProtocol-> AmdExecuteSmbiosInfoDxe (
  876. mIscpDxeProtocol,
  877. &mSmbiosInfo
  878. );
  879. if (EFI_ERROR (Status)) {
  880. DEBUG ((EFI_D_ERROR, "Failed to get SMBIOS data via ISCP"));
  881. return Status;
  882. }
  883. #endif
  884. BIOSInfoUpdateSmbiosType0();
  885. SysInfoUpdateSmbiosType1();
  886. BoardInfoUpdateSmbiosType2();
  887. EnclosureInfoUpdateSmbiosType3();
  888. ProcessorInfoUpdateSmbiosType4();
  889. CacheInfoUpdateSmbiosType7();
  890. SysSlotInfoUpdateSmbiosType9();
  891. PhyMemArrayInfoUpdateSmbiosType16();
  892. MemDevInfoUpdatedstType17();
  893. MemArrMapInfoUpdateSmbiosType19();
  894. BootInfoUpdateSmbiosType32();
  895. return Status;
  896. }