summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-02-11 20:23:36 +0100
committerH. Peter Anvin <hpa@zytor.com>2009-02-25 20:58:40 -0800
commitc102630bf7b969a162669356a3ccf00f8d48cd9d (patch)
treed7bc2db2af8e1ab9e57f5390df8db42e6943d97f /sample
parent4dbe7f6506bfe4847a95e338d865af86a975d931 (diff)
downloadsyslinux-c102630bf7b969a162669356a3ccf00f8d48cd9d.tar.gz
hdt: Improving memory detection Adding battery detection
Diffstat (limited to 'sample')
-rw-r--r--sample/hdt.c148
1 files changed, 135 insertions, 13 deletions
diff --git a/sample/hdt.c b/sample/hdt.c
index c6de0e12..54177445 100644
--- a/sample/hdt.c
+++ b/sample/hdt.c
@@ -50,8 +50,11 @@
#define PWDATTR 0x74
#define EDITPROMPT 21
+//#define WITH_PCI 1
+#define WITH_MENU_DISPLAY 1
unsigned char MAIN_MENU, CPU_MENU, MOBO_MENU, CHASSIS_MENU, BIOS_MENU, SYSTEM_MENU, PCI_MENU;
-unsigned char PCIBYPRODUCT_MENU, PCIBYBUS_MENU;
+unsigned char MEMORY_MENU, MEMORY_SUBMENU[32], BATTERY_MENU;
+bool is_dmi_valid=false;
TIMEOUTCODE ontimeout()
{
@@ -108,6 +111,91 @@ void compute_PCI(unsigned char *menu,struct pci_domain **pci_domain) {
}
}
+
+void compute_battery(unsigned char *menu, s_dmi *dmi) {
+ char buffer[MENULEN];
+ *menu = add_menu(" Battery ",-1);
+
+ snprintf(buffer,MENULEN,"Vendor : %s",dmi->battery.manufacturer);
+ add_item(buffer,"Vendor",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"Manufacture Date: %s",dmi->battery.manufacture_date);
+ add_item(buffer,"Manufacture Date",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"Serial : %s",dmi->battery.serial);
+ add_item(buffer,"Serial",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"Name : %s",dmi->battery.name);
+ add_item(buffer,"Name",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"Chemistry : %s",dmi->battery.chemistry);
+ add_item(buffer,"Chemistry",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"Design Capacity : %s",dmi->battery.design_capacity);
+ add_item(buffer,"Design Capacity",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"Design Voltage : %s",dmi->battery.design_voltage);
+ add_item(buffer,"Design Voltage",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"SBDS : %s",dmi->battery.sbds);
+ add_item(buffer,"SBDS",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"SBDS Manuf. Date: %s",dmi->battery.sbds_manufacture_date);
+ add_item(buffer,"SBDS Manufacture Date",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"SBDS Chemistry : %s",dmi->battery.sbds_chemistry);
+ add_item(buffer,"SBDS Chemistry",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"Maximum Error : %s",dmi->battery.maximum_error);
+ add_item(buffer,"Maximum Error (%)",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"OEM Info : %s",dmi->battery.oem_info);
+ add_item(buffer,"OEM Info",OPT_INACTIVE,NULL,0);
+}
+
+
+void compute_memory_module(unsigned char *menu, s_dmi *dmi, int slot_number) {
+ int i=slot_number;
+ char buffer[MENULEN];
+ sprintf(buffer," Module <%d> ",i);
+ *menu = add_menu(buffer,-1);
+
+ sprintf(buffer,"Form Factor : %s",dmi->memory[i].form_factor);
+ add_item(buffer,"Form Factor",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Type : %s",dmi->memory[i].type);
+ add_item(buffer,"Memory Type",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Type Details : %s",dmi->memory[i].type_detail);
+ add_item(buffer,"Memory Ty^e Details",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Speed : %s",dmi->memory[i].speed);
+ add_item(buffer,"Speed (MHz)",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Size : %s",dmi->memory[i].size);
+ add_item(buffer,"Size",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Device Set : %s",dmi->memory[i].device_set);
+ add_item(buffer,"Device Set",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Device Loc. : %s",dmi->memory[i].device_locator);
+ add_item(buffer,"Device Location",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Bank Locator : %s",dmi->memory[i].bank_locator);
+ add_item(buffer,"Bank Location",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Total Width : %s",dmi->memory[i].total_width);
+ add_item(buffer,"Total bit Width",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Data Width : %s",dmi->memory[i].data_width);
+ add_item(buffer,"Data bit Width",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Error : %s",dmi->memory[i].error);
+ add_item(buffer,"Error",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Vendor : %s",dmi->memory[i].manufacturer);
+ add_item(buffer,"Vendor",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Serial : %s",dmi->memory[i].serial);
+ add_item(buffer,"Serial Number",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Asset Tag : %s",dmi->memory[i].asset_tag);
+ add_item(buffer,"Asset Tag",OPT_INACTIVE,NULL,0);
+
+ sprintf(buffer,"Part Number : %s",dmi->memory[i].part_number);
+ add_item(buffer,"Part Number",OPT_INACTIVE,NULL,0);
+
+}
+
void compute_motherboard(unsigned char *menu,s_dmi *dmi) {
char buffer[MENULEN];
*menu = add_menu(" Motherboard ",-1);
@@ -196,21 +284,23 @@ void compute_processor(unsigned char *menu,s_cpu *cpu, s_dmi *dmi) {
add_item(buffer,"Model ID",OPT_INACTIVE,NULL,0);
snprintf(buffer,MENULEN,"Stepping : %d",cpu->stepping);
add_item(buffer,"Stepping",OPT_INACTIVE,NULL,0);
- snprintf(buffer,MENULEN,"FSB : %d",dmi->processor.external_clock);
- add_item(buffer,"Front Side Bus (MHz)",OPT_INACTIVE,NULL,0);
- snprintf(buffer,MENULEN,"Cur. Speed: %d",dmi->processor.current_speed);
- add_item(buffer,"Current Speed (MHz)",OPT_INACTIVE,NULL,0);
- snprintf(buffer,MENULEN,"Max Speed : %d",dmi->processor.max_speed);
- add_item(buffer,"Max Speed (MHz)",OPT_INACTIVE,NULL,0);
- snprintf(buffer,MENULEN,"Upgrade : %s",dmi->processor.upgrade);
- add_item(buffer,"Upgrade",OPT_INACTIVE,NULL,0);
+ if (is_dmi_valid) {
+ snprintf(buffer,MENULEN,"FSB : %d",dmi->processor.external_clock);
+ add_item(buffer,"Front Side Bus (MHz)",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"Cur. Speed: %d",dmi->processor.current_speed);
+ add_item(buffer,"Current Speed (MHz)",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"Max Speed : %d",dmi->processor.max_speed);
+ add_item(buffer,"Max Speed (MHz)",OPT_INACTIVE,NULL,0);
+ snprintf(buffer,MENULEN,"Upgrade : %s",dmi->processor.upgrade);
+ add_item(buffer,"Upgrade",OPT_INACTIVE,NULL,0);
+ }
if (cpu->flags.smp) snprintf(buffer,MENULEN,"SMP : Yes");
else snprintf(buffer,MENULEN,"SMP : No");
add_item(buffer,"SMP system",OPT_INACTIVE,NULL,0);
if (cpu->flags.lm) snprintf(buffer,MENULEN,"x86_64 : Yes");
- else snprintf(buffer,MENULEN,"X86_64 : No");
+ else snprintf(buffer,MENULEN,"X86_64 : No");
add_item(buffer,"x86_64 compatible processor",OPT_INACTIVE,NULL,0);
buffer1[0]='\0';
@@ -291,12 +381,14 @@ void detect_hardware(s_dmi *dmi, s_cpu *cpu, struct pci_domain **pci_domain) {
detect_cpu(cpu);
printf("DMI: Detecting Table\n");
- detect_dmi(dmi);
+ if (detect_dmi(dmi) == 0)
+ is_dmi_valid=true;
printf("PCI: Detecting Devices\n");
/* Scanning to detect pci buses and devices */
*pci_domain = pci_scan();
+#ifdef WITH_PCI
printf("PCI: Resolving names\n");
/* Assigning product & vendor name for each device*/
get_name_from_pci_ids(*pci_domain);
@@ -308,26 +400,54 @@ void detect_hardware(s_dmi *dmi, s_cpu *cpu, struct pci_domain **pci_domain) {
printf("PCI: Resolving module names\n");
/* Detecting which kernel module should match each device */
get_module_name_from_pci_ids(*pci_domain);
+#endif
+}
+
+void compute_memory(unsigned char *menu, s_dmi *dmi) {
+char buffer[MENULEN];
+for (int i=0;i<dmi->memory_count;i++) {
+ compute_memory_module(&MEMORY_SUBMENU[i],dmi,i);
+}
+
+*menu = add_menu(" Modules ",-1);
+
+for (int i=0;i<dmi->memory_count;i++) {
+ sprintf(buffer," Module <%d> ",i);
+ add_item(buffer,"Memory Module",OPT_SUBMENU,NULL,MEMORY_SUBMENU[i]);
+}
}
void compute_submenus(s_dmi *dmi, s_cpu *cpu, struct pci_domain **pci_domain) {
+if (is_dmi_valid) {
compute_motherboard(&MOBO_MENU,dmi);
compute_chassis(&CHASSIS_MENU,dmi);
+ compute_system(&SYSTEM_MENU,dmi);
+ compute_memory(&MEMORY_MENU,dmi);
compute_bios(&BIOS_MENU,dmi);
+ compute_battery(&BATTERY_MENU,dmi);
+}
compute_processor(&CPU_MENU,cpu,dmi);
- compute_system(&SYSTEM_MENU,dmi);
+#ifdef WITH_PCI
compute_PCI(&PCI_MENU,pci_domain);
+#endif
}
void compute_main_menu() {
- MAIN_MENU = add_menu(" Main Menu ",8);
+ MAIN_MENU = add_menu(" Main Menu ",-1);
set_item_options(-1,24);
add_item("<P>rocessor","Main Processor",OPT_SUBMENU,NULL,CPU_MENU);
+
+if (is_dmi_valid) {
add_item("<M>otherboard","Motherboard",OPT_SUBMENU,NULL,MOBO_MENU);
add_item("<B>ios","Bios",OPT_SUBMENU,NULL,BIOS_MENU);
add_item("<C>hassis","Chassis",OPT_SUBMENU,NULL,CHASSIS_MENU);
add_item("<S>ystem","System",OPT_SUBMENU,NULL,SYSTEM_MENU);
+ add_item("<M>emory Modules","Memory Modules",OPT_SUBMENU,NULL,MEMORY_MENU);
+ add_item("Ba<t>tery","Battery",OPT_SUBMENU,NULL,BATTERY_MENU);
+}
+#ifdef WITH_PCI
add_item("PCI <D>evices","PCI Devices",OPT_SUBMENU,NULL,PCI_MENU);
+#endif
}
int main(void)
@@ -344,8 +464,10 @@ int main(void)
compute_main_menu();
+#ifdef WITH_MENU_DISPLAY
printf("Starting Menu\n");
showmenus(MAIN_MENU);
+#endif
return 0;
}