PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/com32/modules/dmitest.c

https://github.com/pierre/syslinux
C | 224 lines | 177 code | 15 blank | 32 comment | 14 complexity | 32cea8b86d50c4f1ee9621f90a5e7e54 MD5 | raw file
  1. /* ----------------------------------------------------------------------- *
  2. *
  3. * Copyright 2006 Erwan Velu - All Rights Reserved
  4. *
  5. * Permission is hereby granted, free of charge, to any person
  6. * obtaining a copy of this software and associated documentation
  7. * files (the "Software"), to deal in the Software without
  8. * restriction, including without limitation the rights to use,
  9. * copy, modify, merge, publish, distribute, sublicense, and/or
  10. * sell copies of the Software, and to permit persons to whom
  11. * the Software is furnished to do so, subject to the following
  12. * conditions:
  13. *
  14. * The above copyright notice and this permission notice shall
  15. * be included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  19. * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  21. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  22. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  23. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  24. * OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. * -----------------------------------------------------------------------
  27. */
  28. /*
  29. * dmitest.c
  30. *
  31. * DMI demo program using libcom32
  32. */
  33. #include <string.h>
  34. #include <stdio.h>
  35. #include <console.h>
  36. #include "dmi/dmi.h"
  37. char display_line;
  38. void display_memory(s_dmi * dmi)
  39. {
  40. int i;
  41. for (i = 0; i < dmi->memory_count; i++) {
  42. moreprintf("Memory Bank %d\n", i);
  43. moreprintf("\tForm Factor : %s\n", dmi->memory[i].form_factor);
  44. moreprintf("\tType : %s\n", dmi->memory[i].type);
  45. moreprintf("\tType Detail : %s\n", dmi->memory[i].type_detail);
  46. moreprintf("\tSpeed : %s\n", dmi->memory[i].speed);
  47. moreprintf("\tSize : %s\n", dmi->memory[i].size);
  48. moreprintf("\tDevice Set : %s\n", dmi->memory[i].device_set);
  49. moreprintf("\tDevice Loc. : %s\n", dmi->memory[i].device_locator);
  50. moreprintf("\tBank Locator : %s\n", dmi->memory[i].bank_locator);
  51. moreprintf("\tTotal Width : %s\n", dmi->memory[i].total_width);
  52. moreprintf("\tData Width : %s\n", dmi->memory[i].data_width);
  53. moreprintf("\tError : %s\n", dmi->memory[i].error);
  54. moreprintf("\tVendor : %s\n", dmi->memory[i].manufacturer);
  55. moreprintf("\tSerial : %s\n", dmi->memory[i].serial);
  56. moreprintf("\tAsset Tag : %s\n", dmi->memory[i].asset_tag);
  57. moreprintf("\tPart Number : %s\n", dmi->memory[i].part_number);
  58. }
  59. }
  60. void display_battery(s_dmi * dmi)
  61. {
  62. moreprintf("Battery\n");
  63. moreprintf("\tVendor : %s\n", dmi->battery.manufacturer);
  64. moreprintf("\tManufacture Date : %s\n", dmi->battery.manufacture_date);
  65. moreprintf("\tSerial : %s\n", dmi->battery.serial);
  66. moreprintf("\tName : %s\n", dmi->battery.name);
  67. moreprintf("\tChemistry : %s\n", dmi->battery.chemistry);
  68. moreprintf("\tDesign Capacity : %s\n", dmi->battery.design_capacity);
  69. moreprintf("\tDesign Voltage : %s\n", dmi->battery.design_voltage);
  70. moreprintf("\tSBDS : %s\n", dmi->battery.sbds);
  71. moreprintf("\tSBDS Manufact. Date : %s\n",
  72. dmi->battery.sbds_manufacture_date);
  73. moreprintf("\tSBDS Chemistry : %s\n", dmi->battery.sbds_chemistry);
  74. moreprintf("\tMaximum Error : %s\n", dmi->battery.maximum_error);
  75. moreprintf("\tOEM Info : %s\n", dmi->battery.oem_info);
  76. }
  77. void display_bios(s_dmi * dmi)
  78. {
  79. moreprintf("BIOS\n");
  80. moreprintf("\tVendor: %s\n", dmi->bios.vendor);
  81. moreprintf("\tVersion: %s\n", dmi->bios.version);
  82. moreprintf("\tRelease: %s\n", dmi->bios.release_date);
  83. moreprintf("\tBios Revision %s\n", dmi->bios.bios_revision);
  84. moreprintf("\tFirmware Revision %s\n", dmi->bios.firmware_revision);
  85. moreprintf("\tAddress: 0x%04X0\n", dmi->bios.address);
  86. moreprintf("\tRuntime address: %u %s\n", dmi->bios.runtime_size,
  87. dmi->bios.runtime_size_unit);
  88. moreprintf("\tRom size: %u %s\n", dmi->bios.rom_size,
  89. dmi->bios.rom_size_unit);
  90. display_bios_characteristics(dmi);
  91. }
  92. void display_system(s_dmi * dmi)
  93. {
  94. moreprintf("\nSystem\n");
  95. moreprintf("\tManufacturer %s\n", dmi->system.manufacturer);
  96. moreprintf("\tProduct Name %s\n", dmi->system.product_name);
  97. moreprintf("\tVersion %s\n", dmi->system.version);
  98. moreprintf("\tSerial %s\n", dmi->system.serial);
  99. moreprintf("\tUUID %s\n", dmi->system.uuid);
  100. moreprintf("\tWakeup Type %s\n", dmi->system.wakeup_type);
  101. moreprintf("\tSKU Number %s\n", dmi->system.sku_number);
  102. moreprintf("\tFamily %s\n", dmi->system.family);
  103. }
  104. void display_base_board(s_dmi * dmi)
  105. {
  106. moreprintf("Base board\n");
  107. moreprintf("\tManufacturer %s\n", dmi->base_board.manufacturer);
  108. moreprintf("\tProduct Name %s\n", dmi->base_board.product_name);
  109. moreprintf("\tVersion %s\n", dmi->base_board.version);
  110. moreprintf("\tSerial %s\n", dmi->base_board.serial);
  111. moreprintf("\tAsset Tag %s\n", dmi->base_board.asset_tag);
  112. moreprintf("\tLocation %s\n", dmi->base_board.location);
  113. moreprintf("\tType %s\n", dmi->base_board.type);
  114. display_base_board_features(dmi);
  115. }
  116. void display_chassis(s_dmi * dmi)
  117. {
  118. moreprintf("\nChassis\n");
  119. moreprintf("\tManufacturer %s\n", dmi->chassis.manufacturer);
  120. moreprintf("\tType %s\n", dmi->chassis.type);
  121. moreprintf("\tLock %s\n", dmi->chassis.lock);
  122. moreprintf("\tVersion %s\n", dmi->chassis.version);
  123. moreprintf("\tSerial %s\n", dmi->chassis.serial);
  124. moreprintf("\tAsset Tag %s\n", dmi->chassis.asset_tag);
  125. moreprintf("\tBoot up state %s\n", dmi->chassis.boot_up_state);
  126. moreprintf("\tPower supply state %s\n", dmi->chassis.power_supply_state);
  127. moreprintf("\tThermal state %s\n", dmi->chassis.thermal_state);
  128. moreprintf("\tSecurity Status %s\n", dmi->chassis.security_status);
  129. moreprintf("\tOEM Information %s\n", dmi->chassis.oem_information);
  130. moreprintf("\tHeight %u\n", dmi->chassis.height);
  131. moreprintf("\tNB Power Cords %u\n", dmi->chassis.nb_power_cords);
  132. }
  133. void display_cpu(s_dmi * dmi)
  134. {
  135. moreprintf("\nCPU\n");
  136. moreprintf("\tSocket Designation %s\n", dmi->processor.socket_designation);
  137. moreprintf("\tType %s\n", dmi->processor.type);
  138. moreprintf("\tFamily %s\n", dmi->processor.family);
  139. moreprintf("\tManufacturer %s\n", dmi->processor.manufacturer);
  140. moreprintf("\tVersion %s\n", dmi->processor.version);
  141. moreprintf("\tExternal Clock %u\n", dmi->processor.external_clock);
  142. moreprintf("\tMax Speed %u\n", dmi->processor.max_speed);
  143. moreprintf("\tCurrent Speed %u\n", dmi->processor.current_speed);
  144. moreprintf("\tCpu Type %u\n", dmi->processor.signature.type);
  145. moreprintf("\tCpu Family %u\n", dmi->processor.signature.family);
  146. moreprintf("\tCpu Model %u\n", dmi->processor.signature.model);
  147. moreprintf("\tCpu Stepping %u\n", dmi->processor.signature.stepping);
  148. moreprintf("\tCpu Minor Stepping %u\n",
  149. dmi->processor.signature.minor_stepping);
  150. moreprintf("\tVoltage %d mV\n", dmi->processor.voltage_mv);
  151. moreprintf("\tStatus %s\n", dmi->processor.status);
  152. moreprintf("\tUpgrade %s\n", dmi->processor.upgrade);
  153. moreprintf("\tCache L1 Handle %s\n", dmi->processor.cache1);
  154. moreprintf("\tCache L2 Handle %s\n", dmi->processor.cache2);
  155. moreprintf("\tCache L3 Handle %s\n", dmi->processor.cache3);
  156. moreprintf("\tSerial %s\n", dmi->processor.serial);
  157. moreprintf("\tPart Number %s\n", dmi->processor.part_number);
  158. moreprintf("\tID %s\n", dmi->processor.id);
  159. display_processor_flags(dmi);
  160. }
  161. int main(void)
  162. {
  163. char buffer[1024];
  164. s_dmi dmi;
  165. openconsole(&dev_stdcon_r, &dev_stdcon_w);
  166. if (dmi_iterate(&dmi) == -ENODMITABLE) {
  167. printf("No DMI Structure found\n");
  168. return -1;
  169. } else {
  170. printf("DMI %u.%u present.\n", dmi.dmitable.major_version,
  171. dmi.dmitable.minor_version);
  172. printf("%d structures occupying %d bytes.\n", dmi.dmitable.num,
  173. dmi.dmitable.len);
  174. printf("DMI table at 0x%08X.\n", dmi.dmitable.base);
  175. }
  176. parse_dmitable(&dmi);
  177. for (;;) {
  178. printf
  179. ("Available commands are system, chassis, base_board, cpu, bios, memory, battery, all, exit\n");
  180. printf("dmi: ");
  181. fgets(buffer, sizeof buffer, stdin);
  182. if (!strncmp(buffer, "exit", 4))
  183. break;
  184. if (!strncmp(buffer, "system", 6))
  185. display_system(&dmi);
  186. if (!strncmp(buffer, "chassis", 6))
  187. display_chassis(&dmi);
  188. if (!strncmp(buffer, "base_board", 10))
  189. display_base_board(&dmi);
  190. if (!strncmp(buffer, "cpu", 3))
  191. display_cpu(&dmi);
  192. if (!strncmp(buffer, "bios", 4))
  193. display_bios(&dmi);
  194. if (!strncmp(buffer, "memory", 6))
  195. display_memory(&dmi);
  196. if (!strncmp(buffer, "battery", 7))
  197. display_battery(&dmi);
  198. if (!strncmp(buffer, "all", 3)) {
  199. display_bios(&dmi);
  200. display_system(&dmi);
  201. display_chassis(&dmi);
  202. display_base_board(&dmi);
  203. display_cpu(&dmi);
  204. display_memory(&dmi);
  205. display_battery(&dmi);
  206. }
  207. }
  208. return 0;
  209. }