smbios.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. smbios.c
  5. Abstract:
  6. This module implements SMBIOS tables for the PandaBoard.
  7. Author:
  8. Evan Green 7-May-2014
  9. Environment:
  10. Firmware
  11. --*/
  12. //
  13. // ------------------------------------------------------------------- Includes
  14. //
  15. #include <minoca/lib/types.h>
  16. #include <minoca/lib/status.h>
  17. #include <minoca/lib/rtl.h>
  18. #include <minoca/fw/smbios.h>
  19. #include "uefifw.h"
  20. #include "pandafw.h"
  21. //
  22. // ---------------------------------------------------------------- Definitions
  23. //
  24. //
  25. // Set the build date and version to a hardcoded value to avoid the SMBIOS
  26. // table changing from build to build. The automated tests checksum the whole
  27. // table to get a machine ID, so if the dates or versions change then each
  28. // new firmware iteration looks like an entirely new machine.
  29. //
  30. #define PANDA_FIRMWARE_VERSION_MAJOR 1
  31. #define PANDA_FIRMWARE_VERSION_MINOR 0
  32. #define PANDA_FIRMWARE_VERSION_STRING "1.0"
  33. #define PANDA_FIRMWARE_BUILD_DATE "08/15/2014"
  34. #define PANDA_SMBIOS_BIOS_VENDOR "Minoca Corp"
  35. #define PANDA_SMBIOS_SYSTEM_MANUFACTURER "Texas Instruments"
  36. #define PANDA_SMBIOS_SYSTEM_PRODUCT_NAME "PandaBoard"
  37. #define PANDA_SMBIOS_SYSTEM_PRODUCT_NAME_ES "PandaBoard ES"
  38. #define PANDA_SMBIOS_SYSTEM_PRODUCT_VERSION ""
  39. #define PANDA_SMBIOS_MODULE_MANUFACTURER "Texas Instruments"
  40. #define PANDA_SMBIOS_PROCESSOR_MANUFACTURER "Texas Instruments"
  41. #define PANDA_SMBIOS_PROCESSOR_PART_4430 "OMAP4430"
  42. #define PANDA_SMBIOS_PROCESSOR_PART_4460 "OMAP4460"
  43. #define PANDA_SMBIOS_PROCESSOR_EXTERNAL_CLOCK 38
  44. #define PANDA_SMBIOS_PROCESSOR_MAX_SPEED_4430 1000
  45. #define PANDA_SMBIOS_PROCESSOR_MAX_SPEED_4460 1200
  46. #define PANDA_SMBIOS_PROCESSOR_CURRENT_SPEED 1000
  47. #define PANDA_SMBIOS_PROCESSOR_CORE_COUNT 2
  48. #define PANDA_SMBIOS_CACHE_L1_SIZE 32
  49. #define PANDA_SMBIOS_CACHE_L2_SIZE 1024
  50. //
  51. // ------------------------------------------------------ Data Type Definitions
  52. //
  53. //
  54. // ----------------------------------------------- Internal Function Prototypes
  55. //
  56. OMAP4_REVISION
  57. EfipOmap4GetRevision (
  58. VOID
  59. );
  60. //
  61. // -------------------------------------------------------------------- Globals
  62. //
  63. SMBIOS_BIOS_INFORMATION EfiPandaSmbiosBiosInformation = {
  64. {
  65. SmbiosBiosInformation,
  66. sizeof(SMBIOS_BIOS_INFORMATION),
  67. 0x0100
  68. },
  69. 1,
  70. 2,
  71. 0,
  72. 3,
  73. 0,
  74. SMBIOS_BIOS_CHARACTERISTIC_UNSUPPORTED,
  75. 0,
  76. PANDA_FIRMWARE_VERSION_MAJOR,
  77. PANDA_FIRMWARE_VERSION_MINOR,
  78. 0,
  79. 0
  80. };
  81. SMBIOS_SYSTEM_INFORMATION EfiPandaSmbiosSystemInformation = {
  82. {
  83. SmbiosSystemInformation,
  84. sizeof(SMBIOS_SYSTEM_INFORMATION),
  85. 0x0101
  86. },
  87. 1,
  88. 2,
  89. 3,
  90. 4,
  91. {0},
  92. SMBIOS_SYSTEM_WAKEUP_UNKNOWN,
  93. 3,
  94. 2
  95. };
  96. SMBIOS_MODULE_INFORMATION EfiPandaSmbiosModuleInformation = {
  97. {
  98. SmbiosModuleInformation,
  99. sizeof(SMBIOS_MODULE_INFORMATION),
  100. 0x0102
  101. },
  102. 1,
  103. 2,
  104. 0,
  105. 0,
  106. 0,
  107. SMBIOS_MODULE_MOTHERBOARD,
  108. 0,
  109. 0x0104,
  110. SMBIOS_MODULE_TYPE_MOTHERBOARD,
  111. 0
  112. };
  113. SMBIOS_ENCLOSURE EfiPandaSmbiosEnclosure = {
  114. {
  115. SmbiosSystemEnclosure,
  116. sizeof(SMBIOS_ENCLOSURE),
  117. 0x0104
  118. },
  119. 0,
  120. SMBIOS_ENCLOSURE_TYPE_UNKNOWN,
  121. 0,
  122. 0,
  123. 0,
  124. SMBIOS_ENCLOSURE_STATE_UNKNOWN,
  125. SMBIOS_ENCLOSURE_STATE_UNKNOWN,
  126. SMBIOS_ENCLOSURE_SECURITY_STATE_UNKNOWN,
  127. 0,
  128. 0,
  129. 0,
  130. 0,
  131. 0,
  132. 0
  133. };
  134. SMBIOS_PROCESSOR_INFORMATION EfiPandaSmbiosProcessorInformation = {
  135. {
  136. SmbiosProcessorInformation,
  137. sizeof(SMBIOS_PROCESSOR_INFORMATION),
  138. 0x0105
  139. },
  140. 0,
  141. SMBIOS_PROCESSOR_TYPE_CENTRAL_PROCESSOR,
  142. 0x2,
  143. 1,
  144. 0,
  145. 0,
  146. 0,
  147. PANDA_SMBIOS_PROCESSOR_EXTERNAL_CLOCK,
  148. PANDA_SMBIOS_PROCESSOR_MAX_SPEED_4430,
  149. PANDA_SMBIOS_PROCESSOR_CURRENT_SPEED,
  150. SMBIOS_PROCESSOR_STATUS_ENABLED,
  151. 0,
  152. 0x0106,
  153. 0x0107,
  154. 0xFFFF,
  155. 2,
  156. 0,
  157. 3,
  158. PANDA_SMBIOS_PROCESSOR_CORE_COUNT,
  159. 0,
  160. SMBIOS_PROCESSOR_CHARACTERISTIC_UNKNOWN,
  161. 0
  162. };
  163. SMBIOS_CACHE_INFORMATION EfiPandaSmbiosL1Cache = {
  164. {
  165. SmbiosCacheInformation,
  166. sizeof(SMBIOS_CACHE_INFORMATION),
  167. 0x0106
  168. },
  169. 0,
  170. SMBIOS_CACHE_ENABLED | SMBIOS_CACHE_WRITE_BACK,
  171. PANDA_SMBIOS_CACHE_L1_SIZE,
  172. PANDA_SMBIOS_CACHE_L1_SIZE,
  173. SMBIOS_CACHE_SRAM_UNKNOWN,
  174. SMBIOS_CACHE_SRAM_UNKNOWN,
  175. 0,
  176. SMBIOS_CACHE_ERROR_CORRECTION_NONE,
  177. SMBIOS_CACHE_TYPE_DATA,
  178. SMBIOS_CACHE_ASSOCIATIVITY_4_WAY_SET
  179. };
  180. SMBIOS_CACHE_INFORMATION EfiPandaSmbiosL2Cache = {
  181. {
  182. SmbiosCacheInformation,
  183. sizeof(SMBIOS_CACHE_INFORMATION),
  184. 0x0107
  185. },
  186. 0,
  187. SMBIOS_CACHE_ENABLED | SMBIOS_CACHE_WRITE_BACK,
  188. PANDA_SMBIOS_CACHE_L2_SIZE,
  189. PANDA_SMBIOS_CACHE_L2_SIZE,
  190. SMBIOS_CACHE_SRAM_UNKNOWN,
  191. SMBIOS_CACHE_SRAM_UNKNOWN,
  192. 0,
  193. SMBIOS_CACHE_ERROR_CORRECTION_NONE,
  194. SMBIOS_CACHE_TYPE_DATA,
  195. SMBIOS_CACHE_ASSOCIATIVITY_16_WAY_SET
  196. };
  197. //
  198. // ------------------------------------------------------------------ Functions
  199. //
  200. EFI_STATUS
  201. EfipPandaCreateSmbiosTables (
  202. VOID
  203. )
  204. /*++
  205. Routine Description:
  206. This routine creates the SMBIOS tables.
  207. Arguments:
  208. None.
  209. Return Value:
  210. EFI Status code.
  211. --*/
  212. {
  213. UINT32 DieId[4];
  214. CHAR8 *ProcessorPart;
  215. OMAP4_REVISION ProcessorRevision;
  216. CHAR8 *ProductName;
  217. CHAR8 SerialNumber[33];
  218. EFI_STATUS Status;
  219. Status = EfiSmbiosAddStructure(&EfiPandaSmbiosBiosInformation,
  220. PANDA_SMBIOS_BIOS_VENDOR,
  221. PANDA_FIRMWARE_VERSION_STRING,
  222. PANDA_FIRMWARE_BUILD_DATE,
  223. NULL);
  224. if (EFI_ERROR(Status)) {
  225. return Status;
  226. }
  227. //
  228. // Set the die ID as the UUID.
  229. //
  230. DieId[0] = EfiReadRegister32((VOID *)OMAP4430_FUSE_DIE_ID0);
  231. DieId[1] = EfiReadRegister32((VOID *)OMAP4430_FUSE_DIE_ID1);
  232. DieId[2] = EfiReadRegister32((VOID *)OMAP4430_FUSE_DIE_ID2);
  233. DieId[3] = EfiReadRegister32((VOID *)OMAP4430_FUSE_DIE_ID3);
  234. RtlPrintToString(SerialNumber,
  235. sizeof(SerialNumber),
  236. CharacterEncodingAscii,
  237. "%08X%08X%08X%08X",
  238. DieId[0],
  239. DieId[1],
  240. DieId[2],
  241. DieId[3]);
  242. RtlCopyMemory(EfiPandaSmbiosSystemInformation.Uuid,
  243. DieId,
  244. sizeof(EfiPandaSmbiosSystemInformation.Uuid));
  245. ProcessorRevision = EfipOmap4GetRevision();
  246. ProductName = PANDA_SMBIOS_SYSTEM_PRODUCT_NAME;
  247. if (ProcessorRevision >= Omap4460RevisionEs10) {
  248. ProductName = PANDA_SMBIOS_SYSTEM_PRODUCT_NAME_ES;
  249. }
  250. Status = EfiSmbiosAddStructure(&EfiPandaSmbiosSystemInformation,
  251. PANDA_SMBIOS_SYSTEM_MANUFACTURER,
  252. ProductName,
  253. PANDA_SMBIOS_SYSTEM_PRODUCT_VERSION,
  254. SerialNumber,
  255. NULL);
  256. if (EFI_ERROR(Status)) {
  257. return Status;
  258. }
  259. Status = EfiSmbiosAddStructure(&EfiPandaSmbiosModuleInformation,
  260. PANDA_SMBIOS_MODULE_MANUFACTURER,
  261. ProductName,
  262. NULL);
  263. if (EFI_ERROR(Status)) {
  264. return Status;
  265. }
  266. Status = EfiSmbiosAddStructure(&EfiPandaSmbiosEnclosure, NULL);
  267. if (EFI_ERROR(Status)) {
  268. return Status;
  269. }
  270. ProcessorPart = PANDA_SMBIOS_PROCESSOR_PART_4430;
  271. if (ProcessorRevision >= Omap4460RevisionEs10) {
  272. ProcessorPart = PANDA_SMBIOS_PROCESSOR_PART_4460;
  273. EfiPandaSmbiosProcessorInformation.MaxSpeed =
  274. PANDA_SMBIOS_PROCESSOR_MAX_SPEED_4460;
  275. }
  276. Status = EfiSmbiosAddStructure(&EfiPandaSmbiosProcessorInformation,
  277. PANDA_SMBIOS_PROCESSOR_MANUFACTURER,
  278. SerialNumber,
  279. ProcessorPart,
  280. NULL);
  281. if (EFI_ERROR(Status)) {
  282. return Status;
  283. }
  284. Status = EfiSmbiosAddStructure(&EfiPandaSmbiosL1Cache, NULL);
  285. if (EFI_ERROR(Status)) {
  286. return Status;
  287. }
  288. Status = EfiSmbiosAddStructure(&EfiPandaSmbiosL2Cache, NULL);
  289. if (EFI_ERROR(Status)) {
  290. return Status;
  291. }
  292. return EFI_SUCCESS;
  293. }
  294. //
  295. // --------------------------------------------------------- Internal Functions
  296. //