summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-11-24 10:24:49 +0100
committerErwan Velu <erwan.velu@free.fr>2009-11-24 10:24:49 +0100
commit990205b434e7652c835cdb2dd86ef1c43eab7b44 (patch)
tree1b6b13f1871dc6f9e6e100109a8981ac134bc176
parent0179ef2c03b7e9ec5d5dd23fa178387515384fa4 (diff)
downloadsyslinux-990205b434e7652c835cdb2dd86ef1c43eab7b44.tar.gz
hdt: Running Nindent
Impact: Visual cleanup HDT now uses the same indent as syslinux
-rw-r--r--com32/hdt/hdt-ata.h50
-rw-r--r--com32/hdt/hdt-cli-cpu.c286
-rw-r--r--com32/hdt/hdt-cli-disk.c267
-rw-r--r--com32/hdt/hdt-cli-dmi.c1123
-rw-r--r--com32/hdt/hdt-cli-hdt.c488
-rw-r--r--com32/hdt/hdt-cli-kernel.c189
-rw-r--r--com32/hdt/hdt-cli-memory.c143
-rw-r--r--com32/hdt/hdt-cli-pci.c465
-rw-r--r--com32/hdt/hdt-cli-pxe.c81
-rw-r--r--com32/hdt/hdt-cli-syslinux.c30
-rw-r--r--com32/hdt/hdt-cli-vesa.c99
-rw-r--r--com32/hdt/hdt-cli-vpd.c63
-rw-r--r--com32/hdt/hdt-cli.c1692
-rw-r--r--com32/hdt/hdt-cli.h79
-rw-r--r--com32/hdt/hdt-common.c1012
-rw-r--r--com32/hdt/hdt-common.h144
-rw-r--r--com32/hdt/hdt-menu-about.c70
-rw-r--r--com32/hdt/hdt-menu-disk.c364
-rw-r--r--com32/hdt/hdt-menu-dmi.c662
-rw-r--r--com32/hdt/hdt-menu-kernel.c101
-rw-r--r--com32/hdt/hdt-menu-memory.c602
-rw-r--r--com32/hdt/hdt-menu-pci.c312
-rw-r--r--com32/hdt/hdt-menu-processor.c395
-rw-r--r--com32/hdt/hdt-menu-pxe.c155
-rw-r--r--com32/hdt/hdt-menu-summary.c253
-rw-r--r--com32/hdt/hdt-menu-syslinux.c80
-rw-r--r--com32/hdt/hdt-menu-vesa.c144
-rw-r--r--com32/hdt/hdt-menu-vpd.c108
-rw-r--r--com32/hdt/hdt-menu.c455
-rw-r--r--com32/hdt/hdt-menu.h60
-rw-r--r--com32/hdt/hdt-util.c61
-rw-r--r--com32/hdt/hdt.c57
32 files changed, 5000 insertions, 5090 deletions
diff --git a/com32/hdt/hdt-ata.h b/com32/hdt/hdt-ata.h
index a9550837..ff35a59d 100644
--- a/com32/hdt/hdt-ata.h
+++ b/com32/hdt/hdt-ata.h
@@ -34,42 +34,42 @@
#include "hdt.h"
struct ata_identify_device {
- unsigned short words000_009[10];
- unsigned char serial_no[20];
- unsigned short words020_022[3];
- unsigned char fw_rev[8];
- unsigned char model[40];
- unsigned short words047_079[33];
- unsigned short major_rev_num;
- unsigned short minor_rev_num;
- unsigned short command_set_1;
- unsigned short command_set_2;
- unsigned short command_set_extension;
- unsigned short cfs_enable_1;
- unsigned short word086;
- unsigned short csf_default;
- unsigned short words088_255[168];
+ unsigned short words000_009[10];
+ unsigned char serial_no[20];
+ unsigned short words020_022[3];
+ unsigned char fw_rev[8];
+ unsigned char model[40];
+ unsigned short words047_079[33];
+ unsigned short major_rev_num;
+ unsigned short minor_rev_num;
+ unsigned short command_set_1;
+ unsigned short command_set_2;
+ unsigned short command_set_extension;
+ unsigned short cfs_enable_1;
+ unsigned short word086;
+ unsigned short csf_default;
+ unsigned short words088_255[168];
} ATTR_PACKED;
struct ata_driveinfo {
- struct ata_identify_device aid; /* IDENTIFY xxx DEVICE data */
- char host_bus_type[5];
- char interface_type[9];
- char interface_port;
+ struct ata_identify_device aid; /* IDENTIFY xxx DEVICE data */
+ char host_bus_type[5];
+ char interface_type[9];
+ char interface_port;
} ATTR_PACKED;
/* Useless stuff until I manage how to send ata packets */
#ifdef ATA
enum {
- ATA_ID_FW_REV = 23,
- ATA_ID_PROD = 27,
- ATA_ID_FW_REV_LEN = 8,
- ATA_ID_PROD_LEN = 40,
+ ATA_ID_FW_REV = 23,
+ ATA_ID_PROD = 27,
+ ATA_ID_FW_REV_LEN = 8,
+ ATA_ID_PROD_LEN = 40,
};
void ata_id_c_string(const uint16_t * id, unsigned char *s, unsigned int ofs,
- unsigned int len);
+ unsigned int len);
void ata_id_string(const uint16_t * id, unsigned char *s, unsigned int ofs,
- unsigned int len);
+ unsigned int len);
void printregs(const com32sys_t * r);
#endif
diff --git a/com32/hdt/hdt-cli-cpu.c b/com32/hdt/hdt-cli-cpu.c
index d2b5979f..afba2447 100644
--- a/com32/hdt/hdt-cli-cpu.c
+++ b/com32/hdt/hdt-cli-cpu.c
@@ -37,162 +37,160 @@
void main_show_cpu(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- cpu_detect(hardware);
- detect_dmi(hardware);
- more_printf("CPU\n");
- more_printf(" Manufacturer : %s \n", hardware->cpu.vendor);
- more_printf(" Product : %s \n", del_multi_spaces(hardware->cpu.model));
- if ((hardware->cpu.flags.lm == false)
- && (hardware->cpu.flags.smp == false)) {
- more_printf(" Features : %d MhZ : x86 32bits\n",
- hardware->dmi.processor.current_speed);
- } else if ((hardware->cpu.flags.lm == false)
- && (hardware->cpu.flags.smp == true)) {
- more_printf(" Features : %d MhZ : x86 32bits SMP\n",
- hardware->dmi.processor.current_speed);
- } else if ((hardware->cpu.flags.lm == true)
- && (hardware->cpu.flags.smp == false)) {
- more_printf(" Features : %d MhZ : x86_64 64bits\n",
- hardware->dmi.processor.current_speed);
- } else {
- more_printf(" Features : %d MhZ : x86_64 64bits SMP\n",
- hardware->dmi.processor.current_speed);
- }
+ cpu_detect(hardware);
+ detect_dmi(hardware);
+ more_printf("CPU\n");
+ more_printf(" Manufacturer : %s \n", hardware->cpu.vendor);
+ more_printf(" Product : %s \n", del_multi_spaces(hardware->cpu.model));
+ if ((hardware->cpu.flags.lm == false)
+ && (hardware->cpu.flags.smp == false)) {
+ more_printf(" Features : %d MhZ : x86 32bits\n",
+ hardware->dmi.processor.current_speed);
+ } else if ((hardware->cpu.flags.lm == false)
+ && (hardware->cpu.flags.smp == true)) {
+ more_printf(" Features : %d MhZ : x86 32bits SMP\n",
+ hardware->dmi.processor.current_speed);
+ } else if ((hardware->cpu.flags.lm == true)
+ && (hardware->cpu.flags.smp == false)) {
+ more_printf(" Features : %d MhZ : x86_64 64bits\n",
+ hardware->dmi.processor.current_speed);
+ } else {
+ more_printf(" Features : %d MhZ : x86_64 64bits SMP\n",
+ hardware->dmi.processor.current_speed);
+ }
}
static void show_cpu(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- char buffer[81];
- char buffer1[81];
- reset_more_printf();
- more_printf("CPU\n");
- more_printf("Vendor : %s\n", hardware->cpu.vendor);
- more_printf("Model : %s\n", hardware->cpu.model);
- more_printf("Vendor ID : %d\n", hardware->cpu.vendor_id);
- more_printf("Family ID : %d\n", hardware->cpu.family);
- more_printf("Model ID : %d\n", hardware->cpu.model_id);
- more_printf("Stepping : %d\n", hardware->cpu.stepping);
- more_printf("FSB : %d MHz\n",
- hardware->dmi.processor.external_clock);
- more_printf("Cur. Speed: %d MHz\n",
- hardware->dmi.processor.current_speed);
- more_printf("Max Speed : %d MHz\n", hardware->dmi.processor.max_speed);
- more_printf("Upgrade : %s\n", hardware->dmi.processor.upgrade);
- if (hardware->cpu.flags.smp) {
- more_printf("SMP : yes\n");
- } else {
- more_printf("SMP : no\n");
- }
- if (hardware->cpu.flags.lm) {
- more_printf("x86_64 : yes\n");
- } else {
- more_printf("x86_64 : no\n");
- }
+ char buffer[81];
+ char buffer1[81];
+ reset_more_printf();
+ more_printf("CPU\n");
+ more_printf("Vendor : %s\n", hardware->cpu.vendor);
+ more_printf("Model : %s\n", hardware->cpu.model);
+ more_printf("Vendor ID : %d\n", hardware->cpu.vendor_id);
+ more_printf("Family ID : %d\n", hardware->cpu.family);
+ more_printf("Model ID : %d\n", hardware->cpu.model_id);
+ more_printf("Stepping : %d\n", hardware->cpu.stepping);
+ more_printf("FSB : %d MHz\n", hardware->dmi.processor.external_clock);
+ more_printf("Cur. Speed: %d MHz\n", hardware->dmi.processor.current_speed);
+ more_printf("Max Speed : %d MHz\n", hardware->dmi.processor.max_speed);
+ more_printf("Upgrade : %s\n", hardware->dmi.processor.upgrade);
+ if (hardware->cpu.flags.smp) {
+ more_printf("SMP : yes\n");
+ } else {
+ more_printf("SMP : no\n");
+ }
+ if (hardware->cpu.flags.lm) {
+ more_printf("x86_64 : yes\n");
+ } else {
+ more_printf("x86_64 : no\n");
+ }
- memset(buffer, 0, sizeof(buffer));
- memset(buffer1, 0, sizeof(buffer1));
- if (hardware->cpu.flags.fpu)
- strcat(buffer1, "fpu ");
- if (hardware->cpu.flags.vme)
- strcat(buffer1, "vme ");
- if (hardware->cpu.flags.de)
- strcat(buffer1, "de ");
- if (hardware->cpu.flags.pse)
- strcat(buffer1, "pse ");
- if (hardware->cpu.flags.tsc)
- strcat(buffer1, "tsc ");
- if (hardware->cpu.flags.msr)
- strcat(buffer1, "msr ");
- if (hardware->cpu.flags.pae)
- strcat(buffer1, "pae ");
- if (hardware->cpu.flags.mce)
- strcat(buffer1, "mce ");
- if (hardware->cpu.flags.cx8)
- strcat(buffer1, "cx8 ");
- if (hardware->cpu.flags.apic)
- strcat(buffer1, "apic ");
- if (hardware->cpu.flags.sep)
- strcat(buffer1, "sep ");
- if (hardware->cpu.flags.mtrr)
- strcat(buffer1, "mtrr ");
- if (hardware->cpu.flags.pge)
- strcat(buffer1, "pge ");
- if (hardware->cpu.flags.mca)
- strcat(buffer1, "mca ");
- if (buffer1[0]) {
- snprintf(buffer, sizeof buffer, "Flags : %s\n", buffer1);
- more_printf(buffer);
- }
+ memset(buffer, 0, sizeof(buffer));
+ memset(buffer1, 0, sizeof(buffer1));
+ if (hardware->cpu.flags.fpu)
+ strcat(buffer1, "fpu ");
+ if (hardware->cpu.flags.vme)
+ strcat(buffer1, "vme ");
+ if (hardware->cpu.flags.de)
+ strcat(buffer1, "de ");
+ if (hardware->cpu.flags.pse)
+ strcat(buffer1, "pse ");
+ if (hardware->cpu.flags.tsc)
+ strcat(buffer1, "tsc ");
+ if (hardware->cpu.flags.msr)
+ strcat(buffer1, "msr ");
+ if (hardware->cpu.flags.pae)
+ strcat(buffer1, "pae ");
+ if (hardware->cpu.flags.mce)
+ strcat(buffer1, "mce ");
+ if (hardware->cpu.flags.cx8)
+ strcat(buffer1, "cx8 ");
+ if (hardware->cpu.flags.apic)
+ strcat(buffer1, "apic ");
+ if (hardware->cpu.flags.sep)
+ strcat(buffer1, "sep ");
+ if (hardware->cpu.flags.mtrr)
+ strcat(buffer1, "mtrr ");
+ if (hardware->cpu.flags.pge)
+ strcat(buffer1, "pge ");
+ if (hardware->cpu.flags.mca)
+ strcat(buffer1, "mca ");
+ if (buffer1[0]) {
+ snprintf(buffer, sizeof buffer, "Flags : %s\n", buffer1);
+ more_printf(buffer);
+ }
- memset(buffer, 0, sizeof(buffer));
- memset(buffer1, 0, sizeof(buffer1));
- if (hardware->cpu.flags.cmov)
- strcat(buffer1, "cmov ");
- if (hardware->cpu.flags.pat)
- strcat(buffer1, "pat ");
- if (hardware->cpu.flags.pse_36)
- strcat(buffer1, "pse_36 ");
- if (hardware->cpu.flags.psn)
- strcat(buffer1, "psn ");
- if (hardware->cpu.flags.clflsh)
- strcat(buffer1, "clflsh ");
- if (hardware->cpu.flags.dts)
- strcat(buffer1, "dts ");
- if (hardware->cpu.flags.acpi)
- strcat(buffer1, "acpi ");
- if (hardware->cpu.flags.mmx)
- strcat(buffer1, "mmx ");
- if (hardware->cpu.flags.sse)
- strcat(buffer1, "sse ");
- if (hardware->cpu.flags.sse2)
- strcat(buffer1, "sse2 ");
- if (hardware->cpu.flags.ss)
- strcat(buffer1, "ss ");
- if (buffer1[0]) {
- snprintf(buffer, sizeof buffer, "Flags : %s\n", buffer1);
- more_printf(buffer);
- }
+ memset(buffer, 0, sizeof(buffer));
+ memset(buffer1, 0, sizeof(buffer1));
+ if (hardware->cpu.flags.cmov)
+ strcat(buffer1, "cmov ");
+ if (hardware->cpu.flags.pat)
+ strcat(buffer1, "pat ");
+ if (hardware->cpu.flags.pse_36)
+ strcat(buffer1, "pse_36 ");
+ if (hardware->cpu.flags.psn)
+ strcat(buffer1, "psn ");
+ if (hardware->cpu.flags.clflsh)
+ strcat(buffer1, "clflsh ");
+ if (hardware->cpu.flags.dts)
+ strcat(buffer1, "dts ");
+ if (hardware->cpu.flags.acpi)
+ strcat(buffer1, "acpi ");
+ if (hardware->cpu.flags.mmx)
+ strcat(buffer1, "mmx ");
+ if (hardware->cpu.flags.sse)
+ strcat(buffer1, "sse ");
+ if (hardware->cpu.flags.sse2)
+ strcat(buffer1, "sse2 ");
+ if (hardware->cpu.flags.ss)
+ strcat(buffer1, "ss ");
+ if (buffer1[0]) {
+ snprintf(buffer, sizeof buffer, "Flags : %s\n", buffer1);
+ more_printf(buffer);
+ }
- memset(buffer, 0, sizeof(buffer));
- memset(buffer1, 0, sizeof(buffer1));
- if (hardware->cpu.flags.htt)
- strcat(buffer1, "ht ");
- if (hardware->cpu.flags.acc)
- strcat(buffer1, "acc ");
- if (hardware->cpu.flags.syscall)
- strcat(buffer1, "syscall ");
- if (hardware->cpu.flags.mp)
- strcat(buffer1, "mp ");
- if (hardware->cpu.flags.nx)
- strcat(buffer1, "nx ");
- if (hardware->cpu.flags.mmxext)
- strcat(buffer1, "mmxext ");
- if (hardware->cpu.flags.lm)
- strcat(buffer1, "lm ");
- if (hardware->cpu.flags.nowext)
- strcat(buffer1, "3dnowext ");
- if (hardware->cpu.flags.now)
- strcat(buffer1, "3dnow! ");
- if (hardware->cpu.flags.svm)
- strcat(buffer1, "svm ");
- if (hardware->cpu.flags.vmx)
- strcat(buffer1, "vmx ");
- if (buffer1[0]) {
- snprintf(buffer, sizeof buffer, "Flags : %s\n", buffer1);
- more_printf(buffer);
- }
+ memset(buffer, 0, sizeof(buffer));
+ memset(buffer1, 0, sizeof(buffer1));
+ if (hardware->cpu.flags.htt)
+ strcat(buffer1, "ht ");
+ if (hardware->cpu.flags.acc)
+ strcat(buffer1, "acc ");
+ if (hardware->cpu.flags.syscall)
+ strcat(buffer1, "syscall ");
+ if (hardware->cpu.flags.mp)
+ strcat(buffer1, "mp ");
+ if (hardware->cpu.flags.nx)
+ strcat(buffer1, "nx ");
+ if (hardware->cpu.flags.mmxext)
+ strcat(buffer1, "mmxext ");
+ if (hardware->cpu.flags.lm)
+ strcat(buffer1, "lm ");
+ if (hardware->cpu.flags.nowext)
+ strcat(buffer1, "3dnowext ");
+ if (hardware->cpu.flags.now)
+ strcat(buffer1, "3dnow! ");
+ if (hardware->cpu.flags.svm)
+ strcat(buffer1, "svm ");
+ if (hardware->cpu.flags.vmx)
+ strcat(buffer1, "vmx ");
+ if (buffer1[0]) {
+ snprintf(buffer, sizeof buffer, "Flags : %s\n", buffer1);
+ more_printf(buffer);
+ }
}
struct cli_module_descr cpu_show_modules = {
- .modules = NULL,
- .default_callback = show_cpu,
+ .modules = NULL,
+ .default_callback = show_cpu,
};
struct cli_mode_descr cpu_mode = {
- .mode = CPU_MODE,
- .name = CLI_CPU,
- .default_modules = NULL,
- .show_modules = &cpu_show_modules,
- .set_modules = NULL,
+ .mode = CPU_MODE,
+ .name = CLI_CPU,
+ .default_modules = NULL,
+ .show_modules = &cpu_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-disk.c b/com32/hdt/hdt-cli-disk.c
index c83c220e..1f5fde64 100644
--- a/com32/hdt/hdt-cli-disk.c
+++ b/com32/hdt/hdt-cli-disk.c
@@ -55,184 +55,183 @@ static void show_partition_information(struct driveinfo *drive_info,
int partition_offset,
int nb_partitions_seen)
{
- char size[9];
- char bootloader_name[9];
- char *parttype;
- unsigned int start, end;
+ char size[9];
+ char bootloader_name[9];
+ char *parttype;
+ unsigned int start, end;
- int i = nb_partitions_seen;
+ int i = nb_partitions_seen;
reset_more_printf();
- start = partition_offset;
- end = start + ptab->length - 1;
+ start = partition_offset;
+ end = start + ptab->length - 1;
- if (ptab->length > 0)
- sectors_to_size(ptab->length, size);
- else
- memset(size, 0, sizeof size);
+ if (ptab->length > 0)
+ sectors_to_size(ptab->length, size);
+ else
+ memset(size, 0, sizeof size);
- if (i == 1)
- more_printf(" # B Start End Size Id Type\n");
+ if (i == 1)
+ more_printf(" # B Start End Size Id Type\n");
- get_label(ptab->ostype, &parttype);
- more_printf("%2d %s %11d %11d %s %02X %s",
- i, (ptab->active_flag == 0x80) ? "x" : " ",
- start,
- end,
- size,
- ptab->ostype, parttype);
+ get_label(ptab->ostype, &parttype);
+ more_printf("%2d %s %11d %11d %s %02X %s",
+ i, (ptab->active_flag == 0x80) ? "x" : " ",
+ start, end, size, ptab->ostype, parttype);
- /* Extra info */
- if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab))
- more_printf("%s", " (Swsusp sig. detected)");
+ /* Extra info */
+ if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab))
+ more_printf("%s", " (Swsusp sig. detected)");
- if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0)
- more_printf("%-46s %s %s", " ", "Bootloader:", bootloader_name);
+ if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0)
+ more_printf("%-46s %s %s", " ", "Bootloader:", bootloader_name);
- more_printf("\n");
+ more_printf("\n");
- free(parttype);
+ free(parttype);
}
-void main_show_disk(int argc, char **argv,
- struct s_hardware *hardware)
+void main_show_disk(int argc, char **argv, struct s_hardware *hardware)
{
- if (!argc) {
- more_printf("Which disk?\n");
- return;
- }
+ if (!argc) {
+ more_printf("Which disk?\n");
+ return;
+ }
- int drive = strtol(argv[0], (char**) NULL, 16);
+ int drive = strtol(argv[0], (char **)NULL, 16);
- if (drive < 0x80 || drive >= 0xff) {
- more_printf("Invalid disk: %d.\n", drive);
- return;
- }
+ if (drive < 0x80 || drive >= 0xff) {
+ more_printf("Invalid disk: %d.\n", drive);
+ return;
+ }
- int i = drive - 0x80;
- struct driveinfo *d = &hardware->disk_info[i];
- char disk_size[9];
- char mbr_name[50];
+ int i = drive - 0x80;
+ struct driveinfo *d = &hardware->disk_info[i];
+ char disk_size[9];
+ char mbr_name[50];
- detect_disks(hardware);
+ detect_disks(hardware);
reset_more_printf();
- if (!hardware->disk_info[i].cbios)
- return; /* Invalid geometry */
+ if (!hardware->disk_info[i].cbios)
+ return; /* Invalid geometry */
- get_mbr_string(hardware->mbr_ids[i], &mbr_name, 50);
+ get_mbr_string(hardware->mbr_ids[i], &mbr_name, 50);
- if ((int) d->edd_params.sectors > 0)
- sectors_to_size((int) d->edd_params.sectors, disk_size);
- else
- memset(disk_size, 0, sizeof disk_size);
-
- more_printf("DISK 0x%X:\n"
- " C/H/S: %d cylinders, %d heads, %d sectors/track\n"
- " EDD: Version: %X\n"
- " Size: %s, %d bytes/sector, %d sectors/track\n"
- " Host bus: %s, Interface type: %s\n"
- " MBR: %s (id 0x%X)\n\n",
+ if ((int)d->edd_params.sectors > 0)
+ sectors_to_size((int)d->edd_params.sectors, disk_size);
+ else
+ memset(disk_size, 0, sizeof disk_size);
+
+ more_printf("DISK 0x%X:\n"
+ " C/H/S: %d cylinders, %d heads, %d sectors/track\n"
+ " EDD: Version: %X\n"
+ " Size: %s, %d bytes/sector, %d sectors/track\n"
+ " Host bus: %s, Interface type: %s\n"
+ " MBR: %s (id 0x%X)\n\n",
d->disk,
- d->legacy_max_cylinder + 1, d->legacy_max_head + 1, d->legacy_sectors_per_track,
- d->edd_version,
- disk_size, (int) d->edd_params.bytes_per_sector, (int) d->edd_params.sectors_per_track,
- remove_spaces((char *) d->edd_params.host_bus_type), remove_spaces((char*) d->edd_params.interface_type),
- mbr_name, hardware->mbr_ids[i]);
- display_line_nb += 6;
-
- if (parse_partition_table(d, &show_partition_information)) {
- if (errno_disk) {
- fprintf(stderr, "I/O error parsing disk 0x%X\n", d->disk);
- get_error("parse_partition_table");
- } else {
- fprintf(stderr, "Disk 0x%X: unrecognized partition layout\n", d->disk);
- }
- fprintf(stderr, "\n");
+ d->legacy_max_cylinder + 1, d->legacy_max_head + 1,
+ d->legacy_sectors_per_track, d->edd_version, disk_size,
+ (int)d->edd_params.bytes_per_sector,
+ (int)d->edd_params.sectors_per_track,
+ remove_spaces((char *)d->edd_params.host_bus_type),
+ remove_spaces((char *)d->edd_params.interface_type), mbr_name,
+ hardware->mbr_ids[i]);
+ display_line_nb += 6;
+
+ if (parse_partition_table(d, &show_partition_information)) {
+ if (errno_disk) {
+ fprintf(stderr, "I/O error parsing disk 0x%X\n", d->disk);
+ get_error("parse_partition_table");
+ } else {
+ fprintf(stderr, "Disk 0x%X: unrecognized partition layout\n",
+ d->disk);
}
+ fprintf(stderr, "\n");
+ }
- more_printf("\n");
+ more_printf("\n");
}
void main_show_disks(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- reset_more_printf();
- detect_disks(hardware);
+ reset_more_printf();
+ detect_disks(hardware);
int first_one = 0;
- for (int drive = 0x80; drive < 0xff; drive++) {
- if (hardware->disk_info[drive - 0x80].cbios) {
- if (!first_one) {
- first_one = 1;
- } else {
- pause_printf();
- }
- char buf[5] = "";
- sprintf(buf, "0x%x", drive);
- char *argv[1] = { buf };
- main_show_disk(1, argv, hardware);
- }
+ for (int drive = 0x80; drive < 0xff; drive++) {
+ if (hardware->disk_info[drive - 0x80].cbios) {
+ if (!first_one) {
+ first_one = 1;
+ } else {
+ pause_printf();
+ }
+ char buf[5] = "";
+ sprintf(buf, "0x%x", drive);
+ char *argv[1] = { buf };
+ main_show_disk(1, argv, hardware);
}
+ }
}
-void disks_summary(int argc __unused, char** argv __unused,
+void disks_summary(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- int i = -1;
-
- detect_disks(hardware);
- reset_more_printf();
-
- for (int drive = 0x80; drive < 0xff; drive++) {
- i++;
- if (!hardware->disk_info[i].cbios)
- continue; /* Invalid geometry */
- struct driveinfo *d = &hardware->disk_info[i];
- char disk_size[9];
-
- if ((int) d->edd_params.sectors > 0)
- sectors_to_size((int) d->edd_params.sectors, disk_size);
- else
- memset(disk_size, 0, sizeof disk_size);
-
- more_printf("DISK 0x%X:\n", d->disk);
- more_printf(" C/H/S: %d cylinders, %d heads, %d sectors/track\n",
- d->legacy_max_cylinder + 1, d->legacy_max_head + 1,
- d->legacy_sectors_per_track);
- more_printf(" EDD: Version: %X, size: %s\n", d->edd_version,
- disk_size);
- more_printf(" Host bus: %s, Interface type: %s\n\n",
- remove_spaces((char*) d->edd_params.host_bus_type),
- remove_spaces((char*) d->edd_params.interface_type));
- }
+ int i = -1;
+
+ detect_disks(hardware);
+ reset_more_printf();
+
+ for (int drive = 0x80; drive < 0xff; drive++) {
+ i++;
+ if (!hardware->disk_info[i].cbios)
+ continue; /* Invalid geometry */
+ struct driveinfo *d = &hardware->disk_info[i];
+ char disk_size[9];
+
+ if ((int)d->edd_params.sectors > 0)
+ sectors_to_size((int)d->edd_params.sectors, disk_size);
+ else
+ memset(disk_size, 0, sizeof disk_size);
+
+ more_printf("DISK 0x%X:\n", d->disk);
+ more_printf(" C/H/S: %d cylinders, %d heads, %d sectors/track\n",
+ d->legacy_max_cylinder + 1, d->legacy_max_head + 1,
+ d->legacy_sectors_per_track);
+ more_printf(" EDD: Version: %X, size: %s\n", d->edd_version,
+ disk_size);
+ more_printf(" Host bus: %s, Interface type: %s\n\n",
+ remove_spaces((char *)d->edd_params.host_bus_type),
+ remove_spaces((char *)d->edd_params.interface_type));
+ }
}
struct cli_callback_descr list_disk_show_modules[] = {
- {
- .name = "disks",
- .exec = main_show_disks,
- },
- {
- .name = "disk",
- .exec = main_show_disk,
- },
- {
- .name = NULL,
- .exec = NULL,
- },
+ {
+ .name = "disks",
+ .exec = main_show_disks,
+ },
+ {
+ .name = "disk",
+ .exec = main_show_disk,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
};
struct cli_module_descr disk_show_modules = {
- .modules = list_disk_show_modules,
- .default_callback = disks_summary,
+ .modules = list_disk_show_modules,
+ .default_callback = disks_summary,
};
struct cli_mode_descr disk_mode = {
- .mode = DISK_MODE,
- .name = CLI_DISK,
- .default_modules = NULL,
- .show_modules = &disk_show_modules,
- .set_modules = NULL,
+ .mode = DISK_MODE,
+ .name = CLI_DISK,
+ .default_modules = NULL,
+ .show_modules = &disk_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c
index d00489bc..dc0e3c66 100644
--- a/com32/hdt/hdt-cli-dmi.c
+++ b/com32/hdt/hdt-cli-dmi.c
@@ -34,471 +34,458 @@
#include "hdt-cli.h"
#include "hdt-common.h"
-static void show_dmi_modules(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+static void show_dmi_modules(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- char available_dmi_commands[1024];
- reset_more_printf();
- memset(available_dmi_commands, 0, sizeof(available_dmi_commands));
-
- more_printf("Available DMI modules on your system:\n");
- if (hardware->dmi.base_board.filled == true)
- more_printf("\t%s\n", CLI_DMI_BASE_BOARD);
- if (hardware->dmi.battery.filled == true)
- more_printf("\t%s\n", CLI_DMI_BATTERY);
- if (hardware->dmi.bios.filled == true)
- more_printf("\t%s\n", CLI_DMI_BIOS);
- if (hardware->dmi.chassis.filled == true)
- more_printf("\t%s\n", CLI_DMI_CHASSIS);
- for (int i = 0; i < hardware->dmi.memory_count; i++) {
- if (hardware->dmi.memory[i].filled == true) {
- more_printf("\tbank <number>\n");
- break;
- }
+ char available_dmi_commands[1024];
+ reset_more_printf();
+ memset(available_dmi_commands, 0, sizeof(available_dmi_commands));
+
+ more_printf("Available DMI modules on your system:\n");
+ if (hardware->dmi.base_board.filled == true)
+ more_printf("\t%s\n", CLI_DMI_BASE_BOARD);
+ if (hardware->dmi.battery.filled == true)
+ more_printf("\t%s\n", CLI_DMI_BATTERY);
+ if (hardware->dmi.bios.filled == true)
+ more_printf("\t%s\n", CLI_DMI_BIOS);
+ if (hardware->dmi.chassis.filled == true)
+ more_printf("\t%s\n", CLI_DMI_CHASSIS);
+ for (int i = 0; i < hardware->dmi.memory_count; i++) {
+ if (hardware->dmi.memory[i].filled == true) {
+ more_printf("\tbank <number>\n");
+ break;
}
- for (int i = 0; i < hardware->dmi.memory_module_count; i++) {
- if (hardware->dmi.memory_module[i].filled == true) {
- more_printf("\tmodule <number>\n");
- break;
- }
+ }
+ for (int i = 0; i < hardware->dmi.memory_module_count; i++) {
+ if (hardware->dmi.memory_module[i].filled == true) {
+ more_printf("\tmodule <number>\n");
+ break;
}
- if (hardware->dmi.processor.filled == true)
- more_printf("\t%s\n", CLI_DMI_PROCESSOR);
- if (hardware->dmi.system.filled == true)
- more_printf("\t%s\n", CLI_DMI_SYSTEM);
- if (hardware->dmi.ipmi.filled == true)
- more_printf("\t%s\n", CLI_DMI_IPMI);
- if (hardware->dmi.cache_count)
- more_printf("\t%s\n", CLI_DMI_CACHE);
- if (strlen(hardware->dmi.oem_strings))
- more_printf("\t%s\n", CLI_DMI_OEM);
- if (hardware->dmi.hardware_security.filled)
- more_printf("\t%s\n", CLI_DMI_SECURITY);
+ }
+ if (hardware->dmi.processor.filled == true)
+ more_printf("\t%s\n", CLI_DMI_PROCESSOR);
+ if (hardware->dmi.system.filled == true)
+ more_printf("\t%s\n", CLI_DMI_SYSTEM);
+ if (hardware->dmi.ipmi.filled == true)
+ more_printf("\t%s\n", CLI_DMI_IPMI);
+ if (hardware->dmi.cache_count)
+ more_printf("\t%s\n", CLI_DMI_CACHE);
+ if (strlen(hardware->dmi.oem_strings))
+ more_printf("\t%s\n", CLI_DMI_OEM);
+ if (hardware->dmi.hardware_security.filled)
+ more_printf("\t%s\n", CLI_DMI_SECURITY);
}
-static void show_dmi_base_board(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+static void show_dmi_base_board(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- if (hardware->dmi.base_board.filled == false) {
- more_printf("base_board information not found on your system, see "
- "`show list' to see which module is available.\n");
- return;
- }
- reset_more_printf();
- more_printf("Base board\n");
- more_printf(" Manufacturer : %s\n",
- hardware->dmi.base_board.manufacturer);
- more_printf(" Product Name : %s\n",
- hardware->dmi.base_board.product_name);
- more_printf(" Version : %s\n", hardware->dmi.base_board.version);
- more_printf(" Serial : %s\n", hardware->dmi.base_board.serial);
- more_printf(" Asset Tag : %s\n", hardware->dmi.base_board.asset_tag);
- more_printf(" Location : %s\n", hardware->dmi.base_board.location);
- more_printf(" Type : %s\n", hardware->dmi.base_board.type);
- for (int i = 0; i < BASE_BOARD_NB_ELEMENTS; i++) {
- if (((bool *) (&hardware->dmi.base_board.features))[i] == true) {
- more_printf(" %s\n", base_board_features_strings[i]);
+ if (hardware->dmi.base_board.filled == false) {
+ more_printf("base_board information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
}
- }
-
- for (unsigned int i=0; i<sizeof hardware->dmi.base_board.devices_information/sizeof *hardware->dmi.base_board.devices_information; i++) {
- if (strlen(hardware->dmi.base_board.devices_information[i].type)) {
- more_printf("On Board Device #%u Information\n", i)
- more_printf(" Type : %s\n", hardware->dmi.base_board.devices_information[i].type);
- more_printf(" Status : %s\n", hardware->dmi.base_board.devices_information[i].status ? "Enabled" : "Disabled");
- more_printf(" Description : %s\n", hardware->dmi.base_board.devices_information[i].description);
+ reset_more_printf();
+ more_printf("Base board\n");
+ more_printf(" Manufacturer : %s\n", hardware->dmi.base_board.manufacturer);
+ more_printf(" Product Name : %s\n", hardware->dmi.base_board.product_name);
+ more_printf(" Version : %s\n", hardware->dmi.base_board.version);
+ more_printf(" Serial : %s\n", hardware->dmi.base_board.serial);
+ more_printf(" Asset Tag : %s\n", hardware->dmi.base_board.asset_tag);
+ more_printf(" Location : %s\n", hardware->dmi.base_board.location);
+ more_printf(" Type : %s\n", hardware->dmi.base_board.type);
+ for (int i = 0; i < BASE_BOARD_NB_ELEMENTS; i++) {
+ if (((bool *) (&hardware->dmi.base_board.features))[i] == true) {
+ more_printf(" %s\n", base_board_features_strings[i]);
+ }
+ }
+
+ for (unsigned int i = 0;
+ i <
+ sizeof hardware->dmi.base_board.devices_information /
+ sizeof *hardware->dmi.base_board.devices_information; i++) {
+ if (strlen(hardware->dmi.base_board.devices_information[i].type)) {
+ more_printf("On Board Device #%u Information\n", i)
+ more_printf(" Type : %s\n",
+ hardware->dmi.base_board.devices_information[i].
+ type);
+ more_printf(" Status : %s\n",
+ hardware->dmi.base_board.devices_information[i].
+ status ? "Enabled" : "Disabled");
+ more_printf(" Description : %s\n",
+ hardware->dmi.base_board.devices_information[i].
+ description);
+ }
}
- }
}
-static void show_dmi_system(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+static void show_dmi_system(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- if (hardware->dmi.system.filled == false) {
- more_printf("system information not found on your system, see "
- "`show list' to see which module is available.\n");
- return;
- }
- reset_more_printf();
- more_printf("System\n");
- more_printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer);
- more_printf(" Product Name : %s\n", hardware->dmi.system.product_name);
- more_printf(" Version : %s\n", hardware->dmi.system.version);
- more_printf(" Serial : %s\n", hardware->dmi.system.serial);
- more_printf(" UUID : %s\n", hardware->dmi.system.uuid);
- more_printf(" Wakeup Type : %s\n", hardware->dmi.system.wakeup_type);
- more_printf(" SKU Number : %s\n", hardware->dmi.system.sku_number);
- more_printf(" Family : %s\n", hardware->dmi.system.family);
-
- if (strlen(hardware->dmi.system.configuration_options)) {
- more_printf("System Configuration Options\n");
- more_printf("%s\n", hardware->dmi.system.configuration_options);
- }
-
- if (hardware->dmi.system.system_reset.filled) {
- more_printf("System Reset\n");
- more_printf(" Status : %s\n",
- (hardware->dmi.system.system_reset.status ? "Enabled" : "Disabled"));
- more_printf(" Watchdog Timer : %s\n",
- (hardware->dmi.system.system_reset.watchdog ? "Present" : "Not Present"));
- if (strlen(hardware->dmi.system.system_reset.boot_option))
- more_printf(" Boot Option : %s\n", hardware->dmi.system.system_reset.boot_option);
- if (strlen(hardware->dmi.system.system_reset.boot_option_on_limit))
- more_printf(" Boot Option On Limit : %s\n", hardware->dmi.system.system_reset.boot_option_on_limit);
- if (strlen(hardware->dmi.system.system_reset.reset_count))
- more_printf(" Reset Count : %s\n", hardware->dmi.system.system_reset.reset_count);
- if (strlen(hardware->dmi.system.system_reset.reset_limit))
- more_printf(" Reset Limit : %s\n", hardware->dmi.system.system_reset.reset_limit);
- if (strlen(hardware->dmi.system.system_reset.timer_interval))
- more_printf(" Timer Interval : %s\n", hardware->dmi.system.system_reset.timer_interval);
- if (strlen(hardware->dmi.system.system_reset.timeout))
- more_printf(" Timeout : %s\n", hardware->dmi.system.system_reset.timeout);
- }
-
- more_printf("System Boot Information\n");
- more_printf(" Status : %s\n", hardware->dmi.system.system_boot_status);
+ if (hardware->dmi.system.filled == false) {
+ more_printf("system information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("System\n");
+ more_printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer);
+ more_printf(" Product Name : %s\n", hardware->dmi.system.product_name);
+ more_printf(" Version : %s\n", hardware->dmi.system.version);
+ more_printf(" Serial : %s\n", hardware->dmi.system.serial);
+ more_printf(" UUID : %s\n", hardware->dmi.system.uuid);
+ more_printf(" Wakeup Type : %s\n", hardware->dmi.system.wakeup_type);
+ more_printf(" SKU Number : %s\n", hardware->dmi.system.sku_number);
+ more_printf(" Family : %s\n", hardware->dmi.system.family);
+
+ if (strlen(hardware->dmi.system.configuration_options)) {
+ more_printf("System Configuration Options\n");
+ more_printf("%s\n", hardware->dmi.system.configuration_options);
+ }
+
+ if (hardware->dmi.system.system_reset.filled) {
+ more_printf("System Reset\n");
+ more_printf(" Status : %s\n",
+ (hardware->dmi.system.system_reset.
+ status ? "Enabled" : "Disabled"));
+ more_printf(" Watchdog Timer : %s\n",
+ (hardware->dmi.system.system_reset.
+ watchdog ? "Present" : "Not Present"));
+ if (strlen(hardware->dmi.system.system_reset.boot_option))
+ more_printf(" Boot Option : %s\n",
+ hardware->dmi.system.system_reset.boot_option);
+ if (strlen(hardware->dmi.system.system_reset.boot_option_on_limit))
+ more_printf(" Boot Option On Limit : %s\n",
+ hardware->dmi.system.system_reset.boot_option_on_limit);
+ if (strlen(hardware->dmi.system.system_reset.reset_count))
+ more_printf(" Reset Count : %s\n",
+ hardware->dmi.system.system_reset.reset_count);
+ if (strlen(hardware->dmi.system.system_reset.reset_limit))
+ more_printf(" Reset Limit : %s\n",
+ hardware->dmi.system.system_reset.reset_limit);
+ if (strlen(hardware->dmi.system.system_reset.timer_interval))
+ more_printf(" Timer Interval : %s\n",
+ hardware->dmi.system.system_reset.timer_interval);
+ if (strlen(hardware->dmi.system.system_reset.timeout))
+ more_printf(" Timeout : %s\n",
+ hardware->dmi.system.system_reset.timeout);
+ }
+
+ more_printf("System Boot Information\n");
+ more_printf(" Status : %s\n",
+ hardware->dmi.system.system_boot_status);
}
-static void show_dmi_bios(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+static void show_dmi_bios(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- if (hardware->dmi.bios.filled == false) {
- more_printf("bios information not found on your system, see "
- "`show list' to see which module is available.\n");
- return;
- }
- reset_more_printf();
- more_printf("BIOS\n");
- more_printf(" Vendor : %s\n", hardware->dmi.bios.vendor);
- more_printf(" Version : %s\n", hardware->dmi.bios.version);
- more_printf(" Release Date : %s\n",
- hardware->dmi.bios.release_date);
- more_printf(" Bios Revision : %s\n",
- hardware->dmi.bios.bios_revision);
- if (strlen(hardware->dmi.bios.firmware_revision))
- more_printf(" Firmware Revision : %s\n",
- hardware->dmi.bios.firmware_revision);
- more_printf(" Address : 0x%04X0\n",
- hardware->dmi.bios.address);
- more_printf(" Runtime address : %u %s\n",
- hardware->dmi.bios.runtime_size,
- hardware->dmi.bios.runtime_size_unit);
- more_printf(" Rom size : %u %s\n", hardware->dmi.bios.rom_size,
- hardware->dmi.bios.rom_size_unit);
-
- for (int i = 0; i < BIOS_CHAR_NB_ELEMENTS; i++) {
- if (((bool *) (&hardware->dmi.bios.characteristics))[i] == true) {
- more_printf(" %s\n", bios_charac_strings[i]);
+ if (hardware->dmi.bios.filled == false) {
+ more_printf("bios information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("BIOS\n");
+ more_printf(" Vendor : %s\n", hardware->dmi.bios.vendor);
+ more_printf(" Version : %s\n", hardware->dmi.bios.version);
+ more_printf(" Release Date : %s\n", hardware->dmi.bios.release_date);
+ more_printf(" Bios Revision : %s\n", hardware->dmi.bios.bios_revision);
+ if (strlen(hardware->dmi.bios.firmware_revision))
+ more_printf(" Firmware Revision : %s\n",
+ hardware->dmi.bios.firmware_revision);
+ more_printf(" Address : 0x%04X0\n", hardware->dmi.bios.address);
+ more_printf(" Runtime address : %u %s\n",
+ hardware->dmi.bios.runtime_size,
+ hardware->dmi.bios.runtime_size_unit);
+ more_printf(" Rom size : %u %s\n", hardware->dmi.bios.rom_size,
+ hardware->dmi.bios.rom_size_unit);
+
+ for (int i = 0; i < BIOS_CHAR_NB_ELEMENTS; i++) {
+ if (((bool *) (&hardware->dmi.bios.characteristics))[i] == true) {
+ more_printf(" %s\n", bios_charac_strings[i]);
+ }
}
- }
- for (int i = 0; i < BIOS_CHAR_X1_NB_ELEMENTS; i++) {
- if (((bool *) (&hardware->dmi.bios.characteristics_x1))[i] ==
- true) {
- more_printf(" %s\n", bios_charac_x1_strings[i]);
+ for (int i = 0; i < BIOS_CHAR_X1_NB_ELEMENTS; i++) {
+ if (((bool *) (&hardware->dmi.bios.characteristics_x1))[i] == true) {
+ more_printf(" %s\n", bios_charac_x1_strings[i]);
+ }
}
- }
- for (int i = 0; i < BIOS_CHAR_X2_NB_ELEMENTS; i++) {
- if (((bool *) (&hardware->dmi.bios.characteristics_x2))[i] ==
- true) {
- more_printf(" %s\n", bios_charac_x2_strings[i]);
+ for (int i = 0; i < BIOS_CHAR_X2_NB_ELEMENTS; i++) {
+ if (((bool *) (&hardware->dmi.bios.characteristics_x2))[i] == true) {
+ more_printf(" %s\n", bios_charac_x2_strings[i]);
+ }
}
- }
}
-static void show_dmi_chassis(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+static void show_dmi_chassis(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- if (hardware->dmi.chassis.filled == false) {
- more_printf("chassis information not found on your system, see "
- "`show list' to see which module is available.\n");
- return;
- }
- reset_more_printf();
- more_printf("Chassis\n");
- more_printf(" Manufacturer : %s\n",
- hardware->dmi.chassis.manufacturer);
- more_printf(" Type : %s\n", hardware->dmi.chassis.type);
- more_printf(" Lock : %s\n", hardware->dmi.chassis.lock);
- more_printf(" Version : %s\n",
- hardware->dmi.chassis.version);
- more_printf(" Serial : %s\n", hardware->dmi.chassis.serial);
- more_printf(" Asset Tag : %s\n",
- del_multi_spaces(hardware->dmi.chassis.asset_tag));
- more_printf(" Boot up state : %s\n",
- hardware->dmi.chassis.boot_up_state);
- more_printf(" Power supply state : %s\n",
- hardware->dmi.chassis.power_supply_state);
- more_printf(" Thermal state : %s\n",
- hardware->dmi.chassis.thermal_state);
- more_printf(" Security Status : %s\n",
- hardware->dmi.chassis.security_status);
- more_printf(" OEM Information : %s\n",
- hardware->dmi.chassis.oem_information);
- more_printf(" Height : %u\n", hardware->dmi.chassis.height);
- more_printf(" NB Power Cords : %u\n",
- hardware->dmi.chassis.nb_power_cords);
+ if (hardware->dmi.chassis.filled == false) {
+ more_printf("chassis information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("Chassis\n");
+ more_printf(" Manufacturer : %s\n",
+ hardware->dmi.chassis.manufacturer);
+ more_printf(" Type : %s\n", hardware->dmi.chassis.type);
+ more_printf(" Lock : %s\n", hardware->dmi.chassis.lock);
+ more_printf(" Version : %s\n", hardware->dmi.chassis.version);
+ more_printf(" Serial : %s\n", hardware->dmi.chassis.serial);
+ more_printf(" Asset Tag : %s\n",
+ del_multi_spaces(hardware->dmi.chassis.asset_tag));
+ more_printf(" Boot up state : %s\n",
+ hardware->dmi.chassis.boot_up_state);
+ more_printf(" Power supply state : %s\n",
+ hardware->dmi.chassis.power_supply_state);
+ more_printf(" Thermal state : %s\n",
+ hardware->dmi.chassis.thermal_state);
+ more_printf(" Security Status : %s\n",
+ hardware->dmi.chassis.security_status);
+ more_printf(" OEM Information : %s\n",
+ hardware->dmi.chassis.oem_information);
+ more_printf(" Height : %u\n", hardware->dmi.chassis.height);
+ more_printf(" NB Power Cords : %u\n",
+ hardware->dmi.chassis.nb_power_cords);
}
static void show_dmi_ipmi(int argc __unused, char **argv __unused,
- struct s_hardware *hardware)
+ struct s_hardware *hardware)
{
- if (hardware->dmi.ipmi.filled == false) {
- more_printf("IPMI module not available\n");
- return;
- }
- reset_more_printf();
- more_printf("IPMI\n");
- more_printf(" Interface Type : %s\n",
- hardware->dmi.ipmi.interface_type);
- more_printf(" Specification Ver. : %u.%u\n",
- hardware->dmi.ipmi.major_specification_version,
- hardware->dmi.ipmi.minor_specification_version);
- more_printf(" I2C Slave Address : 0x%02x\n",
- hardware->dmi.ipmi.I2C_slave_address);
- more_printf(" Nv Storage Address : %u\n",
- hardware->dmi.ipmi.nv_address);
- uint32_t high = hardware->dmi.ipmi.base_address >> 32;
- uint32_t low = hardware->dmi.ipmi.base_address & 0xFFFF;
- more_printf(" Base Address : %08X%08X\n",
- high,(low & ~1));
- more_printf(" IRQ : %d\n",
- hardware->dmi.ipmi.irq);
+ if (hardware->dmi.ipmi.filled == false) {
+ more_printf("IPMI module not available\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("IPMI\n");
+ more_printf(" Interface Type : %s\n",
+ hardware->dmi.ipmi.interface_type);
+ more_printf(" Specification Ver. : %u.%u\n",
+ hardware->dmi.ipmi.major_specification_version,
+ hardware->dmi.ipmi.minor_specification_version);
+ more_printf(" I2C Slave Address : 0x%02x\n",
+ hardware->dmi.ipmi.I2C_slave_address);
+ more_printf(" Nv Storage Address : %u\n", hardware->dmi.ipmi.nv_address);
+ uint32_t high = hardware->dmi.ipmi.base_address >> 32;
+ uint32_t low = hardware->dmi.ipmi.base_address & 0xFFFF;
+ more_printf(" Base Address : %08X%08X\n", high, (low & ~1));
+ more_printf(" IRQ : %d\n", hardware->dmi.ipmi.irq);
}
-static void show_dmi_battery(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+static void show_dmi_battery(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- if (hardware->dmi.battery.filled == false) {
- more_printf("battery information not found on your system, see "
- "`show list' to see which module is available.\n");
- return;
- }
- reset_more_printf();
- more_printf("Battery \n");
- more_printf(" Vendor : %s\n",
- hardware->dmi.battery.manufacturer);
- more_printf(" Manufacture Date : %s\n",
- hardware->dmi.battery.manufacture_date);
- more_printf(" Serial : %s\n", hardware->dmi.battery.serial);
- more_printf(" Name : %s\n", hardware->dmi.battery.name);
- more_printf(" Chemistry : %s\n",
- hardware->dmi.battery.chemistry);
- more_printf(" Design Capacity : %s\n",
- hardware->dmi.battery.design_capacity);
- more_printf(" Design Voltage : %s\n",
- hardware->dmi.battery.design_voltage);
- more_printf(" SBDS : %s\n", hardware->dmi.battery.sbds);
- more_printf(" SBDS Manuf. Date : %s\n",
- hardware->dmi.battery.sbds_manufacture_date);
- more_printf(" SBDS Chemistry : %s\n",
- hardware->dmi.battery.sbds_chemistry);
- more_printf(" Maximum Error : %s\n",
- hardware->dmi.battery.maximum_error);
- more_printf(" OEM Info : %s\n",
- hardware->dmi.battery.oem_info);
+ if (hardware->dmi.battery.filled == false) {
+ more_printf("battery information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("Battery \n");
+ more_printf(" Vendor : %s\n",
+ hardware->dmi.battery.manufacturer);
+ more_printf(" Manufacture Date : %s\n",
+ hardware->dmi.battery.manufacture_date);
+ more_printf(" Serial : %s\n", hardware->dmi.battery.serial);
+ more_printf(" Name : %s\n", hardware->dmi.battery.name);
+ more_printf(" Chemistry : %s\n", hardware->dmi.battery.chemistry);
+ more_printf(" Design Capacity : %s\n",
+ hardware->dmi.battery.design_capacity);
+ more_printf(" Design Voltage : %s\n",
+ hardware->dmi.battery.design_voltage);
+ more_printf(" SBDS : %s\n", hardware->dmi.battery.sbds);
+ more_printf(" SBDS Manuf. Date : %s\n",
+ hardware->dmi.battery.sbds_manufacture_date);
+ more_printf(" SBDS Chemistry : %s\n",
+ hardware->dmi.battery.sbds_chemistry);
+ more_printf(" Maximum Error : %s\n",
+ hardware->dmi.battery.maximum_error);
+ more_printf(" OEM Info : %s\n", hardware->dmi.battery.oem_info);
}
-static void show_dmi_cpu(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+static void show_dmi_cpu(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- if (hardware->dmi.processor.filled == false) {
- more_printf("processor information not found on your system, see "
- "`show list' to see which module is available.\n");
- return;
- }
- reset_more_printf();
- more_printf("CPU\n");
- more_printf(" Socket Designation : %s\n",
- hardware->dmi.processor.socket_designation);
- more_printf(" Type : %s\n", hardware->dmi.processor.type);
- more_printf(" Family : %s\n",
- hardware->dmi.processor.family);
- more_printf(" Manufacturer : %s\n",
- hardware->dmi.processor.manufacturer);
- more_printf(" Version : %s\n",
- hardware->dmi.processor.version);
- more_printf(" External Clock : %u\n",
- hardware->dmi.processor.external_clock);
- more_printf(" Max Speed : %u\n",
- hardware->dmi.processor.max_speed);
- more_printf(" Current Speed : %u\n",
- hardware->dmi.processor.current_speed);
- more_printf(" Cpu Type : %u\n",
- hardware->dmi.processor.signature.type);
- more_printf(" Cpu Family : %u\n",
- hardware->dmi.processor.signature.family);
- more_printf(" Cpu Model : %u\n",
- hardware->dmi.processor.signature.model);
- more_printf(" Cpu Stepping : %u\n",
- hardware->dmi.processor.signature.stepping);
- more_printf(" Cpu Minor Stepping : %u\n",
- hardware->dmi.processor.signature.minor_stepping);
+ if (hardware->dmi.processor.filled == false) {
+ more_printf("processor information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("CPU\n");
+ more_printf(" Socket Designation : %s\n",
+ hardware->dmi.processor.socket_designation);
+ more_printf(" Type : %s\n", hardware->dmi.processor.type);
+ more_printf(" Family : %s\n", hardware->dmi.processor.family);
+ more_printf(" Manufacturer : %s\n",
+ hardware->dmi.processor.manufacturer);
+ more_printf(" Version : %s\n", hardware->dmi.processor.version);
+ more_printf(" External Clock : %u\n",
+ hardware->dmi.processor.external_clock);
+ more_printf(" Max Speed : %u\n",
+ hardware->dmi.processor.max_speed);
+ more_printf(" Current Speed : %u\n",
+ hardware->dmi.processor.current_speed);
+ more_printf(" Cpu Type : %u\n",
+ hardware->dmi.processor.signature.type);
+ more_printf(" Cpu Family : %u\n",
+ hardware->dmi.processor.signature.family);
+ more_printf(" Cpu Model : %u\n",
+ hardware->dmi.processor.signature.model);
+ more_printf(" Cpu Stepping : %u\n",
+ hardware->dmi.processor.signature.stepping);
+ more_printf(" Cpu Minor Stepping : %u\n",
+ hardware->dmi.processor.signature.minor_stepping);
// more_printf(" Voltage : %f\n",hardware->dmi.processor.voltage);
- more_printf(" Status : %s\n",
- hardware->dmi.processor.status);
- more_printf(" Upgrade : %s\n",
- hardware->dmi.processor.upgrade);
- more_printf(" Cache L1 Handle : %s\n",
- hardware->dmi.processor.cache1);
- more_printf(" Cache L2 Handle : %s\n",
- hardware->dmi.processor.cache2);
- more_printf(" Cache L3 Handle : %s\n",
- hardware->dmi.processor.cache3);
- more_printf(" Serial : %s\n",
- hardware->dmi.processor.serial);
- more_printf(" Part Number : %s\n",
- hardware->dmi.processor.part_number);
- more_printf(" ID : %s\n", hardware->dmi.processor.id);
- for (int i = 0; i < PROCESSOR_FLAGS_ELEMENTS; i++) {
- if (((bool *) (&hardware->dmi.processor.cpu_flags))[i] == true) {
- more_printf(" %s\n", cpu_flags_strings[i]);
+ more_printf(" Status : %s\n", hardware->dmi.processor.status);
+ more_printf(" Upgrade : %s\n", hardware->dmi.processor.upgrade);
+ more_printf(" Cache L1 Handle : %s\n", hardware->dmi.processor.cache1);
+ more_printf(" Cache L2 Handle : %s\n", hardware->dmi.processor.cache2);
+ more_printf(" Cache L3 Handle : %s\n", hardware->dmi.processor.cache3);
+ more_printf(" Serial : %s\n", hardware->dmi.processor.serial);
+ more_printf(" Part Number : %s\n",
+ hardware->dmi.processor.part_number);
+ more_printf(" ID : %s\n", hardware->dmi.processor.id);
+ for (int i = 0; i < PROCESSOR_FLAGS_ELEMENTS; i++) {
+ if (((bool *) (&hardware->dmi.processor.cpu_flags))[i] == true) {
+ more_printf(" %s\n", cpu_flags_strings[i]);
+ }
}
- }
}
-void show_dmi_memory_bank(int argc, char** argv,
- struct s_hardware *hardware)
+void show_dmi_memory_bank(int argc, char **argv, struct s_hardware *hardware)
{
- int bank = -1;
+ int bank = -1;
- /* Sanitize arguments */
- if (argc > 0)
- bank = strtol(argv[0], (char **)NULL, 10);
+ /* Sanitize arguments */
+ if (argc > 0)
+ bank = strtol(argv[0], (char **)NULL, 10);
- if (errno == ERANGE || bank < 0) {
- more_printf("This bank number is incorrect\n");
- return;
- }
+ if (errno == ERANGE || bank < 0) {
+ more_printf("This bank number is incorrect\n");
+ return;
+ }
- if ((bank >= hardware->dmi.memory_count) || (bank < 0)) {
- more_printf("Bank %d number doesn't exist\n", bank);
- return;
- }
- if (hardware->dmi.memory[bank].filled == false) {
- more_printf("Bank %d doesn't contain any information\n", bank);
- return;
- }
-
- reset_more_printf();
- more_printf("Memory Bank %d\n", bank);
- more_printf(" Form Factor : %s\n",
- hardware->dmi.memory[bank].form_factor);
- more_printf(" Type : %s\n", hardware->dmi.memory[bank].type);
- more_printf(" Type Detail : %s\n",
- hardware->dmi.memory[bank].type_detail);
- more_printf(" Speed : %s\n", hardware->dmi.memory[bank].speed);
- more_printf(" Size : %s\n", hardware->dmi.memory[bank].size);
- more_printf(" Device Set : %s\n",
- hardware->dmi.memory[bank].device_set);
- more_printf(" Device Loc. : %s\n",
- hardware->dmi.memory[bank].device_locator);
- more_printf(" Bank Locator : %s\n",
- hardware->dmi.memory[bank].bank_locator);
- more_printf(" Total Width : %s\n",
- hardware->dmi.memory[bank].total_width);
- more_printf(" Data Width : %s\n",
- hardware->dmi.memory[bank].data_width);
- more_printf(" Error : %s\n", hardware->dmi.memory[bank].error);
- more_printf(" Vendor : %s\n",
- hardware->dmi.memory[bank].manufacturer);
- more_printf(" Serial : %s\n", hardware->dmi.memory[bank].serial);
- more_printf(" Asset Tag : %s\n",
- hardware->dmi.memory[bank].asset_tag);
- more_printf(" Part Number : %s\n",
- hardware->dmi.memory[bank].part_number);
+ if ((bank >= hardware->dmi.memory_count) || (bank < 0)) {
+ more_printf("Bank %d number doesn't exist\n", bank);
+ return;
+ }
+ if (hardware->dmi.memory[bank].filled == false) {
+ more_printf("Bank %d doesn't contain any information\n", bank);
+ return;
+ }
+
+ reset_more_printf();
+ more_printf("Memory Bank %d\n", bank);
+ more_printf(" Form Factor : %s\n", hardware->dmi.memory[bank].form_factor);
+ more_printf(" Type : %s\n", hardware->dmi.memory[bank].type);
+ more_printf(" Type Detail : %s\n", hardware->dmi.memory[bank].type_detail);
+ more_printf(" Speed : %s\n", hardware->dmi.memory[bank].speed);
+ more_printf(" Size : %s\n", hardware->dmi.memory[bank].size);
+ more_printf(" Device Set : %s\n", hardware->dmi.memory[bank].device_set);
+ more_printf(" Device Loc. : %s\n",
+ hardware->dmi.memory[bank].device_locator);
+ more_printf(" Bank Locator : %s\n",
+ hardware->dmi.memory[bank].bank_locator);
+ more_printf(" Total Width : %s\n", hardware->dmi.memory[bank].total_width);
+ more_printf(" Data Width : %s\n", hardware->dmi.memory[bank].data_width);
+ more_printf(" Error : %s\n", hardware->dmi.memory[bank].error);
+ more_printf(" Vendor : %s\n",
+ hardware->dmi.memory[bank].manufacturer);
+ more_printf(" Serial : %s\n", hardware->dmi.memory[bank].serial);
+ more_printf(" Asset Tag : %s\n", hardware->dmi.memory[bank].asset_tag);
+ more_printf(" Part Number : %s\n", hardware->dmi.memory[bank].part_number);
}
-static void show_dmi_cache(int argc, char** argv,
- struct s_hardware *hardware)
+static void show_dmi_cache(int argc, char **argv, struct s_hardware *hardware)
{
- if (!hardware->dmi.cache_count) {
- more_printf("cache information not found on your system, see "
- "`show list' to see which module is available.\n");
- return;
- }
+ if (!hardware->dmi.cache_count) {
+ more_printf("cache information not found on your system, see "
+ "`show list' to see which module is available.\n");
+ return;
+ }
- int cache = strtol(argv[0], NULL, 10);
+ int cache = strtol(argv[0], NULL, 10);
- if (argc != 1 || cache > hardware->dmi.cache_count) {
- more_printf("show cache [0-%d]\n", hardware->dmi.cache_count-1);
- return;
- }
+ if (argc != 1 || cache > hardware->dmi.cache_count) {
+ more_printf("show cache [0-%d]\n", hardware->dmi.cache_count - 1);
+ return;
+ }
- reset_more_printf();
-
- more_printf("Cache Information #%d\n", cache);
- more_printf(" Socket Designation : %s\n",
- hardware->dmi.cache[cache].socket_designation);
- more_printf(" Configuration : %s\n",
- hardware->dmi.cache[cache].configuration);
- more_printf(" Operational Mode : %s\n",
- hardware->dmi.cache[cache].mode);
- more_printf(" Location : %s\n",
- hardware->dmi.cache[cache].location);
- more_printf(" Installed Size : %u KB",
- hardware->dmi.cache[cache].installed_size);
- more_printf("\n");
- more_printf(" Maximum Size : %u KB",
- hardware->dmi.cache[cache].max_size);
- more_printf("\n");
- more_printf(" Supported SRAM Types : %s",
- hardware->dmi.cache[cache].supported_sram_types);
- more_printf("\n");
- more_printf(" Installed SRAM Type : %s",
- hardware->dmi.cache[cache].installed_sram_types);
- more_printf("\n");
- more_printf(" Speed : %u ns",
- hardware->dmi.cache[cache].speed);
- more_printf("\n");
- more_printf(" Error Correction Type : %s\n",
- hardware->dmi.cache[cache].error_correction_type);
- more_printf(" System Type : %s\n",
- hardware->dmi.cache[cache].system_type);
- more_printf(" Associativity : %s\n",
- hardware->dmi.cache[cache].associativity);
+ reset_more_printf();
+
+ more_printf("Cache Information #%d\n", cache);
+ more_printf(" Socket Designation : %s\n",
+ hardware->dmi.cache[cache].socket_designation);
+ more_printf(" Configuration : %s\n",
+ hardware->dmi.cache[cache].configuration);
+ more_printf(" Operational Mode : %s\n",
+ hardware->dmi.cache[cache].mode);
+ more_printf(" Location : %s\n",
+ hardware->dmi.cache[cache].location);
+ more_printf(" Installed Size : %u KB",
+ hardware->dmi.cache[cache].installed_size);
+ more_printf("\n");
+ more_printf(" Maximum Size : %u KB",
+ hardware->dmi.cache[cache].max_size);
+ more_printf("\n");
+ more_printf(" Supported SRAM Types : %s",
+ hardware->dmi.cache[cache].supported_sram_types);
+ more_printf("\n");
+ more_printf(" Installed SRAM Type : %s",
+ hardware->dmi.cache[cache].installed_sram_types);
+ more_printf("\n");
+ more_printf(" Speed : %u ns",
+ hardware->dmi.cache[cache].speed);
+ more_printf("\n");
+ more_printf(" Error Correction Type : %s\n",
+ hardware->dmi.cache[cache].error_correction_type);
+ more_printf(" System Type : %s\n",
+ hardware->dmi.cache[cache].system_type);
+ more_printf(" Associativity : %s\n",
+ hardware->dmi.cache[cache].associativity);
}
-void show_dmi_memory_module(int argc, char** argv,
- struct s_hardware *hardware)
+void show_dmi_memory_module(int argc, char **argv, struct s_hardware *hardware)
{
- int module = -1;
+ int module = -1;
- /* Sanitize arguments */
- if (argc > 0)
- module = strtol(argv[0], (char **)NULL, 10);
+ /* Sanitize arguments */
+ if (argc > 0)
+ module = strtol(argv[0], (char **)NULL, 10);
- if (errno == ERANGE || module < 0) {
- more_printf("This module number is incorrect\n");
- return;
- }
+ if (errno == ERANGE || module < 0) {
+ more_printf("This module number is incorrect\n");
+ return;
+ }
- if ((module >= hardware->dmi.memory_module_count) || (module < 0)) {
- more_printf("Module number %d doesn't exist\n", module);
- return;
- }
+ if ((module >= hardware->dmi.memory_module_count) || (module < 0)) {
+ more_printf("Module number %d doesn't exist\n", module);
+ return;
+ }
- if (hardware->dmi.memory_module[module].filled == false) {
- more_printf("Module %d doesn't contain any information\n", module);
- return;
- }
+ if (hardware->dmi.memory_module[module].filled == false) {
+ more_printf("Module %d doesn't contain any information\n", module);
+ return;
+ }
- reset_more_printf();
- more_printf("Memory Module %d\n", module);
- more_printf(" Socket Designation : %s\n",
+ reset_more_printf();
+ more_printf("Memory Module %d\n", module);
+ more_printf(" Socket Designation : %s\n",
hardware->dmi.memory_module[module].socket_designation);
- more_printf(" Bank Connections : %s\n",
+ more_printf(" Bank Connections : %s\n",
hardware->dmi.memory_module[module].bank_connections);
- more_printf(" Current Speed : %s\n",
+ more_printf(" Current Speed : %s\n",
hardware->dmi.memory_module[module].speed);
- more_printf(" Type : %s\n",
+ more_printf(" Type : %s\n",
hardware->dmi.memory_module[module].type);
- more_printf(" Installed Size : %s\n",
+ more_printf(" Installed Size : %s\n",
hardware->dmi.memory_module[module].installed_size);
- more_printf(" Enabled Size : %s\n",
+ more_printf(" Enabled Size : %s\n",
hardware->dmi.memory_module[module].enabled_size);
- more_printf(" Error Status : %s\n",
+ more_printf(" Error Status : %s\n",
hardware->dmi.memory_module[module].error_status);
}
@@ -506,193 +493,193 @@ void main_show_dmi(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- detect_dmi(hardware);
+ detect_dmi(hardware);
- if (hardware->is_dmi_valid == false) {
- more_printf("No valid DMI table found, exiting.\n");
- return;
- }
- reset_more_printf();
- more_printf("DMI Table version %u.%u found\n",
- hardware->dmi.dmitable.major_version,
- hardware->dmi.dmitable.minor_version);
+ if (hardware->is_dmi_valid == false) {
+ more_printf("No valid DMI table found, exiting.\n");
+ return;
+ }
+ reset_more_printf();
+ more_printf("DMI Table version %u.%u found\n",
+ hardware->dmi.dmitable.major_version,
+ hardware->dmi.dmitable.minor_version);
- show_dmi_modules(0, NULL, hardware);
+ show_dmi_modules(0, NULL, hardware);
}
-void show_dmi_memory_modules(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+void show_dmi_memory_modules(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- /* Do we have so display unpopulated banks ?*/
- int show_free_banks = 1;
-
- /* Needed, if called by the memory mode */
- detect_dmi(hardware);
-
- more_printf("Memory Size : %lu MB (%lu KB)\n",
- (hardware->detected_memory_size + (1<<9)) >>10,
- hardware->detected_memory_size);
-
- if ((hardware->dmi.memory_count <= 0) && (hardware->dmi.memory_module_count <= 0)) {
- more_printf("No memory bank found\n");
- return;
- }
-
- /* Sanitize arguments */
- if (argc > 0) {
- /* When we display a summary, there is no need to show the unpopulated banks
- * The first argv is set to define this behavior
- */
- show_free_banks = strtol(argv[0], NULL, 10);
- if (errno == ERANGE || show_free_banks < 0 || show_free_banks > 1)
- goto usage;
- }
-
- reset_more_printf();
- /* If type 17 is available */
- if (hardware->dmi.memory_count>0) {
- char bank_number[255];
- more_printf("Memory Banks\n");
- for (int i = 0; i < hardware->dmi.memory_count; i++) {
- if (hardware->dmi.memory[i].filled == true) {
- memset(bank_number, 0, sizeof(bank_number));
- snprintf(bank_number, sizeof(bank_number), "%d ", i);
- if (show_free_banks == false) {
- if (strncmp
- (hardware->dmi.memory[i].size, "Free", 4))
- more_printf(" bank %02d : %s %s@%s\n",
- i, hardware->dmi.memory[i].size,
- hardware->dmi.memory[i].type,
- hardware->dmi.memory[i].speed);
- } else {
- more_printf(" bank %02d : %s %s@%s\n", i,
- hardware->dmi.memory[i].size,
- hardware->dmi.memory[i].type,
- hardware->dmi.memory[i].speed);
- }
+ /* Do we have so display unpopulated banks ? */
+ int show_free_banks = 1;
+
+ /* Needed, if called by the memory mode */
+ detect_dmi(hardware);
+
+ more_printf("Memory Size : %lu MB (%lu KB)\n",
+ (hardware->detected_memory_size + (1 << 9)) >> 10,
+ hardware->detected_memory_size);
+
+ if ((hardware->dmi.memory_count <= 0)
+ && (hardware->dmi.memory_module_count <= 0)) {
+ more_printf("No memory bank found\n");
+ return;
+ }
+
+ /* Sanitize arguments */
+ if (argc > 0) {
+ /* When we display a summary, there is no need to show the unpopulated banks
+ * The first argv is set to define this behavior
+ */
+ show_free_banks = strtol(argv[0], NULL, 10);
+ if (errno == ERANGE || show_free_banks < 0 || show_free_banks > 1)
+ goto usage;
}
- }
- } else if (hardware->dmi.memory_module_count>0) {
- /* Let's use type 6 as a fallback of type 17*/
- more_printf("Memory Modules\n");
- for (int i = 0; i < hardware->dmi.memory_module_count; i++) {
- if (hardware->dmi.memory_module[i].filled == true) {
- more_printf(" module %02d : %s %s@%s\n", i,
- hardware->dmi.memory_module[i].enabled_size,
- hardware->dmi.memory_module[i].type,
- hardware->dmi.memory_module[i].speed);
- }
+
+ reset_more_printf();
+ /* If type 17 is available */
+ if (hardware->dmi.memory_count > 0) {
+ char bank_number[255];
+ more_printf("Memory Banks\n");
+ for (int i = 0; i < hardware->dmi.memory_count; i++) {
+ if (hardware->dmi.memory[i].filled == true) {
+ memset(bank_number, 0, sizeof(bank_number));
+ snprintf(bank_number, sizeof(bank_number), "%d ", i);
+ if (show_free_banks == false) {
+ if (strncmp(hardware->dmi.memory[i].size, "Free", 4))
+ more_printf(" bank %02d : %s %s@%s\n",
+ i, hardware->dmi.memory[i].size,
+ hardware->dmi.memory[i].type,
+ hardware->dmi.memory[i].speed);
+ } else {
+ more_printf(" bank %02d : %s %s@%s\n", i,
+ hardware->dmi.memory[i].size,
+ hardware->dmi.memory[i].type,
+ hardware->dmi.memory[i].speed);
+ }
+ }
+ }
+ } else if (hardware->dmi.memory_module_count > 0) {
+ /* Let's use type 6 as a fallback of type 17 */
+ more_printf("Memory Modules\n");
+ for (int i = 0; i < hardware->dmi.memory_module_count; i++) {
+ if (hardware->dmi.memory_module[i].filled == true) {
+ more_printf(" module %02d : %s %s@%s\n", i,
+ hardware->dmi.memory_module[i].enabled_size,
+ hardware->dmi.memory_module[i].type,
+ hardware->dmi.memory_module[i].speed);
+ }
+ }
}
- }
- return;
- //printf("Type 'show bank<bank_number>' for more details.\n");
+ return;
+ //printf("Type 'show bank<bank_number>' for more details.\n");
usage:
- more_printf("show memory <clear screen? <show free banks?>>\n");
- return;
+ more_printf("show memory <clear screen? <show free banks?>>\n");
+ return;
}
-void show_dmi_oem_strings(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+void show_dmi_oem_strings(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- reset_more_printf();
+ reset_more_printf();
- if (strlen(hardware->dmi.oem_strings))
- more_printf("OEM Strings\n%s", hardware->dmi.oem_strings);
+ if (strlen(hardware->dmi.oem_strings))
+ more_printf("OEM Strings\n%s", hardware->dmi.oem_strings);
}
-void show_dmi_hardware_security(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+void show_dmi_hardware_security(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
- reset_more_printf();
-
- if (!hardware->dmi.hardware_security.filled)
- return;
-
- more_printf("Hardware Security\n");
- more_printf(" Power-On Password Status : %s\n",
- hardware->dmi.hardware_security.power_on_passwd_status);
- more_printf(" Keyboard Password Status : %s\n",
- hardware->dmi.hardware_security.keyboard_passwd_status);
- more_printf(" Administrator Password Status : %s\n",
- hardware->dmi.hardware_security.administrator_passwd_status);
- more_printf(" Front Panel Reset Status : %s\n",
- hardware->dmi.hardware_security.front_panel_reset_status);
+ reset_more_printf();
+
+ if (!hardware->dmi.hardware_security.filled)
+ return;
+
+ more_printf("Hardware Security\n");
+ more_printf(" Power-On Password Status : %s\n",
+ hardware->dmi.hardware_security.power_on_passwd_status);
+ more_printf(" Keyboard Password Status : %s\n",
+ hardware->dmi.hardware_security.keyboard_passwd_status);
+ more_printf(" Administrator Password Status : %s\n",
+ hardware->dmi.hardware_security.administrator_passwd_status);
+ more_printf(" Front Panel Reset Status : %s\n",
+ hardware->dmi.hardware_security.front_panel_reset_status);
}
struct cli_callback_descr list_dmi_show_modules[] = {
- {
- .name = CLI_DMI_BASE_BOARD,
- .exec = show_dmi_base_board,
- },
- {
- .name = CLI_DMI_BIOS,
- .exec = show_dmi_bios,
- },
- {
- .name = CLI_DMI_BATTERY,
- .exec = show_dmi_battery,
- },
- {
- .name = CLI_DMI_CHASSIS,
- .exec = show_dmi_chassis,
- },
- {
- .name = CLI_DMI_MEMORY,
- .exec = show_dmi_memory_modules,
- },
- {
- .name = CLI_DMI_MEMORY_BANK,
- .exec = show_dmi_memory_bank,
- },
- {
- .name = "module",
- .exec = show_dmi_memory_module,
- },
- {
- .name = CLI_DMI_PROCESSOR,
- .exec = show_dmi_cpu,
- },
- {
- .name = CLI_DMI_SYSTEM,
- .exec = show_dmi_system,
- },
- {
- .name = CLI_DMI_OEM,
- .exec = show_dmi_oem_strings,
- },
- {
- .name = CLI_DMI_SECURITY,
- .exec = show_dmi_hardware_security,
- },
- {
- .name = CLI_DMI_IPMI,
- .exec = show_dmi_ipmi,
- },
- {
- .name = CLI_DMI_CACHE,
- .exec = show_dmi_cache,
- },
- {
- .name = CLI_DMI_LIST,
- .exec = show_dmi_modules,
- },
- {
- .name = NULL,
- .exec = NULL,
- },
+ {
+ .name = CLI_DMI_BASE_BOARD,
+ .exec = show_dmi_base_board,
+ },
+ {
+ .name = CLI_DMI_BIOS,
+ .exec = show_dmi_bios,
+ },
+ {
+ .name = CLI_DMI_BATTERY,
+ .exec = show_dmi_battery,
+ },
+ {
+ .name = CLI_DMI_CHASSIS,
+ .exec = show_dmi_chassis,
+ },
+ {
+ .name = CLI_DMI_MEMORY,
+ .exec = show_dmi_memory_modules,
+ },
+ {
+ .name = CLI_DMI_MEMORY_BANK,
+ .exec = show_dmi_memory_bank,
+ },
+ {
+ .name = "module",
+ .exec = show_dmi_memory_module,
+ },
+ {
+ .name = CLI_DMI_PROCESSOR,
+ .exec = show_dmi_cpu,
+ },
+ {
+ .name = CLI_DMI_SYSTEM,
+ .exec = show_dmi_system,
+ },
+ {
+ .name = CLI_DMI_OEM,
+ .exec = show_dmi_oem_strings,
+ },
+ {
+ .name = CLI_DMI_SECURITY,
+ .exec = show_dmi_hardware_security,
+ },
+ {
+ .name = CLI_DMI_IPMI,
+ .exec = show_dmi_ipmi,
+ },
+ {
+ .name = CLI_DMI_CACHE,
+ .exec = show_dmi_cache,
+ },
+ {
+ .name = CLI_DMI_LIST,
+ .exec = show_dmi_modules,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
};
struct cli_module_descr dmi_show_modules = {
- .modules = list_dmi_show_modules,
- .default_callback = main_show_dmi,
+ .modules = list_dmi_show_modules,
+ .default_callback = main_show_dmi,
};
struct cli_mode_descr dmi_mode = {
- .mode = DMI_MODE,
- .name = CLI_DMI,
- .default_modules = NULL,
- .show_modules = &dmi_show_modules,
- .set_modules = NULL,
+ .mode = DMI_MODE,
+ .name = CLI_DMI,
+ .default_modules = NULL,
+ .show_modules = &dmi_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c
index f11cbec4..99a54b41 100644
--- a/com32/hdt/hdt-cli-hdt.c
+++ b/com32/hdt/hdt-cli-hdt.c
@@ -38,27 +38,27 @@
/**
* cli_clear_screen - clear (erase) the entire screen
**/
-static void cli_clear_screen(int argc __unused, char** argv __unused,
+static void cli_clear_screen(int argc __unused, char **argv __unused,
struct s_hardware *hardware __unused)
{
- clear_screen();
+ clear_screen();
}
/**
* main_show_modes - show availables modes
**/
-static void main_show_modes(int argc __unused, char** argv __unused,
+static void main_show_modes(int argc __unused, char **argv __unused,
struct s_hardware *hardware __unused)
{
- int i = 0;
+ int i = 0;
reset_more_printf();
- printf("Available modes:\n");
- while (list_modes[i]) {
- printf("%s ", list_modes[i]->name);
- i++;
- }
- printf("\n");
+ printf("Available modes:\n");
+ while (list_modes[i]) {
+ printf("%s ", list_modes[i]->name);
+ i++;
+ }
+ printf("\n");
}
/**
@@ -66,137 +66,128 @@ static void main_show_modes(int argc __unused, char** argv __unused,
*
* The mode number must be supplied in argv, position 0.
**/
-static void cli_set_mode(int argc, char **argv,
- struct s_hardware *hardware)
+static void cli_set_mode(int argc, char **argv, struct s_hardware *hardware)
{
- cli_mode_t new_mode;
+ cli_mode_t new_mode;
reset_more_printf();
- if (argc <= 0) {
- more_printf("Which mode?\n");
- return;
- }
-
- /*
- * Note! argv[0] is a string representing the mode, we need the
- * equivalent cli_mode_t to pass it to set_mode.
- */
- new_mode = mode_s_to_mode_t(argv[0]);
- set_mode(new_mode, hardware);
+ if (argc <= 0) {
+ more_printf("Which mode?\n");
+ return;
+ }
+
+ /*
+ * Note! argv[0] is a string representing the mode, we need the
+ * equivalent cli_mode_t to pass it to set_mode.
+ */
+ new_mode = mode_s_to_mode_t(argv[0]);
+ set_mode(new_mode, hardware);
}
/**
* do_exit - shared helper to exit a mode
**/
-static void do_exit(int argc __unused, char** argv __unused,
+static void do_exit(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- int new_mode = HDT_MODE;
-
- switch (hdt_cli.mode) {
- case HDT_MODE:
- new_mode = EXIT_MODE;
- break;
- default:
- new_mode = HDT_MODE;
- break;
- }
-
- dprintf("CLI DEBUG: Switching from mode %d to mode %d\n", hdt_cli.mode,
- new_mode);
- set_mode(new_mode, hardware);
+ int new_mode = HDT_MODE;
+
+ switch (hdt_cli.mode) {
+ case HDT_MODE:
+ new_mode = EXIT_MODE;
+ break;
+ default:
+ new_mode = HDT_MODE;
+ break;
+ }
+
+ dprintf("CLI DEBUG: Switching from mode %d to mode %d\n", hdt_cli.mode,
+ new_mode);
+ set_mode(new_mode, hardware);
}
/**
* show_cli_help - shared helper to show available commands
**/
-static void show_cli_help(int argc __unused, char** argv __unused,
+static void show_cli_help(int argc __unused, char **argv __unused,
struct s_hardware *hardware __unused)
{
- int j = 0;
- struct cli_mode_descr *current_mode;
- struct cli_callback_descr* associated_module = NULL;
-
- find_cli_mode_descr(hdt_cli.mode, &current_mode);
-
- printf("Available commands are:\n");
-
- /* List first default modules of the mode */
- if (current_mode->default_modules &&
- current_mode->default_modules->modules) {
- while (current_mode->default_modules->modules[j].name) {
- printf("%s ",
- current_mode->default_modules->modules[j].name);
- j++;
- }
- printf("\n");
- }
+ int j = 0;
+ struct cli_mode_descr *current_mode;
+ struct cli_callback_descr *associated_module = NULL;
- /* List secondly the show modules of the mode */
- if (current_mode->show_modules &&
- current_mode->show_modules->modules) {
- printf("\nshow commands:\n");
- j = 0;
- while (current_mode->show_modules->modules[j].name) {
- printf("%s ",
- current_mode->show_modules->modules[j].name);
- j++;
- }
- printf("\n");
- }
+ find_cli_mode_descr(hdt_cli.mode, &current_mode);
- /* List thirdly the set modules of the mode */
- if (current_mode->set_modules &&
- current_mode->set_modules->modules) {
- printf("\nset commands:\n");
- j = 0;
- while (current_mode->set_modules->modules[j].name) {
- printf("%s ",
- current_mode->set_modules->modules[j].name);
- j++;
- }
- printf("\n");
- }
+ printf("Available commands are:\n");
- /* List finally the default modules of the hdt mode */
- if (current_mode->mode != hdt_mode.mode &&
- hdt_mode.default_modules &&
- hdt_mode.default_modules->modules) {
- j = 0;
- while (hdt_mode.default_modules->modules[j].name) {
- /*
- * Any default command that is present in hdt mode but
- * not in the current mode is available. A default
- * command can be redefined in the current mode though.
- * This next call test this use case: if it is
- * overwritten, do not print it again.
- */
- find_cli_callback_descr(hdt_mode.default_modules->modules[j].name,
- current_mode->default_modules,
- &associated_module);
- if (associated_module == NULL)
- printf("%s ",
- hdt_mode.default_modules->modules[j].name);
- j++;
- }
- printf("\n");
+ /* List first default modules of the mode */
+ if (current_mode->default_modules && current_mode->default_modules->modules) {
+ while (current_mode->default_modules->modules[j].name) {
+ printf("%s ", current_mode->default_modules->modules[j].name);
+ j++;
+ }
+ printf("\n");
+ }
+
+ /* List secondly the show modules of the mode */
+ if (current_mode->show_modules && current_mode->show_modules->modules) {
+ printf("\nshow commands:\n");
+ j = 0;
+ while (current_mode->show_modules->modules[j].name) {
+ printf("%s ", current_mode->show_modules->modules[j].name);
+ j++;
+ }
+ printf("\n");
+ }
+
+ /* List thirdly the set modules of the mode */
+ if (current_mode->set_modules && current_mode->set_modules->modules) {
+ printf("\nset commands:\n");
+ j = 0;
+ while (current_mode->set_modules->modules[j].name) {
+ printf("%s ", current_mode->set_modules->modules[j].name);
+ j++;
}
-
printf("\n");
- main_show_modes(argc, argv, hardware);
+ }
+
+ /* List finally the default modules of the hdt mode */
+ if (current_mode->mode != hdt_mode.mode &&
+ hdt_mode.default_modules && hdt_mode.default_modules->modules) {
+ j = 0;
+ while (hdt_mode.default_modules->modules[j].name) {
+ /*
+ * Any default command that is present in hdt mode but
+ * not in the current mode is available. A default
+ * command can be redefined in the current mode though.
+ * This next call test this use case: if it is
+ * overwritten, do not print it again.
+ */
+ find_cli_callback_descr(hdt_mode.default_modules->modules[j].name,
+ current_mode->default_modules,
+ &associated_module);
+ if (associated_module == NULL)
+ printf("%s ", hdt_mode.default_modules->modules[j].name);
+ j++;
+ }
+ printf("\n");
+ }
+
+ printf("\n");
+ main_show_modes(argc, argv, hardware);
}
/**
* show_cli_help - shared helper to show available commands
**/
-static void goto_menu(int argc __unused, char** argv __unused,
+static void goto_menu(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- char version_string[256];
- snprintf(version_string, sizeof version_string, "%s %s (%s)",
- PRODUCT_NAME, VERSION, CODENAME);
- start_menu_mode(hardware, version_string);
- return;
+ char version_string[256];
+ snprintf(version_string, sizeof version_string, "%s %s (%s)",
+ PRODUCT_NAME, VERSION, CODENAME);
+ start_menu_mode(hardware, version_string);
+ return;
}
/**
@@ -205,181 +196,176 @@ static void goto_menu(int argc __unused, char** argv __unused,
void main_show_summary(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- detect_pci(hardware); /* pxe is detected in the pci */
- detect_dmi(hardware);
- cpu_detect(hardware);
+ detect_pci(hardware); /* pxe is detected in the pci */
+ detect_dmi(hardware);
+ cpu_detect(hardware);
reset_more_printf();
- clear_screen();
- main_show_cpu(argc, argv, hardware);
- if (hardware->is_dmi_valid) {
- more_printf("System\n");
- more_printf(" Manufacturer : %s\n",
- hardware->dmi.system.manufacturer);
- more_printf(" Product Name : %s\n",
- hardware->dmi.system.product_name);
- more_printf(" Serial : %s\n",
- hardware->dmi.system.serial);
- more_printf("Bios\n");
- more_printf(" Version : %s\n", hardware->dmi.bios.version);
- more_printf(" Release : %s\n",
- hardware->dmi.bios.release_date);
-
- int argc = 1;
- char *argv[1] = { "0" };
- show_dmi_memory_modules(argc, argv, hardware);
- }
- main_show_pci(argc, argv, hardware);
-
- if (hardware->is_pxe_valid)
- main_show_pxe(argc, argv, hardware);
-
- main_show_kernel(argc, argv, hardware);
+ clear_screen();
+ main_show_cpu(argc, argv, hardware);
+ if (hardware->is_dmi_valid) {
+ more_printf("System\n");
+ more_printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer);
+ more_printf(" Product Name : %s\n", hardware->dmi.system.product_name);
+ more_printf(" Serial : %s\n", hardware->dmi.system.serial);
+ more_printf("Bios\n");
+ more_printf(" Version : %s\n", hardware->dmi.bios.version);
+ more_printf(" Release : %s\n", hardware->dmi.bios.release_date);
+
+ int argc = 1;
+ char *argv[1] = { "0" };
+ show_dmi_memory_modules(argc, argv, hardware);
+ }
+ main_show_pci(argc, argv, hardware);
+
+ if (hardware->is_pxe_valid)
+ main_show_pxe(argc, argv, hardware);
+
+ main_show_kernel(argc, argv, hardware);
}
void main_show_hdt(int argc __unused, char **argv __unused,
struct s_hardware *hardware __unused)
{
reset_more_printf();
- more_printf("HDT\n");
- more_printf(" Product : %s\n", PRODUCT_NAME);
- more_printf(" Version : %s (%s)\n", VERSION, CODENAME);
- more_printf(" Project Leader : %s\n", AUTHOR);
- more_printf(" Contact : %s\n", CONTACT);
- more_printf(" Core Developer : %s\n", CORE_DEVELOPER);
- char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS;
- for (int c = 0; c < NB_CONTRIBUTORS; c++) {
- more_printf(" Contributor : %s\n", contributors[c]);
- }
+ more_printf("HDT\n");
+ more_printf(" Product : %s\n", PRODUCT_NAME);
+ more_printf(" Version : %s (%s)\n", VERSION, CODENAME);
+ more_printf(" Project Leader : %s\n", AUTHOR);
+ more_printf(" Contact : %s\n", CONTACT);
+ more_printf(" Core Developer : %s\n", CORE_DEVELOPER);
+ char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS;
+ for (int c = 0; c < NB_CONTRIBUTORS; c++) {
+ more_printf(" Contributor : %s\n", contributors[c]);
+ }
}
/**
* do_reboot - reboot the system
**/
-static void do_reboot(int argc __unused, char** argv __unused,
- struct s_hardware *hardware)
+static void do_reboot(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
/* Use specific syslinux call if needed */
if (issyslinux())
- return runsyslinuxcmd(hardware->reboot_label);
+ return runsyslinuxcmd(hardware->reboot_label);
else
- return csprint(hardware->reboot_label, 0x07);
+ return csprint(hardware->reboot_label, 0x07);
}
/* Default hdt mode */
struct cli_callback_descr list_hdt_default_modules[] = {
- {
- .name = CLI_CLEAR,
- .exec = cli_clear_screen,
- },
- {
- .name = CLI_EXIT,
- .exec = do_exit,
- },
- {
- .name = CLI_HELP,
- .exec = show_cli_help,
- },
- {
- .name = CLI_MENU,
- .exec = goto_menu,
- },
- {
- .name = CLI_REBOOT,
- .exec = do_reboot,
- },
- {
- .name = NULL,
- .exec = NULL
- },
+ {
+ .name = CLI_CLEAR,
+ .exec = cli_clear_screen,
+ },
+ {
+ .name = CLI_EXIT,
+ .exec = do_exit,
+ },
+ {
+ .name = CLI_HELP,
+ .exec = show_cli_help,
+ },
+ {
+ .name = CLI_MENU,
+ .exec = goto_menu,
+ },
+ {
+ .name = CLI_REBOOT,
+ .exec = do_reboot,
+ },
+ {
+ .name = NULL,
+ .exec = NULL},
};
struct cli_callback_descr list_hdt_show_modules[] = {
- {
- .name = CLI_SUMMARY,
- .exec = main_show_summary,
- },
- {
- .name = CLI_PCI,
- .exec = main_show_pci,
- },
- {
- .name = CLI_DMI,
- .exec = main_show_dmi,
- },
- {
- .name = CLI_CPU,
- .exec = main_show_cpu,
- },
- {
- .name = CLI_DISK,
- .exec = disks_summary,
- },
- {
- .name = CLI_PXE,
- .exec = main_show_pxe,
- },
- {
- .name = CLI_SYSLINUX,
- .exec = main_show_syslinux,
- },
- {
- .name = CLI_KERNEL,
- .exec = main_show_kernel,
- },
- {
- .name = CLI_VESA,
- .exec = main_show_vesa,
- },
- {
- .name = CLI_HDT,
- .exec = main_show_hdt,
- },
- {
- .name = CLI_VPD,
- .exec = main_show_vpd,
- },
- {
- .name = CLI_MEMORY,
- .exec = show_dmi_memory_modules,
- },
- {
- .name = "modes",
- .exec = main_show_modes,
- },
- {
- .name = NULL,
- .exec = NULL,
- },
+ {
+ .name = CLI_SUMMARY,
+ .exec = main_show_summary,
+ },
+ {
+ .name = CLI_PCI,
+ .exec = main_show_pci,
+ },
+ {
+ .name = CLI_DMI,
+ .exec = main_show_dmi,
+ },
+ {
+ .name = CLI_CPU,
+ .exec = main_show_cpu,
+ },
+ {
+ .name = CLI_DISK,
+ .exec = disks_summary,
+ },
+ {
+ .name = CLI_PXE,
+ .exec = main_show_pxe,
+ },
+ {
+ .name = CLI_SYSLINUX,
+ .exec = main_show_syslinux,
+ },
+ {
+ .name = CLI_KERNEL,
+ .exec = main_show_kernel,
+ },
+ {
+ .name = CLI_VESA,
+ .exec = main_show_vesa,
+ },
+ {
+ .name = CLI_HDT,
+ .exec = main_show_hdt,
+ },
+ {
+ .name = CLI_VPD,
+ .exec = main_show_vpd,
+ },
+ {
+ .name = CLI_MEMORY,
+ .exec = show_dmi_memory_modules,
+ },
+ {
+ .name = "modes",
+ .exec = main_show_modes,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
};
struct cli_callback_descr list_hdt_set_modules[] = {
- {
- .name = CLI_MODE,
- .exec = cli_set_mode,
- },
- {
- .name = NULL,
- .exec = NULL,
- },
+ {
+ .name = CLI_MODE,
+ .exec = cli_set_mode,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
};
struct cli_module_descr hdt_default_modules = {
- .modules = list_hdt_default_modules,
+ .modules = list_hdt_default_modules,
};
struct cli_module_descr hdt_show_modules = {
- .modules = list_hdt_show_modules,
- .default_callback = main_show_summary,
+ .modules = list_hdt_show_modules,
+ .default_callback = main_show_summary,
};
struct cli_module_descr hdt_set_modules = {
- .modules = list_hdt_set_modules,
+ .modules = list_hdt_set_modules,
};
struct cli_mode_descr hdt_mode = {
- .mode = HDT_MODE,
- .name = CLI_HDT,
- .default_modules = &hdt_default_modules,
- .show_modules = &hdt_show_modules,
- .set_modules = &hdt_set_modules,
+ .mode = HDT_MODE,
+ .name = CLI_HDT,
+ .default_modules = &hdt_default_modules,
+ .show_modules = &hdt_show_modules,
+ .set_modules = &hdt_set_modules,
};
diff --git a/com32/hdt/hdt-cli-kernel.c b/com32/hdt/hdt-cli-kernel.c
index d33cdd80..c97c6a79 100644
--- a/com32/hdt/hdt-cli-kernel.c
+++ b/com32/hdt/hdt-cli-kernel.c
@@ -37,125 +37,122 @@
void main_show_kernel(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- char buffer[1024];
- struct pci_device *pci_device;
- bool found = false;
- char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
- MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+ char buffer[1024];
+ struct pci_device *pci_device;
+ bool found = false;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
- memset(buffer, 0, sizeof(buffer));
+ memset(buffer, 0, sizeof(buffer));
- detect_pci(hardware);
+ detect_pci(hardware);
reset_more_printf();
- more_printf("Kernel modules\n");
+ more_printf("Kernel modules\n");
// more_printf(" PCI device no: %d \n", p->pci_device_pos);
- if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP)
- && (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
- more_printf(" modules.pcimap and modules.alias files are missing\n");
- return;
+ if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP)
+ && (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
+ more_printf(" modules.pcimap and modules.alias files are missing\n");
+ return;
+ }
+
+ /* For every detected pci device, compute its submenu */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+
+ for (int kmod = 0;
+ kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) {
+ if (kmod > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[kmod],
+ LINUX_KERNEL_MODULE_SIZE - 1);
}
- /* For every detected pci device, compute its submenu */
- for_each_pci_func(pci_device, hardware->pci_domain) {
- memset(kernel_modules, 0, sizeof kernel_modules);
-
- for (int kmod = 0;
- kmod < pci_device->dev_info->linux_kernel_module_count;
- kmod++) {
- if (kmod > 0) {
- strncat(kernel_modules, " | ", 3);
- }
- strncat(kernel_modules,
- pci_device->dev_info->linux_kernel_module[kmod],
- LINUX_KERNEL_MODULE_SIZE - 1);
- }
-
- if ((pci_device->dev_info->linux_kernel_module_count > 0)
- && (!strstr(buffer, kernel_modules))) {
- found = true;
- if (pci_device->dev_info->linux_kernel_module_count > 1)
- strncat(buffer, "(", 1);
- strncat(buffer, kernel_modules, sizeof(kernel_modules));
- if (pci_device->dev_info->linux_kernel_module_count > 1)
- strncat(buffer, ")", 1);
- strncat(buffer, " # ", 3);
- }
-
- }
- if (found == true) {
- strncat(buffer, "\n", 1);
- more_printf(buffer);
+ if ((pci_device->dev_info->linux_kernel_module_count > 0)
+ && (!strstr(buffer, kernel_modules))) {
+ found = true;
+ if (pci_device->dev_info->linux_kernel_module_count > 1)
+ strncat(buffer, "(", 1);
+ strncat(buffer, kernel_modules, sizeof(kernel_modules));
+ if (pci_device->dev_info->linux_kernel_module_count > 1)
+ strncat(buffer, ")", 1);
+ strncat(buffer, " # ", 3);
}
+
+ }
+ if (found == true) {
+ strncat(buffer, "\n", 1);
+ more_printf(buffer);
+ }
}
static void show_kernel_modules(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- struct pci_device *pci_device;
- char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
- MAX_KERNEL_MODULES_PER_PCI_DEVICE];
- bool nopciids = false;
- bool nomodulespcimap = false;
- char modules[MAX_PCI_CLASSES][256];
- char category_name[MAX_PCI_CLASSES][256];
-
- detect_pci(hardware);
- memset(&modules, 0, sizeof(modules));
-
- if (hardware->pci_ids_return_code == -ENOPCIIDS) {
- nopciids = true;
- more_printf(" Missing pci.ids, we can't compute the list\n");
- return;
- }
+ struct pci_device *pci_device;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+ bool nopciids = false;
+ bool nomodulespcimap = false;
+ char modules[MAX_PCI_CLASSES][256];
+ char category_name[MAX_PCI_CLASSES][256];
+
+ detect_pci(hardware);
+ memset(&modules, 0, sizeof(modules));
+
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ nopciids = true;
+ more_printf(" Missing pci.ids, we can't compute the list\n");
+ return;
+ }
+
+ if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
+ nomodulespcimap = true;
+ more_printf(" Missing modules.pcimap, we can't compute the list\n");
+ return;
+ }
- if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
- nomodulespcimap = true;
- more_printf
- (" Missing modules.pcimap, we can't compute the list\n");
- return;
+ reset_more_printf();
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+
+ for (int kmod = 0;
+ kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) {
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[kmod],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ strncat(kernel_modules, " ", 1);
}
- reset_more_printf();
- for_each_pci_func(pci_device, hardware->pci_domain) {
- memset(kernel_modules, 0, sizeof kernel_modules);
-
- for (int kmod = 0;
- kmod < pci_device->dev_info->linux_kernel_module_count;
- kmod++) {
- strncat(kernel_modules,
- pci_device->dev_info->linux_kernel_module[kmod],
- LINUX_KERNEL_MODULE_SIZE - 1);
- strncat(kernel_modules, " ", 1);
- }
-
- if ((pci_device->dev_info->linux_kernel_module_count > 0)
- && (!strstr(modules[pci_device->class[2]], kernel_modules))) {
- strncat(modules[pci_device->class[2]], kernel_modules,
- sizeof(kernel_modules));
- snprintf(category_name[pci_device->class[2]],
- sizeof(category_name[pci_device->class[2]]),
- "%s", pci_device->dev_info->category_name);
- }
+ if ((pci_device->dev_info->linux_kernel_module_count > 0)
+ && (!strstr(modules[pci_device->class[2]], kernel_modules))) {
+ strncat(modules[pci_device->class[2]], kernel_modules,
+ sizeof(kernel_modules));
+ snprintf(category_name[pci_device->class[2]],
+ sizeof(category_name[pci_device->class[2]]),
+ "%s", pci_device->dev_info->category_name);
}
- /* Print the found items */
- for (int i = 0; i < MAX_PCI_CLASSES; i++) {
- if (strlen(category_name[i]) > 1) {
- more_printf("%s : %s\n", category_name[i], modules[i]);
- }
+ }
+ /* Print the found items */
+ for (int i = 0; i < MAX_PCI_CLASSES; i++) {
+ if (strlen(category_name[i]) > 1) {
+ more_printf("%s : %s\n", category_name[i], modules[i]);
}
+ }
}
struct cli_module_descr kernel_show_modules = {
- .modules = NULL,
- .default_callback = show_kernel_modules,
+ .modules = NULL,
+ .default_callback = show_kernel_modules,
};
struct cli_mode_descr kernel_mode = {
- .mode = KERNEL_MODE,
- .name = CLI_KERNEL,
- .default_modules = NULL,
- .show_modules = &kernel_show_modules,
- .set_modules = NULL,
+ .mode = KERNEL_MODE,
+ .name = CLI_KERNEL,
+ .default_modules = NULL,
+ .show_modules = &kernel_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-memory.c b/com32/hdt/hdt-cli-memory.c
index 650c6898..51d087e8 100644
--- a/com32/hdt/hdt-cli-memory.c
+++ b/com32/hdt/hdt-cli-memory.c
@@ -34,98 +34,101 @@
static void show_memory_e820(int argc __unused, char **argv __unused,
struct s_hardware *hardware __unused)
{
- struct e820entry map[E820MAX];
- unsigned long memsize=0;
- int count = 0;
- char type[14];
+ struct e820entry map[E820MAX];
+ unsigned long memsize = 0;
+ int count = 0;
+ char type[14];
- detect_memory_e820(map, E820MAX, &count);
- memsize=memsize_e820(map,count);
- reset_more_printf();
- more_printf("Detected RAM : %lu MiB (%lu KiB)\n",(memsize+(1<<9))>>10,memsize);
- more_printf("BIOS-provided physical RAM e820 map:\n");
- for (int i = 0; i < count; i++) {
- get_type(map[i].type, type, 14);
- more_printf("%016llx - %016llx %016llx (%s)\n",
- map[i].addr, map[i].size, map[i].addr+map[i].size,
- remove_spaces(type));
- }
- struct e820entry nm[E820MAX];
+ detect_memory_e820(map, E820MAX, &count);
+ memsize = memsize_e820(map, count);
+ reset_more_printf();
+ more_printf("Detected RAM : %lu MiB (%lu KiB)\n",
+ (memsize + (1 << 9)) >> 10, memsize);
+ more_printf("BIOS-provided physical RAM e820 map:\n");
+ for (int i = 0; i < count; i++) {
+ get_type(map[i].type, type, 14);
+ more_printf("%016llx - %016llx %016llx (%s)\n",
+ map[i].addr, map[i].size, map[i].addr + map[i].size,
+ remove_spaces(type));
+ }
+ struct e820entry nm[E820MAX];
- /* Clean up, adjust and copy the BIOS-supplied E820-map. */
- int nr = sanitize_e820_map(map, nm, count);
+ /* Clean up, adjust and copy the BIOS-supplied E820-map. */
+ int nr = sanitize_e820_map(map, nm, count);
- more_printf("\n");
- more_printf("Sanitized e820 map:\n");
- for (int i = 0; i < nr; i++) {
- get_type(nm[i].type, type, 14);
- more_printf("%016llx - %016llx %016llx (%s)\n",
- nm[i].addr, nm[i].size, nm[i].addr+nm[i].size,
- remove_spaces(type));
- }
+ more_printf("\n");
+ more_printf("Sanitized e820 map:\n");
+ for (int i = 0; i < nr; i++) {
+ get_type(nm[i].type, type, 14);
+ more_printf("%016llx - %016llx %016llx (%s)\n",
+ nm[i].addr, nm[i].size, nm[i].addr + nm[i].size,
+ remove_spaces(type));
+ }
}
static void show_memory_e801(int argc __unused, char **argv __unused,
struct s_hardware *hardware __unused)
{
- int mem_low, mem_high = 0;
+ int mem_low, mem_high = 0;
- reset_more_printf();
- if (detect_memory_e801(&mem_low, &mem_high)) {
- more_printf("e801 bogus!\n");
- } else {
- more_printf("Detected RAM : %d MiB(%d KiB)\n",(mem_low>>10) + (mem_high>>4),mem_low+(mem_high << 6));
- more_printf("e801 details : %d Kb (%d MiB) - %d Kb (%d MiB)\n",
- mem_low, mem_low >> 10, mem_high << 6, mem_high >> 4);
- }
+ reset_more_printf();
+ if (detect_memory_e801(&mem_low, &mem_high)) {
+ more_printf("e801 bogus!\n");
+ } else {
+ more_printf("Detected RAM : %d MiB(%d KiB)\n",
+ (mem_low >> 10) + (mem_high >> 4),
+ mem_low + (mem_high << 6));
+ more_printf("e801 details : %d Kb (%d MiB) - %d Kb (%d MiB)\n", mem_low,
+ mem_low >> 10, mem_high << 6, mem_high >> 4);
+ }
}
static void show_memory_88(int argc __unused, char **argv __unused,
struct s_hardware *hardware __unused)
{
- int mem_size = 0;
+ int mem_size = 0;
- reset_more_printf();
- if (detect_memory_88(&mem_size)) {
- more_printf("8800h bogus!\n");
- } else {
- more_printf("8800h memory size: %d Kb (%d MiB)\n", mem_size,
- mem_size >> 10);
- }
+ reset_more_printf();
+ if (detect_memory_88(&mem_size)) {
+ more_printf("8800h bogus!\n");
+ } else {
+ more_printf("8800h memory size: %d Kb (%d MiB)\n", mem_size,
+ mem_size >> 10);
+ }
}
struct cli_callback_descr list_memory_show_modules[] = {
- {
- .name = "e820",
- .exec = show_memory_e820,
- },
- {
- .name = "e801",
- .exec = show_memory_e801,
- },
- {
- .name = "88",
- .exec = show_memory_88,
- },
- {
- .name = CLI_DMI_MEMORY_BANK,
- .exec = show_dmi_memory_bank,
- },
- {
- .name = NULL,
- .exec = NULL,
- },
+ {
+ .name = "e820",
+ .exec = show_memory_e820,
+ },
+ {
+ .name = "e801",
+ .exec = show_memory_e801,
+ },
+ {
+ .name = "88",
+ .exec = show_memory_88,
+ },
+ {
+ .name = CLI_DMI_MEMORY_BANK,
+ .exec = show_dmi_memory_bank,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
};
struct cli_module_descr memory_show_modules = {
- .modules = list_memory_show_modules,
- .default_callback = show_dmi_memory_modules,
+ .modules = list_memory_show_modules,
+ .default_callback = show_dmi_memory_modules,
};
struct cli_mode_descr memory_mode = {
- .mode = MEMORY_MODE,
- .name = CLI_MEMORY,
- .default_modules = NULL,
- .show_modules = &memory_show_modules,
- .set_modules = NULL,
+ .mode = MEMORY_MODE,
+ .name = CLI_MEMORY,
+ .default_modules = NULL,
+ .show_modules = &memory_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c
index 75e28968..c86a7928 100644
--- a/com32/hdt/hdt-cli-pci.c
+++ b/com32/hdt/hdt-cli-pci.c
@@ -36,292 +36,283 @@
void main_show_pci(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- cli_detect_pci(hardware);
- reset_more_printf();
- more_printf("PCI\n");
- more_printf(" NB Devices : %d\n", hardware->nb_pci_devices);
+ cli_detect_pci(hardware);
+ reset_more_printf();
+ more_printf("PCI\n");
+ more_printf(" NB Devices : %d\n", hardware->nb_pci_devices);
}
-static void show_pci_device(int argc, char **argv,
- struct s_hardware *hardware)
+static void show_pci_device(int argc, char **argv, struct s_hardware *hardware)
{
- int i = 0;
- struct pci_device *pci_device = NULL, *temp_pci_device;
- int pcidev = -1;
- bool nopciids = false;
- bool nomodulespcimap = false;
- bool nomodulesalias = false;
- bool nomodulesfiles = false;
- char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
- MAX_KERNEL_MODULES_PER_PCI_DEVICE];
- int bus = 0, slot = 0, func = 0;
+ int i = 0;
+ struct pci_device *pci_device = NULL, *temp_pci_device;
+ int pcidev = -1;
+ bool nopciids = false;
+ bool nomodulespcimap = false;
+ bool nomodulesalias = false;
+ bool nomodulesfiles = false;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+ int bus = 0, slot = 0, func = 0;
reset_more_printf();
- /* Sanitize arguments */
- if (argc <= 0) {
- more_printf("show device <number>\n");
- return;
- } else
- pcidev = strtol(argv[0], (char **)NULL, 10);
+ /* Sanitize arguments */
+ if (argc <= 0) {
+ more_printf("show device <number>\n");
+ return;
+ } else
+ pcidev = strtol(argv[0], (char **)NULL, 10);
- if (errno == ERANGE) {
- more_printf("This PCI device number is incorrect\n");
- return;
- }
- if ((pcidev > hardware->nb_pci_devices) || (pcidev <= 0)) {
- more_printf("PCI device %d doesn't exist\n", pcidev);
- return;
- }
- if (hardware->pci_ids_return_code == -ENOPCIIDS) {
- nopciids = true;
- }
- if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
- nomodulespcimap = true;
- }
- if (hardware->modules_alias_return_code == -ENOMODULESALIAS) {
- nomodulesalias = true;
- }
- nomodulesfiles=nomodulespcimap && nomodulesalias;
- for_each_pci_func(temp_pci_device, hardware->pci_domain) {
- i++;
- if (i == pcidev) {
- bus = __pci_bus;
- slot = __pci_slot;
- func = __pci_func;
- pci_device = temp_pci_device;
- }
+ if (errno == ERANGE) {
+ more_printf("This PCI device number is incorrect\n");
+ return;
+ }
+ if ((pcidev > hardware->nb_pci_devices) || (pcidev <= 0)) {
+ more_printf("PCI device %d doesn't exist\n", pcidev);
+ return;
+ }
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ nopciids = true;
+ }
+ if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
+ nomodulespcimap = true;
+ }
+ if (hardware->modules_alias_return_code == -ENOMODULESALIAS) {
+ nomodulesalias = true;
+ }
+ nomodulesfiles = nomodulespcimap && nomodulesalias;
+ for_each_pci_func(temp_pci_device, hardware->pci_domain) {
+ i++;
+ if (i == pcidev) {
+ bus = __pci_bus;
+ slot = __pci_slot;
+ func = __pci_func;
+ pci_device = temp_pci_device;
}
+ }
- if (pci_device == NULL) {
- more_printf("We were enabled to find PCI device %d\n", pcidev);
- return;
- }
+ if (pci_device == NULL) {
+ more_printf("We were enabled to find PCI device %d\n", pcidev);
+ return;
+ }
- memset(kernel_modules, 0, sizeof kernel_modules);
- for (int kmod = 0;
- kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) {
- if (kmod > 0) {
- strncat(kernel_modules, " | ", 3);
- }
- strncat(kernel_modules,
- pci_device->dev_info->linux_kernel_module[kmod],
- LINUX_KERNEL_MODULE_SIZE - 1);
+ memset(kernel_modules, 0, sizeof kernel_modules);
+ for (int kmod = 0;
+ kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) {
+ if (kmod > 0) {
+ strncat(kernel_modules, " | ", 3);
}
- if (pci_device->dev_info->linux_kernel_module_count == 0)
- strlcpy(kernel_modules, "unknown", 7);
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[kmod],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ if (pci_device->dev_info->linux_kernel_module_count == 0)
+ strlcpy(kernel_modules, "unknown", 7);
- more_printf("PCI Device %d\n", pcidev);
+ more_printf("PCI Device %d\n", pcidev);
- if (nopciids == false) {
- more_printf("Vendor Name : %s\n",
- pci_device->dev_info->vendor_name);
- more_printf("Product Name : %s\n",
- pci_device->dev_info->product_name);
- more_printf("Class Name : %s\n",
- pci_device->dev_info->class_name);
- }
+ if (nopciids == false) {
+ more_printf("Vendor Name : %s\n", pci_device->dev_info->vendor_name);
+ more_printf("Product Name : %s\n", pci_device->dev_info->product_name);
+ more_printf("Class Name : %s\n", pci_device->dev_info->class_name);
+ }
- if (nomodulesfiles == false) {
- more_printf("Kernel module : %s\n", kernel_modules);
- }
+ if (nomodulesfiles == false) {
+ more_printf("Kernel module : %s\n", kernel_modules);
+ }
- more_printf("Vendor ID : %04x\n", pci_device->vendor);
- more_printf("Product ID : %04x\n", pci_device->product);
- more_printf("SubVendor ID : %04x\n", pci_device->sub_vendor);
- more_printf("SubProduct ID : %04x\n", pci_device->sub_product);
- more_printf("Class ID : %02x.%02x.%02x\n", pci_device->class[2],
- pci_device->class[1], pci_device->class[0]);
- more_printf("Revision : %02x\n", pci_device->revision);
- if ((pci_device->dev_info->irq > 0)
- && (pci_device->dev_info->irq < 255))
- more_printf("IRQ : %0d\n", pci_device->dev_info->irq);
- more_printf("Latency : %0d\n", pci_device->dev_info->latency);
- more_printf("PCI Bus : %02d\n", bus);
- more_printf("PCI Slot : %02d\n", slot);
- more_printf("PCI Func : %02d\n", func);
+ more_printf("Vendor ID : %04x\n", pci_device->vendor);
+ more_printf("Product ID : %04x\n", pci_device->product);
+ more_printf("SubVendor ID : %04x\n", pci_device->sub_vendor);
+ more_printf("SubProduct ID : %04x\n", pci_device->sub_product);
+ more_printf("Class ID : %02x.%02x.%02x\n", pci_device->class[2],
+ pci_device->class[1], pci_device->class[0]);
+ more_printf("Revision : %02x\n", pci_device->revision);
+ if ((pci_device->dev_info->irq > 0)
+ && (pci_device->dev_info->irq < 255))
+ more_printf("IRQ : %0d\n", pci_device->dev_info->irq);
+ more_printf("Latency : %0d\n", pci_device->dev_info->latency);
+ more_printf("PCI Bus : %02d\n", bus);
+ more_printf("PCI Slot : %02d\n", slot);
+ more_printf("PCI Func : %02d\n", func);
- if (hardware->is_pxe_valid == true) {
- if ((hardware->pxe.pci_device != NULL)
- && (hardware->pxe.pci_device == pci_device)) {
- more_printf("Mac Address : %s\n", hardware->pxe.mac_addr);
- more_printf("PXE : Current boot device\n");
- }
+ if (hardware->is_pxe_valid == true) {
+ if ((hardware->pxe.pci_device != NULL)
+ && (hardware->pxe.pci_device == pci_device)) {
+ more_printf("Mac Address : %s\n", hardware->pxe.mac_addr);
+ more_printf("PXE : Current boot device\n");
}
+ }
}
static void show_pci_devices(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- int i = 1;
- struct pci_device *pci_device;
- char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
- MAX_KERNEL_MODULES_PER_PCI_DEVICE];
- bool nopciids = false;
- bool nomodulespcimap = false;
- bool nomodulesalias = false;
- bool nomodulesfile = false;
- char first_line[81];
- char second_line[81];
+ int i = 1;
+ struct pci_device *pci_device;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+ bool nopciids = false;
+ bool nomodulespcimap = false;
+ bool nomodulesalias = false;
+ bool nomodulesfile = false;
+ char first_line[81];
+ char second_line[81];
- reset_more_printf();
- more_printf("%d PCI devices detected\n", hardware->nb_pci_devices);
+ reset_more_printf();
+ more_printf("%d PCI devices detected\n", hardware->nb_pci_devices);
- if (hardware->pci_ids_return_code == -ENOPCIIDS) {
- nopciids = true;
- }
- if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
- nomodulespcimap = true;
- }
- if (hardware->modules_pcimap_return_code == -ENOMODULESALIAS) {
- nomodulesalias = true;
- }
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ nopciids = true;
+ }
+ if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
+ nomodulespcimap = true;
+ }
+ if (hardware->modules_pcimap_return_code == -ENOMODULESALIAS) {
+ nomodulesalias = true;
+ }
- nomodulesfile = nomodulespcimap && nomodulesalias;
+ nomodulesfile = nomodulespcimap && nomodulesalias;
- /* For every detected pci device, compute its submenu */
- for_each_pci_func(pci_device, hardware->pci_domain) {
- memset(kernel_modules, 0, sizeof kernel_modules);
- for (int kmod = 0;
- kmod < pci_device->dev_info->linux_kernel_module_count;
- kmod++) {
- if (kmod > 0) {
- strncat(kernel_modules, " | ", 3);
- }
- strncat(kernel_modules,
- pci_device->dev_info->linux_kernel_module[kmod],
- LINUX_KERNEL_MODULE_SIZE - 1);
- }
- if (pci_device->dev_info->linux_kernel_module_count == 0)
- strlcpy(kernel_modules, "unknown", 7);
+ /* For every detected pci device, compute its submenu */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+ for (int kmod = 0;
+ kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) {
+ if (kmod > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[kmod],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ if (pci_device->dev_info->linux_kernel_module_count == 0)
+ strlcpy(kernel_modules, "unknown", 7);
- if (nopciids == false) {
- snprintf(first_line, sizeof(first_line),
- "%02d: %s %s \n", i,
- pci_device->dev_info->vendor_name,
- pci_device->dev_info->product_name);
- if (nomodulesfile == false)
- snprintf(second_line, sizeof(second_line),
- " # %-25s # Kmod: %s\n",
- pci_device->dev_info->class_name,
- kernel_modules);
- else
- snprintf(second_line, sizeof(second_line),
- " # %-25s # ID:%04x:%04x[%04x:%04x]\n",
- pci_device->dev_info->class_name,
- pci_device->vendor,
- pci_device->product,
- pci_device->sub_vendor,
- pci_device->sub_product);
+ if (nopciids == false) {
+ snprintf(first_line, sizeof(first_line),
+ "%02d: %s %s \n", i,
+ pci_device->dev_info->vendor_name,
+ pci_device->dev_info->product_name);
+ if (nomodulesfile == false)
+ snprintf(second_line, sizeof(second_line),
+ " # %-25s # Kmod: %s\n",
+ pci_device->dev_info->class_name, kernel_modules);
+ else
+ snprintf(second_line, sizeof(second_line),
+ " # %-25s # ID:%04x:%04x[%04x:%04x]\n",
+ pci_device->dev_info->class_name,
+ pci_device->vendor,
+ pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
- more_printf(first_line);
- more_printf(second_line);
- more_printf("\n");
- } else if (nopciids == true) {
- if (nomodulesfile == true) {
- more_printf("%02d: %04x:%04x [%04x:%04x] \n",
- i, pci_device->vendor,
- pci_device->product,
- pci_device->sub_vendor,
- pci_device->sub_product);
- } else {
- more_printf
- ("%02d: %04x:%04x [%04x:%04x] Kmod:%s\n", i,
- pci_device->vendor, pci_device->product,
- pci_device->sub_vendor,
- pci_device->sub_product, kernel_modules);
- }
- }
- i++;
+ more_printf(first_line);
+ more_printf(second_line);
+ more_printf("\n");
+ } else if (nopciids == true) {
+ if (nomodulesfile == true) {
+ more_printf("%02d: %04x:%04x [%04x:%04x] \n",
+ i, pci_device->vendor,
+ pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
+ } else {
+ more_printf
+ ("%02d: %04x:%04x [%04x:%04x] Kmod:%s\n", i,
+ pci_device->vendor, pci_device->product,
+ pci_device->sub_vendor,
+ pci_device->sub_product, kernel_modules);
+ }
}
+ i++;
+ }
}
static void show_pci_irq(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- struct pci_device *pci_device;
- bool nopciids = false;
+ struct pci_device *pci_device;
+ bool nopciids = false;
- reset_more_printf();
- more_printf("%d PCI devices detected\n", hardware->nb_pci_devices);
- more_printf("IRQ : product\n");
- more_printf("-------------\n");
+ reset_more_printf();
+ more_printf("%d PCI devices detected\n", hardware->nb_pci_devices);
+ more_printf("IRQ : product\n");
+ more_printf("-------------\n");
- if (hardware->pci_ids_return_code == -ENOPCIIDS) {
- nopciids = true;
- }
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ nopciids = true;
+ }
- /* For every detected pci device, compute its submenu */
- for_each_pci_func(pci_device, hardware->pci_domain) {
- /* Only display valid IRQs */
- if ((pci_device->dev_info->irq > 0)
- && (pci_device->dev_info->irq < 255)) {
- if (nopciids == false) {
- more_printf("%02d : %s %s \n",
- pci_device->dev_info->irq,
- pci_device->dev_info->vendor_name,
- pci_device->dev_info->product_name);
- } else {
- more_printf("%02d : %04x:%04x [%04x:%04x] \n",
- pci_device->dev_info->irq,
- pci_device->vendor,
- pci_device->product,
- pci_device->sub_vendor,
- pci_device->sub_product);
- }
- }
+ /* For every detected pci device, compute its submenu */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ /* Only display valid IRQs */
+ if ((pci_device->dev_info->irq > 0)
+ && (pci_device->dev_info->irq < 255)) {
+ if (nopciids == false) {
+ more_printf("%02d : %s %s \n",
+ pci_device->dev_info->irq,
+ pci_device->dev_info->vendor_name,
+ pci_device->dev_info->product_name);
+ } else {
+ more_printf("%02d : %04x:%04x [%04x:%04x] \n",
+ pci_device->dev_info->irq,
+ pci_device->vendor,
+ pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
+ }
}
+ }
}
struct cli_callback_descr list_pci_show_modules[] = {
- {
- .name = CLI_IRQ,
- .exec = show_pci_irq,
- },
- {
- .name = CLI_PCI_DEVICE,
- .exec = show_pci_device,
- },
- {
- .name = NULL,
- .exec = NULL,
- },
+ {
+ .name = CLI_IRQ,
+ .exec = show_pci_irq,
+ },
+ {
+ .name = CLI_PCI_DEVICE,
+ .exec = show_pci_device,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
};
struct cli_module_descr pci_show_modules = {
- .modules = list_pci_show_modules,
- .default_callback = show_pci_devices,
+ .modules = list_pci_show_modules,
+ .default_callback = show_pci_devices,
};
struct cli_mode_descr pci_mode = {
- .mode = PCI_MODE,
- .name = CLI_PCI,
- .default_modules = NULL,
- .show_modules = &pci_show_modules,
- .set_modules = NULL,
+ .mode = PCI_MODE,
+ .name = CLI_PCI,
+ .default_modules = NULL,
+ .show_modules = &pci_show_modules,
+ .set_modules = NULL,
};
void cli_detect_pci(struct s_hardware *hardware)
{
- bool error = false;
- if (hardware->pci_detection == false) {
- detect_pci(hardware);
- if (hardware->pci_ids_return_code == -ENOPCIIDS) {
- more_printf
- ("The pci.ids file is missing, device names can't be computed.\n");
- more_printf("Please put one in same dir as hdt\n");
- error = true;
- }
- if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) &&
- (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
- more_printf
- ("The modules.pcimap or modules.alias files are missing, device names can't be computed.\n");
- more_printf("Please put one of them in same dir as hdt\n");
- error = true;
- }
- if (error == true) {
- char tempbuf[10];
- more_printf("Press enter to continue\n");
- fgets(tempbuf, sizeof(tempbuf), stdin);
- }
+ bool error = false;
+ if (hardware->pci_detection == false) {
+ detect_pci(hardware);
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ more_printf
+ ("The pci.ids file is missing, device names can't be computed.\n");
+ more_printf("Please put one in same dir as hdt\n");
+ error = true;
+ }
+ if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) &&
+ (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
+ more_printf
+ ("The modules.pcimap or modules.alias files are missing, device names can't be computed.\n");
+ more_printf("Please put one of them in same dir as hdt\n");
+ error = true;
+ }
+ if (error == true) {
+ char tempbuf[10];
+ more_printf("Press enter to continue\n");
+ fgets(tempbuf, sizeof(tempbuf), stdin);
}
+ }
}
diff --git a/com32/hdt/hdt-cli-pxe.c b/com32/hdt/hdt-cli-pxe.c
index a281d158..7c550e36 100644
--- a/com32/hdt/hdt-cli-pxe.c
+++ b/com32/hdt/hdt-cli-pxe.c
@@ -39,55 +39,54 @@
void main_show_pxe(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- char buffer[81];
- memset(buffer, 0, sizeof(81));
+ char buffer[81];
+ memset(buffer, 0, sizeof(81));
reset_more_printf();
- if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
- more_printf("You are not currently using PXELINUX\n");
- return;
- }
+ if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
+ more_printf("You are not currently using PXELINUX\n");
+ return;
+ }
- detect_pxe(hardware);
- more_printf("PXE\n");
- if (hardware->is_pxe_valid == false) {
- more_printf(" No valid PXE ROM found\n");
- return;
- }
+ detect_pxe(hardware);
+ more_printf("PXE\n");
+ if (hardware->is_pxe_valid == false) {
+ more_printf(" No valid PXE ROM found\n");
+ return;
+ }
- struct s_pxe *p = &hardware->pxe;
- more_printf(" PCI device no: %d \n", p->pci_device_pos);
+ struct s_pxe *p = &hardware->pxe;
+ more_printf(" PCI device no: %d \n", p->pci_device_pos);
- if (hardware->pci_ids_return_code == -ENOPCIIDS ||
- (p->pci_device == NULL)) {
- snprintf(buffer, sizeof(buffer),
- " PCI ID : %04x:%04x[%04x:%04X] rev(%02x)\n",
- p->vendor_id, p->product_id, p->subvendor_id,
- p->subproduct_id, p->rev);
- snprintf(buffer, sizeof(buffer),
- " PCI Bus pos. : %02x:%02x.%02x\n", p->pci_bus,
- p->pci_dev, p->pci_func);
- more_printf(buffer);
- } else {
- snprintf(buffer, sizeof(buffer), " Manufacturer : %s \n",
- p->pci_device->dev_info->vendor_name);
- more_printf(buffer);
- snprintf(buffer, sizeof(buffer), " Product : %s \n",
- p->pci_device->dev_info->product_name);
- more_printf(buffer);
- }
- more_printf(" Addresses : %d.%d.%d.%d @ %s\n", p->ip_addr[0],
- p->ip_addr[1], p->ip_addr[2], p->ip_addr[3], p->mac_addr);
+ if (hardware->pci_ids_return_code == -ENOPCIIDS || (p->pci_device == NULL)) {
+ snprintf(buffer, sizeof(buffer),
+ " PCI ID : %04x:%04x[%04x:%04X] rev(%02x)\n",
+ p->vendor_id, p->product_id, p->subvendor_id,
+ p->subproduct_id, p->rev);
+ snprintf(buffer, sizeof(buffer),
+ " PCI Bus pos. : %02x:%02x.%02x\n", p->pci_bus,
+ p->pci_dev, p->pci_func);
+ more_printf(buffer);
+ } else {
+ snprintf(buffer, sizeof(buffer), " Manufacturer : %s \n",
+ p->pci_device->dev_info->vendor_name);
+ more_printf(buffer);
+ snprintf(buffer, sizeof(buffer), " Product : %s \n",
+ p->pci_device->dev_info->product_name);
+ more_printf(buffer);
+ }
+ more_printf(" Addresses : %d.%d.%d.%d @ %s\n", p->ip_addr[0],
+ p->ip_addr[1], p->ip_addr[2], p->ip_addr[3], p->mac_addr);
}
struct cli_module_descr pxe_show_modules = {
- .modules = NULL,
- .default_callback = main_show_pxe,
+ .modules = NULL,
+ .default_callback = main_show_pxe,
};
struct cli_mode_descr pxe_mode = {
- .mode = PXE_MODE,
- .name = CLI_PXE,
- .default_modules = NULL,
- .show_modules = &pxe_show_modules,
- .set_modules = NULL,
+ .mode = PXE_MODE,
+ .name = CLI_PXE,
+ .default_modules = NULL,
+ .show_modules = &pxe_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-syslinux.c b/com32/hdt/hdt-cli-syslinux.c
index 160e33c4..6c231ed5 100644
--- a/com32/hdt/hdt-cli-syslinux.c
+++ b/com32/hdt/hdt-cli-syslinux.c
@@ -37,26 +37,26 @@
#include "hdt-common.h"
void main_show_syslinux(int argc __unused, char **argv __unused,
- struct s_hardware *hardware)
+ struct s_hardware *hardware)
{
- reset_more_printf();
- more_printf("SYSLINUX\n");
- more_printf(" Bootloader : %s\n", hardware->syslinux_fs);
- more_printf(" Version : %s\n", hardware->sv->version_string + 2);
- more_printf(" Version : %u\n", hardware->sv->version);
- more_printf(" Max API : %u\n", hardware->sv->max_api);
- more_printf(" Copyright : %s\n", hardware->sv->copyright_string + 1);
+ reset_more_printf();
+ more_printf("SYSLINUX\n");
+ more_printf(" Bootloader : %s\n", hardware->syslinux_fs);
+ more_printf(" Version : %s\n", hardware->sv->version_string + 2);
+ more_printf(" Version : %u\n", hardware->sv->version);
+ more_printf(" Max API : %u\n", hardware->sv->max_api);
+ more_printf(" Copyright : %s\n", hardware->sv->copyright_string + 1);
}
struct cli_module_descr syslinux_show_modules = {
- .modules = NULL,
- .default_callback = main_show_syslinux,
+ .modules = NULL,
+ .default_callback = main_show_syslinux,
};
struct cli_mode_descr syslinux_mode = {
- .mode = SYSLINUX_MODE,
- .name = CLI_SYSLINUX,
- .default_modules = NULL,
- .show_modules = &syslinux_show_modules,
- .set_modules = NULL,
+ .mode = SYSLINUX_MODE,
+ .name = CLI_SYSLINUX,
+ .default_modules = NULL,
+ .show_modules = &syslinux_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-vesa.c b/com32/hdt/hdt-cli-vesa.c
index c6eea072..e4032ea5 100644
--- a/com32/hdt/hdt-cli-vesa.c
+++ b/com32/hdt/hdt-cli-vesa.c
@@ -37,68 +37,69 @@ void main_show_vesa(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
reset_more_printf();
- detect_vesa(hardware);
- if (hardware->is_vesa_valid == false) {
- more_printf("No VESA BIOS detected\n");
- return;
- }
- more_printf("VESA\n");
- more_printf(" Vesa version : %d.%d\n", hardware->vesa.major_version,
- hardware->vesa.minor_version);
- more_printf(" Vendor : %s\n", hardware->vesa.vendor);
- more_printf(" Product : %s\n", hardware->vesa.product);
- more_printf(" Product rev. : %s\n", hardware->vesa.product_revision);
- more_printf(" Software rev.: %d\n", hardware->vesa.software_rev);
- more_printf(" Memory (KB) : %d\n", hardware->vesa.total_memory * 64);
- more_printf(" Modes : %d\n", hardware->vesa.vmi_count);
+ detect_vesa(hardware);
+ if (hardware->is_vesa_valid == false) {
+ more_printf("No VESA BIOS detected\n");
+ return;
+ }
+ more_printf("VESA\n");
+ more_printf(" Vesa version : %d.%d\n", hardware->vesa.major_version,
+ hardware->vesa.minor_version);
+ more_printf(" Vendor : %s\n", hardware->vesa.vendor);
+ more_printf(" Product : %s\n", hardware->vesa.product);
+ more_printf(" Product rev. : %s\n", hardware->vesa.product_revision);
+ more_printf(" Software rev.: %d\n", hardware->vesa.software_rev);
+ more_printf(" Memory (KB) : %d\n", hardware->vesa.total_memory * 64);
+ more_printf(" Modes : %d\n", hardware->vesa.vmi_count);
}
static void show_vesa_modes(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- detect_vesa(hardware);
- reset_more_printf();
- if (hardware->is_vesa_valid == false) {
- more_printf("No VESA BIOS detected\n");
- return;
- }
- more_printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n");
- more_printf("----------------------------------------\n");
+ detect_vesa(hardware);
+ reset_more_printf();
+ if (hardware->is_vesa_valid == false) {
+ more_printf("No VESA BIOS detected\n");
+ return;
+ }
+ more_printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n");
+ more_printf("----------------------------------------\n");
- for (int i = 0; i < hardware->vesa.vmi_count; i++) {
- struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi;
- /*
- * Sometimes, vesa bios reports 0x0 modes.
- * We don't need to display that ones.
- */
- if ((mi->h_res == 0) || (mi->v_res == 0)) continue;
- more_printf("%5u %5u %3u %3d 0x%04x\n",
- mi->h_res, mi->v_res, mi->bpp,
- hardware->vesa.vmi[i].mode + 0x200,
- hardware->vesa.vmi[i].mode);
- }
+ for (int i = 0; i < hardware->vesa.vmi_count; i++) {
+ struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi;
+ /*
+ * Sometimes, vesa bios reports 0x0 modes.
+ * We don't need to display that ones.
+ */
+ if ((mi->h_res == 0) || (mi->v_res == 0))
+ continue;
+ more_printf("%5u %5u %3u %3d 0x%04x\n",
+ mi->h_res, mi->v_res, mi->bpp,
+ hardware->vesa.vmi[i].mode + 0x200,
+ hardware->vesa.vmi[i].mode);
+ }
}
struct cli_callback_descr list_vesa_show_modules[] = {
- {
- .name = CLI_MODES,
- .exec = show_vesa_modes,
- },
- {
- .name = NULL,
- .exec = NULL,
- },
+ {
+ .name = CLI_MODES,
+ .exec = show_vesa_modes,
+ },
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
};
struct cli_module_descr vesa_show_modules = {
- .modules = list_vesa_show_modules,
- .default_callback = main_show_vesa,
+ .modules = list_vesa_show_modules,
+ .default_callback = main_show_vesa,
};
struct cli_mode_descr vesa_mode = {
- .mode = VESA_MODE,
- .name = CLI_VESA,
- .default_modules = NULL,
- .show_modules = &vesa_show_modules,
- .set_modules = NULL,
+ .mode = VESA_MODE,
+ .name = CLI_VESA,
+ .default_modules = NULL,
+ .show_modules = &vesa_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli-vpd.c b/com32/hdt/hdt-cli-vpd.c
index a445d833..4974720b 100644
--- a/com32/hdt/hdt-cli-vpd.c
+++ b/com32/hdt/hdt-cli-vpd.c
@@ -35,40 +35,47 @@
void main_show_vpd(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- reset_more_printf();
- detect_vpd(hardware);
+ reset_more_printf();
+ detect_vpd(hardware);
- if (!hardware->is_vpd_valid) {
- more_printf("No VPD structure detected.\n");
- return;
- }
+ if (!hardware->is_vpd_valid) {
+ more_printf("No VPD structure detected.\n");
+ return;
+ }
- more_printf("VPD present at address : 0x%s\n", hardware->vpd.base_address);
- if (strlen(hardware->vpd.bios_build_id) > 0)
- more_printf("Bios Build ID : %s\n", hardware->vpd.bios_build_id);
- if (strlen(hardware->vpd.bios_release_date) > 0)
- more_printf("Bios Release Date : %s\n", hardware->vpd.bios_release_date);
- if (strlen(hardware->vpd.bios_version) > 0)
- more_printf("Bios Version : %s\n", hardware->vpd.bios_version);
- if (strlen(hardware->vpd.default_flash_filename) > 0)
- more_printf("Default Flash Filename : %s\n", hardware->vpd.default_flash_filename);
- if (strlen(hardware->vpd.box_serial_number) > 0)
- more_printf("Box Serial Number : %s\n", hardware->vpd.box_serial_number);
- if (strlen(hardware->vpd.motherboard_serial_number) > 0)
- more_printf("Motherboard Serial Number : %s\n", hardware->vpd.motherboard_serial_number);
- if (strlen(hardware->vpd.machine_type_model) > 0)
- more_printf("Machine Type/Model : %s\n", hardware->vpd.machine_type_model);
+ more_printf("VPD present at address : 0x%s\n", hardware->vpd.base_address);
+ if (strlen(hardware->vpd.bios_build_id) > 0)
+ more_printf("Bios Build ID : %s\n",
+ hardware->vpd.bios_build_id);
+ if (strlen(hardware->vpd.bios_release_date) > 0)
+ more_printf("Bios Release Date : %s\n",
+ hardware->vpd.bios_release_date);
+ if (strlen(hardware->vpd.bios_version) > 0)
+ more_printf("Bios Version : %s\n",
+ hardware->vpd.bios_version);
+ if (strlen(hardware->vpd.default_flash_filename) > 0)
+ more_printf("Default Flash Filename : %s\n",
+ hardware->vpd.default_flash_filename);
+ if (strlen(hardware->vpd.box_serial_number) > 0)
+ more_printf("Box Serial Number : %s\n",
+ hardware->vpd.box_serial_number);
+ if (strlen(hardware->vpd.motherboard_serial_number) > 0)
+ more_printf("Motherboard Serial Number : %s\n",
+ hardware->vpd.motherboard_serial_number);
+ if (strlen(hardware->vpd.machine_type_model) > 0)
+ more_printf("Machine Type/Model : %s\n",
+ hardware->vpd.machine_type_model);
}
struct cli_module_descr vpd_show_modules = {
- .modules = NULL,
- .default_callback = main_show_vpd,
+ .modules = NULL,
+ .default_callback = main_show_vpd,
};
struct cli_mode_descr vpd_mode = {
- .mode = VPD_MODE,
- .name = CLI_VPD,
- .default_modules = NULL,
- .show_modules = &vpd_show_modules,
- .set_modules = NULL,
+ .mode = VPD_MODE,
+ .name = CLI_VPD,
+ .default_modules = NULL,
+ .show_modules = &vpd_show_modules,
+ .set_modules = NULL,
};
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index dfb5e312..1bd50674 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -34,18 +34,18 @@
#include "hdt-common.h"
struct cli_mode_descr *list_modes[] = {
- &hdt_mode,
- &dmi_mode,
- &syslinux_mode,
- &pxe_mode,
- &kernel_mode,
- &cpu_mode,
- &pci_mode,
- &vesa_mode,
- &disk_mode,
- &vpd_mode,
- &memory_mode,
- NULL,
+ &hdt_mode,
+ &dmi_mode,
+ &syslinux_mode,
+ &pxe_mode,
+ &kernel_mode,
+ &cpu_mode,
+ &pci_mode,
+ &vesa_mode,
+ &disk_mode,
+ &vpd_mode,
+ &memory_mode,
+ NULL,
};
/*
@@ -53,61 +53,61 @@ struct cli_mode_descr *list_modes[] = {
* array of variables. There is no easy way around it besides declaring the arrays of
* strings first.
*/
-const char *exit_aliases[] = {"q", "quit"};
-const char *help_aliases[] = {"h", "?"};
+const char *exit_aliases[] = { "q", "quit" };
+const char *help_aliases[] = { "h", "?" };
/* List of aliases */
struct cli_alias hdt_aliases[] = {
- {
- .command = CLI_EXIT,
- .nb_aliases = 2,
- .aliases = exit_aliases,
- },
- {
- .command = CLI_HELP,
- .nb_aliases = 2,
- .aliases = help_aliases,
- },
+ {
+ .command = CLI_EXIT,
+ .nb_aliases = 2,
+ .aliases = exit_aliases,
+ },
+ {
+ .command = CLI_HELP,
+ .nb_aliases = 2,
+ .aliases = help_aliases,
+ },
};
struct cli_mode_descr *current_mode;
int autocomplete_backlog;
struct autocomplete_list {
- char autocomplete_token[MAX_LINE_SIZE];
- struct autocomplete_list *next;
+ char autocomplete_token[MAX_LINE_SIZE];
+ struct autocomplete_list *next;
};
-struct autocomplete_list* autocomplete_head = NULL;
-struct autocomplete_list* autocomplete_tail = NULL;
-struct autocomplete_list* autocomplete_last_seen = NULL;
+struct autocomplete_list *autocomplete_head = NULL;
+struct autocomplete_list *autocomplete_tail = NULL;
+struct autocomplete_list *autocomplete_last_seen = NULL;
static void autocomplete_add_token_to_list(const char *token)
{
- struct autocomplete_list *new = malloc(sizeof(struct autocomplete_list));
+ struct autocomplete_list *new = malloc(sizeof(struct autocomplete_list));
- strncpy(new->autocomplete_token, token, sizeof(new->autocomplete_token));
- new->next = NULL;
- autocomplete_backlog++;
+ strncpy(new->autocomplete_token, token, sizeof(new->autocomplete_token));
+ new->next = NULL;
+ autocomplete_backlog++;
- if (autocomplete_tail != NULL)
- autocomplete_tail->next = new;
- if (autocomplete_head == NULL)
- autocomplete_head = new;
- autocomplete_tail = new;
+ if (autocomplete_tail != NULL)
+ autocomplete_tail->next = new;
+ if (autocomplete_head == NULL)
+ autocomplete_head = new;
+ autocomplete_tail = new;
}
static void autocomplete_destroy_list()
{
- struct autocomplete_list* tmp = NULL;
+ struct autocomplete_list *tmp = NULL;
- while (autocomplete_head != NULL) {
- tmp = autocomplete_head->next;
- free(autocomplete_head);
- autocomplete_head = tmp;
- }
- autocomplete_backlog = 0;
- autocomplete_tail = NULL;
- autocomplete_last_seen = NULL;
+ while (autocomplete_head != NULL) {
+ tmp = autocomplete_head->next;
+ free(autocomplete_head);
+ autocomplete_head = tmp;
+ }
+ autocomplete_backlog = 0;
+ autocomplete_tail = NULL;
+ autocomplete_last_seen = NULL;
}
/**
@@ -116,106 +116,95 @@ static void autocomplete_destroy_list()
*
* Unlike cli_set_mode, this function is not used by the cli directly.
**/
-void set_mode(cli_mode_t mode, struct s_hardware* hardware)
+void set_mode(cli_mode_t mode, struct s_hardware *hardware)
{
- int i = 0;
-
- switch (mode) {
- case EXIT_MODE:
- hdt_cli.mode = mode;
- break;
- case HDT_MODE:
- hdt_cli.mode = mode;
- snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
- CLI_HDT);
- break;
- case PXE_MODE:
- if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
- printf("You are not currently using PXELINUX\n");
- break;
- }
- hdt_cli.mode = mode;
- snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
- CLI_PXE);
- break;
- case KERNEL_MODE:
- detect_pci(hardware);
- hdt_cli.mode = mode;
- snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
- CLI_KERNEL);
- break;
- case SYSLINUX_MODE:
- hdt_cli.mode = mode;
- snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
- CLI_SYSLINUX);
- break;
- case VESA_MODE:
- hdt_cli.mode = mode;
- snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
- CLI_VESA);
- break;
- case PCI_MODE:
- hdt_cli.mode = mode;
- snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
- CLI_PCI);
- if (!hardware->pci_detection)
- cli_detect_pci(hardware);
- break;
- case CPU_MODE:
- hdt_cli.mode = mode;
- snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
- CLI_CPU);
- if (!hardware->dmi_detection)
- detect_dmi(hardware);
- if (!hardware->cpu_detection)
- cpu_detect(hardware);
- break;
- case DMI_MODE:
- detect_dmi(hardware);
- if (!hardware->is_dmi_valid) {
- printf("No valid DMI table found, exiting.\n");
- break;
- }
- hdt_cli.mode = mode;
- snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
- CLI_DMI);
- break;
- case DISK_MODE:
- detect_disks(hardware);
- hdt_cli.mode = mode;
- snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
- CLI_DISK);
- break;
- case VPD_MODE:
- detect_vpd(hardware);
- if (!hardware->is_vpd_valid) {
- printf("No valid VPD table found, exiting.\n");
- break;
- }
- hdt_cli.mode = mode;
- snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
- CLI_VPD);
- break;
- case MEMORY_MODE:
- hdt_cli.mode = mode;
- snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
- CLI_MEMORY);
- break;
- default:
- /* Invalid mode */
- printf("Unknown mode, please choose among:\n");
- while (list_modes[i]) {
- printf("\t%s\n", list_modes[i]->name);
- i++;
- }
+ int i = 0;
+
+ switch (mode) {
+ case EXIT_MODE:
+ hdt_cli.mode = mode;
+ break;
+ case HDT_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_HDT);
+ break;
+ case PXE_MODE:
+ if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
+ printf("You are not currently using PXELINUX\n");
+ break;
}
-
- find_cli_mode_descr(hdt_cli.mode, &current_mode);
- /* There is not cli_mode_descr struct for the exit mode */
- if (current_mode == NULL && hdt_cli.mode != EXIT_MODE) {
- /* Shouldn't get here... */
- printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode);
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_PXE);
+ break;
+ case KERNEL_MODE:
+ detect_pci(hardware);
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_KERNEL);
+ break;
+ case SYSLINUX_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_SYSLINUX);
+ break;
+ case VESA_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_VESA);
+ break;
+ case PCI_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_PCI);
+ if (!hardware->pci_detection)
+ cli_detect_pci(hardware);
+ break;
+ case CPU_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_CPU);
+ if (!hardware->dmi_detection)
+ detect_dmi(hardware);
+ if (!hardware->cpu_detection)
+ cpu_detect(hardware);
+ break;
+ case DMI_MODE:
+ detect_dmi(hardware);
+ if (!hardware->is_dmi_valid) {
+ printf("No valid DMI table found, exiting.\n");
+ break;
+ }
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_DMI);
+ break;
+ case DISK_MODE:
+ detect_disks(hardware);
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_DISK);
+ break;
+ case VPD_MODE:
+ detect_vpd(hardware);
+ if (!hardware->is_vpd_valid) {
+ printf("No valid VPD table found, exiting.\n");
+ break;
}
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_VPD);
+ break;
+ case MEMORY_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_MEMORY);
+ break;
+ default:
+ /* Invalid mode */
+ printf("Unknown mode, please choose among:\n");
+ while (list_modes[i]) {
+ printf("\t%s\n", list_modes[i]->name);
+ i++;
+ }
+ }
+
+ find_cli_mode_descr(hdt_cli.mode, &current_mode);
+ /* There is not cli_mode_descr struct for the exit mode */
+ if (current_mode == NULL && hdt_cli.mode != EXIT_MODE) {
+ /* Shouldn't get here... */
+ printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode);
+ }
}
/**
@@ -223,19 +212,18 @@ void set_mode(cli_mode_t mode, struct s_hardware* hardware)
**/
cli_mode_t mode_s_to_mode_t(char *name)
{
- int i = 0;
+ int i = 0;
- while (list_modes[i]) {
- if (!strncmp(name, list_modes[i]->name,
- sizeof(list_modes[i]->name)))
- break;
- i++;
- }
+ while (list_modes[i]) {
+ if (!strncmp(name, list_modes[i]->name, sizeof(list_modes[i]->name)))
+ break;
+ i++;
+ }
- if (!list_modes[i])
- return INVALID_MODE;
- else
- return list_modes[i]->mode;
+ if (!list_modes[i])
+ return INVALID_MODE;
+ else
+ return list_modes[i]->mode;
}
/**
@@ -249,17 +237,16 @@ cli_mode_t mode_s_to_mode_t(char *name)
**/
void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found)
{
- int i = 0;
+ int i = 0;
- while (list_modes[i] &&
- list_modes[i]->mode != mode)
- i++;
+ while (list_modes[i] && list_modes[i]->mode != mode)
+ i++;
- /* Shouldn't get here... */
- if (!list_modes[i])
- *mode_found = NULL;
- else
- *mode_found = list_modes[i];
+ /* Shouldn't get here... */
+ if (!list_modes[i])
+ *mode_found = NULL;
+ else
+ *mode_found = list_modes[i];
}
/**
@@ -276,55 +263,55 @@ void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found)
static void expand_aliases(char *line __unused, char **command, char **module,
int *argc, char **argv)
{
- struct cli_mode_descr *mode;
- int i, j;
-
- find_cli_mode_descr(mode_s_to_mode_t(*command), &mode);
- if (mode != NULL && *module == NULL) {
- /*
- * The user specified a mode instead of `set mode...', e.g.
- * `dmi' instead of `set mode dmi'
- */
-
- /* *argv is NULL since *module is NULL */
- *argc = 1;
- *argv = malloc(*argc * sizeof(char *));
- argv[0] = malloc((sizeof(*command) + 1) * sizeof(char));
- strncpy(argv[0], *command, sizeof(*command) + 1);
- dprintf("CLI DEBUG: ALIAS %s ", *command);
+ struct cli_mode_descr *mode;
+ int i, j;
+
+ find_cli_mode_descr(mode_s_to_mode_t(*command), &mode);
+ if (mode != NULL && *module == NULL) {
+ /*
+ * The user specified a mode instead of `set mode...', e.g.
+ * `dmi' instead of `set mode dmi'
+ */
+
+ /* *argv is NULL since *module is NULL */
+ *argc = 1;
+ *argv = malloc(*argc * sizeof(char *));
+ argv[0] = malloc((sizeof(*command) + 1) * sizeof(char));
+ strncpy(argv[0], *command, sizeof(*command) + 1);
+ dprintf("CLI DEBUG: ALIAS %s ", *command);
- strncpy(*command, CLI_SET, sizeof(CLI_SET)); /* set */
+ strncpy(*command, CLI_SET, sizeof(CLI_SET)); /* set */
- *module = malloc(sizeof(CLI_MODE) * sizeof(char));
- strncpy(*module, CLI_MODE, sizeof(CLI_MODE)); /* mode */
+ *module = malloc(sizeof(CLI_MODE) * sizeof(char));
+ strncpy(*module, CLI_MODE, sizeof(CLI_MODE)); /* mode */
- dprintf("--> %s %s %s\n", *command, *module, argv[0]);
- goto out;
- }
+ dprintf("--> %s %s %s\n", *command, *module, argv[0]);
+ goto out;
+ }
- /* Simple aliases mapping a single command to another one */
- for (i = 0; i < MAX_ALIASES; i++) {
- for (j = 0; j < hdt_aliases[i].nb_aliases; j++) {
- if (!strncmp(*command, hdt_aliases[i].aliases[j],
- sizeof(hdt_aliases[i].aliases[j]))) {
- dprintf("CLI DEBUG: ALIAS %s ", *command);
- strncpy(*command, hdt_aliases[i].command,
- sizeof(hdt_aliases[i].command) + 1);
- dprintf("--> %s\n", *command);
- goto out; /* Don't allow chaining aliases */
- }
- }
+ /* Simple aliases mapping a single command to another one */
+ for (i = 0; i < MAX_ALIASES; i++) {
+ for (j = 0; j < hdt_aliases[i].nb_aliases; j++) {
+ if (!strncmp(*command, hdt_aliases[i].aliases[j],
+ sizeof(hdt_aliases[i].aliases[j]))) {
+ dprintf("CLI DEBUG: ALIAS %s ", *command);
+ strncpy(*command, hdt_aliases[i].command,
+ sizeof(hdt_aliases[i].command) + 1);
+ dprintf("--> %s\n", *command);
+ goto out; /* Don't allow chaining aliases */
+ }
}
- return;
+ }
+ return;
out:
- dprintf("CLI DEBUG: New parameters:\n");
- dprintf("CLI DEBUG: command = %s\n", *command);
- dprintf("CLI DEBUG: module = %s\n", *module);
- dprintf("CLI DEBUG: argc = %d\n", *argc);
- for (i = 0; i < *argc; i++)
- dprintf("CLI DEBUG: argv[%d] = %s\n", i, argv[0]);
- return;
+ dprintf("CLI DEBUG: New parameters:\n");
+ dprintf("CLI DEBUG: command = %s\n", *command);
+ dprintf("CLI DEBUG: module = %s\n", *module);
+ dprintf("CLI DEBUG: argc = %d\n", *argc);
+ for (i = 0; i < *argc; i++)
+ dprintf("CLI DEBUG: argv[%d] = %s\n", i, argv[0]);
+ return;
}
/**
@@ -342,84 +329,83 @@ out:
static void parse_command_line(char *line, char **command, char **module,
int *argc, char **argv)
{
- int argc_iter = 0, args_pos = 0, token_found = 0, token_len = 0;
- int args_len = 0;
- char *pch = NULL, *pch_next = NULL, *tmp_pch_next = NULL;
-
- *command = NULL;
- *module = NULL;
- *argc = 0;
-
- pch = line;
- while (pch != NULL) {
- pch_next = strchr(pch + 1, ' ');
- tmp_pch_next = pch_next;
-
- /*
- * Skip whitespaces if the user entered
- * 'set mode foo' for 'set mode foo'
- * ^ ^
- * |___|___ pch
- * |___ pch_next <- wrong!
- *
- * We still keep the position into tmp_pch_next to compute
- * the lenght of the current token.
- */
- while (pch_next != NULL && !strncmp(pch_next, CLI_SPACE, 1))
- pch_next++;
-
- /* End of line guaranteed to be zeroed */
- if (pch_next == NULL) {
- token_len = (int) (strchr(pch + 1, '\0') - pch);
- args_len = token_len;
- }
- else {
- token_len = (int) (tmp_pch_next - pch);
- args_len = (int) (pch_next - pch);
- }
-
- if (token_found == 0) {
- /* Main command to execute */
- *command = malloc((token_len + 1) * sizeof(char));
- strncpy(*command, pch, token_len);
- (*command)[token_len] = '\0';
- dprintf("CLI DEBUG: command = %s\n", *command);
- args_pos += args_len;
- } else if (token_found == 1) {
- /* Module */
- *module = malloc((token_len + 1) * sizeof(char));
- strncpy(*module, pch, token_len);
- (*module)[token_len] = '\0';
- dprintf("CLI DEBUG: module = %s\n", *module);
- args_pos += args_len;
- } else
- (*argc)++;
-
- token_found++;
- pch = pch_next;
- }
- dprintf("CLI DEBUG: argc = %d\n", *argc);
+ int argc_iter = 0, args_pos = 0, token_found = 0, token_len = 0;
+ int args_len = 0;
+ char *pch = NULL, *pch_next = NULL, *tmp_pch_next = NULL;
- /* Skip arguments handling if none is supplied */
- if (!*argc)
- return;
+ *command = NULL;
+ *module = NULL;
+ *argc = 0;
- /* Transform the arguments string into an array */
- *argv = malloc(*argc * sizeof(char *));
- pch = strtok(line + args_pos, CLI_SPACE);
- while (pch != NULL) {
- dprintf("CLI DEBUG: argv[%d] = %s\n", argc_iter, pch);
- argv[argc_iter] = malloc(sizeof(pch) * sizeof(char));
- strncpy(argv[argc_iter], pch, sizeof(pch));
- argc_iter++;
- pch = strtok(NULL, CLI_SPACE);
- /*
- * strtok(NULL, CLI_SPACE) over a stream of spaces
- * will return an empty string
- */
- while (pch != NULL && !strncmp(pch, "", 1))
- pch = strtok(NULL, CLI_SPACE);
+ pch = line;
+ while (pch != NULL) {
+ pch_next = strchr(pch + 1, ' ');
+ tmp_pch_next = pch_next;
+
+ /*
+ * Skip whitespaces if the user entered
+ * 'set mode foo' for 'set mode foo'
+ * ^ ^
+ * |___|___ pch
+ * |___ pch_next <- wrong!
+ *
+ * We still keep the position into tmp_pch_next to compute
+ * the lenght of the current token.
+ */
+ while (pch_next != NULL && !strncmp(pch_next, CLI_SPACE, 1))
+ pch_next++;
+
+ /* End of line guaranteed to be zeroed */
+ if (pch_next == NULL) {
+ token_len = (int)(strchr(pch + 1, '\0') - pch);
+ args_len = token_len;
+ } else {
+ token_len = (int)(tmp_pch_next - pch);
+ args_len = (int)(pch_next - pch);
}
+
+ if (token_found == 0) {
+ /* Main command to execute */
+ *command = malloc((token_len + 1) * sizeof(char));
+ strncpy(*command, pch, token_len);
+ (*command)[token_len] = '\0';
+ dprintf("CLI DEBUG: command = %s\n", *command);
+ args_pos += args_len;
+ } else if (token_found == 1) {
+ /* Module */
+ *module = malloc((token_len + 1) * sizeof(char));
+ strncpy(*module, pch, token_len);
+ (*module)[token_len] = '\0';
+ dprintf("CLI DEBUG: module = %s\n", *module);
+ args_pos += args_len;
+ } else
+ (*argc)++;
+
+ token_found++;
+ pch = pch_next;
+ }
+ dprintf("CLI DEBUG: argc = %d\n", *argc);
+
+ /* Skip arguments handling if none is supplied */
+ if (!*argc)
+ return;
+
+ /* Transform the arguments string into an array */
+ *argv = malloc(*argc * sizeof(char *));
+ pch = strtok(line + args_pos, CLI_SPACE);
+ while (pch != NULL) {
+ dprintf("CLI DEBUG: argv[%d] = %s\n", argc_iter, pch);
+ argv[argc_iter] = malloc(sizeof(pch) * sizeof(char));
+ strncpy(argv[argc_iter], pch, sizeof(pch));
+ argc_iter++;
+ pch = strtok(NULL, CLI_SPACE);
+ /*
+ * strtok(NULL, CLI_SPACE) over a stream of spaces
+ * will return an empty string
+ */
+ while (pch != NULL && !strncmp(pch, "", 1))
+ pch = strtok(NULL, CLI_SPACE);
+ }
}
/**
@@ -431,30 +417,29 @@ static void parse_command_line(char *line, char **command, char **module,
* Given a module name and a list of possible modules, find the corresponding
* module structure that matches the module name and store it in @module_found.
**/
-void find_cli_callback_descr(const char* module_name,
- struct cli_module_descr* modules_list,
- struct cli_callback_descr** module_found)
+void find_cli_callback_descr(const char *module_name,
+ struct cli_module_descr *modules_list,
+ struct cli_callback_descr **module_found)
{
- int modules_iter = 0;
+ int modules_iter = 0;
- if (modules_list == NULL)
- goto not_found;
+ if (modules_list == NULL)
+ goto not_found;
- /* Find the callback to execute */
- while (modules_list->modules[modules_iter].name &&
- strcmp(module_name,
- modules_list->modules[modules_iter].name) != 0)
- modules_iter++;
+ /* Find the callback to execute */
+ while (modules_list->modules[modules_iter].name &&
+ strcmp(module_name, modules_list->modules[modules_iter].name) != 0)
+ modules_iter++;
- if (modules_list->modules[modules_iter].name) {
- *module_found = &(modules_list->modules[modules_iter]);
- dprintf("CLI DEBUG: module %s found\n", (*module_found)->name);
- return;
- }
+ if (modules_list->modules[modules_iter].name) {
+ *module_found = &(modules_list->modules[modules_iter]);
+ dprintf("CLI DEBUG: module %s found\n", (*module_found)->name);
+ return;
+ }
not_found:
- *module_found = NULL;
- return;
+ *module_found = NULL;
+ return;
}
/**
@@ -467,84 +452,81 @@ not_found:
**/
static void autocomplete_command(char *command)
{
- int j = 0;
- struct cli_callback_descr* associated_module = NULL;
+ int j = 0;
+ struct cli_callback_descr *associated_module = NULL;
- /* First take care of the two special commands: 'show' and 'set' */
- if (strncmp(CLI_SHOW, command, strlen(command)) == 0) {
- printf("%s\n", CLI_SHOW);
- autocomplete_add_token_to_list(CLI_SHOW);
- }
- if (strncmp(CLI_SET, command, strlen(command)) == 0) {
- printf("%s\n", CLI_SET);
- autocomplete_add_token_to_list(CLI_SET);
- }
+ /* First take care of the two special commands: 'show' and 'set' */
+ if (strncmp(CLI_SHOW, command, strlen(command)) == 0) {
+ printf("%s\n", CLI_SHOW);
+ autocomplete_add_token_to_list(CLI_SHOW);
+ }
+ if (strncmp(CLI_SET, command, strlen(command)) == 0) {
+ printf("%s\n", CLI_SET);
+ autocomplete_add_token_to_list(CLI_SET);
+ }
- /*
- * Then, go through the modes for the special case
- * '<mode>' -> 'set mode <mode>'
- */
- while (list_modes[j]) {
- if (strncmp(list_modes[j]->name, command, strlen(command)) == 0) {
- printf("%s\n", list_modes[j]->name);
- autocomplete_add_token_to_list(list_modes[j]->name);
- }
- j++;
+ /*
+ * Then, go through the modes for the special case
+ * '<mode>' -> 'set mode <mode>'
+ */
+ while (list_modes[j]) {
+ if (strncmp(list_modes[j]->name, command, strlen(command)) == 0) {
+ printf("%s\n", list_modes[j]->name);
+ autocomplete_add_token_to_list(list_modes[j]->name);
}
+ j++;
+ }
- /*
- * Let's go now through the list of default_modules for the current mode
- * (single token commands for the current_mode)
- */
- j = 0;
- if (current_mode->default_modules &&
- current_mode->default_modules->modules) {
- while (current_mode->default_modules->modules[j].name) {
- if (strncmp(current_mode->default_modules->modules[j].name,
- command,
- strlen(command)) == 0) {
- printf("%s\n",
- current_mode->default_modules->modules[j].name);
- autocomplete_add_token_to_list(current_mode->default_modules->modules[j].name);
- }
- j++;
- }
+ /*
+ * Let's go now through the list of default_modules for the current mode
+ * (single token commands for the current_mode)
+ */
+ j = 0;
+ if (current_mode->default_modules && current_mode->default_modules->modules) {
+ while (current_mode->default_modules->modules[j].name) {
+ if (strncmp(current_mode->default_modules->modules[j].name,
+ command, strlen(command)) == 0) {
+ printf("%s\n", current_mode->default_modules->modules[j].name);
+ autocomplete_add_token_to_list(current_mode->default_modules->
+ modules[j].name);
+ }
+ j++;
+ }
}
- /*
- * Finally, if the current_mode is not hdt, list the available
- * default_modules of hdt (these are always available from any mode).
- */
- if (current_mode->mode == HDT_MODE)
- return;
+ /*
+ * Finally, if the current_mode is not hdt, list the available
+ * default_modules of hdt (these are always available from any mode).
+ */
+ if (current_mode->mode == HDT_MODE)
+ return;
- if (!hdt_mode.default_modules ||
- !hdt_mode.default_modules->modules)
- return;
+ if (!hdt_mode.default_modules || !hdt_mode.default_modules->modules)
+ return;
- j = 0;
- while (hdt_mode.default_modules &&
- hdt_mode.default_modules->modules[j].name) {
- /*
- * Any default command that is present in hdt mode but
- * not in the current mode is available. A default
- * command can be redefined in the current mode though.
- * This next call tests this use case: if it is
- * overwritten, do not print it again.
- */
- find_cli_callback_descr(hdt_mode.default_modules->modules[j].name,
- current_mode->default_modules,
- &associated_module);
- if (associated_module == NULL &&
- strncmp(command,
- hdt_mode.default_modules->modules[j].name,
- strlen(command)) == 0) {
- printf("%s\n",
- hdt_mode.default_modules->modules[j].name);
- autocomplete_add_token_to_list(hdt_mode.default_modules->modules[j].name);
- }
- j++;
+ j = 0;
+ while (hdt_mode.default_modules &&
+ hdt_mode.default_modules->modules[j].name) {
+ /*
+ * Any default command that is present in hdt mode but
+ * not in the current mode is available. A default
+ * command can be redefined in the current mode though.
+ * This next call tests this use case: if it is
+ * overwritten, do not print it again.
+ */
+ find_cli_callback_descr(hdt_mode.default_modules->modules[j].name,
+ current_mode->default_modules,
+ &associated_module);
+ if (associated_module == NULL &&
+ strncmp(command,
+ hdt_mode.default_modules->modules[j].name,
+ strlen(command)) == 0) {
+ printf("%s\n", hdt_mode.default_modules->modules[j].name);
+ autocomplete_add_token_to_list(hdt_mode.default_modules->modules[j].
+ name);
}
+ j++;
+ }
}
/**
@@ -557,47 +539,41 @@ static void autocomplete_command(char *command)
* list of commands for the current mode and the hdt mode (if the current mode
* is not hdt).
**/
-static void autocomplete_module(char *command, char* module)
+static void autocomplete_module(char *command, char *module)
{
- int j = 0;
- char autocomplete_full_line[MAX_LINE_SIZE];
-
- if (strncmp(CLI_SHOW, command, strlen(command)) == 0) {
- if (!current_mode->show_modules ||
- !current_mode->show_modules->modules)
- return;
-
- while (current_mode->show_modules->modules[j].name) {
- if (strncmp(current_mode->show_modules->modules[j].name,
- module,
- strlen(module)) == 0) {
- printf("%s\n",
- current_mode->show_modules->modules[j].name);
- sprintf(autocomplete_full_line, "%s %s",
- CLI_SHOW, current_mode->show_modules->modules[j].name);
- autocomplete_add_token_to_list(autocomplete_full_line);
- }
- j++;
- }
- } else if (strncmp(CLI_SET, command, strlen(command)) == 0) {
- j = 0;
- if (!current_mode->set_modules ||
- !current_mode->set_modules->modules)
- return;
-
- while (current_mode->set_modules->modules[j].name) {
- if (strncmp(current_mode->set_modules->modules[j].name,
- module,
- strlen(module)) == 0) {
- printf("%s\n",
- current_mode->set_modules->modules[j].name);
- sprintf(autocomplete_full_line, "%s %s",
- CLI_SET, current_mode->set_modules->modules[j].name);
- autocomplete_add_token_to_list(autocomplete_full_line);
- }
- j++;
- }
+ int j = 0;
+ char autocomplete_full_line[MAX_LINE_SIZE];
+
+ if (strncmp(CLI_SHOW, command, strlen(command)) == 0) {
+ if (!current_mode->show_modules || !current_mode->show_modules->modules)
+ return;
+
+ while (current_mode->show_modules->modules[j].name) {
+ if (strncmp(current_mode->show_modules->modules[j].name,
+ module, strlen(module)) == 0) {
+ printf("%s\n", current_mode->show_modules->modules[j].name);
+ sprintf(autocomplete_full_line, "%s %s",
+ CLI_SHOW, current_mode->show_modules->modules[j].name);
+ autocomplete_add_token_to_list(autocomplete_full_line);
+ }
+ j++;
}
+ } else if (strncmp(CLI_SET, command, strlen(command)) == 0) {
+ j = 0;
+ if (!current_mode->set_modules || !current_mode->set_modules->modules)
+ return;
+
+ while (current_mode->set_modules->modules[j].name) {
+ if (strncmp(current_mode->set_modules->modules[j].name,
+ module, strlen(module)) == 0) {
+ printf("%s\n", current_mode->set_modules->modules[j].name);
+ sprintf(autocomplete_full_line, "%s %s",
+ CLI_SET, current_mode->set_modules->modules[j].name);
+ autocomplete_add_token_to_list(autocomplete_full_line);
+ }
+ j++;
+ }
+ }
}
/**
@@ -606,501 +582,505 @@ static void autocomplete_module(char *command, char* module)
**/
static void autocomplete(char *line)
{
- int i;
- int argc = 0;
- char *command = NULL, *module = NULL;
- char **argv = NULL;
-
- parse_command_line(line, &command, &module, &argc, argv);
-
- /* If the user specified arguments, there is nothing we can complete */
- if (argc != 0)
- goto out;
-
- /* No argument, (the start of) a module has been specified */
- if (module != NULL) {
- autocomplete_module(command, module);
- free(module);
- goto out;
- }
+ int i;
+ int argc = 0;
+ char *command = NULL, *module = NULL;
+ char **argv = NULL;
+
+ parse_command_line(line, &command, &module, &argc, argv);
+
+ /* If the user specified arguments, there is nothing we can complete */
+ if (argc != 0)
+ goto out;
+
+ /* No argument, (the start of) a module has been specified */
+ if (module != NULL) {
+ autocomplete_module(command, module);
+ free(module);
+ goto out;
+ }
- /* No argument, no module, (the start of) a command has been specified */
- if (command != NULL) {
- autocomplete_command(command);
- free(command);
- goto out;
- }
+ /* No argument, no module, (the start of) a command has been specified */
+ if (command != NULL) {
+ autocomplete_command(command);
+ free(command);
+ goto out;
+ }
out:
- /* Let's not forget to clean ourselves */
- for (i = 0; i < argc; i++)
- free(argv[i]);
+ /* Let's not forget to clean ourselves */
+ for (i = 0; i < argc; i++)
+ free(argv[i]);
if (argc > 0)
- free(argv);
- return;
+ free(argv);
+ return;
}
-
/**
* exec_command - main logic to map the command line to callbacks
**/
-static void exec_command(char *line,
- struct s_hardware *hardware)
+static void exec_command(char *line, struct s_hardware *hardware)
{
- int argc, i = 0;
- char *command = NULL, *module = NULL;
- char **argv = NULL;
- struct cli_callback_descr* current_module = NULL;
+ int argc, i = 0;
+ char *command = NULL, *module = NULL;
+ char **argv = NULL;
+ struct cli_callback_descr *current_module = NULL;
- /* This will allocate memory for command and module */
- parse_command_line(line, &command, &module, &argc, argv);
+ /* This will allocate memory for command and module */
+ parse_command_line(line, &command, &module, &argc, argv);
- /*
+ /*
* Expand shortcuts, if needed
* This will allocate memory for argc/argv
*/
- expand_aliases(line, &command, &module, &argc, argv);
+ expand_aliases(line, &command, &module, &argc, argv);
if (module == NULL) {
- dprintf("CLI DEBUG: single command detected\n");
- /*
- * A single word was specified: look at the list of default
- * commands in the current mode to see if there is a match.
- * If not, it may be a generic function (exit, help, ...). These
- * are stored in the list of default commands of the hdt mode.
- */
- find_cli_callback_descr(command, current_mode->default_modules,
- &current_module);
- if (current_module != NULL)
- current_module->exec(argc, argv, hardware);
- else if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1) &&
- current_mode->show_modules != NULL &&
- current_mode->show_modules->default_callback != NULL)
- current_mode->show_modules
- ->default_callback(argc,
- argv,
- hardware);
- else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1) &&
- current_mode->set_modules != NULL &&
- current_mode->set_modules->default_callback != NULL)
- current_mode->set_modules
- ->default_callback(argc,
- argv,
- hardware);
- else {
- find_cli_callback_descr(command, hdt_mode.default_modules,
- &current_module);
- if (current_module != NULL)
- current_module->exec(argc, argv, hardware);
- else
- printf("unknown command: '%s'\n", command);
- }
+ dprintf("CLI DEBUG: single command detected\n");
+ /*
+ * A single word was specified: look at the list of default
+ * commands in the current mode to see if there is a match.
+ * If not, it may be a generic function (exit, help, ...). These
+ * are stored in the list of default commands of the hdt mode.
+ */
+ find_cli_callback_descr(command, current_mode->default_modules,
+ &current_module);
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1) &&
+ current_mode->show_modules != NULL &&
+ current_mode->show_modules->default_callback != NULL)
+ current_mode->show_modules->default_callback(argc, argv, hardware);
+ else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1) &&
+ current_mode->set_modules != NULL &&
+ current_mode->set_modules->default_callback != NULL)
+ current_mode->set_modules->default_callback(argc, argv, hardware);
+ else {
+ find_cli_callback_descr(command, hdt_mode.default_modules,
+ &current_module);
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else
+ printf("unknown command: '%s'\n", command);
+ }
} else {
- /*
- * A module has been specified! We now need to find the type of command.
- *
- * The syntax of the cli is the following:
- * <type of command> <module on which to operate> <args>
- * e.g.
- * dmi> show system
- * dmi> show bank 1
- * dmi> show memory 0 1
- * pci> show device 12
- * hdt> set mode dmi
- */
- if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1)) {
- dprintf("CLI DEBUG: %s command detected\n", CLI_SHOW);
- /* Look first for a 'show' callback in the current mode */
- find_cli_callback_descr(module, current_mode->show_modules,
- &current_module);
- /* Execute the callback, if found */
- if (current_module != NULL)
- current_module->exec(argc, argv, hardware);
- else {
- /* Look now for a 'show' callback in the hdt mode */
- find_cli_callback_descr(module, hdt_mode.show_modules,
- &current_module);
- /* Execute the callback, if found */
- if (current_module != NULL)
- current_module->exec(argc, argv, hardware);
- else
- printf("unknown module: '%s'\n", module);
- }
- } else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1)) {
- dprintf("CLI DEBUG: %s command detected\n", CLI_SET);
- /* Look now for a 'set' callback in the hdt mode */
- find_cli_callback_descr(module, current_mode->set_modules,
- &current_module);
- /* Execute the callback, if found */
- if (current_module != NULL)
- current_module->exec(argc, argv, hardware);
- else {
- /* Look now for a 'set' callback in the hdt mode */
- find_cli_callback_descr(module, hdt_mode.set_modules,
- &current_module);
- /* Execute the callback, if found */
- if (current_module != NULL)
- current_module->exec(argc, argv, hardware);
- else
- printf("unknown module: '%s'\n", module);
- }
- }
+ /*
+ * A module has been specified! We now need to find the type of command.
+ *
+ * The syntax of the cli is the following:
+ * <type of command> <module on which to operate> <args>
+ * e.g.
+ * dmi> show system
+ * dmi> show bank 1
+ * dmi> show memory 0 1
+ * pci> show device 12
+ * hdt> set mode dmi
+ */
+ if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1)) {
+ dprintf("CLI DEBUG: %s command detected\n", CLI_SHOW);
+ /* Look first for a 'show' callback in the current mode */
+ find_cli_callback_descr(module, current_mode->show_modules,
+ &current_module);
+ /* Execute the callback, if found */
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else {
+ /* Look now for a 'show' callback in the hdt mode */
+ find_cli_callback_descr(module, hdt_mode.show_modules,
+ &current_module);
+ /* Execute the callback, if found */
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else
+ printf("unknown module: '%s'\n", module);
+ }
+ } else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1)) {
+ dprintf("CLI DEBUG: %s command detected\n", CLI_SET);
+ /* Look now for a 'set' callback in the hdt mode */
+ find_cli_callback_descr(module, current_mode->set_modules,
+ &current_module);
+ /* Execute the callback, if found */
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else {
+ /* Look now for a 'set' callback in the hdt mode */
+ find_cli_callback_descr(module, hdt_mode.set_modules,
+ &current_module);
+ /* Execute the callback, if found */
+ if (current_module != NULL)
+ current_module->exec(argc, argv, hardware);
+ else
+ printf("unknown module: '%s'\n", module);
+ }
+ }
}
out:
/* Let's not forget to clean ourselves */
if (command != NULL)
- free(command);
+ free(command);
if (module != NULL)
- free(module);
+ free(module);
for (i = 0; i < argc; i++)
- free(argv[i]);
+ free(argv[i]);
if (argc > 0)
- free(argv);
+ free(argv);
}
static void reset_prompt()
{
- /* No need to display the prompt if we exit */
- if (hdt_cli.mode != EXIT_MODE) {
- printf("%s", hdt_cli.prompt);
- /* Reset the line */
- memset(hdt_cli.input, '\0', MAX_LINE_SIZE);
- hdt_cli.cursor_pos = 0;
- }
+ /* No need to display the prompt if we exit */
+ if (hdt_cli.mode != EXIT_MODE) {
+ printf("%s", hdt_cli.prompt);
+ /* Reset the line */
+ memset(hdt_cli.input, '\0', MAX_LINE_SIZE);
+ hdt_cli.cursor_pos = 0;
+ }
}
void start_auto_mode(struct s_hardware *hardware)
{
- char *mypch;
- int nb_commands=0;
- char *commands[MAX_NB_AUTO_COMMANDS];
-
- if (!quiet)
- more_printf("\nEntering Auto mode\n");
-
- /* Protecting the auto_label from the strtok modifications */
- char *temp=strdup(hardware->auto_label);
-
- /* Searching & saving all commands */
- mypch = strtok (temp,AUTO_SEPARATOR);
- while (mypch != NULL) {
- if ((strlen(remove_spaces(mypch))>0) &&
- (remove_spaces(mypch)[0] != AUTO_SEPARATOR[0])) {
- nb_commands++;
- if ((commands[nb_commands]=malloc(AUTO_COMMAND_SIZE)) != NULL) {
- sprintf(commands[nb_commands],"%s",remove_spaces(mypch));
- } else
- nb_commands--;
- }
- mypch = strtok (NULL, AUTO_SEPARATOR);
- }
-
- /* Executing found commands */
- for (int i=1;i<=nb_commands;i++) {
- if (commands[i]) {
- if (!quiet)
- more_printf("%s%s\n",hdt_cli.prompt,commands[i]);
- exec_command(commands[i], hardware);
- free(commands[i]);
- }
+ char *mypch;
+ int nb_commands = 0;
+ char *commands[MAX_NB_AUTO_COMMANDS];
+
+ if (!quiet)
+ more_printf("\nEntering Auto mode\n");
+
+ /* Protecting the auto_label from the strtok modifications */
+ char *temp = strdup(hardware->auto_label);
+
+ /* Searching & saving all commands */
+ mypch = strtok(temp, AUTO_SEPARATOR);
+ while (mypch != NULL) {
+ if ((strlen(remove_spaces(mypch)) > 0) &&
+ (remove_spaces(mypch)[0] != AUTO_SEPARATOR[0])) {
+ nb_commands++;
+ if ((commands[nb_commands] = malloc(AUTO_COMMAND_SIZE)) != NULL) {
+ sprintf(commands[nb_commands], "%s", remove_spaces(mypch));
+ } else
+ nb_commands--;
+ }
+ mypch = strtok(NULL, AUTO_SEPARATOR);
+ }
+
+ /* Executing found commands */
+ for (int i = 1; i <= nb_commands; i++) {
+ if (commands[i]) {
+ if (!quiet)
+ more_printf("%s%s\n", hdt_cli.prompt, commands[i]);
+ exec_command(commands[i], hardware);
+ free(commands[i]);
}
+ }
if (!quiet)
- more_printf("\nExiting Auto mode\n");
+ more_printf("\nExiting Auto mode\n");
more_printf("\n");
}
-
/* Code that manages the cli mode */
void start_cli_mode(struct s_hardware *hardware)
{
- int current_key = 0;
- int future_history_pos=1; /* Temp variable*/
- bool display_history=true; /* Temp Variable*/
- char temp_command[MAX_LINE_SIZE];
+ int current_key = 0;
+ int future_history_pos = 1; /* Temp variable */
+ bool display_history = true; /* Temp Variable */
+ char temp_command[MAX_LINE_SIZE];
+
+ hdt_cli.cursor_pos = 0;
+ memset(hdt_cli.input, '\0', MAX_LINE_SIZE);
+ memset(hdt_cli.history, '\0', sizeof(hdt_cli.history));
+ hdt_cli.history_pos = 1;
+ hdt_cli.max_history_pos = 1;
+
+ /* Find the mode selected */
+ set_mode(HDT_MODE, hardware);
+ find_cli_mode_descr(hdt_cli.mode, &current_mode);
+ if (current_mode == NULL) {
+ /* Shouldn't get here... */
+ printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode);
+ return;
+ }
- hdt_cli.cursor_pos=0;
- memset(hdt_cli.input, '\0', MAX_LINE_SIZE);
- memset(hdt_cli.history, '\0', sizeof(hdt_cli.history));
- hdt_cli.history_pos=1;
- hdt_cli.max_history_pos=1;
-
- /* Find the mode selected */
- set_mode(HDT_MODE, hardware);
- find_cli_mode_descr(hdt_cli.mode, &current_mode);
- if (current_mode == NULL) {
- /* Shouldn't get here... */
- printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode);
- return;
- }
+ /* Start the auto mode if the command line is set */
+ if (strlen(hardware->auto_label) > 0) {
+ start_auto_mode(hardware);
+ }
- /* Start the auto mode if the command line is set*/
- if (strlen(hardware->auto_label) > 0) {
- start_auto_mode(hardware);
- }
+ printf("Entering CLI mode\n");
+
+ reset_prompt();
+
+ while (hdt_cli.mode != EXIT_MODE) {
+
+ /* Display the cursor */
+ display_cursor(true);
+
+ /* Let's put the cursor blinking until we get an input */
+ set_cursor_blink(true);
+
+ /* We wait endlessly for a keyboard input */
+ current_key = get_key(stdin, 0);
+
+ /* We have to cancel the blinking mode to prevent
+ * input text to blink */
+ set_cursor_blink(false);
+
+ /* Reset autocomplete buffer unless TAB is pressed */
+ if (current_key != KEY_TAB)
+ autocomplete_destroy_list();
+
+ switch (current_key) {
+ /* clear until then end of line */
+ case KEY_CTRL('k'):
+ /* Clear the end of the line */
+ clear_end_of_line();
+ memset(&hdt_cli.input[hdt_cli.cursor_pos], 0,
+ strlen(hdt_cli.input) - hdt_cli.cursor_pos);
+ break;
+
+ case KEY_CTRL('c'):
+ printf("\n");
+ reset_prompt();
+ break;
+
+ case KEY_LEFT:
+ if (hdt_cli.cursor_pos > 0) {
+ move_cursor_left(1);
+ hdt_cli.cursor_pos--;
+ }
+ break;
+
+ case KEY_RIGHT:
+ if (hdt_cli.cursor_pos < (int)strlen(hdt_cli.input)) {
+ move_cursor_right(1);
+ hdt_cli.cursor_pos++;
+ }
+ break;
+
+ case KEY_CTRL('e'):
+ case KEY_END:
+ /* Calling with a 0 value will make the cursor move */
+ /* So, let's move the cursor only if needed */
+ if ((strlen(hdt_cli.input) - hdt_cli.cursor_pos) > 0) {
+ /* Return to the begining of line */
+ move_cursor_right(strlen(hdt_cli.input) - hdt_cli.cursor_pos);
+ hdt_cli.cursor_pos = strlen(hdt_cli.input);
+ }
+ break;
+
+ case KEY_CTRL('a'):
+ case KEY_HOME:
+ /* Calling with a 0 value will make the cursor move */
+ /* So, let's move the cursor only if needed */
+ if (hdt_cli.cursor_pos > 0) {
+ /* Return to the begining of line */
+ move_cursor_left(hdt_cli.cursor_pos);
+ hdt_cli.cursor_pos = 0;
+ }
+ break;
+
+ case KEY_UP:
+ /* We have to compute the next position */
+ future_history_pos = hdt_cli.history_pos;
+ if (future_history_pos == 1) {
+ future_history_pos = MAX_HISTORY_SIZE - 1;
+ } else {
+ future_history_pos--;
+ }
+ /* Does the next position is valid */
+ if (strlen(hdt_cli.history[future_history_pos]) == 0)
+ break;
+
+ /* Let's make that future position the one we use */
+ hdt_cli.history_pos = future_history_pos;
+
+ /* Clear the line */
+ clear_line();
+
+ /* Move to the begining of line */
+ move_cursor_to_column(0);
+
+ reset_prompt();
+ printf("%s", hdt_cli.history[hdt_cli.history_pos]);
+ strncpy(hdt_cli.input, hdt_cli.history[hdt_cli.history_pos],
+ sizeof(hdt_cli.input));
+ hdt_cli.cursor_pos = strlen(hdt_cli.input);
+ break;
+
+ case KEY_DOWN:
+ display_history = true;
+
+ /* We have to compute the next position */
+ future_history_pos = hdt_cli.history_pos;
+ if (future_history_pos == MAX_HISTORY_SIZE - 1) {
+ future_history_pos = 1;
+ } else {
+ future_history_pos++;
+ }
+ /* Does the next position is valid */
+ if (strlen(hdt_cli.history[future_history_pos]) == 0)
+ display_history = false;
+
+ /* An exception is made to reach the last empty line */
+ if (future_history_pos == hdt_cli.max_history_pos)
+ display_history = true;
+ if (display_history == false)
+ break;
+
+ /* Let's make that future position the one we use */
+ hdt_cli.history_pos = future_history_pos;
+
+ /* Clear the line */
+ clear_line();
+
+ /* Move to the begining of line */
+ move_cursor_to_column(0);
+
+ reset_prompt();
+ printf("%s", hdt_cli.history[hdt_cli.history_pos]);
+ strncpy(hdt_cli.input, hdt_cli.history[hdt_cli.history_pos],
+ sizeof(hdt_cli.input));
+ hdt_cli.cursor_pos = strlen(hdt_cli.input);
+ break;
+
+ case KEY_TAB:
+ if (autocomplete_backlog) {
+ clear_line();
+ /* Move to the begining of line */
+ move_cursor_to_column(0);
+ reset_prompt();
+ printf("%s", autocomplete_last_seen->autocomplete_token);
+ strncpy(hdt_cli.input,
+ autocomplete_last_seen->autocomplete_token,
+ sizeof(hdt_cli.input));
+ hdt_cli.cursor_pos = strlen(hdt_cli.input);
+
+ /* Cycle through the list */
+ autocomplete_last_seen = autocomplete_last_seen->next;
+ if (autocomplete_last_seen == NULL)
+ autocomplete_last_seen = autocomplete_head;
+ } else {
+ printf("\n");
+ autocomplete(skip_spaces(hdt_cli.input));
+ autocomplete_last_seen = autocomplete_head;
+
+ printf("%s%s", hdt_cli.prompt, hdt_cli.input);
+ }
+ break;
+
+ case KEY_ENTER:
+ printf("\n");
+ if (strlen(remove_spaces(hdt_cli.input)) < 1) {
+ reset_prompt();
+ break;
+ }
+ if (hdt_cli.history_pos == MAX_HISTORY_SIZE - 1)
+ hdt_cli.history_pos = 1;
+ strncpy(hdt_cli.history[hdt_cli.history_pos],
+ remove_spaces(hdt_cli.input),
+ sizeof(hdt_cli.history[hdt_cli.history_pos]));
+ hdt_cli.history_pos++;
+ if (hdt_cli.history_pos > hdt_cli.max_history_pos)
+ hdt_cli.max_history_pos = hdt_cli.history_pos;
+ exec_command(remove_spaces(hdt_cli.input), hardware);
+ reset_prompt();
+ break;
+
+ case KEY_CTRL('d'):
+ case KEY_DELETE:
+ /* No need to delete when input is empty */
+ if (strlen(hdt_cli.input) == 0)
+ break;
+ /* Don't delete when cursor is at the end of the line */
+ if (hdt_cli.cursor_pos >= strlen(hdt_cli.input))
+ break;
- printf("Entering CLI mode\n");
-
- reset_prompt();
-
- while (hdt_cli.mode != EXIT_MODE) {
-
- /* Display the cursor */
- display_cursor(true);
-
- /* Let's put the cursor blinking until we get an input */
- set_cursor_blink(true);
-
- /* We wait endlessly for a keyboard input*/
- current_key = get_key(stdin, 0);
-
- /* We have to cancel the blinking mode to prevent
- * input text to blink */
- set_cursor_blink(false);
-
- /* Reset autocomplete buffer unless TAB is pressed */
- if (current_key != KEY_TAB)
- autocomplete_destroy_list();
-
- switch (current_key) {
- /* clear until then end of line */
- case KEY_CTRL('k'):
- /* Clear the end of the line */
- clear_end_of_line();
- memset(&hdt_cli.input[hdt_cli.cursor_pos], 0,
- strlen(hdt_cli.input) - hdt_cli.cursor_pos);
- break;
-
- case KEY_CTRL('c'):
- printf("\n");
- reset_prompt();
- break;
-
- case KEY_LEFT:
- if (hdt_cli.cursor_pos > 0) {
- move_cursor_left(1);
- hdt_cli.cursor_pos--;
- }
- break;
-
- case KEY_RIGHT:
- if (hdt_cli.cursor_pos < (int)strlen(hdt_cli.input)) {
- move_cursor_right(1);
- hdt_cli.cursor_pos++;
- }
- break;
-
- case KEY_CTRL('e'):
- case KEY_END:
- /* Calling with a 0 value will make the cursor move */
- /* So, let's move the cursor only if needed */
- if ((strlen(hdt_cli.input) - hdt_cli.cursor_pos) > 0) {
- /* Return to the begining of line */
- move_cursor_right(strlen(hdt_cli.input) - hdt_cli.cursor_pos);
- hdt_cli.cursor_pos = strlen(hdt_cli.input);
- }
- break;
-
- case KEY_CTRL('a'):
- case KEY_HOME:
- /* Calling with a 0 value will make the cursor move */
- /* So, let's move the cursor only if needed */
- if (hdt_cli.cursor_pos > 0) {
- /* Return to the begining of line */
- move_cursor_left(hdt_cli.cursor_pos);
- hdt_cli.cursor_pos = 0;
- }
- break;
-
- case KEY_UP:
- /* We have to compute the next position*/
- future_history_pos=hdt_cli.history_pos;
- if (future_history_pos==1) {
- future_history_pos=MAX_HISTORY_SIZE-1;
- } else {
- future_history_pos--;
- }
- /* Does the next position is valid */
- if (strlen(hdt_cli.history[future_history_pos])==0) break;
-
- /* Let's make that future position the one we use*/
- hdt_cli.history_pos=future_history_pos;
-
- /* Clear the line */
- clear_line();
-
- /* Move to the begining of line*/
- move_cursor_to_column(0);
-
- reset_prompt();
- printf("%s",hdt_cli.history[hdt_cli.history_pos]);
- strncpy(hdt_cli.input,hdt_cli.history[hdt_cli.history_pos],sizeof(hdt_cli.input));
- hdt_cli.cursor_pos=strlen(hdt_cli.input);
- break;
-
- case KEY_DOWN:
- display_history=true;
-
- /* We have to compute the next position*/
- future_history_pos=hdt_cli.history_pos;
- if (future_history_pos==MAX_HISTORY_SIZE-1) {
- future_history_pos=1;
- } else {
- future_history_pos++;
- }
- /* Does the next position is valid */
- if (strlen(hdt_cli.history[future_history_pos])==0) display_history = false;
-
- /* An exception is made to reach the last empty line */
- if (future_history_pos==hdt_cli.max_history_pos) display_history=true;
- if (display_history==false) break;
-
- /* Let's make that future position the one we use*/
- hdt_cli.history_pos=future_history_pos;
-
- /* Clear the line */
- clear_line();
-
- /* Move to the begining of line*/
- move_cursor_to_column(0);
-
- reset_prompt();
- printf("%s",hdt_cli.history[hdt_cli.history_pos]);
- strncpy(hdt_cli.input,hdt_cli.history[hdt_cli.history_pos],sizeof(hdt_cli.input));
- hdt_cli.cursor_pos=strlen(hdt_cli.input);
- break;
-
- case KEY_TAB:
- if (autocomplete_backlog) {
- clear_line();
- /* Move to the begining of line*/
- move_cursor_to_column(0);
- reset_prompt();
- printf("%s",autocomplete_last_seen->autocomplete_token);
- strncpy(hdt_cli.input,autocomplete_last_seen->autocomplete_token,sizeof(hdt_cli.input));
- hdt_cli.cursor_pos=strlen(hdt_cli.input);
-
- /* Cycle through the list */
- autocomplete_last_seen = autocomplete_last_seen->next;
- if (autocomplete_last_seen == NULL)
- autocomplete_last_seen = autocomplete_head;
- } else {
- printf("\n");
- autocomplete(skip_spaces(hdt_cli.input));
- autocomplete_last_seen = autocomplete_head;
-
- printf("%s%s", hdt_cli.prompt, hdt_cli.input);
- }
- break;
-
- case KEY_ENTER:
- printf("\n");
- if (strlen(remove_spaces(hdt_cli.input)) < 1) {
- reset_prompt();
- break;
- }
- if (hdt_cli.history_pos == MAX_HISTORY_SIZE-1) hdt_cli.history_pos=1;
- strncpy(hdt_cli.history[hdt_cli.history_pos],remove_spaces(hdt_cli.input),sizeof(hdt_cli.history[hdt_cli.history_pos]));
- hdt_cli.history_pos++;
- if (hdt_cli.history_pos>hdt_cli.max_history_pos) hdt_cli.max_history_pos=hdt_cli.history_pos;
- exec_command(remove_spaces(hdt_cli.input), hardware);
- reset_prompt();
- break;
-
- case KEY_CTRL('d'):
- case KEY_DELETE:
- /* No need to delete when input is empty */
- if (strlen(hdt_cli.input)==0) break;
- /* Don't delete when cursor is at the end of the line */
- if (hdt_cli.cursor_pos>=strlen(hdt_cli.input)) break;
-
- for (int c = hdt_cli.cursor_pos;
- c < (int)strlen(hdt_cli.input) - 1; c++)
- hdt_cli.input[c] = hdt_cli.input[c + 1];
- hdt_cli.input[strlen(hdt_cli.input) - 1] = '\0';
-
- /* Clear the end of the line */
- clear_end_of_line();
-
- /* Print the resulting buffer */
- printf("%s", hdt_cli.input + hdt_cli.cursor_pos);
-
- /* Replace the cursor at the proper place */
- if (strlen(hdt_cli.input + hdt_cli.cursor_pos)>0)
- move_cursor_left(strlen(hdt_cli.input + hdt_cli.cursor_pos));
- break;
-
- case KEY_DEL:
- case KEY_BACKSPACE:
- /* Don't delete prompt */
- if (hdt_cli.cursor_pos == 0)
- break;
-
- for (int c = hdt_cli.cursor_pos - 1;
- c < (int)strlen(hdt_cli.input) - 1; c++)
- hdt_cli.input[c] = hdt_cli.input[c + 1];
- hdt_cli.input[strlen(hdt_cli.input) - 1] = '\0';
-
- /* Get one char back */
- move_cursor_left(1);
-
- /* Clear the end of the line */
- clear_end_of_line();
-
- /* Print the resulting buffer */
- printf("%s", hdt_cli.input + hdt_cli.cursor_pos - 1);
-
- /* Realing to a char before the place we were */
- hdt_cli.cursor_pos--;
- move_cursor_to_column(strlen(hdt_cli.prompt)+hdt_cli.cursor_pos+1);
-
- break;
-
- case KEY_F1:
- printf("\n");
- exec_command(CLI_HELP, hardware);
- reset_prompt();
- break;
-
- default:
- if ( ( current_key < 0x20 ) || ( current_key > 0x7e ) ) break;
- /* Prevent overflow */
- if (hdt_cli.cursor_pos > MAX_LINE_SIZE - 2)
- break;
- /* If we aren't at the end of the input line, let's insert */
- if (hdt_cli.cursor_pos < (int)strlen(hdt_cli.input)) {
- char key[2];
- int trailing_chars =
- strlen(hdt_cli.input) - hdt_cli.cursor_pos;
- memset(temp_command, 0, sizeof(temp_command));
- strncpy(temp_command, hdt_cli.input,
- hdt_cli.cursor_pos);
- sprintf(key, "%c", current_key);
- strncat(temp_command, key, 1);
- strncat(temp_command,
- hdt_cli.input + hdt_cli.cursor_pos,
- trailing_chars);
- memset(hdt_cli.input, 0, sizeof(hdt_cli.input));
- snprintf(hdt_cli.input, sizeof(hdt_cli.input), "%s",
- temp_command);
-
- /* Clear the end of the line */
- clear_end_of_line();
-
- /* Print the resulting buffer */
- printf("%s", hdt_cli.input + hdt_cli.cursor_pos);
-
- /* Return where we must put the new char */
- move_cursor_left(trailing_chars);
-
- } else {
- putchar(current_key);
- hdt_cli.input[hdt_cli.cursor_pos] = current_key;
- }
- hdt_cli.cursor_pos++;
- break;
- }
+ for (int c = hdt_cli.cursor_pos;
+ c < (int)strlen(hdt_cli.input) - 1; c++)
+ hdt_cli.input[c] = hdt_cli.input[c + 1];
+ hdt_cli.input[strlen(hdt_cli.input) - 1] = '\0';
+
+ /* Clear the end of the line */
+ clear_end_of_line();
+
+ /* Print the resulting buffer */
+ printf("%s", hdt_cli.input + hdt_cli.cursor_pos);
+
+ /* Replace the cursor at the proper place */
+ if (strlen(hdt_cli.input + hdt_cli.cursor_pos) > 0)
+ move_cursor_left(strlen(hdt_cli.input + hdt_cli.cursor_pos));
+ break;
+
+ case KEY_DEL:
+ case KEY_BACKSPACE:
+ /* Don't delete prompt */
+ if (hdt_cli.cursor_pos == 0)
+ break;
+
+ for (int c = hdt_cli.cursor_pos - 1;
+ c < (int)strlen(hdt_cli.input) - 1; c++)
+ hdt_cli.input[c] = hdt_cli.input[c + 1];
+ hdt_cli.input[strlen(hdt_cli.input) - 1] = '\0';
+
+ /* Get one char back */
+ move_cursor_left(1);
+
+ /* Clear the end of the line */
+ clear_end_of_line();
+
+ /* Print the resulting buffer */
+ printf("%s", hdt_cli.input + hdt_cli.cursor_pos - 1);
+
+ /* Realing to a char before the place we were */
+ hdt_cli.cursor_pos--;
+ move_cursor_to_column(strlen(hdt_cli.prompt) + hdt_cli.cursor_pos +
+ 1);
+
+ break;
+
+ case KEY_F1:
+ printf("\n");
+ exec_command(CLI_HELP, hardware);
+ reset_prompt();
+ break;
+
+ default:
+ if ((current_key < 0x20) || (current_key > 0x7e))
+ break;
+ /* Prevent overflow */
+ if (hdt_cli.cursor_pos > MAX_LINE_SIZE - 2)
+ break;
+ /* If we aren't at the end of the input line, let's insert */
+ if (hdt_cli.cursor_pos < (int)strlen(hdt_cli.input)) {
+ char key[2];
+ int trailing_chars = strlen(hdt_cli.input) - hdt_cli.cursor_pos;
+ memset(temp_command, 0, sizeof(temp_command));
+ strncpy(temp_command, hdt_cli.input, hdt_cli.cursor_pos);
+ sprintf(key, "%c", current_key);
+ strncat(temp_command, key, 1);
+ strncat(temp_command,
+ hdt_cli.input + hdt_cli.cursor_pos, trailing_chars);
+ memset(hdt_cli.input, 0, sizeof(hdt_cli.input));
+ snprintf(hdt_cli.input, sizeof(hdt_cli.input), "%s",
+ temp_command);
+
+ /* Clear the end of the line */
+ clear_end_of_line();
+
+ /* Print the resulting buffer */
+ printf("%s", hdt_cli.input + hdt_cli.cursor_pos);
+
+ /* Return where we must put the new char */
+ move_cursor_left(trailing_chars);
+
+ } else {
+ putchar(current_key);
+ hdt_cli.input[hdt_cli.cursor_pos] = current_key;
+ }
+ hdt_cli.cursor_pos++;
+ break;
}
+ }
}
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 3684fa40..7a254eef 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -70,64 +70,65 @@
#define CLI_MEMORY "memory"
typedef enum {
- INVALID_MODE,
- EXIT_MODE,
- HDT_MODE,
- PCI_MODE,
- DMI_MODE,
- CPU_MODE,
- PXE_MODE,
- KERNEL_MODE,
- SYSLINUX_MODE,
- VESA_MODE,
- DISK_MODE,
- VPD_MODE,
- MEMORY_MODE,
+ INVALID_MODE,
+ EXIT_MODE,
+ HDT_MODE,
+ PCI_MODE,
+ DMI_MODE,
+ CPU_MODE,
+ PXE_MODE,
+ KERNEL_MODE,
+ SYSLINUX_MODE,
+ VESA_MODE,
+ DISK_MODE,
+ VPD_MODE,
+ MEMORY_MODE,
} cli_mode_t;
#define PROMPT_SIZE 32
#define MAX_HISTORY_SIZE 32
struct s_cli {
- cli_mode_t mode;
- char prompt[PROMPT_SIZE];
- char input[MAX_LINE_SIZE];
- uint8_t cursor_pos;
- char history[MAX_HISTORY_SIZE][MAX_LINE_SIZE];
- int history_pos;
- int max_history_pos;
+ cli_mode_t mode;
+ char prompt[PROMPT_SIZE];
+ char input[MAX_LINE_SIZE];
+ uint8_t cursor_pos;
+ char history[MAX_HISTORY_SIZE][MAX_LINE_SIZE];
+ int history_pos;
+ int max_history_pos;
};
struct s_cli hdt_cli;
/* Describe a cli mode */
struct cli_mode_descr {
- const unsigned int mode;
- const char* name;
- /* Handle 1-token commands */
- struct cli_module_descr* default_modules;
- /* Handle show <module> <args> */
- struct cli_module_descr* show_modules;
- /* Handle set <module> <args> */
- struct cli_module_descr* set_modules;
+ const unsigned int mode;
+ const char *name;
+ /* Handle 1-token commands */
+ struct cli_module_descr *default_modules;
+ /* Handle show <module> <args> */
+ struct cli_module_descr *show_modules;
+ /* Handle set <module> <args> */
+ struct cli_module_descr *set_modules;
};
/* Describe a subset of commands in a module (default, show, set, ...) */
struct cli_module_descr {
- struct cli_callback_descr* modules;
- void ( * default_callback ) ( int argc, char** argv, struct s_hardware *hardware );
+ struct cli_callback_descr *modules;
+ void (*default_callback) (int argc, char **argv,
+ struct s_hardware * hardware);
};
/* Describe a callback (belongs to a mode and a module) */
struct cli_callback_descr {
- const char *name;
- void ( * exec ) ( int argc, char** argv, struct s_hardware *hardware );
+ const char *name;
+ void (*exec) (int argc, char **argv, struct s_hardware * hardware);
};
/* Manage aliases */
#define MAX_ALIASES 2
struct cli_alias {
- const char *command; /* Original command */
- const int nb_aliases; /* Size of aliases array */
- const char **aliases; /* List of aliases */
+ const char *command; /* Original command */
+ const int nb_aliases; /* Size of aliases array */
+ const char **aliases; /* List of aliases */
};
/* List of implemented modes */
@@ -171,8 +172,9 @@ void main_show(char *item, struct s_hardware *hardware);
#define CLI_DMI_SECURITY "security"
#define CLI_DMI_LIST CLI_SHOW_LIST
void main_show_dmi(int argc, char **argv, struct s_hardware *hardware);
-void show_dmi_memory_modules(int argc, char** argv, struct s_hardware *hardware);
-void show_dmi_memory_bank(int argc, char** argv, struct s_hardware *hardware);
+void show_dmi_memory_modules(int argc, char **argv,
+ struct s_hardware *hardware);
+void show_dmi_memory_bank(int argc, char **argv, struct s_hardware *hardware);
// PCI STUFF
#define CLI_PCI_DEVICE "device"
@@ -198,5 +200,6 @@ void main_show_syslinux(int argc, char **argv, struct s_hardware *hardware);
void main_show_vesa(int argc, char **argv, struct s_hardware *hardware);
// VPD STUFF
-void main_show_vpd(int argc __unused, char **argv __unused, struct s_hardware *hardware);
+void main_show_vpd(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware);
#endif
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index bde1f375..754798c4 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -37,158 +37,165 @@
#include <disk/mbrs.h>
/* ISOlinux requires a 8.3 format */
-void convert_isolinux_filename(char *filename, struct s_hardware *hardware) {
- /* Exit if we are not running ISOLINUX */
- if (hardware->sv->filesystem != SYSLINUX_FS_ISOLINUX) return;
- /* Searching the dot */
- char *dot=strchr(filename,'.');
- /* Exiting if no dot exists in that string */
- if (dot==NULL) return;
- /* Exiting if the extension is 3 char or less */
- if (strlen(dot)<=4) return;
-
- /* We have an extension bigger than .blah
- * so we have to shorten it to 3*/
- dot[4]='\0';
+void convert_isolinux_filename(char *filename, struct s_hardware *hardware)
+{
+ /* Exit if we are not running ISOLINUX */
+ if (hardware->sv->filesystem != SYSLINUX_FS_ISOLINUX)
+ return;
+ /* Searching the dot */
+ char *dot = strchr(filename, '.');
+ /* Exiting if no dot exists in that string */
+ if (dot == NULL)
+ return;
+ /* Exiting if the extension is 3 char or less */
+ if (strlen(dot) <= 4)
+ return;
+
+ /* We have an extension bigger than .blah
+ * so we have to shorten it to 3*/
+ dot[4] = '\0';
}
void detect_parameters(const int argc, const char *argv[],
- struct s_hardware *hardware)
+ struct s_hardware *hardware)
{
- /* Quiet mode - make the output more quiet */
- quiet = false;
-
- /* Vesa mode isn't set until we explictly call it*/
- vesamode = false;
-
- for (int i = 1; i < argc; i++) {
- if (!strncmp(argv[i], "quiet", 5)) {
- quiet = true;
- } else if (!strncmp(argv[i], "modules_pcimap=", 15)) {
- strncpy(hardware->modules_pcimap_path, argv[i] + 15,
- sizeof(hardware->modules_pcimap_path));
- convert_isolinux_filename(hardware->modules_pcimap_path,hardware);
- } else if (!strncmp(argv[i], "pciids=", 7)) {
- strncpy(hardware->pciids_path, argv[i] + 7,
- sizeof(hardware->pciids_path));
- convert_isolinux_filename(hardware->pciids_path,hardware);
- } else if (!strncmp(argv[i], "modules_alias=", 14)) {
- strncpy(hardware->modules_alias_path, argv[i] + 14,
- sizeof(hardware->modules_alias_path));
- convert_isolinux_filename(hardware->modules_alias_path,hardware);
- } else if (!strncmp(argv[i], "memtest=", 8)) {
- strncpy(hardware->memtest_label, argv[i] + 8,
- sizeof(hardware->memtest_label));
- convert_isolinux_filename(hardware->memtest_label,hardware);
- } else if (!strncmp(argv[i], "reboot=", 7)) {
- strncpy(hardware->reboot_label, argv[i] + 7,
- sizeof(hardware->reboot_label));
- convert_isolinux_filename(hardware->reboot_label,hardware);
- } else if (!strncmp(argv[i], "vesa", 4)) {
- vesamode=true;
- max_console_lines=24;
- /* If the user defines a background image */
- if (!strncmp(argv[i], "vesa=", 5)) {
- strncpy(hardware->vesa_background,argv[i]+5,sizeof(hardware->vesa_background));
- }
- } else if (!strncmp(argv[i], "auto=", 5)) {
- /* The auto= parameter is separated in several argv[]
- * as it can contains spaces.
- * We use the AUTO_DELIMITER char to define the limits
- * of this parameter.
- * i.e auto='show dmi; show pci'
- */
-
- /* Extracting the first parameter */
- strcpy(hardware->auto_label, argv[i] + 6);
- strcat(hardware->auto_label," ");
- char *pos;
+ /* Quiet mode - make the output more quiet */
+ quiet = false;
+
+ /* Vesa mode isn't set until we explictly call it */
+ vesamode = false;
+
+ for (int i = 1; i < argc; i++) {
+ if (!strncmp(argv[i], "quiet", 5)) {
+ quiet = true;
+ } else if (!strncmp(argv[i], "modules_pcimap=", 15)) {
+ strncpy(hardware->modules_pcimap_path, argv[i] + 15,
+ sizeof(hardware->modules_pcimap_path));
+ convert_isolinux_filename(hardware->modules_pcimap_path, hardware);
+ } else if (!strncmp(argv[i], "pciids=", 7)) {
+ strncpy(hardware->pciids_path, argv[i] + 7,
+ sizeof(hardware->pciids_path));
+ convert_isolinux_filename(hardware->pciids_path, hardware);
+ } else if (!strncmp(argv[i], "modules_alias=", 14)) {
+ strncpy(hardware->modules_alias_path, argv[i] + 14,
+ sizeof(hardware->modules_alias_path));
+ convert_isolinux_filename(hardware->modules_alias_path, hardware);
+ } else if (!strncmp(argv[i], "memtest=", 8)) {
+ strncpy(hardware->memtest_label, argv[i] + 8,
+ sizeof(hardware->memtest_label));
+ convert_isolinux_filename(hardware->memtest_label, hardware);
+ } else if (!strncmp(argv[i], "reboot=", 7)) {
+ strncpy(hardware->reboot_label, argv[i] + 7,
+ sizeof(hardware->reboot_label));
+ convert_isolinux_filename(hardware->reboot_label, hardware);
+ } else if (!strncmp(argv[i], "vesa", 4)) {
+ vesamode = true;
+ max_console_lines = 24;
+ /* If the user defines a background image */
+ if (!strncmp(argv[i], "vesa=", 5)) {
+ strncpy(hardware->vesa_background, argv[i] + 5,
+ sizeof(hardware->vesa_background));
+ }
+ } else if (!strncmp(argv[i], "auto=", 5)) {
+ /* The auto= parameter is separated in several argv[]
+ * as it can contains spaces.
+ * We use the AUTO_DELIMITER char to define the limits
+ * of this parameter.
+ * i.e auto='show dmi; show pci'
+ */
+
+ /* Extracting the first parameter */
+ strcpy(hardware->auto_label, argv[i] + 6);
+ strcat(hardware->auto_label, " ");
+ char *pos;
+ i++;
+
+ /* While we can't find the other AUTO_DELIMITER, let's process the argv[] */
+ while (((pos = strstr(argv[i], AUTO_DELIMITER)) == NULL)
+ && (i < argc)) {
+ strcat(hardware->auto_label, argv[i]);
+ strcat(hardware->auto_label, " ");
i++;
+ }
- /* While we can't find the other AUTO_DELIMITER, let's process the argv[] */
- while(((pos=strstr(argv[i],AUTO_DELIMITER)) == NULL) && (i<argc)) {
- strcat(hardware->auto_label,argv[i]);
- strcat(hardware->auto_label," ");
- i++;
- }
-
- /* If we didn't reach the end of the line, let's grab the last item */
- if (i<argc) {
- strcat(hardware->auto_label,argv[i]);
- hardware->auto_label[strlen(hardware->auto_label)-1]=0;
- }
+ /* If we didn't reach the end of the line, let's grab the last item */
+ if (i < argc) {
+ strcat(hardware->auto_label, argv[i]);
+ hardware->auto_label[strlen(hardware->auto_label) - 1] = 0;
+ }
+ }
}
- }
}
void detect_syslinux(struct s_hardware *hardware)
{
- hardware->sv = syslinux_version();
- switch (hardware->sv->filesystem) {
- case SYSLINUX_FS_SYSLINUX:
- strlcpy(hardware->syslinux_fs, "SYSlinux", 9);
- break;
- case SYSLINUX_FS_PXELINUX:
- strlcpy(hardware->syslinux_fs, "PXElinux", 9);
- break;
- case SYSLINUX_FS_ISOLINUX:
- strlcpy(hardware->syslinux_fs, "ISOlinux", 9);
- break;
- case SYSLINUX_FS_EXTLINUX:
- strlcpy(hardware->syslinux_fs, "EXTlinux", 9);
- break;
- case SYSLINUX_FS_UNKNOWN:
- default:
- strlcpy(hardware->syslinux_fs, "Unknown Bootloader",
- sizeof hardware->syslinux_fs);
- break;
- }
+ hardware->sv = syslinux_version();
+ switch (hardware->sv->filesystem) {
+ case SYSLINUX_FS_SYSLINUX:
+ strlcpy(hardware->syslinux_fs, "SYSlinux", 9);
+ break;
+ case SYSLINUX_FS_PXELINUX:
+ strlcpy(hardware->syslinux_fs, "PXElinux", 9);
+ break;
+ case SYSLINUX_FS_ISOLINUX:
+ strlcpy(hardware->syslinux_fs, "ISOlinux", 9);
+ break;
+ case SYSLINUX_FS_EXTLINUX:
+ strlcpy(hardware->syslinux_fs, "EXTlinux", 9);
+ break;
+ case SYSLINUX_FS_UNKNOWN:
+ default:
+ strlcpy(hardware->syslinux_fs, "Unknown Bootloader",
+ sizeof hardware->syslinux_fs);
+ break;
+ }
}
void init_hardware(struct s_hardware *hardware)
{
- hardware->pci_ids_return_code = 0;
- hardware->modules_pcimap_return_code = 0;
- hardware->modules_alias_return_code = 0;
- hardware->cpu_detection = false;
- hardware->pci_detection = false;
- hardware->disk_detection = false;
- hardware->disks_count=0;
- hardware->dmi_detection = false;
- hardware->pxe_detection = false;
- hardware->vesa_detection = false;
- hardware->vpd_detection = false;
- hardware->nb_pci_devices = 0;
- hardware->is_dmi_valid = false;
- hardware->is_pxe_valid = false;
- hardware->is_vpd_valid = false;
- hardware->pci_domain = NULL;
- hardware->detected_memory_size = 0;
-
- /* Cleaning structures */
- memset(hardware->disk_info, 0, sizeof(hardware->disk_info));
- memset(hardware->mbr_ids, 0, sizeof(hardware->mbr_ids));
- memset(&hardware->dmi, 0, sizeof(s_dmi));
- memset(&hardware->cpu, 0, sizeof(s_cpu));
- memset(&hardware->pxe, 0, sizeof(struct s_pxe));
- memset(&hardware->vesa, 0, sizeof(struct s_vesa));
- memset(&hardware->vpd, 0, sizeof(s_vpd));
- memset(hardware->syslinux_fs, 0, sizeof hardware->syslinux_fs);
- memset(hardware->pciids_path, 0, sizeof hardware->pciids_path);
- memset(hardware->modules_pcimap_path, 0,
- sizeof hardware->modules_pcimap_path);
- memset(hardware->modules_alias_path, 0,
- sizeof hardware->modules_alias_path);
- memset(hardware->memtest_label, 0, sizeof hardware->memtest_label);
- memset(hardware->reboot_label, 0, sizeof hardware->reboot_label);
- memset(hardware->auto_label, 0, sizeof hardware->auto_label);
- memset(hardware->vesa_background, 0, sizeof hardware->vesa_background);
- strcat(hardware->pciids_path, "pci.ids");
- strcat(hardware->modules_pcimap_path, "modules.pcimap");
- strcat(hardware->modules_alias_path, "modules.alias");
- strcat(hardware->memtest_label, "memtest");
- strcat(hardware->reboot_label, "reboot.c32");
- strncpy(hardware->vesa_background,CLI_DEFAULT_BACKGROUND,sizeof(hardware->vesa_background));
+ hardware->pci_ids_return_code = 0;
+ hardware->modules_pcimap_return_code = 0;
+ hardware->modules_alias_return_code = 0;
+ hardware->cpu_detection = false;
+ hardware->pci_detection = false;
+ hardware->disk_detection = false;
+ hardware->disks_count = 0;
+ hardware->dmi_detection = false;
+ hardware->pxe_detection = false;
+ hardware->vesa_detection = false;
+ hardware->vpd_detection = false;
+ hardware->nb_pci_devices = 0;
+ hardware->is_dmi_valid = false;
+ hardware->is_pxe_valid = false;
+ hardware->is_vpd_valid = false;
+ hardware->pci_domain = NULL;
+ hardware->detected_memory_size = 0;
+
+ /* Cleaning structures */
+ memset(hardware->disk_info, 0, sizeof(hardware->disk_info));
+ memset(hardware->mbr_ids, 0, sizeof(hardware->mbr_ids));
+ memset(&hardware->dmi, 0, sizeof(s_dmi));
+ memset(&hardware->cpu, 0, sizeof(s_cpu));
+ memset(&hardware->pxe, 0, sizeof(struct s_pxe));
+ memset(&hardware->vesa, 0, sizeof(struct s_vesa));
+ memset(&hardware->vpd, 0, sizeof(s_vpd));
+ memset(hardware->syslinux_fs, 0, sizeof hardware->syslinux_fs);
+ memset(hardware->pciids_path, 0, sizeof hardware->pciids_path);
+ memset(hardware->modules_pcimap_path, 0,
+ sizeof hardware->modules_pcimap_path);
+ memset(hardware->modules_alias_path, 0,
+ sizeof hardware->modules_alias_path);
+ memset(hardware->memtest_label, 0, sizeof hardware->memtest_label);
+ memset(hardware->reboot_label, 0, sizeof hardware->reboot_label);
+ memset(hardware->auto_label, 0, sizeof hardware->auto_label);
+ memset(hardware->vesa_background, 0, sizeof hardware->vesa_background);
+ strcat(hardware->pciids_path, "pci.ids");
+ strcat(hardware->modules_pcimap_path, "modules.pcimap");
+ strcat(hardware->modules_alias_path, "modules.alias");
+ strcat(hardware->memtest_label, "memtest");
+ strcat(hardware->reboot_label, "reboot.c32");
+ strncpy(hardware->vesa_background, CLI_DEFAULT_BACKGROUND,
+ sizeof(hardware->vesa_background));
}
/*
@@ -197,17 +204,17 @@ void init_hardware(struct s_hardware *hardware)
*/
int detect_dmi(struct s_hardware *hardware)
{
- if (hardware->dmi_detection == true)
- return -1;
- hardware->dmi_detection = true;
- if (dmi_iterate(&hardware->dmi) == -ENODMITABLE) {
- hardware->is_dmi_valid = false;
- return -ENODMITABLE;
- }
+ if (hardware->dmi_detection == true)
+ return -1;
+ hardware->dmi_detection = true;
+ if (dmi_iterate(&hardware->dmi) == -ENODMITABLE) {
+ hardware->is_dmi_valid = false;
+ return -ENODMITABLE;
+ }
- parse_dmitable(&hardware->dmi);
- hardware->is_dmi_valid = true;
- return 0;
+ parse_dmitable(&hardware->dmi);
+ hardware->is_dmi_valid = true;
+ return 0;
}
/**
@@ -220,325 +227,303 @@ int detect_dmi(struct s_hardware *hardware)
**/
int detect_vpd(struct s_hardware *hardware)
{
- if (hardware->vpd_detection)
- return -1;
- else
- hardware->vpd_detection = true;
-
- if (vpd_decode(&hardware->vpd) == -ENOVPDTABLE) {
- hardware->is_vpd_valid = false;
- return -ENOVPDTABLE;
- } else {
- hardware->is_vpd_valid = true;
- return 0;
- }
+ if (hardware->vpd_detection)
+ return -1;
+ else
+ hardware->vpd_detection = true;
+
+ if (vpd_decode(&hardware->vpd) == -ENOVPDTABLE) {
+ hardware->is_vpd_valid = false;
+ return -ENOVPDTABLE;
+ } else {
+ hardware->is_vpd_valid = true;
+ return 0;
+ }
}
/* Detection vesa stuff*/
-int detect_vesa(struct s_hardware *hardware) {
- static com32sys_t rm;
- struct vesa_general_info *gi;
- struct vesa_mode_info *mi;
- uint16_t mode, *mode_ptr;
- char *oem_ptr;
-
- if (hardware->vesa_detection == true) return -1;
-
- hardware->vesa_detection=true;
- hardware->is_vesa_valid=false;
-
- /* Allocate space in the bounce buffer for these structures */
- gi = &((struct vesa_info *)__com32.cs_bounce)->gi;
- mi = &((struct vesa_info *)__com32.cs_bounce)->mi;
-
- gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */
- rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
- rm.edi.w[0] = OFFS(gi);
- rm.es = SEG(gi);
- __intcall(0x10, &rm, &rm);
-
- if ( rm.eax.w[0] != 0x004F ) {
- return -1;
- };
-
- mode_ptr = GET_PTR(gi->video_mode_ptr);
- oem_ptr = GET_PTR(gi->oem_vendor_name_ptr);
- strncpy(hardware->vesa.vendor,oem_ptr,sizeof(hardware->vesa.vendor));
- oem_ptr = GET_PTR(gi->oem_product_name_ptr);
- strncpy(hardware->vesa.product,oem_ptr,sizeof(hardware->vesa.product));
- oem_ptr = GET_PTR(gi->oem_product_rev_ptr);
- strncpy(hardware->vesa.product_revision,oem_ptr,sizeof(hardware->vesa.product_revision));
-
- hardware->vesa.major_version=(gi->version >> 8) & 0xff;
- hardware->vesa.minor_version=gi->version & 0xff;
- hardware->vesa.total_memory=gi->total_memory;
- hardware->vesa.software_rev=gi->oem_software_rev;
-
- hardware->vesa.vmi_count=0;
-
- while ((mode = *mode_ptr++) != 0xFFFF) {
-
- rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
- rm.ecx.w[0] = mode;
- rm.edi.w[0] = OFFS(mi);
- rm.es = SEG(mi);
+int detect_vesa(struct s_hardware *hardware)
+{
+ static com32sys_t rm;
+ struct vesa_general_info *gi;
+ struct vesa_mode_info *mi;
+ uint16_t mode, *mode_ptr;
+ char *oem_ptr;
+
+ if (hardware->vesa_detection == true)
+ return -1;
+
+ hardware->vesa_detection = true;
+ hardware->is_vesa_valid = false;
+
+ /* Allocate space in the bounce buffer for these structures */
+ gi = &((struct vesa_info *)__com32.cs_bounce)->gi;
+ mi = &((struct vesa_info *)__com32.cs_bounce)->mi;
+
+ gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */
+ rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
+ rm.edi.w[0] = OFFS(gi);
+ rm.es = SEG(gi);
__intcall(0x10, &rm, &rm);
- /* Must be a supported mode */
- if ( rm.eax.w[0] != 0x004f )
- continue;
+ if (rm.eax.w[0] != 0x004F) {
+ return -1;
+ };
- /* Saving detected values*/
- memcpy(&hardware->vesa.vmi[hardware->vesa.vmi_count].mi, mi,
- sizeof(struct vesa_mode_info));
- hardware->vesa.vmi[hardware->vesa.vmi_count].mode = mode;
+ mode_ptr = GET_PTR(gi->video_mode_ptr);
+ oem_ptr = GET_PTR(gi->oem_vendor_name_ptr);
+ strncpy(hardware->vesa.vendor, oem_ptr, sizeof(hardware->vesa.vendor));
+ oem_ptr = GET_PTR(gi->oem_product_name_ptr);
+ strncpy(hardware->vesa.product, oem_ptr, sizeof(hardware->vesa.product));
+ oem_ptr = GET_PTR(gi->oem_product_rev_ptr);
+ strncpy(hardware->vesa.product_revision, oem_ptr,
+ sizeof(hardware->vesa.product_revision));
- hardware->vesa.vmi_count++;
- }
- hardware->is_vesa_valid = true;
- return 0;
+ hardware->vesa.major_version = (gi->version >> 8) & 0xff;
+ hardware->vesa.minor_version = gi->version & 0xff;
+ hardware->vesa.total_memory = gi->total_memory;
+ hardware->vesa.software_rev = gi->oem_software_rev;
+
+ hardware->vesa.vmi_count = 0;
+
+ while ((mode = *mode_ptr++) != 0xFFFF) {
+
+ rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
+ rm.ecx.w[0] = mode;
+ rm.edi.w[0] = OFFS(mi);
+ rm.es = SEG(mi);
+ __intcall(0x10, &rm, &rm);
+
+ /* Must be a supported mode */
+ if (rm.eax.w[0] != 0x004f)
+ continue;
+
+ /* Saving detected values */
+ memcpy(&hardware->vesa.vmi[hardware->vesa.vmi_count].mi, mi,
+ sizeof(struct vesa_mode_info));
+ hardware->vesa.vmi[hardware->vesa.vmi_count].mode = mode;
+
+ hardware->vesa.vmi_count++;
+ }
+ hardware->is_vesa_valid = true;
+ return 0;
}
/* Try to detect disks from port 0x80 to 0xff */
void detect_disks(struct s_hardware *hardware)
{
- int i = -1;
- int err;
+ int i = -1;
+ int err;
- if (hardware->disk_detection)
- return;
+ if (hardware->disk_detection)
+ return;
- hardware->disk_detection = true;
- for (int drive = 0x80; drive < 0xff; drive++) {
- i++;
- hardware->disk_info[i].disk = drive;
- err = get_drive_parameters(&hardware->disk_info[i]);
+ hardware->disk_detection = true;
+ for (int drive = 0x80; drive < 0xff; drive++) {
+ i++;
+ hardware->disk_info[i].disk = drive;
+ err = get_drive_parameters(&hardware->disk_info[i]);
- /*
- * Do not print output when drive does not exist or
- * doesn't support int13 (cdrom, ...)
- */
- if (err == -1 || !hardware->disk_info[i].cbios)
- continue;
+ /*
+ * Do not print output when drive does not exist or
+ * doesn't support int13 (cdrom, ...)
+ */
+ if (err == -1 || !hardware->disk_info[i].cbios)
+ continue;
- /* Detect MBR */
- hardware->mbr_ids[i] = get_mbr_id(&hardware->disk_info[i]);
+ /* Detect MBR */
+ hardware->mbr_ids[i] = get_mbr_id(&hardware->disk_info[i]);
- hardware->disks_count++;
- }
+ hardware->disks_count++;
+ }
}
int detect_pxe(struct s_hardware *hardware)
{
- void *dhcpdata;
-
- size_t dhcplen;
- t_PXENV_UNDI_GET_NIC_TYPE gnt;
-
- if (hardware->pxe_detection == true)
- return -1;
- hardware->pxe_detection = true;
- hardware->is_pxe_valid = false;
- memset(&gnt, 0, sizeof(t_PXENV_UNDI_GET_NIC_TYPE));
- memset(&hardware->pxe, 0, sizeof(struct s_pxe));
-
- /* This code can only work if pxelinux is loaded */
- if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
- return -1;
- }
+ void *dhcpdata;
+
+ size_t dhcplen;
+ t_PXENV_UNDI_GET_NIC_TYPE gnt;
+
+ if (hardware->pxe_detection == true)
+ return -1;
+ hardware->pxe_detection = true;
+ hardware->is_pxe_valid = false;
+ memset(&gnt, 0, sizeof(t_PXENV_UNDI_GET_NIC_TYPE));
+ memset(&hardware->pxe, 0, sizeof(struct s_pxe));
+
+ /* This code can only work if pxelinux is loaded */
+ if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
+ return -1;
+ }
// printf("PXE: PXElinux detected\n");
- if (!pxe_get_cached_info
- (PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) {
- pxe_bootp_t *dhcp = &hardware->pxe.dhcpdata;
- memcpy(&hardware->pxe.dhcpdata, dhcpdata,
- sizeof(hardware->pxe.dhcpdata));
- snprintf(hardware->pxe.mac_addr, sizeof(hardware->pxe.mac_addr),
- "%02x:%02x:%02x:%02x:%02x:%02x", dhcp->CAddr[0],
- dhcp->CAddr[1], dhcp->CAddr[2], dhcp->CAddr[3],
- dhcp->CAddr[4], dhcp->CAddr[5]);
-
- /* Saving our IP address in a easy format */
- hardware->pxe.ip_addr[0] = hardware->pxe.dhcpdata.yip & 0xff;
- hardware->pxe.ip_addr[1] =
- hardware->pxe.dhcpdata.yip >> 8 & 0xff;
- hardware->pxe.ip_addr[2] =
- hardware->pxe.dhcpdata.yip >> 16 & 0xff;
- hardware->pxe.ip_addr[3] =
- hardware->pxe.dhcpdata.yip >> 24 & 0xff;
-
- if (!pxe_get_nic_type(&gnt)) {
- switch (gnt.NicType) {
- case PCI_NIC:
- hardware->is_pxe_valid = true;
- hardware->pxe.vendor_id =
- gnt.info.pci.Vendor_ID;
- hardware->pxe.product_id = gnt.info.pci.Dev_ID;
- hardware->pxe.subvendor_id =
- gnt.info.pci.SubVendor_ID;
- hardware->pxe.subproduct_id =
- gnt.info.pci.SubDevice_ID,
- hardware->pxe.rev = gnt.info.pci.Rev;
- hardware->pxe.pci_bus =
- (gnt.info.pci.BusDevFunc >> 8) & 0xff;
- hardware->pxe.pci_dev =
- (gnt.info.pci.BusDevFunc >> 3) & 0x7;
- hardware->pxe.pci_func =
- gnt.info.pci.BusDevFunc & 0x03;
- hardware->pxe.base_class =
- gnt.info.pci.Base_Class;
- hardware->pxe.sub_class =
- gnt.info.pci.Sub_Class;
- hardware->pxe.prog_intf =
- gnt.info.pci.Prog_Intf;
- hardware->pxe.nictype = gnt.NicType;
- break;
- case CardBus_NIC:
- hardware->is_pxe_valid = true;
- hardware->pxe.vendor_id =
- gnt.info.cardbus.Vendor_ID;
- hardware->pxe.product_id =
- gnt.info.cardbus.Dev_ID;
- hardware->pxe.subvendor_id =
- gnt.info.cardbus.SubVendor_ID;
- hardware->pxe.subproduct_id =
- gnt.info.cardbus.SubDevice_ID,
- hardware->pxe.rev = gnt.info.cardbus.Rev;
- hardware->pxe.pci_bus =
- (gnt.info.cardbus.BusDevFunc >> 8) & 0xff;
- hardware->pxe.pci_dev =
- (gnt.info.cardbus.BusDevFunc >> 3) & 0x7;
- hardware->pxe.pci_func =
- gnt.info.cardbus.BusDevFunc & 0x03;
- hardware->pxe.base_class =
- gnt.info.cardbus.Base_Class;
- hardware->pxe.sub_class =
- gnt.info.cardbus.Sub_Class;
- hardware->pxe.prog_intf =
- gnt.info.cardbus.Prog_Intf;
- hardware->pxe.nictype = gnt.NicType;
- break;
- case PnP_NIC:
- default:
- return -1;
- break;
- }
- /* Let's try to find the associated pci device */
- detect_pci(hardware);
-
- /* The firt pass try to find the exact pci device */
- hardware->pxe.pci_device = NULL;
- hardware->pxe.pci_device_pos = 0;
- struct pci_device *pci_device;
- int pci_number = 0;
- for_each_pci_func(pci_device, hardware->pci_domain) {
- pci_number++;
- if ((__pci_bus == hardware->pxe.pci_bus) &&
- (__pci_slot == hardware->pxe.pci_dev) &&
- (__pci_func == hardware->pxe.pci_func) &&
- (pci_device->vendor ==
- hardware->pxe.vendor_id)
- && (pci_device->product ==
- hardware->pxe.product_id)) {
- hardware->pxe.pci_device = pci_device;
- hardware->pxe.pci_device_pos =
- pci_number;
- return 0;
- }
- }
-
- /* If we reach that part, it means the pci device pointed by
- * the pxe rom wasn't found in our list.
- * Let's try to find the device only by its pci ids.
- * The pci device we'll match is maybe not exactly the good one
- * as we can have the same pci id several times.
- * At least, the pci id, the vendor/product will be right.
- * That's clearly a workaround for some weird cases.
- * This should happend very unlikely */
- hardware->pxe.pci_device = NULL;
- hardware->pxe.pci_device_pos = 0;
- pci_number = 0;
- for_each_pci_func(pci_device, hardware->pci_domain) {
- pci_number++;
- if ((pci_device->vendor ==
- hardware->pxe.vendor_id)
- && (pci_device->product ==
- hardware->pxe.product_id)) {
- hardware->pxe.pci_device = pci_device;
- hardware->pxe.pci_device_pos =
- pci_number;
- return 0;
- }
- }
+ if (!pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) {
+ pxe_bootp_t *dhcp = &hardware->pxe.dhcpdata;
+ memcpy(&hardware->pxe.dhcpdata, dhcpdata,
+ sizeof(hardware->pxe.dhcpdata));
+ snprintf(hardware->pxe.mac_addr, sizeof(hardware->pxe.mac_addr),
+ "%02x:%02x:%02x:%02x:%02x:%02x", dhcp->CAddr[0],
+ dhcp->CAddr[1], dhcp->CAddr[2], dhcp->CAddr[3],
+ dhcp->CAddr[4], dhcp->CAddr[5]);
+
+ /* Saving our IP address in a easy format */
+ hardware->pxe.ip_addr[0] = hardware->pxe.dhcpdata.yip & 0xff;
+ hardware->pxe.ip_addr[1] = hardware->pxe.dhcpdata.yip >> 8 & 0xff;
+ hardware->pxe.ip_addr[2] = hardware->pxe.dhcpdata.yip >> 16 & 0xff;
+ hardware->pxe.ip_addr[3] = hardware->pxe.dhcpdata.yip >> 24 & 0xff;
+
+ if (!pxe_get_nic_type(&gnt)) {
+ switch (gnt.NicType) {
+ case PCI_NIC:
+ hardware->is_pxe_valid = true;
+ hardware->pxe.vendor_id = gnt.info.pci.Vendor_ID;
+ hardware->pxe.product_id = gnt.info.pci.Dev_ID;
+ hardware->pxe.subvendor_id = gnt.info.pci.SubVendor_ID;
+ hardware->pxe.subproduct_id =
+ gnt.info.pci.SubDevice_ID,
+ hardware->pxe.rev = gnt.info.pci.Rev;
+ hardware->pxe.pci_bus = (gnt.info.pci.BusDevFunc >> 8) & 0xff;
+ hardware->pxe.pci_dev = (gnt.info.pci.BusDevFunc >> 3) & 0x7;
+ hardware->pxe.pci_func = gnt.info.pci.BusDevFunc & 0x03;
+ hardware->pxe.base_class = gnt.info.pci.Base_Class;
+ hardware->pxe.sub_class = gnt.info.pci.Sub_Class;
+ hardware->pxe.prog_intf = gnt.info.pci.Prog_Intf;
+ hardware->pxe.nictype = gnt.NicType;
+ break;
+ case CardBus_NIC:
+ hardware->is_pxe_valid = true;
+ hardware->pxe.vendor_id = gnt.info.cardbus.Vendor_ID;
+ hardware->pxe.product_id = gnt.info.cardbus.Dev_ID;
+ hardware->pxe.subvendor_id = gnt.info.cardbus.SubVendor_ID;
+ hardware->pxe.subproduct_id =
+ gnt.info.cardbus.SubDevice_ID,
+ hardware->pxe.rev = gnt.info.cardbus.Rev;
+ hardware->pxe.pci_bus =
+ (gnt.info.cardbus.BusDevFunc >> 8) & 0xff;
+ hardware->pxe.pci_dev =
+ (gnt.info.cardbus.BusDevFunc >> 3) & 0x7;
+ hardware->pxe.pci_func = gnt.info.cardbus.BusDevFunc & 0x03;
+ hardware->pxe.base_class = gnt.info.cardbus.Base_Class;
+ hardware->pxe.sub_class = gnt.info.cardbus.Sub_Class;
+ hardware->pxe.prog_intf = gnt.info.cardbus.Prog_Intf;
+ hardware->pxe.nictype = gnt.NicType;
+ break;
+ case PnP_NIC:
+ default:
+ return -1;
+ break;
+ }
+ /* Let's try to find the associated pci device */
+ detect_pci(hardware);
+
+ /* The firt pass try to find the exact pci device */
+ hardware->pxe.pci_device = NULL;
+ hardware->pxe.pci_device_pos = 0;
+ struct pci_device *pci_device;
+ int pci_number = 0;
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ pci_number++;
+ if ((__pci_bus == hardware->pxe.pci_bus) &&
+ (__pci_slot == hardware->pxe.pci_dev) &&
+ (__pci_func == hardware->pxe.pci_func) &&
+ (pci_device->vendor == hardware->pxe.vendor_id)
+ && (pci_device->product == hardware->pxe.product_id)) {
+ hardware->pxe.pci_device = pci_device;
+ hardware->pxe.pci_device_pos = pci_number;
+ return 0;
+ }
+ }
+
+ /* If we reach that part, it means the pci device pointed by
+ * the pxe rom wasn't found in our list.
+ * Let's try to find the device only by its pci ids.
+ * The pci device we'll match is maybe not exactly the good one
+ * as we can have the same pci id several times.
+ * At least, the pci id, the vendor/product will be right.
+ * That's clearly a workaround for some weird cases.
+ * This should happend very unlikely */
+ hardware->pxe.pci_device = NULL;
+ hardware->pxe.pci_device_pos = 0;
+ pci_number = 0;
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ pci_number++;
+ if ((pci_device->vendor == hardware->pxe.vendor_id)
+ && (pci_device->product == hardware->pxe.product_id)) {
+ hardware->pxe.pci_device = pci_device;
+ hardware->pxe.pci_device_pos = pci_number;
+ return 0;
+ }
+ }
+ }
}
- }
- return 0;
+ return 0;
}
void detect_pci(struct s_hardware *hardware)
{
- if (hardware->pci_detection == true)
- return;
- hardware->pci_detection = true;
-
- hardware->nb_pci_devices = 0;
-
- /* Scanning to detect pci buses and devices */
- hardware->pci_domain = pci_scan();
-
- if (!hardware->pci_domain)
- return;
-
- /* Gathering addtional information*/
- gather_additional_pci_config(hardware->pci_domain);
-
- struct pci_device *pci_device;
- for_each_pci_func(pci_device, hardware->pci_domain) {
- hardware->nb_pci_devices++;
- }
-
- if (!quiet) {
- more_printf("PCI: %d devices detected\n", hardware->nb_pci_devices);
- more_printf("PCI: Resolving names\n");
- }
- /* Assigning product & vendor name for each device */
- hardware->pci_ids_return_code =
- get_name_from_pci_ids(hardware->pci_domain, hardware->pciids_path);
-
- if (!quiet)
- more_printf("PCI: Resolving class names\n");
- /* Assigning class name for each device */
- hardware->pci_ids_return_code =
- get_class_name_from_pci_ids(hardware->pci_domain,
- hardware->pciids_path);
-
- if (!quiet)
- more_printf("PCI: Resolving module names\n");
- /* Detecting which kernel module should match each device using modules.pcimap*/
- hardware->modules_pcimap_return_code =
- get_module_name_from_pcimap(hardware->pci_domain,
- hardware->modules_pcimap_path);
-
- /* Detecting which kernel module should match each device using modules.alias*/
- hardware->modules_alias_return_code =
- get_module_name_from_alias(hardware->pci_domain,
- hardware->modules_alias_path);
-
-
- /* We try to detect the pxe stuff to populate the PXE: field of pci devices */
- detect_pxe(hardware);
+ if (hardware->pci_detection == true)
+ return;
+ hardware->pci_detection = true;
+
+ hardware->nb_pci_devices = 0;
+
+ /* Scanning to detect pci buses and devices */
+ hardware->pci_domain = pci_scan();
+
+ if (!hardware->pci_domain)
+ return;
+
+ /* Gathering addtional information */
+ gather_additional_pci_config(hardware->pci_domain);
+
+ struct pci_device *pci_device;
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ hardware->nb_pci_devices++;
+ }
+
+ if (!quiet) {
+ more_printf("PCI: %d devices detected\n", hardware->nb_pci_devices);
+ more_printf("PCI: Resolving names\n");
+ }
+ /* Assigning product & vendor name for each device */
+ hardware->pci_ids_return_code =
+ get_name_from_pci_ids(hardware->pci_domain, hardware->pciids_path);
+
+ if (!quiet)
+ more_printf("PCI: Resolving class names\n");
+ /* Assigning class name for each device */
+ hardware->pci_ids_return_code =
+ get_class_name_from_pci_ids(hardware->pci_domain,
+ hardware->pciids_path);
+
+ if (!quiet)
+ more_printf("PCI: Resolving module names\n");
+ /* Detecting which kernel module should match each device using modules.pcimap */
+ hardware->modules_pcimap_return_code =
+ get_module_name_from_pcimap(hardware->pci_domain,
+ hardware->modules_pcimap_path);
+
+ /* Detecting which kernel module should match each device using modules.alias */
+ hardware->modules_alias_return_code =
+ get_module_name_from_alias(hardware->pci_domain,
+ hardware->modules_alias_path);
+
+ /* We try to detect the pxe stuff to populate the PXE: field of pci devices */
+ detect_pxe(hardware);
}
void cpu_detect(struct s_hardware *hardware)
{
- if (hardware->cpu_detection == true)
- return;
- detect_cpu(&hardware->cpu);
- /* Old processors doesn't manage the identify commands
- * Let's use the dmi value in that case */
- if (strlen(remove_spaces(hardware->cpu.model))==0)
- strncpy(hardware->cpu.model,hardware->dmi.processor.version,sizeof(hardware->cpu.model));
- hardware->cpu_detection = true;
+ if (hardware->cpu_detection == true)
+ return;
+ detect_cpu(&hardware->cpu);
+ /* Old processors doesn't manage the identify commands
+ * Let's use the dmi value in that case */
+ if (strlen(remove_spaces(hardware->cpu.model)) == 0)
+ strncpy(hardware->cpu.model, hardware->dmi.processor.version,
+ sizeof(hardware->cpu.model));
+ hardware->cpu_detection = true;
}
/*
@@ -547,120 +532,123 @@ void cpu_detect(struct s_hardware *hardware)
*/
const char *find_argument(const char **argv, const char *argument)
{
- int la = strlen(argument);
- const char **arg;
- const char *ptr = NULL;
+ int la = strlen(argument);
+ const char **arg;
+ const char *ptr = NULL;
- for (arg = argv; *arg; arg++) {
- if (!memcmp(*arg, argument, la))
- ptr = *arg + la;
- }
+ for (arg = argv; *arg; arg++) {
+ if (!memcmp(*arg, argument, la))
+ ptr = *arg + la;
+ }
- return ptr;
+ return ptr;
}
void clear_screen(void)
{
- move_cursor_to_next_line();
- disable_utf8();
- set_g1_special_char();
- set_us_g0_charset();
- display_cursor(false);
- clear_entire_screen();
- reset_more_printf();
+ move_cursor_to_next_line();
+ disable_utf8();
+ set_g1_special_char();
+ set_us_g0_charset();
+ display_cursor(false);
+ clear_entire_screen();
+ reset_more_printf();
}
/* remove begining spaces */
char *skip_spaces(char *p)
{
- while (*p && *p <= ' ') {
- p++;
- }
+ while (*p && *p <= ' ') {
+ p++;
+ }
- return p;
+ return p;
}
/* remove trailing & begining spaces */
char *remove_spaces(char *p)
{
- char *save=p;
- p+=strlen(p)-1;
- while (*p && *p <= ' ') {
- *p='\0';
- p--;
- }
- p=save;
- while (*p && *p <= ' ') {
- p++;
- }
-
- return p;
+ char *save = p;
+ p += strlen(p) - 1;
+ while (*p && *p <= ' ') {
+ *p = '\0';
+ p--;
+ }
+ p = save;
+ while (*p && *p <= ' ') {
+ p++;
+ }
+
+ return p;
}
/* remove trailing LF */
char *remove_trailing_lf(char *p)
{
- char *save=p;
- p+=strlen(p)-1;
- while (*p && *p == 10) {
- *p='\0';
- p--;
- }
- p=save;
-
- return p;
+ char *save = p;
+ p += strlen(p) - 1;
+ while (*p && *p == 10) {
+ *p = '\0';
+ p--;
+ }
+ p = save;
+
+ return p;
}
/* delete multiple spaces, one is enough */
-char *del_multi_spaces(char *p) {
- /* Saving the original pointer*/
- char *save=p;
-
- /* Let's parse the complete string
- * As we search for a double spacing
- * we have to be sure then string is
- * long enough to be processed */
- while (*p && *p+1) {
-
- /* If we have two consecutive spaces*/
- if ((*p == ' ') && (*(p+1) == ' ')) {
-
- /* Let's copy to the current position
- * the content from the second space*/
- strncpy(p,p+1,strlen(p+1));
-
- /* The string is 1 char smaller*/
- *(p+strlen(p)-1)='\0';
-
- /* Don't increment the pointer as we
- * changed the content of the current position*/
- continue;
- }
-
- /* Nothing as been found, let's see on the next char*/
- p++;
- }
- /* Returning the original pointer*/
- return save;
+char *del_multi_spaces(char *p)
+{
+ /* Saving the original pointer */
+ char *save = p;
+
+ /* Let's parse the complete string
+ * As we search for a double spacing
+ * we have to be sure then string is
+ * long enough to be processed */
+ while (*p && *p + 1) {
+
+ /* If we have two consecutive spaces */
+ if ((*p == ' ') && (*(p + 1) == ' ')) {
+
+ /* Let's copy to the current position
+ * the content from the second space*/
+ strncpy(p, p + 1, strlen(p + 1));
+
+ /* The string is 1 char smaller */
+ *(p + strlen(p) - 1) = '\0';
+
+ /* Don't increment the pointer as we
+ * changed the content of the current position*/
+ continue;
+ }
+
+ /* Nothing as been found, let's see on the next char */
+ p++;
+ }
+ /* Returning the original pointer */
+ return save;
}
/* Reset the more_printf counter */
-void reset_more_printf() {
- display_line_nb=0;
+void reset_more_printf()
+{
+ display_line_nb = 0;
}
int draw_background(const char *what)
{
if (!what)
- return vesacon_default_background();
+ return vesacon_default_background();
else
- return vesacon_load_background(what);
+ return vesacon_load_background(what);
}
-void init_console(struct s_hardware *hardware) {
- if (vesamode) {
+void init_console(struct s_hardware *hardware)
+{
+ if (vesamode) {
openconsole(&dev_rawcon_r, &dev_vesaserial_w);
draw_background(hardware->vesa_background);
- }
- else console_ansi_raw();
+ } else
+ console_ansi_raw();
}
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index fc24f638..6001df26 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -111,89 +111,89 @@ extern bool disable_more_printf;
/* Display CPU registers for debugging purposes */
static inline void printregs(const com32sys_t * r)
{
- printf("eflags = %08x ds = %04x es = %04x fs = %04x gs = %04x\n"
- "eax = %08x ebx = %08x ecx = %08x edx = %08x\n"
- "ebp = %08x esi = %08x edi = %08x esp = %08x\n",
- r->eflags.l, r->ds, r->es, r->fs, r->gs,
- r->eax.l, r->ebx.l, r->ecx.l, r->edx.l,
- r->ebp.l, r->esi.l, r->edi.l, r->_unused_esp.l);
+ printf("eflags = %08x ds = %04x es = %04x fs = %04x gs = %04x\n"
+ "eax = %08x ebx = %08x ecx = %08x edx = %08x\n"
+ "ebp = %08x esi = %08x edi = %08x esp = %08x\n",
+ r->eflags.l, r->ds, r->es, r->fs, r->gs,
+ r->eax.l, r->ebx.l, r->ecx.l, r->edx.l,
+ r->ebp.l, r->esi.l, r->edi.l, r->_unused_esp.l);
}
struct s_pxe {
- uint16_t vendor_id;
- uint16_t product_id;
- uint16_t subvendor_id;
- uint16_t subproduct_id;
- uint8_t rev;
- uint8_t pci_bus;
- uint8_t pci_dev;
- uint8_t pci_func;
- uint8_t base_class;
- uint8_t sub_class;
- uint8_t prog_intf;
- uint8_t nictype;
- char mac_addr[18]; /* The current mac address */
- uint8_t ip_addr[4];
- pxe_bootp_t dhcpdata; /* The dhcp answer */
- struct pci_device *pci_device; /* The matching pci device */
- uint8_t pci_device_pos; /* It position in our pci sorted list */
+ uint16_t vendor_id;
+ uint16_t product_id;
+ uint16_t subvendor_id;
+ uint16_t subproduct_id;
+ uint8_t rev;
+ uint8_t pci_bus;
+ uint8_t pci_dev;
+ uint8_t pci_func;
+ uint8_t base_class;
+ uint8_t sub_class;
+ uint8_t prog_intf;
+ uint8_t nictype;
+ char mac_addr[18]; /* The current mac address */
+ uint8_t ip_addr[4];
+ pxe_bootp_t dhcpdata; /* The dhcp answer */
+ struct pci_device *pci_device; /* The matching pci device */
+ uint8_t pci_device_pos; /* It position in our pci sorted list */
};
struct s_vesa_mode_info {
- struct vesa_mode_info mi;
- uint16_t mode;
+ struct vesa_mode_info mi;
+ uint16_t mode;
};
struct s_vesa {
- uint8_t major_version;
- uint8_t minor_version;
- struct s_vesa_mode_info vmi[MAX_VESA_MODES];
- uint8_t vmi_count;
- uint16_t total_memory;
- char vendor[256];
- char product[256];
- char product_revision[256];
- uint16_t software_rev;
+ uint8_t major_version;
+ uint8_t minor_version;
+ struct s_vesa_mode_info vmi[MAX_VESA_MODES];
+ uint8_t vmi_count;
+ uint16_t total_memory;
+ char vendor[256];
+ char product[256];
+ char product_revision[256];
+ uint16_t software_rev;
};
struct s_hardware {
- s_dmi dmi; /* DMI table */
- s_cpu cpu; /* CPU information */
- s_vpd vpd; /* VPD information */
- struct pci_domain *pci_domain; /* PCI Devices */
- struct driveinfo disk_info[256]; /* Disk Information */
- uint32_t mbr_ids[256]; /* MBR ids */
- int disks_count; /* Number of detected disks */
- struct s_pxe pxe;
- struct s_vesa vesa;
- unsigned long detected_memory_size; /* The detected memory size (in KB) */
-
- int pci_ids_return_code;
- int modules_pcimap_return_code;
- int modules_alias_return_code;
- int nb_pci_devices;
- bool is_dmi_valid;
- bool is_pxe_valid;
- bool is_vesa_valid;
- bool is_vpd_valid;
-
- bool dmi_detection; /* Does the dmi stuff has already been detected? */
- bool pci_detection; /* Does the pci stuff has already been detected? */
- bool cpu_detection; /* Does the cpu stuff has already been detected? */
- bool disk_detection;/* Does the disk stuff has already been detected? */
- bool pxe_detection; /* Does the pxe stuff has already been detected? */
- bool vesa_detection;/* Does the vesa sutff have been already detected? */
- bool vpd_detection; /* Does the vpd stuff has already been detected? */
-
- char syslinux_fs[22];
- const struct syslinux_version *sv;
- char modules_pcimap_path[255];
- char modules_alias_path[255];
- char pciids_path[255];
- char memtest_label[255];
- char reboot_label[255];
- char auto_label[AUTO_COMMAND_SIZE];
- char vesa_background[255];
+ s_dmi dmi; /* DMI table */
+ s_cpu cpu; /* CPU information */
+ s_vpd vpd; /* VPD information */
+ struct pci_domain *pci_domain; /* PCI Devices */
+ struct driveinfo disk_info[256]; /* Disk Information */
+ uint32_t mbr_ids[256]; /* MBR ids */
+ int disks_count; /* Number of detected disks */
+ struct s_pxe pxe;
+ struct s_vesa vesa;
+ unsigned long detected_memory_size; /* The detected memory size (in KB) */
+
+ int pci_ids_return_code;
+ int modules_pcimap_return_code;
+ int modules_alias_return_code;
+ int nb_pci_devices;
+ bool is_dmi_valid;
+ bool is_pxe_valid;
+ bool is_vesa_valid;
+ bool is_vpd_valid;
+
+ bool dmi_detection; /* Does the dmi stuff has already been detected? */
+ bool pci_detection; /* Does the pci stuff has already been detected? */
+ bool cpu_detection; /* Does the cpu stuff has already been detected? */
+ bool disk_detection; /* Does the disk stuff has already been detected? */
+ bool pxe_detection; /* Does the pxe stuff has already been detected? */
+ bool vesa_detection; /* Does the vesa sutff have been already detected? */
+ bool vpd_detection; /* Does the vpd stuff has already been detected? */
+
+ char syslinux_fs[22];
+ const struct syslinux_version *sv;
+ char modules_pcimap_path[255];
+ char modules_alias_path[255];
+ char pciids_path[255];
+ char memtest_label[255];
+ char reboot_label[255];
+ char auto_label[AUTO_COMMAND_SIZE];
+ char vesa_background[255];
};
void reset_more_printf();
@@ -212,7 +212,7 @@ void init_hardware(struct s_hardware *hardware);
void clear_screen(void);
void detect_syslinux(struct s_hardware *hardware);
void detect_parameters(const int argc, const char *argv[],
- struct s_hardware *hardware);
+ struct s_hardware *hardware);
int detect_vesa(struct s_hardware *hardware);
void init_console(struct s_hardware *hardware);
#endif
diff --git a/com32/hdt/hdt-menu-about.c b/com32/hdt/hdt-menu-about.c
index 53b58f21..19e5cb0d 100644
--- a/com32/hdt/hdt-menu-about.c
+++ b/com32/hdt/hdt-menu-about.c
@@ -31,46 +31,50 @@
/* Computing About menu*/
void compute_aboutmenu(struct s_my_menu *menu)
{
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
- menu->menu = add_menu(" About ", -1);
- menu->items_count = 0;
+ menu->menu = add_menu(" About ", -1);
+ menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
- snprintf(buffer, sizeof buffer, "Product : %s", PRODUCT_NAME);
- snprintf(statbuffer, sizeof statbuffer, "Product : %s", PRODUCT_NAME);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Product : %s", PRODUCT_NAME);
+ snprintf(statbuffer, sizeof statbuffer, "Product : %s", PRODUCT_NAME);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer, sizeof buffer, "Version : %s (%s)", VERSION, CODENAME);
- snprintf(statbuffer, sizeof statbuffer, "Version : %s (%s)", VERSION,CODENAME);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Version : %s (%s)", VERSION,
+ CODENAME);
+ snprintf(statbuffer, sizeof statbuffer, "Version : %s (%s)", VERSION,
+ CODENAME);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer, sizeof buffer, "Project Leader : %s", AUTHOR);
- snprintf(statbuffer, sizeof statbuffer, "Project Leader : %s", AUTHOR);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Project Leader : %s", AUTHOR);
+ snprintf(statbuffer, sizeof statbuffer, "Project Leader : %s", AUTHOR);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer, sizeof buffer, "Contact : %s", CONTACT);
- snprintf(statbuffer, sizeof statbuffer, "Contact : %s", CONTACT);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Contact : %s", CONTACT);
+ snprintf(statbuffer, sizeof statbuffer, "Contact : %s", CONTACT);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer, sizeof buffer, "Core Developer : %s", CORE_DEVELOPER);
- snprintf(statbuffer, sizeof statbuffer, "Core Developer : %s", CORE_DEVELOPER);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Core Developer : %s", CORE_DEVELOPER);
+ snprintf(statbuffer, sizeof statbuffer, "Core Developer : %s",
+ CORE_DEVELOPER);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS;
- for (int c=0; c<NB_CONTRIBUTORS; c++) {
- snprintf(buffer, sizeof buffer, "Contributor : %s", contributors[c]);
- snprintf(statbuffer, sizeof statbuffer, "Contributor : %s", contributors[c]);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
+ char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS;
+ for (int c = 0; c < NB_CONTRIBUTORS; c++) {
+ snprintf(buffer, sizeof buffer, "Contributor : %s", contributors[c]);
+ snprintf(statbuffer, sizeof statbuffer, "Contributor : %s",
+ contributors[c]);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
- printf("MENU: About menu done (%d items)\n", menu->items_count);
+ printf("MENU: About menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu-disk.c b/com32/hdt/hdt-menu-disk.c
index 2f3571b9..17be236a 100644
--- a/com32/hdt/hdt-menu-disk.c
+++ b/com32/hdt/hdt-menu-disk.c
@@ -34,25 +34,27 @@
static int dn;
static void show_partition_information(struct driveinfo *drive_info,
- struct part_entry *ptab __unused,
- int partition_offset __unused,
- int nb_partitions_seen)
+ struct part_entry *ptab __unused,
+ int partition_offset __unused,
+ int nb_partitions_seen)
{
- char menu_title[MENULEN + 1];
- char menu_title_ref[MENULEN + 1];
+ char menu_title[MENULEN + 1];
+ char menu_title_ref[MENULEN + 1];
- if (nb_partitions_seen == 1)
- add_sep();
+ if (nb_partitions_seen == 1)
+ add_sep();
- memset(menu_title,0,sizeof menu_title);
- memset(menu_title_ref,0,sizeof menu_title_ref);
- snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d",
- drive_info[dn].disk, nb_partitions_seen);
- snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen);
+ memset(menu_title, 0, sizeof menu_title);
+ memset(menu_title_ref, 0, sizeof menu_title_ref);
+ snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d",
+ drive_info[dn].disk, nb_partitions_seen);
+ snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen);
- add_item(menu_title, "Partition information (start, end, length, type, ...)",
- OPT_SUBMENU, menu_title_ref, 0);
+ add_item(menu_title,
+ "Partition information (start, end, length, type, ...)",
+ OPT_SUBMENU, menu_title_ref, 0);
}
+
/**
* compute_partition_information - print information about a partition
* @ptab: part_entry describing the partition
@@ -69,197 +71,187 @@ static void show_partition_information(struct driveinfo *drive_info,
* at the MBR... but still not absolute!
**/
static void compute_partition_information(struct driveinfo *drive_info,
- struct part_entry *ptab,
- int partition_offset,
- int nb_partitions_seen)
+ struct part_entry *ptab,
+ int partition_offset,
+ int nb_partitions_seen)
{
- char size[9];
- char bootloader_name[9];
- char *parttype;
- unsigned int start, end;
- char buffer[SUBMENULEN+1];
- char statbuffer[STATLEN+1];
- char menu_title[MENULEN + 1];
- char menu_title_ref[MENULEN + 1];
-
- memset(buffer,0,sizeof buffer);
- memset(statbuffer,0,sizeof statbuffer);
- memset(menu_title,0,sizeof menu_title);
- memset(menu_title_ref,0,sizeof menu_title_ref);
- snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d", drive_info[dn].disk, nb_partitions_seen);
- snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen);
-
- add_named_menu(menu_title_ref,menu_title,-1);
- set_menu_pos(SUBMENU_Y,SUBMENU_X);
-
- start = partition_offset;
- end = start + ptab->length - 1;
-
- if (ptab->length > 0)
- sectors_to_size(ptab->length, size);
- else
- memset(size, 0, sizeof size);
-
- get_label(ptab->ostype, &parttype);
-
- snprintf(buffer, sizeof buffer, "Size : %s",
- remove_spaces(size));
- snprintf(statbuffer, sizeof statbuffer, "Size : %s",
- remove_spaces(size));
+ char size[9];
+ char bootloader_name[9];
+ char *parttype;
+ unsigned int start, end;
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+ char menu_title[MENULEN + 1];
+ char menu_title_ref[MENULEN + 1];
+
+ memset(buffer, 0, sizeof buffer);
+ memset(statbuffer, 0, sizeof statbuffer);
+ memset(menu_title, 0, sizeof menu_title);
+ memset(menu_title_ref, 0, sizeof menu_title_ref);
+ snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d",
+ drive_info[dn].disk, nb_partitions_seen);
+ snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen);
+
+ add_named_menu(menu_title_ref, menu_title, -1);
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ start = partition_offset;
+ end = start + ptab->length - 1;
+
+ if (ptab->length > 0)
+ sectors_to_size(ptab->length, size);
+ else
+ memset(size, 0, sizeof size);
+
+ get_label(ptab->ostype, &parttype);
+
+ snprintf(buffer, sizeof buffer, "Size : %s", remove_spaces(size));
+ snprintf(statbuffer, sizeof statbuffer, "Size : %s", remove_spaces(size));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ snprintf(buffer, sizeof buffer, "Type : %s", parttype);
+ snprintf(statbuffer, sizeof statbuffer, "Type: %s", parttype);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0) {
+ snprintf(buffer, sizeof buffer, "Bootloader : %s", bootloader_name);
+ snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s",
+ bootloader_name);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ }
- snprintf(buffer, sizeof buffer, "Type : %s",
- parttype);
- snprintf(statbuffer, sizeof statbuffer, "Type: %s",
- parttype);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ snprintf(buffer, sizeof buffer, "Bootable : %s",
+ (ptab->active_flag == 0x80) ? "Yes" : "No");
+ snprintf(statbuffer, sizeof statbuffer, "Bootable: %s",
+ (ptab->active_flag == 0x80) ? "Yes" : "No");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0) {
- snprintf(buffer, sizeof buffer, "Bootloader : %s",
- bootloader_name);
- snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s",
- bootloader_name);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- }
-
- snprintf(buffer, sizeof buffer, "Bootable : %s",
- (ptab->active_flag == 0x80) ? "Yes" : "No");
- snprintf(statbuffer, sizeof statbuffer, "Bootable: %s",
- (ptab->active_flag == 0x80) ? "Yes" : "No");
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ snprintf(buffer, sizeof buffer, "Start : %d", start);
+ snprintf(statbuffer, sizeof statbuffer, "Start: %d", start);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- snprintf(buffer, sizeof buffer, "Start : %d",
- start);
- snprintf(statbuffer, sizeof statbuffer, "Start: %d",
- start);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ snprintf(buffer, sizeof buffer, "End : %d", end);
+ snprintf(statbuffer, sizeof statbuffer, "End: %d", end);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- snprintf(buffer, sizeof buffer, "End : %d",
- end);
- snprintf(statbuffer, sizeof statbuffer, "End: %d",
- end);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
-
- snprintf(buffer, sizeof buffer, "Id : %X",
- ptab->ostype);
- snprintf(statbuffer, sizeof statbuffer, "Id: %X",
- ptab->ostype);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ snprintf(buffer, sizeof buffer, "Id : %X", ptab->ostype);
+ snprintf(statbuffer, sizeof statbuffer, "Id: %X", ptab->ostype);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ free(parttype);
- free(parttype);
-
- /* Extra info */
- if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab) != -1) {
- snprintf(buffer, sizeof buffer, "%s","Swsusp sig : detected");
- snprintf(statbuffer, sizeof statbuffer, "%s","Swsusp sig : detected");
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- }
+ /* Extra info */
+ if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab) != -1) {
+ snprintf(buffer, sizeof buffer, "%s", "Swsusp sig : detected");
+ snprintf(statbuffer, sizeof statbuffer, "%s", "Swsusp sig : detected");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ }
}
/* Compute the disk submenu */
static int compute_disk_module(struct s_my_menu *menu, int nb_sub_disk_menu,
- const struct s_hardware *hardware, int disk_number)
+ const struct s_hardware *hardware,
+ int disk_number)
{
- char buffer[MENULEN + 1];
- char statbuffer[STATLEN + 1];
- char mbr_name[50];
- struct driveinfo *d = (struct driveinfo*) hardware->disk_info;
-
- snprintf(buffer, sizeof buffer, " Disk <0x%X> (EDD %X)", d[disk_number].disk,
- d[disk_number].edd_version);
- menu[nb_sub_disk_menu].menu = add_menu(buffer, -1);
- menu[nb_sub_disk_menu].items_count = 0;
-
- int previous_size, size;
- char previous_unit[3], unit[3]; // GB
- char size_iec[9]; // GiB
- sectors_to_size_dec(previous_unit, &previous_size, unit, &size, d[disk_number].edd_params.sectors);
- sectors_to_size(d[disk_number].edd_params.sectors, size_iec);
-
- snprintf(buffer, sizeof buffer, "Size : %s/%d %s (%d %s)", remove_spaces(size_iec),
- size, unit, previous_size, previous_unit);
- snprintf(statbuffer, sizeof statbuffer, "Size: %s/%d %s (%d %s)", remove_spaces(size_iec), size,
- unit, previous_size, previous_unit);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu[nb_sub_disk_menu].items_count++;
-
- snprintf(buffer, sizeof buffer, "Host Bus / Interface : %s / %s",
- remove_spaces((char *) d[disk_number].edd_params.host_bus_type),
- d[disk_number].edd_params.interface_type);
- snprintf(statbuffer, sizeof statbuffer, "Host Bus / Interface: %s / %s",
- remove_spaces((char *) d[disk_number].edd_params.host_bus_type),
- d[disk_number].edd_params.interface_type);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu[nb_sub_disk_menu].items_count++;
-
- snprintf(buffer, sizeof buffer, "C / H / S : %d / %d / %d",
- d[disk_number].legacy_max_cylinder + 1,
- d[disk_number].legacy_max_head + 1,
- (int) d[disk_number].edd_params.sectors);
- snprintf(statbuffer, sizeof statbuffer, "Cylinders / Heads / Sectors: %d / %d / %d",
- d[disk_number].legacy_max_cylinder + 1,
- d[disk_number].legacy_max_head + 1,
- (int) d[disk_number].edd_params.sectors);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu[nb_sub_disk_menu].items_count++;
-
- snprintf(buffer, sizeof buffer, "Sectors/Track : %d",
- d[disk_number].legacy_sectors_per_track);
- snprintf(statbuffer, sizeof statbuffer, "Sectors per Track: %d",
- d[disk_number].legacy_sectors_per_track);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu[nb_sub_disk_menu].items_count++;
-
- get_mbr_string(hardware->mbr_ids[disk_number], &mbr_name, 50);
-
- snprintf(buffer, sizeof buffer, "MBR : %s (0x%X)",
- remove_spaces(mbr_name),
- hardware->mbr_ids[disk_number]);
- snprintf(statbuffer, sizeof statbuffer, "MBR: %s (id 0x%X)",
- remove_spaces(mbr_name),
- hardware->mbr_ids[disk_number]);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu[nb_sub_disk_menu].items_count++;
-
- dn=disk_number;
-
- parse_partition_table(&d[disk_number], &show_partition_information);
- if (!parse_partition_table(&d[disk_number], &compute_partition_information)) {
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+ char mbr_name[50];
+ struct driveinfo *d = (struct driveinfo *)hardware->disk_info;
+
+ snprintf(buffer, sizeof buffer, " Disk <0x%X> (EDD %X)",
+ d[disk_number].disk, d[disk_number].edd_version);
+ menu[nb_sub_disk_menu].menu = add_menu(buffer, -1);
+ menu[nb_sub_disk_menu].items_count = 0;
+
+ int previous_size, size;
+ char previous_unit[3], unit[3]; // GB
+ char size_iec[9]; // GiB
+ sectors_to_size_dec(previous_unit, &previous_size, unit, &size,
+ d[disk_number].edd_params.sectors);
+ sectors_to_size(d[disk_number].edd_params.sectors, size_iec);
+
+ snprintf(buffer, sizeof buffer, "Size : %s/%d %s (%d %s)",
+ remove_spaces(size_iec), size, unit, previous_size, previous_unit);
+ snprintf(statbuffer, sizeof statbuffer, "Size: %s/%d %s (%d %s)",
+ remove_spaces(size_iec), size, unit, previous_size, previous_unit);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu[nb_sub_disk_menu].items_count++;
+
+ snprintf(buffer, sizeof buffer, "Host Bus / Interface : %s / %s",
+ remove_spaces((char *)d[disk_number].edd_params.host_bus_type),
+ d[disk_number].edd_params.interface_type);
+ snprintf(statbuffer, sizeof statbuffer, "Host Bus / Interface: %s / %s",
+ remove_spaces((char *)d[disk_number].edd_params.host_bus_type),
+ d[disk_number].edd_params.interface_type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu[nb_sub_disk_menu].items_count++;
+
+ snprintf(buffer, sizeof buffer, "C / H / S : %d / %d / %d",
+ d[disk_number].legacy_max_cylinder + 1,
+ d[disk_number].legacy_max_head + 1,
+ (int)d[disk_number].edd_params.sectors);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Cylinders / Heads / Sectors: %d / %d / %d",
+ d[disk_number].legacy_max_cylinder + 1,
+ d[disk_number].legacy_max_head + 1,
+ (int)d[disk_number].edd_params.sectors);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu[nb_sub_disk_menu].items_count++;
+
+ snprintf(buffer, sizeof buffer, "Sectors/Track : %d",
+ d[disk_number].legacy_sectors_per_track);
+ snprintf(statbuffer, sizeof statbuffer, "Sectors per Track: %d",
+ d[disk_number].legacy_sectors_per_track);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu[nb_sub_disk_menu].items_count++;
+
+ get_mbr_string(hardware->mbr_ids[disk_number], &mbr_name, 50);
+
+ snprintf(buffer, sizeof buffer, "MBR : %s (0x%X)",
+ remove_spaces(mbr_name), hardware->mbr_ids[disk_number]);
+ snprintf(statbuffer, sizeof statbuffer, "MBR: %s (id 0x%X)",
+ remove_spaces(mbr_name), hardware->mbr_ids[disk_number]);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu[nb_sub_disk_menu].items_count++;
+
+ dn = disk_number;
+
+ parse_partition_table(&d[disk_number], &show_partition_information);
+ if (!parse_partition_table(&d[disk_number], &compute_partition_information)) {
get_error("parse_partition_table");
menu[nb_sub_disk_menu].items_count++;
- }
+ }
- return 0;
+ return 0;
}
/* Compute the Disks menu */
void compute_disks(struct s_hdt_menu *menu, struct s_hardware *hardware)
{
- char buffer[MENULEN + 1];
- int nb_sub_disk_menu = 0;
-
- /* No need to compute that menu if no disks were detected */
- menu->disk_menu.items_count = 0;
- if (hardware->disks_count == 0) return;
-
- for (int i = 0; i < hardware->disks_count; i++) {
- if (!hardware->disk_info[i].cbios)
- continue; /* Invalid geometry */
- compute_disk_module
- ((struct s_my_menu*) &(menu->disk_sub_menu), nb_sub_disk_menu,
- hardware, i);
- nb_sub_disk_menu++;
- }
-
- menu->disk_menu.menu = add_menu(" Disks ", -1);
-
- for (int i = 0; i < nb_sub_disk_menu; i++) {
- snprintf(buffer, sizeof buffer, " Disk <%d> ", i+1);
- add_item(buffer, "Disk", OPT_SUBMENU, NULL,
- menu->disk_sub_menu[i].menu);
- menu->disk_menu.items_count++;
- }
- printf("MENU: Disks menu done (%d items)\n",
- menu->disk_menu.items_count);
+ char buffer[MENULEN + 1];
+ int nb_sub_disk_menu = 0;
+
+ /* No need to compute that menu if no disks were detected */
+ menu->disk_menu.items_count = 0;
+ if (hardware->disks_count == 0)
+ return;
+
+ for (int i = 0; i < hardware->disks_count; i++) {
+ if (!hardware->disk_info[i].cbios)
+ continue; /* Invalid geometry */
+ compute_disk_module
+ ((struct s_my_menu *)&(menu->disk_sub_menu), nb_sub_disk_menu,
+ hardware, i);
+ nb_sub_disk_menu++;
+ }
+
+ menu->disk_menu.menu = add_menu(" Disks ", -1);
+
+ for (int i = 0; i < nb_sub_disk_menu; i++) {
+ snprintf(buffer, sizeof buffer, " Disk <%d> ", i + 1);
+ add_item(buffer, "Disk", OPT_SUBMENU, NULL,
+ menu->disk_sub_menu[i].menu);
+ menu->disk_menu.items_count++;
+ }
+ printf("MENU: Disks menu done (%d items)\n", menu->disk_menu.items_count);
}
diff --git a/com32/hdt/hdt-menu-dmi.c b/com32/hdt/hdt-menu-dmi.c
index 77ee90e5..7a413a15 100644
--- a/com32/hdt/hdt-menu-dmi.c
+++ b/com32/hdt/hdt-menu-dmi.c
@@ -31,369 +31,351 @@
/* Compute System main menu */
void compute_system(struct s_my_menu *menu, s_dmi * dmi)
{
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- menu->menu = add_menu(" System ", -1);
- menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
-
- snprintf(buffer, sizeof buffer, "Vendor : %s",
- dmi->system.manufacturer);
- snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
- dmi->system.manufacturer);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Product : %s",
- dmi->system.product_name);
- snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
- dmi->system.product_name);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Version : %s", dmi->system.version);
- snprintf(statbuffer, sizeof statbuffer, "Version: %s",
- dmi->system.version);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Serial : %s", dmi->system.serial);
- snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
- dmi->system.serial);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "UUID : %s", dmi->system.uuid);
- snprintf(statbuffer, sizeof statbuffer, "UUID: %s", dmi->system.uuid);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Wakeup : %s",
- dmi->system.wakeup_type);
- snprintf(statbuffer, sizeof statbuffer, "Wakeup Type: %s",
- dmi->system.wakeup_type);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "SKU Number: %s",
- dmi->system.sku_number);
- snprintf(statbuffer, sizeof statbuffer, "SKU Number: %s",
- dmi->system.sku_number);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Family : %s", dmi->system.family);
- snprintf(statbuffer, sizeof statbuffer, "Family: %s",
- dmi->system.family);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- printf("MENU: System menu done (%d items)\n", menu->items_count);
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ menu->menu = add_menu(" System ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s", dmi->system.manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
+ dmi->system.manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Product : %s", dmi->system.product_name);
+ snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
+ dmi->system.product_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Version : %s", dmi->system.version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s", dmi->system.version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Serial : %s", dmi->system.serial);
+ snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
+ dmi->system.serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "UUID : %s", dmi->system.uuid);
+ snprintf(statbuffer, sizeof statbuffer, "UUID: %s", dmi->system.uuid);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Wakeup : %s", dmi->system.wakeup_type);
+ snprintf(statbuffer, sizeof statbuffer, "Wakeup Type: %s",
+ dmi->system.wakeup_type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "SKU Number: %s", dmi->system.sku_number);
+ snprintf(statbuffer, sizeof statbuffer, "SKU Number: %s",
+ dmi->system.sku_number);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Family : %s", dmi->system.family);
+ snprintf(statbuffer, sizeof statbuffer, "Family: %s", dmi->system.family);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: System menu done (%d items)\n", menu->items_count);
}
/* Compute Chassis menu */
void compute_chassis(struct s_my_menu *menu, s_dmi * dmi)
{
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
- menu->menu = add_menu(" Chassis ", -1);
- menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
-
- snprintf(buffer, sizeof buffer, "Vendor : %s",
- dmi->chassis.manufacturer);
- snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
- dmi->chassis.manufacturer);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Type : %s", dmi->chassis.type);
- snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->chassis.type);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Version : %s", dmi->chassis.version);
- snprintf(statbuffer, sizeof statbuffer, "Version: %s",
- dmi->chassis.version);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Serial : %s", dmi->chassis.serial);
- snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
- dmi->chassis.serial);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Asset Tag : %s",
- del_multi_spaces(dmi->chassis.asset_tag));
- snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
- del_multi_spaces(dmi->chassis.asset_tag));
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Lock : %s", dmi->chassis.lock);
- snprintf(statbuffer, sizeof statbuffer, "Lock: %s", dmi->chassis.lock);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- printf("MENU: Chassis menu done (%d items)\n", menu->items_count);
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+ menu->menu = add_menu(" Chassis ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s",
+ dmi->chassis.manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
+ dmi->chassis.manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type : %s", dmi->chassis.type);
+ snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->chassis.type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Version : %s", dmi->chassis.version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s",
+ dmi->chassis.version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Serial : %s", dmi->chassis.serial);
+ snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
+ dmi->chassis.serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Asset Tag : %s",
+ del_multi_spaces(dmi->chassis.asset_tag));
+ snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
+ del_multi_spaces(dmi->chassis.asset_tag));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Lock : %s", dmi->chassis.lock);
+ snprintf(statbuffer, sizeof statbuffer, "Lock: %s", dmi->chassis.lock);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: Chassis menu done (%d items)\n", menu->items_count);
}
/* Compute BIOS menu */
void compute_bios(struct s_my_menu *menu, s_dmi * dmi)
{
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- menu->menu = add_menu(" BIOS ", -1);
- menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
-
- snprintf(buffer, sizeof buffer, "Vendor : %s", dmi->bios.vendor);
- snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", dmi->bios.vendor);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Version : %s", dmi->bios.version);
- snprintf(statbuffer, sizeof statbuffer, "Version: %s",
- dmi->bios.version);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Release : %s",
- dmi->bios.release_date);
- snprintf(statbuffer, sizeof statbuffer, "Release Date: %s",
- dmi->bios.release_date);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Bios Rev. : %s",
- dmi->bios.bios_revision);
- snprintf(statbuffer, sizeof statbuffer, "Bios Revision: %s",
- dmi->bios.bios_revision);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Fw. Rev. : %s",
- dmi->bios.firmware_revision);
- snprintf(statbuffer, sizeof statbuffer, "Firmware Revision : %s",
- dmi->bios.firmware_revision);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
-
- printf("MENU: BIOS menu done (%d items)\n", menu->items_count);
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ menu->menu = add_menu(" BIOS ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s", dmi->bios.vendor);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", dmi->bios.vendor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Version : %s", dmi->bios.version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s", dmi->bios.version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Release : %s", dmi->bios.release_date);
+ snprintf(statbuffer, sizeof statbuffer, "Release Date: %s",
+ dmi->bios.release_date);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Bios Rev. : %s", dmi->bios.bios_revision);
+ snprintf(statbuffer, sizeof statbuffer, "Bios Revision: %s",
+ dmi->bios.bios_revision);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Fw. Rev. : %s",
+ dmi->bios.firmware_revision);
+ snprintf(statbuffer, sizeof statbuffer, "Firmware Revision : %s",
+ dmi->bios.firmware_revision);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ printf("MENU: BIOS menu done (%d items)\n", menu->items_count);
}
/* Compute Motherboard main menu */
void compute_motherboard(struct s_my_menu *menu, s_dmi * dmi)
{
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- menu->menu = add_menu(" Motherboard ", -1);
- menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
-
- snprintf(buffer, sizeof buffer, "Vendor : %s",
- dmi->base_board.manufacturer);
- snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
- dmi->base_board.manufacturer);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Product : %s",
- dmi->base_board.product_name);
- snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
- dmi->base_board.product_name);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Version : %s",
- dmi->base_board.version);
- snprintf(statbuffer, sizeof statbuffer, "Version: %s",
- dmi->base_board.version);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Serial : %s",
- dmi->base_board.serial);
- snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
- dmi->base_board.serial);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Asset Tag : %s",
- dmi->base_board.asset_tag);
- snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
- dmi->base_board.asset_tag);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Location : %s",
- dmi->base_board.location);
- snprintf(statbuffer, sizeof statbuffer, "Location: %s",
- dmi->base_board.location);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Type : %s", dmi->base_board.type);
- snprintf(statbuffer, sizeof statbuffer, "Type: %s",
- dmi->base_board.type);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- printf("MENU: Motherboard menu done (%d items)\n", menu->items_count);
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ menu->menu = add_menu(" Motherboard ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s",
+ dmi->base_board.manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
+ dmi->base_board.manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Product : %s",
+ dmi->base_board.product_name);
+ snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
+ dmi->base_board.product_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Version : %s", dmi->base_board.version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s",
+ dmi->base_board.version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Serial : %s", dmi->base_board.serial);
+ snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
+ dmi->base_board.serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Asset Tag : %s",
+ dmi->base_board.asset_tag);
+ snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
+ dmi->base_board.asset_tag);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Location : %s", dmi->base_board.location);
+ snprintf(statbuffer, sizeof statbuffer, "Location: %s",
+ dmi->base_board.location);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type : %s", dmi->base_board.type);
+ snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->base_board.type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: Motherboard menu done (%d items)\n", menu->items_count);
}
/* Compute Main IPMI menu */
void compute_ipmi(struct s_my_menu *menu, s_dmi * dmi)
{
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
- menu->menu = add_menu(" IPMI ", -1);
- menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
-
- snprintf(buffer, sizeof buffer, "Interface Type : %s",
- dmi->ipmi.interface_type);
- snprintf(statbuffer, sizeof statbuffer, "Interface Type: %s",
- dmi->ipmi.interface_type);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Spec. Version : %u.%u",
- dmi->ipmi.major_specification_version,
- dmi->ipmi.minor_specification_version);
- snprintf(statbuffer, sizeof statbuffer, "Specification Version: %u.%u",
- dmi->ipmi.major_specification_version,
- dmi->ipmi.minor_specification_version);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "I2C Slave @ : 0x%02x",
- dmi->ipmi.I2C_slave_address);
- snprintf(statbuffer, sizeof statbuffer, "I2C Slave Address: 0x%02x",
- dmi->ipmi.I2C_slave_address);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "NV Storage @ : %u",
- dmi->ipmi.nv_address);
- snprintf(statbuffer, sizeof statbuffer, "NV Storage Address: %u",
- dmi->ipmi.nv_address);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- uint32_t high = dmi->ipmi.base_address >> 32;
- uint32_t low = dmi->ipmi.base_address & 0xFFFF;
-
- snprintf(buffer, sizeof buffer, "Base Address : %08X%08X",
- high,(low & ~1));
- snprintf(statbuffer, sizeof statbuffer, "Base Address : %08X%08X",
- high,(low & ~1));
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "IRQ : %d",
- dmi->ipmi.irq);
- snprintf(statbuffer, sizeof statbuffer, "IRQ : %d",
- dmi->ipmi.irq);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- printf("MENU: IPMI menu done (%d items)\n", menu->items_count);
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+ menu->menu = add_menu(" IPMI ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Interface Type : %s",
+ dmi->ipmi.interface_type);
+ snprintf(statbuffer, sizeof statbuffer, "Interface Type: %s",
+ dmi->ipmi.interface_type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Spec. Version : %u.%u",
+ dmi->ipmi.major_specification_version,
+ dmi->ipmi.minor_specification_version);
+ snprintf(statbuffer, sizeof statbuffer, "Specification Version: %u.%u",
+ dmi->ipmi.major_specification_version,
+ dmi->ipmi.minor_specification_version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "I2C Slave @ : 0x%02x",
+ dmi->ipmi.I2C_slave_address);
+ snprintf(statbuffer, sizeof statbuffer, "I2C Slave Address: 0x%02x",
+ dmi->ipmi.I2C_slave_address);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "NV Storage @ : %u",
+ dmi->ipmi.nv_address);
+ snprintf(statbuffer, sizeof statbuffer, "NV Storage Address: %u",
+ dmi->ipmi.nv_address);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ uint32_t high = dmi->ipmi.base_address >> 32;
+ uint32_t low = dmi->ipmi.base_address & 0xFFFF;
+
+ snprintf(buffer, sizeof buffer, "Base Address : %08X%08X",
+ high, (low & ~1));
+ snprintf(statbuffer, sizeof statbuffer, "Base Address : %08X%08X",
+ high, (low & ~1));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "IRQ : %d", dmi->ipmi.irq);
+ snprintf(statbuffer, sizeof statbuffer, "IRQ : %d", dmi->ipmi.irq);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: IPMI menu done (%d items)\n", menu->items_count);
}
/* Compute Main Battery menu */
void compute_battery(struct s_my_menu *menu, s_dmi * dmi)
{
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
- menu->menu = add_menu(" Battery ", -1);
- menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
-
- snprintf(buffer, sizeof buffer, "Vendor : %s",
- dmi->battery.manufacturer);
- snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
- dmi->battery.manufacturer);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Manufacture Date: %s",
- dmi->battery.manufacture_date);
- snprintf(statbuffer, sizeof statbuffer, "Manufacture Date: %s",
- dmi->battery.manufacture_date);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Serial : %s",
- dmi->battery.serial);
- snprintf(statbuffer, sizeof statbuffer, "Serial: %s",
- dmi->battery.serial);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Name : %s",
- dmi->battery.name);
- snprintf(statbuffer, sizeof statbuffer, "Name: %s", dmi->battery.name);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Chemistry : %s",
- dmi->battery.chemistry);
- snprintf(statbuffer, sizeof statbuffer, "Chemistry: %s",
- dmi->battery.chemistry);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Design Capacity : %s",
- dmi->battery.design_capacity);
- snprintf(statbuffer, sizeof statbuffer, "Design Capacity: %s",
- dmi->battery.design_capacity);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Design Voltage : %s",
- dmi->battery.design_voltage);
- snprintf(statbuffer, sizeof statbuffer, "Design Voltage : %s",
- dmi->battery.design_voltage);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "SBDS : %s",
- dmi->battery.sbds);
- snprintf(statbuffer, sizeof statbuffer, "SBDS: %s", dmi->battery.sbds);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "SBDS Manuf. Date: %s",
- dmi->battery.sbds_manufacture_date);
- snprintf(statbuffer, sizeof statbuffer, "SBDS Manufacture Date: %s",
- dmi->battery.sbds_manufacture_date);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "SBDS Chemistry : %s",
- dmi->battery.sbds_chemistry);
- snprintf(statbuffer, sizeof statbuffer, "SBDS Chemistry : %s",
- dmi->battery.sbds_chemistry);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Maximum Error : %s",
- dmi->battery.maximum_error);
- snprintf(statbuffer, sizeof statbuffer, "Maximum Error (percent) : %s",
- dmi->battery.maximum_error);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "OEM Info : %s",
- dmi->battery.oem_info);
- snprintf(statbuffer, sizeof statbuffer, "OEM Info: %s",
- dmi->battery.oem_info);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- printf("MENU: Battery menu done (%d items)\n", menu->items_count);
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+ menu->menu = add_menu(" Battery ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s",
+ dmi->battery.manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
+ dmi->battery.manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Manufacture Date: %s",
+ dmi->battery.manufacture_date);
+ snprintf(statbuffer, sizeof statbuffer, "Manufacture Date: %s",
+ dmi->battery.manufacture_date);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Serial : %s",
+ dmi->battery.serial);
+ snprintf(statbuffer, sizeof statbuffer, "Serial: %s", dmi->battery.serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Name : %s", dmi->battery.name);
+ snprintf(statbuffer, sizeof statbuffer, "Name: %s", dmi->battery.name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Chemistry : %s",
+ dmi->battery.chemistry);
+ snprintf(statbuffer, sizeof statbuffer, "Chemistry: %s",
+ dmi->battery.chemistry);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Design Capacity : %s",
+ dmi->battery.design_capacity);
+ snprintf(statbuffer, sizeof statbuffer, "Design Capacity: %s",
+ dmi->battery.design_capacity);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Design Voltage : %s",
+ dmi->battery.design_voltage);
+ snprintf(statbuffer, sizeof statbuffer, "Design Voltage : %s",
+ dmi->battery.design_voltage);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "SBDS : %s", dmi->battery.sbds);
+ snprintf(statbuffer, sizeof statbuffer, "SBDS: %s", dmi->battery.sbds);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "SBDS Manuf. Date: %s",
+ dmi->battery.sbds_manufacture_date);
+ snprintf(statbuffer, sizeof statbuffer, "SBDS Manufacture Date: %s",
+ dmi->battery.sbds_manufacture_date);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "SBDS Chemistry : %s",
+ dmi->battery.sbds_chemistry);
+ snprintf(statbuffer, sizeof statbuffer, "SBDS Chemistry : %s",
+ dmi->battery.sbds_chemistry);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Maximum Error : %s",
+ dmi->battery.maximum_error);
+ snprintf(statbuffer, sizeof statbuffer, "Maximum Error (percent) : %s",
+ dmi->battery.maximum_error);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "OEM Info : %s",
+ dmi->battery.oem_info);
+ snprintf(statbuffer, sizeof statbuffer, "OEM Info: %s",
+ dmi->battery.oem_info);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: Battery menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu-kernel.c b/com32/hdt/hdt-menu-kernel.c
index 81b44dbf..98e52091 100644
--- a/com32/hdt/hdt-menu-kernel.c
+++ b/com32/hdt/hdt-menu-kernel.c
@@ -31,62 +31,57 @@
/* Main Kernel menu */
void compute_kernel(struct s_my_menu *menu, struct s_hardware *hardware)
{
- char buffer[SUBMENULEN + 1];
- char infobar[STATLEN + 1];
- char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
- MAX_KERNEL_MODULES_PER_PCI_DEVICE];
- struct pci_device *pci_device;
+ char buffer[SUBMENULEN + 1];
+ char infobar[STATLEN + 1];
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+ struct pci_device *pci_device;
- menu->menu = add_menu(" Kernel Modules ", -1);
- menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
+ menu->menu = add_menu(" Kernel Modules ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
- if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) &&
- (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
- add_item("The modules.{pcimap|alias} file is missing",
- "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
- add_item("Kernel modules can't be computed.",
- "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
- add_item("Please put one of them in same dir as hdt",
- "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
- add_item("", "", OPT_SEP, "", 0);
- } else {
- /*
- * For every detected pci device, grab its kernel module to
- * compute this submenu
- */
- for_each_pci_func(pci_device, hardware->pci_domain) {
- memset(kernel_modules, 0, sizeof kernel_modules);
- for (int i = 0;
- i <
- pci_device->dev_info->linux_kernel_module_count;
- i++) {
- if (i > 0) {
- strncat(kernel_modules, " | ", 3);
- }
- strncat(kernel_modules,
- pci_device->dev_info->
- linux_kernel_module[i],
- LINUX_KERNEL_MODULE_SIZE - 1);
- }
- /* No need to add unknown kernel modules */
- if (strlen(kernel_modules) > 0) {
- snprintf(buffer, sizeof buffer, "%s (%s)",
- kernel_modules,
- pci_device->dev_info->class_name);
- snprintf(infobar, sizeof infobar,
- "%04x:%04x %s : %s",
- pci_device->vendor,
- pci_device->product,
- pci_device->dev_info->vendor_name,
- pci_device->dev_info->product_name);
+ if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) &&
+ (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
+ add_item("The modules.{pcimap|alias} file is missing",
+ "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
+ add_item("Kernel modules can't be computed.",
+ "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
+ add_item("Please put one of them in same dir as hdt",
+ "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
+ add_item("", "", OPT_SEP, "", 0);
+ } else {
+ /*
+ * For every detected pci device, grab its kernel module to
+ * compute this submenu
+ */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+ for (int i = 0;
+ i < pci_device->dev_info->linux_kernel_module_count; i++) {
+ if (i > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[i],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ /* No need to add unknown kernel modules */
+ if (strlen(kernel_modules) > 0) {
+ snprintf(buffer, sizeof buffer, "%s (%s)",
+ kernel_modules, pci_device->dev_info->class_name);
+ snprintf(infobar, sizeof infobar,
+ "%04x:%04x %s : %s",
+ pci_device->vendor,
+ pci_device->product,
+ pci_device->dev_info->vendor_name,
+ pci_device->dev_info->product_name);
- add_item(buffer, infobar, OPT_INACTIVE, NULL,
- 0);
- menu->items_count++;
- }
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+ }
}
- }
- printf("MENU: Kernel menu done (%d items)\n", menu->items_count);
+ printf("MENU: Kernel menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu-memory.c b/com32/hdt/hdt-menu-memory.c
index 3f3e0f1f..75e51a70 100644
--- a/com32/hdt/hdt-menu-memory.c
+++ b/com32/hdt/hdt-menu-memory.c
@@ -33,356 +33,350 @@
/* Compute the e820 submenu */
static void compute_e820(struct s_my_menu *menu)
{
- char buffer[MENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- sprintf(buffer, " e820 Physical RAM map ");
- menu->items_count = 0;
- menu->menu = add_menu(buffer, -1);
-
- struct e820entry map[E820MAX];
- int count = 0;
- char type[14];
-
- detect_memory_e820(map, E820MAX, &count);
- unsigned long memory_size = memsize_e820(map, count);
- snprintf(buffer, sizeof buffer,"Detected Memory - %lu MiB (%lu KiB)",
- memory_size>>10, memory_size);
- snprintf(statbuffer, sizeof statbuffer,"Detected Memory : %lu MiB (%lu KiB)",
- memory_size>>10, memory_size);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- add_item("", "", OPT_SEP, "", 0);
-
- for (int j = 0; j < count; j++) {
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " e820 Physical RAM map ");
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ struct e820entry map[E820MAX];
+ int count = 0;
+ char type[14];
+
+ detect_memory_e820(map, E820MAX, &count);
+ unsigned long memory_size = memsize_e820(map, count);
+ snprintf(buffer, sizeof buffer, "Detected Memory - %lu MiB (%lu KiB)",
+ memory_size >> 10, memory_size);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Detected Memory : %lu MiB (%lu KiB)", memory_size >> 10,
+ memory_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ add_item("", "", OPT_SEP, "", 0);
+
+ for (int j = 0; j < count; j++) {
get_type(map[j].type, type, 14);
- snprintf(buffer, sizeof buffer,
- "%016llx - %016llx (%s)",
- map[j].addr, map[j].size,
- remove_spaces(type));
+ snprintf(buffer, sizeof buffer,
+ "%016llx - %016llx (%s)",
+ map[j].addr, map[j].size, remove_spaces(type));
snprintf(statbuffer, sizeof statbuffer,
- "%016llx - %016llx (%s)",
- map[j].addr, map[j].size,
- remove_spaces(type));
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
+ "%016llx - %016llx (%s)",
+ map[j].addr, map[j].size, remove_spaces(type));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
}
/* Compute the e801 submenu */
static void compute_e801(struct s_my_menu *menu)
{
- char buffer[MENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- sprintf(buffer, " e801 information ");
- menu->items_count = 0;
- menu->menu = add_menu(buffer, -1);
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+ sprintf(buffer, " e801 information ");
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
- int mem_low, mem_high = 0;
- if (detect_memory_e801(&mem_low, &mem_high)) {
- snprintf(buffer, sizeof buffer, "%s", "e801 output is bogus");
- snprintf(statbuffer, sizeof statbuffer, "%s", "e801 output is bogus");
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- } else {
+ int mem_low, mem_high = 0;
+ if (detect_memory_e801(&mem_low, &mem_high)) {
+ snprintf(buffer, sizeof buffer, "%s", "e801 output is bogus");
+ snprintf(statbuffer, sizeof statbuffer, "%s", "e801 output is bogus");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ } else {
snprintf(buffer, sizeof buffer, "Detected Memory : %d MiB (%d KiB)",
- (mem_high >> 4)+(mem_low >> 10),mem_low+(mem_high << 6));
- snprintf(statbuffer, sizeof statbuffer,"Detected Memory : %d MiB (%d KiB)",
- (mem_high >> 4)+(mem_low >> 10),mem_low+(mem_high << 6));
+ (mem_high >> 4) + (mem_low >> 10), mem_low + (mem_high << 6));
+ snprintf(statbuffer, sizeof statbuffer,
+ "Detected Memory : %d MiB (%d KiB)",
+ (mem_high >> 4) + (mem_low >> 10), mem_low + (mem_high << 6));
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- add_item("", "", OPT_SEP, "", 0);
- snprintf(buffer, sizeof buffer, "Low Memory : %d KiB (%d MiB)",
- mem_low, mem_low >> 10);
- snprintf(statbuffer, sizeof statbuffer, "Low Memory : %d KiB (%d MiB)",
- mem_low, mem_low >> 10);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ add_item("", "", OPT_SEP, "", 0);
+ snprintf(buffer, sizeof buffer, "Low Memory : %d KiB (%d MiB)",
+ mem_low, mem_low >> 10);
+ snprintf(statbuffer, sizeof statbuffer, "Low Memory : %d KiB (%d MiB)",
+ mem_low, mem_low >> 10);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
snprintf(buffer, sizeof buffer, "High Memory : %d KiB (%d MiB)",
- mem_high << 6, mem_high >> 4);
- snprintf(statbuffer, sizeof statbuffer, "High Memory : %d KiB (%d MiB)",
- mem_high << 6, mem_high >> 4);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ mem_high << 6, mem_high >> 4);
+ snprintf(statbuffer, sizeof statbuffer, "High Memory : %d KiB (%d MiB)",
+ mem_high << 6, mem_high >> 4);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- }
- menu->items_count++;
+ }
+ menu->items_count++;
}
/* Compute the 88 submenu */
static void compute_88(struct s_my_menu *menu)
{
- char buffer[MENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- sprintf(buffer, " 88 information ");
- menu->items_count = 0;
- menu->menu = add_menu(buffer, -1);
-
- int mem_size = 0;
- if (detect_memory_88(&mem_size)) {
- snprintf(buffer, sizeof buffer, "%s", "88 output is bogus");
- snprintf(statbuffer, sizeof statbuffer, "%s", "88 output is bogus");
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- } else {
- snprintf(buffer, sizeof buffer, "Detected Memory : %d MiB (%d KiB)",
- mem_size >> 10, mem_size);
- snprintf(statbuffer, sizeof statbuffer, "Detected Memory : %d MiB (%d KiB)",
- mem_size >> 10, mem_size);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- }
- menu->items_count++;
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " 88 information ");
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ int mem_size = 0;
+ if (detect_memory_88(&mem_size)) {
+ snprintf(buffer, sizeof buffer, "%s", "88 output is bogus");
+ snprintf(statbuffer, sizeof statbuffer, "%s", "88 output is bogus");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ } else {
+ snprintf(buffer, sizeof buffer, "Detected Memory : %d MiB (%d KiB)",
+ mem_size >> 10, mem_size);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Detected Memory : %d MiB (%d KiB)", mem_size >> 10, mem_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ }
+ menu->items_count++;
}
/* Compute the Memory submenu */
static void compute_memory_module(struct s_my_menu *menu, s_dmi * dmi,
- int slot_number)
+ int slot_number)
{
- int i = slot_number;
- char buffer[MENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- sprintf(buffer, " Bank <%d> ", i);
- menu->items_count = 0;
- menu->menu = add_menu(buffer, -1);
-
- snprintf(buffer, sizeof buffer, "Form Factor : %s",
- dmi->memory[i].form_factor);
- snprintf(statbuffer, sizeof statbuffer, "Form Factor: %s",
- dmi->memory[i].form_factor);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Type : %s",
- dmi->memory[i].type);
- snprintf(statbuffer, sizeof statbuffer, "Type: %s",
- dmi->memory[i].type);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Type Details : %s",
- dmi->memory[i].type_detail);
- snprintf(statbuffer, sizeof statbuffer, "Type Details: %s",
- dmi->memory[i].type_detail);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Speed : %s",
- dmi->memory[i].speed);
- snprintf(statbuffer, sizeof statbuffer, "Speed (Mhz): %s",
- dmi->memory[i].speed);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Size : %s",
- dmi->memory[i].size);
- snprintf(statbuffer, sizeof statbuffer, "Size: %s",
- dmi->memory[i].size);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Device Set : %s",
- dmi->memory[i].device_set);
- snprintf(statbuffer, sizeof statbuffer, "Device Set: %s",
- dmi->memory[i].device_set);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Device Loc. : %s",
- dmi->memory[i].device_locator);
- snprintf(statbuffer, sizeof statbuffer, "Device Location: %s",
- dmi->memory[i].device_locator);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Bank Locator : %s",
- dmi->memory[i].bank_locator);
- snprintf(statbuffer, sizeof statbuffer, "Bank Locator: %s",
- dmi->memory[i].bank_locator);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Total Width : %s",
- dmi->memory[i].total_width);
- snprintf(statbuffer, sizeof statbuffer, "Total bit Width: %s",
- dmi->memory[i].total_width);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Data Width : %s",
- dmi->memory[i].data_width);
- snprintf(statbuffer, sizeof statbuffer, "Data bit Width: %s",
- dmi->memory[i].data_width);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Error : %s",
- dmi->memory[i].error);
- snprintf(statbuffer, sizeof statbuffer, "Error: %s",
- dmi->memory[i].error);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Vendor : %s",
- dmi->memory[i].manufacturer);
- snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
- dmi->memory[i].manufacturer);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Serial : %s",
- dmi->memory[i].serial);
- snprintf(statbuffer, sizeof statbuffer, "Serial: %s",
- dmi->memory[i].serial);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Asset Tag : %s",
- dmi->memory[i].asset_tag);
- snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
- dmi->memory[i].asset_tag);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Part Number : %s",
- dmi->memory[i].part_number);
- snprintf(buffer, sizeof statbuffer, "Part Number: %s",
- dmi->memory[i].part_number);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ int i = slot_number;
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " Bank <%d> ", i);
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ snprintf(buffer, sizeof buffer, "Form Factor : %s",
+ dmi->memory[i].form_factor);
+ snprintf(statbuffer, sizeof statbuffer, "Form Factor: %s",
+ dmi->memory[i].form_factor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type : %s", dmi->memory[i].type);
+ snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->memory[i].type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type Details : %s",
+ dmi->memory[i].type_detail);
+ snprintf(statbuffer, sizeof statbuffer, "Type Details: %s",
+ dmi->memory[i].type_detail);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Speed : %s", dmi->memory[i].speed);
+ snprintf(statbuffer, sizeof statbuffer, "Speed (Mhz): %s",
+ dmi->memory[i].speed);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Size : %s", dmi->memory[i].size);
+ snprintf(statbuffer, sizeof statbuffer, "Size: %s", dmi->memory[i].size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Device Set : %s",
+ dmi->memory[i].device_set);
+ snprintf(statbuffer, sizeof statbuffer, "Device Set: %s",
+ dmi->memory[i].device_set);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Device Loc. : %s",
+ dmi->memory[i].device_locator);
+ snprintf(statbuffer, sizeof statbuffer, "Device Location: %s",
+ dmi->memory[i].device_locator);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Bank Locator : %s",
+ dmi->memory[i].bank_locator);
+ snprintf(statbuffer, sizeof statbuffer, "Bank Locator: %s",
+ dmi->memory[i].bank_locator);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Total Width : %s",
+ dmi->memory[i].total_width);
+ snprintf(statbuffer, sizeof statbuffer, "Total bit Width: %s",
+ dmi->memory[i].total_width);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Data Width : %s",
+ dmi->memory[i].data_width);
+ snprintf(statbuffer, sizeof statbuffer, "Data bit Width: %s",
+ dmi->memory[i].data_width);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Error : %s", dmi->memory[i].error);
+ snprintf(statbuffer, sizeof statbuffer, "Error: %s", dmi->memory[i].error);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s",
+ dmi->memory[i].manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
+ dmi->memory[i].manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Serial : %s", dmi->memory[i].serial);
+ snprintf(statbuffer, sizeof statbuffer, "Serial: %s",
+ dmi->memory[i].serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Asset Tag : %s",
+ dmi->memory[i].asset_tag);
+ snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
+ dmi->memory[i].asset_tag);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Part Number : %s",
+ dmi->memory[i].part_number);
+ snprintf(buffer, sizeof statbuffer, "Part Number: %s",
+ dmi->memory[i].part_number);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
}
/* Compute the Memory submenu when type 6 is used*/
static void compute_memory_module_type6(struct s_my_menu *menu, s_dmi * dmi,
- int slot_number)
+ int slot_number)
{
- int i = slot_number;
- char buffer[MENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- sprintf(buffer, " Bank <%d> ", i);
- menu->items_count = 0;
- menu->menu = add_menu(buffer, -1);
-
- snprintf(buffer, sizeof buffer, "Socket Designation : %s",
- dmi->memory_module[i].socket_designation);
- snprintf(statbuffer, sizeof statbuffer, "Socket Designation : %s",
- dmi->memory_module[i].socket_designation);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Bank Connections : %s",
- dmi->memory_module[i].bank_connections);
- snprintf(statbuffer, sizeof statbuffer, "Bank Connections: %s",
- dmi->memory_module[i].bank_connections);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Type : %s",
- dmi->memory_module[i].type);
- snprintf(statbuffer, sizeof statbuffer, "Type : %s",
- dmi->memory_module[i].type);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Current Speed : %s",
- dmi->memory_module[i].speed);
- snprintf(statbuffer, sizeof statbuffer, "Current Speed : %s",
- dmi->memory_module[i].speed);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Installed Size : %s",
- dmi->memory_module[i].installed_size);
- snprintf(statbuffer, sizeof statbuffer, "Installed Size : %s",
- dmi->memory_module[i].installed_size);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Enabled Size : %s",
- dmi->memory_module[i].enabled_size);
- snprintf(statbuffer, sizeof statbuffer, "Enabled Size : %s",
- dmi->memory_module[i].enabled_size);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Error Status : %s",
- dmi->memory_module[i].error_status);
- snprintf(statbuffer, sizeof statbuffer, "Error Status : %s",
- dmi->memory_module[i].error_status);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ int i = slot_number;
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " Bank <%d> ", i);
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ snprintf(buffer, sizeof buffer, "Socket Designation : %s",
+ dmi->memory_module[i].socket_designation);
+ snprintf(statbuffer, sizeof statbuffer, "Socket Designation : %s",
+ dmi->memory_module[i].socket_designation);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Bank Connections : %s",
+ dmi->memory_module[i].bank_connections);
+ snprintf(statbuffer, sizeof statbuffer, "Bank Connections: %s",
+ dmi->memory_module[i].bank_connections);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type : %s",
+ dmi->memory_module[i].type);
+ snprintf(statbuffer, sizeof statbuffer, "Type : %s",
+ dmi->memory_module[i].type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Current Speed : %s",
+ dmi->memory_module[i].speed);
+ snprintf(statbuffer, sizeof statbuffer, "Current Speed : %s",
+ dmi->memory_module[i].speed);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Installed Size : %s",
+ dmi->memory_module[i].installed_size);
+ snprintf(statbuffer, sizeof statbuffer, "Installed Size : %s",
+ dmi->memory_module[i].installed_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Enabled Size : %s",
+ dmi->memory_module[i].enabled_size);
+ snprintf(statbuffer, sizeof statbuffer, "Enabled Size : %s",
+ dmi->memory_module[i].enabled_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Error Status : %s",
+ dmi->memory_module[i].error_status);
+ snprintf(statbuffer, sizeof statbuffer, "Error Status : %s",
+ dmi->memory_module[i].error_status);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
}
/* Compute the Memory menu */
-void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi, struct s_hardware *hardware)
+void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi,
+ struct s_hardware *hardware)
{
- char buffer[MENULEN + 1];
- int i=0;
- int memory_count=0;
+ char buffer[MENULEN + 1];
+ int i = 0;
+ int memory_count = 0;
- /* If memory type 17 is available */
- if (dmi->memory_count >0) {
- memory_count=dmi->memory_count;
+ /* If memory type 17 is available */
+ if (dmi->memory_count > 0) {
+ memory_count = dmi->memory_count;
for (i = 0; i < dmi->memory_count; i++) {
- compute_memory_module(&(menu->memory_sub_menu[i]), dmi, i);
- }
- } else if (dmi->memory_module_count >0) {
- memory_count=dmi->memory_module_count;
+ compute_memory_module(&(menu->memory_sub_menu[i]), dmi, i);
+ }
+ } else if (dmi->memory_module_count > 0) {
+ memory_count = dmi->memory_module_count;
/* Memory Type 17 isn't available, let's fallback on type 6 */
for (i = 0; i < dmi->memory_module_count; i++) {
- compute_memory_module_type6(&(menu->memory_sub_menu[i]), dmi, i);
- }
- }
+ compute_memory_module_type6(&(menu->memory_sub_menu[i]), dmi, i);
+ }
+ }
- compute_e820(&(menu->memory_sub_menu[++i]));
- compute_e801(&(menu->memory_sub_menu[++i]));
- compute_88(&(menu->memory_sub_menu[++i]));
+ compute_e820(&(menu->memory_sub_menu[++i]));
+ compute_e801(&(menu->memory_sub_menu[++i]));
+ compute_88(&(menu->memory_sub_menu[++i]));
- menu->memory_menu.menu = add_menu(" Memory ", -1);
- menu->memory_menu.items_count = 0;
+ menu->memory_menu.menu = add_menu(" Memory ", -1);
+ menu->memory_menu.items_count = 0;
- snprintf(buffer, sizeof(buffer), " %lu MB detected ",
- (hardware->detected_memory_size+(1<<9))>>10);
- add_item(buffer, "Detected Memory", OPT_INACTIVE, NULL,menu->memory_sub_menu[0].menu);
- menu->memory_menu.items_count++;
+ snprintf(buffer, sizeof(buffer), " %lu MB detected ",
+ (hardware->detected_memory_size + (1 << 9)) >> 10);
+ add_item(buffer, "Detected Memory", OPT_INACTIVE, NULL,
+ menu->memory_sub_menu[0].menu);
+ menu->memory_menu.items_count++;
- add_item("", "", OPT_SEP, "", 0);
+ add_item("", "", OPT_SEP, "", 0);
- if (memory_count==0) {
+ if (memory_count == 0) {
snprintf(buffer, sizeof buffer, " No memory bank detected ");
add_item(buffer, "Memory Bank", OPT_INACTIVE, NULL,
- menu->memory_sub_menu[1].menu);
+ menu->memory_sub_menu[1].menu);
menu->memory_menu.items_count++;
- } else for (i = 0; i < memory_count; i++) {
- snprintf(buffer, sizeof buffer, " Bank <%d> ", i);
- add_item(buffer, "Memory Bank", OPT_SUBMENU, NULL,
- menu->memory_sub_menu[i].menu);
- menu->memory_menu.items_count++;
- }
-
- add_item("", "", OPT_SEP, "", 0);
-
- snprintf(buffer, sizeof buffer, " e820 ");
- add_item(buffer, "e820 mapping", OPT_SUBMENU, NULL,
- menu->memory_sub_menu[++i].menu);
- menu->memory_menu.items_count++;
-
- snprintf(buffer, sizeof buffer, " e801 ");
- add_item(buffer, "e801 information", OPT_SUBMENU, NULL,
- menu->memory_sub_menu[++i].menu);
- menu->memory_menu.items_count++;
-
- snprintf(buffer, sizeof buffer, " 88 ");
- add_item(buffer, "88 information", OPT_SUBMENU, NULL,
- menu->memory_sub_menu[++i].menu);
- menu->memory_menu.items_count++;
-
- add_item("", "", OPT_SEP, "", 0);
- printf("MENU: Memory menu done (%d items)\n",
- menu->memory_menu.items_count);
- add_item("Run Test", "Run Test", OPT_RUN, hardware->memtest_label, 0);
+ } else
+ for (i = 0; i < memory_count; i++) {
+ snprintf(buffer, sizeof buffer, " Bank <%d> ", i);
+ add_item(buffer, "Memory Bank", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[i].menu);
+ menu->memory_menu.items_count++;
+ }
+
+ add_item("", "", OPT_SEP, "", 0);
+
+ snprintf(buffer, sizeof buffer, " e820 ");
+ add_item(buffer, "e820 mapping", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[++i].menu);
+ menu->memory_menu.items_count++;
+
+ snprintf(buffer, sizeof buffer, " e801 ");
+ add_item(buffer, "e801 information", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[++i].menu);
+ menu->memory_menu.items_count++;
+
+ snprintf(buffer, sizeof buffer, " 88 ");
+ add_item(buffer, "88 information", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[++i].menu);
+ menu->memory_menu.items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+ printf("MENU: Memory menu done (%d items)\n",
+ menu->memory_menu.items_count);
+ add_item("Run Test", "Run Test", OPT_RUN, hardware->memtest_label, 0);
}
diff --git a/com32/hdt/hdt-menu-pci.c b/com32/hdt/hdt-menu-pci.c
index d4a6b7e7..734b7444 100644
--- a/com32/hdt/hdt-menu-pci.c
+++ b/com32/hdt/hdt-menu-pci.c
@@ -30,168 +30,174 @@
/* Dynamic submenu for pci devices */
static void compute_pci_device(struct s_my_menu *menu,
- struct pci_device *pci_device,
- int pci_bus, int pci_slot, int pci_func,
+ struct pci_device *pci_device,
+ int pci_bus, int pci_slot, int pci_func,
struct s_hardware *hardware)
{
- char buffer[56];
- char statbuffer[STATLEN];
- char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
- MAX_KERNEL_MODULES_PER_PCI_DEVICE];
-
- menu->menu = add_menu(" Details ", -1);
- menu->items_count = 0;
- set_menu_pos(5, 17);
-
- snprintf(buffer, sizeof buffer, "Vendor : %s",
- pci_device->dev_info->vendor_name);
- snprintf(statbuffer, sizeof statbuffer, "Vendor Name: %s",
- pci_device->dev_info->vendor_name);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Product : %s",
- pci_device->dev_info->product_name);
- snprintf(statbuffer, sizeof statbuffer, "Product Name %s",
- pci_device->dev_info->product_name);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Class : %s",
- pci_device->dev_info->class_name);
- snprintf(statbuffer, sizeof statbuffer, "Class Name: %s",
- pci_device->dev_info->class_name);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Location: %02x:%02x.%01x", pci_bus,
- pci_slot, pci_func);
- snprintf(statbuffer, sizeof statbuffer,
- "Location on the PCI Bus: %02x:%02x.%01x", pci_bus, pci_slot,
- pci_func);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "PCI ID : %04x:%04x[%04x:%04x]",
- pci_device->vendor, pci_device->product,
- pci_device->sub_vendor, pci_device->sub_product);
- snprintf(statbuffer, sizeof statbuffer,
- "vendor:product[sub_vendor:sub_product] : %04x:%04x[%04x:%04x]",
- pci_device->vendor, pci_device->product,
- pci_device->sub_vendor, pci_device->sub_product);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- if ((pci_device->dev_info->irq>0) && (pci_device->dev_info->irq<255)) {
- snprintf(buffer, sizeof buffer,"IRQ : %d", pci_device->dev_info->irq);
- snprintf(statbuffer, sizeof statbuffer,"IRQ : %d", pci_device->dev_info->irq);
+ char buffer[56];
+ char statbuffer[STATLEN];
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+
+ menu->menu = add_menu(" Details ", -1);
+ menu->items_count = 0;
+ set_menu_pos(5, 17);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s",
+ pci_device->dev_info->vendor_name);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor Name: %s",
+ pci_device->dev_info->vendor_name);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- }
-
- snprintf(buffer, sizeof buffer, "Latency : %d",pci_device->dev_info->latency);
- snprintf(statbuffer,sizeof statbuffer,"Latency : %d",pci_device->dev_info->latency);
- add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
- menu->items_count++;
-
- memset(kernel_modules,0,sizeof(kernel_modules));
-
- if (pci_device->dev_info->linux_kernel_module_count > 1) {
- for (int i = 0;
- i < pci_device->dev_info->linux_kernel_module_count; i++) {
- if (i > 0) {
- strncat(kernel_modules, " | ", 3);
- }
- strncat(kernel_modules,
- pci_device->dev_info->linux_kernel_module[i],
- LINUX_KERNEL_MODULE_SIZE - 1);
+
+ snprintf(buffer, sizeof buffer, "Product : %s",
+ pci_device->dev_info->product_name);
+ snprintf(statbuffer, sizeof statbuffer, "Product Name %s",
+ pci_device->dev_info->product_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Class : %s",
+ pci_device->dev_info->class_name);
+ snprintf(statbuffer, sizeof statbuffer, "Class Name: %s",
+ pci_device->dev_info->class_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Location: %02x:%02x.%01x", pci_bus,
+ pci_slot, pci_func);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Location on the PCI Bus: %02x:%02x.%01x", pci_bus, pci_slot,
+ pci_func);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PCI ID : %04x:%04x[%04x:%04x]",
+ pci_device->vendor, pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
+ snprintf(statbuffer, sizeof statbuffer,
+ "vendor:product[sub_vendor:sub_product] : %04x:%04x[%04x:%04x]",
+ pci_device->vendor, pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ if ((pci_device->dev_info->irq > 0) && (pci_device->dev_info->irq < 255)) {
+ snprintf(buffer, sizeof buffer, "IRQ : %d",
+ pci_device->dev_info->irq);
+ snprintf(statbuffer, sizeof statbuffer, "IRQ : %d",
+ pci_device->dev_info->irq);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ snprintf(buffer, sizeof buffer, "Latency : %d",
+ pci_device->dev_info->latency);
+ snprintf(statbuffer, sizeof statbuffer, "Latency : %d",
+ pci_device->dev_info->latency);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ memset(kernel_modules, 0, sizeof(kernel_modules));
+
+ if (pci_device->dev_info->linux_kernel_module_count > 1) {
+ for (int i = 0;
+ i < pci_device->dev_info->linux_kernel_module_count; i++) {
+ if (i > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[i],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ snprintf(buffer, sizeof buffer, "Modules : %s", kernel_modules);
+ snprintf(statbuffer, sizeof statbuffer, "Kernel Modules: %s",
+ kernel_modules);
+ } else {
+ snprintf(buffer, sizeof buffer, "Module : %s",
+ pci_device->dev_info->linux_kernel_module[0]);
+ snprintf(statbuffer, sizeof statbuffer, "Kernel Module: %s",
+ pci_device->dev_info->linux_kernel_module[0]);
+ }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ if (hardware->is_pxe_valid == true) {
+ if ((hardware->pxe.pci_device != NULL)
+ && (hardware->pxe.pci_device == pci_device)) {
+
+ snprintf(buffer, sizeof buffer, "MAC Addr: %s",
+ hardware->pxe.mac_addr);
+ snprintf(statbuffer, sizeof statbuffer, "MAC Address : %s",
+ hardware->pxe.mac_addr);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PXE : %s",
+ "Current Boot device");
+ snprintf(statbuffer, sizeof statbuffer, "PXE : %s",
+ "Current Boot device");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
}
- snprintf(buffer, sizeof buffer, "Modules : %s", kernel_modules);
- snprintf(statbuffer, sizeof statbuffer, "Kernel Modules: %s",
- kernel_modules);
- } else {
- snprintf(buffer, sizeof buffer, "Module : %s",
- pci_device->dev_info->linux_kernel_module[0]);
- snprintf(statbuffer, sizeof statbuffer, "Kernel Module: %s",
- pci_device->dev_info->linux_kernel_module[0]);
- }
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- if (hardware->is_pxe_valid == true) {
- if ((hardware->pxe.pci_device != NULL)
- && (hardware->pxe.pci_device == pci_device)) {
-
- snprintf(buffer,sizeof buffer,"MAC Addr: %s",hardware->pxe.mac_addr);
- snprintf(statbuffer,sizeof statbuffer,"MAC Address : %s",hardware->pxe.mac_addr);
- add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
- menu->items_count++;
-
- snprintf(buffer,sizeof buffer,"PXE : %s","Current Boot device");
- snprintf(statbuffer,sizeof statbuffer,"PXE : %s","Current Boot device");
- add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
- menu->items_count++;
- }
- }
}
/* Main PCI menu */
int compute_PCI(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
{
- int i = 0;
- char menuname[255][MENULEN + 1];
- char infobar[255][STATLEN + 1];
- struct pci_device *pci_device;
- char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
- MAX_KERNEL_MODULES_PER_PCI_DEVICE];
-
- /* For every detected pci device, compute its submenu */
- for_each_pci_func(pci_device, hardware->pci_domain) {
- memset(kernel_modules, 0, sizeof kernel_modules);
- for (int kmod = 0;
- kmod < pci_device->dev_info->linux_kernel_module_count;
- kmod++) {
- if (kmod > 0) {
- strncat(kernel_modules, " | ", 3);
- }
- strncat(kernel_modules,
- pci_device->dev_info->linux_kernel_module[kmod],
- LINUX_KERNEL_MODULE_SIZE - 1);
+ int i = 0;
+ char menuname[255][MENULEN + 1];
+ char infobar[255][STATLEN + 1];
+ struct pci_device *pci_device;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+
+ /* For every detected pci device, compute its submenu */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+ for (int kmod = 0;
+ kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) {
+ if (kmod > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[kmod],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ if (pci_device->dev_info->linux_kernel_module_count == 0)
+ strlcpy(kernel_modules, "unknown", 7);
+
+ compute_pci_device(&(hdt_menu->pci_sub_menu[i]), pci_device,
+ __pci_bus, __pci_slot, __pci_func, hardware);
+ snprintf(menuname[i], 59, "%s|%s",
+ pci_device->dev_info->vendor_name,
+ pci_device->dev_info->product_name);
+ snprintf(infobar[i], STATLEN,
+ "%02x:%02x.%01x # %s # ID:%04x:%04x[%04x:%04x] # Kmod:%s",
+ __pci_bus, __pci_slot, __pci_func,
+ pci_device->dev_info->class_name, pci_device->vendor,
+ pci_device->product, pci_device->sub_vendor,
+ pci_device->sub_product, kernel_modules);
+ i++;
+ }
+
+ hdt_menu->pci_menu.menu = add_menu(" PCI Devices ", -1);
+ hdt_menu->pci_menu.items_count = 0;
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ add_item("The pci.ids file is missing", "Missing pci.ids file",
+ OPT_INACTIVE, NULL, 0);
+ add_item("PCI Device names can't be computed.",
+ "Missing pci.ids file", OPT_INACTIVE, NULL, 0);
+ add_item("Please put one in same dir as hdt",
+ "Missing pci.ids file", OPT_INACTIVE, NULL, 0);
+ add_item("", "", OPT_SEP, "", 0);
+ }
+ for (int j = 0; j < i; j++) {
+ add_item(menuname[j], infobar[j], OPT_SUBMENU, NULL,
+ hdt_menu->pci_sub_menu[j].menu);
+ hdt_menu->pci_menu.items_count++;
}
- if (pci_device->dev_info->linux_kernel_module_count == 0)
- strlcpy(kernel_modules, "unknown", 7);
-
- compute_pci_device(&(hdt_menu->pci_sub_menu[i]), pci_device,
- __pci_bus, __pci_slot, __pci_func, hardware);
- snprintf(menuname[i], 59, "%s|%s",
- pci_device->dev_info->vendor_name,
- pci_device->dev_info->product_name);
- snprintf(infobar[i], STATLEN,
- "%02x:%02x.%01x # %s # ID:%04x:%04x[%04x:%04x] # Kmod:%s",
- __pci_bus, __pci_slot, __pci_func,
- pci_device->dev_info->class_name, pci_device->vendor,
- pci_device->product, pci_device->sub_vendor,
- pci_device->sub_product, kernel_modules);
- i++;
- }
-
- hdt_menu->pci_menu.menu = add_menu(" PCI Devices ", -1);
- hdt_menu->pci_menu.items_count = 0;
- if (hardware->pci_ids_return_code == -ENOPCIIDS) {
- add_item("The pci.ids file is missing", "Missing pci.ids file",
- OPT_INACTIVE, NULL, 0);
- add_item("PCI Device names can't be computed.",
- "Missing pci.ids file", OPT_INACTIVE, NULL, 0);
- add_item("Please put one in same dir as hdt",
- "Missing pci.ids file", OPT_INACTIVE, NULL, 0);
- add_item("", "", OPT_SEP, "", 0);
- }
- for (int j = 0; j < i; j++) {
- add_item(menuname[j], infobar[j], OPT_SUBMENU, NULL,
- hdt_menu->pci_sub_menu[j].menu);
- hdt_menu->pci_menu.items_count++;
- }
- printf("MENU: PCI menu done (%d items)\n",
- hdt_menu->pci_menu.items_count);
- return 0;
+ printf("MENU: PCI menu done (%d items)\n", hdt_menu->pci_menu.items_count);
+ return 0;
}
diff --git a/com32/hdt/hdt-menu-processor.c b/com32/hdt/hdt-menu-processor.c
index 4e102cb5..e788ba52 100644
--- a/com32/hdt/hdt-menu-processor.c
+++ b/com32/hdt/hdt-menu-processor.c
@@ -31,214 +31,211 @@
/* Compute Processor menu */
void compute_processor(struct s_my_menu *menu, struct s_hardware *hardware)
{
- char buffer[SUBMENULEN + 1];
- char buffer1[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- menu->menu = add_menu(" Main Processor ", -1);
- menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
-
- snprintf(buffer, sizeof buffer, "Vendor : %s", hardware->cpu.vendor);
- snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
- hardware->cpu.vendor);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Model : %s", del_multi_spaces(hardware->cpu.model));
- snprintf(statbuffer, sizeof statbuffer, "Model: %s",
- del_multi_spaces(hardware->cpu.model));
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Vendor ID : %d",
- hardware->cpu.vendor_id);
- snprintf(statbuffer, sizeof statbuffer, "Vendor ID: %d",
- hardware->cpu.vendor_id);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Family ID : %d", hardware->cpu.family);
- snprintf(statbuffer, sizeof statbuffer, "Family ID: %d",
- hardware->cpu.family);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Model ID : %d",
- hardware->cpu.model_id);
- snprintf(statbuffer, sizeof statbuffer, "Model ID: %d",
- hardware->cpu.model_id);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Stepping : %d",
- hardware->cpu.stepping);
- snprintf(statbuffer, sizeof statbuffer, "Stepping: %d",
- hardware->cpu.stepping);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- if (hardware->is_dmi_valid) {
- snprintf(buffer, sizeof buffer, "FSB : %d",
- hardware->dmi.processor.external_clock);
- snprintf(statbuffer, sizeof statbuffer,
- "Front Side Bus (MHz): %d",
- hardware->dmi.processor.external_clock);
+ char buffer[SUBMENULEN + 1];
+ char buffer1[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ menu->menu = add_menu(" Main Processor ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s", hardware->cpu.vendor);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", hardware->cpu.vendor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Model : %s",
+ del_multi_spaces(hardware->cpu.model));
+ snprintf(statbuffer, sizeof statbuffer, "Model: %s",
+ del_multi_spaces(hardware->cpu.model));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Vendor ID : %d", hardware->cpu.vendor_id);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor ID: %d",
+ hardware->cpu.vendor_id);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Family ID : %d", hardware->cpu.family);
+ snprintf(statbuffer, sizeof statbuffer, "Family ID: %d",
+ hardware->cpu.family);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Model ID : %d", hardware->cpu.model_id);
+ snprintf(statbuffer, sizeof statbuffer, "Model ID: %d",
+ hardware->cpu.model_id);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Stepping : %d", hardware->cpu.stepping);
+ snprintf(statbuffer, sizeof statbuffer, "Stepping: %d",
+ hardware->cpu.stepping);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "Cur. Speed: %d",
- hardware->dmi.processor.current_speed);
- snprintf(statbuffer, sizeof statbuffer,
- "Current Speed (MHz): %d",
- hardware->dmi.processor.current_speed);
+ if (hardware->is_dmi_valid) {
+ snprintf(buffer, sizeof buffer, "FSB : %d",
+ hardware->dmi.processor.external_clock);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Front Side Bus (MHz): %d",
+ hardware->dmi.processor.external_clock);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Cur. Speed: %d",
+ hardware->dmi.processor.current_speed);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Current Speed (MHz): %d",
+ hardware->dmi.processor.current_speed);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Max Speed : %d",
+ hardware->dmi.processor.max_speed);
+ snprintf(statbuffer, sizeof statbuffer, "Max Speed (MHz): %d",
+ hardware->dmi.processor.max_speed);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Upgrade : %s",
+ hardware->dmi.processor.upgrade);
+ snprintf(statbuffer, sizeof statbuffer, "Upgrade: %s",
+ hardware->dmi.processor.upgrade);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ if (hardware->cpu.flags.smp) {
+ snprintf(buffer, sizeof buffer, "SMP : Yes");
+ snprintf(statbuffer, sizeof statbuffer, "SMP: Yes");
+ } else {
+ snprintf(buffer, sizeof buffer, "SMP : No");
+ snprintf(statbuffer, sizeof statbuffer, "SMP: No");
+ }
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "Max Speed : %d",
- hardware->dmi.processor.max_speed);
- snprintf(statbuffer, sizeof statbuffer, "Max Speed (MHz): %d",
- hardware->dmi.processor.max_speed);
+ if (hardware->cpu.flags.lm) {
+ snprintf(buffer, sizeof buffer, "x86_64 : Yes");
+ snprintf(statbuffer, sizeof statbuffer,
+ "x86_64 compatible processor: Yes");
+ } else {
+ snprintf(buffer, sizeof buffer, "X86_64 : No");
+ snprintf(statbuffer, sizeof statbuffer,
+ "X86_64 compatible processor: No");
+ }
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "Upgrade : %s",
- hardware->dmi.processor.upgrade);
- snprintf(statbuffer, sizeof statbuffer, "Upgrade: %s",
- hardware->dmi.processor.upgrade);
+ buffer1[0] = '\0';
+ if (hardware->cpu.flags.fpu)
+ strcat(buffer1, "fpu ");
+ if (hardware->cpu.flags.vme)
+ strcat(buffer1, "vme ");
+ if (hardware->cpu.flags.de)
+ strcat(buffer1, "de ");
+ if (hardware->cpu.flags.pse)
+ strcat(buffer1, "pse ");
+ if (hardware->cpu.flags.tsc)
+ strcat(buffer1, "tsc ");
+ if (hardware->cpu.flags.msr)
+ strcat(buffer1, "msr ");
+ if (hardware->cpu.flags.pae)
+ strcat(buffer1, "pae ");
+ snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
+ snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- }
-
- if (hardware->cpu.flags.smp) {
- snprintf(buffer, sizeof buffer, "SMP : Yes");
- snprintf(statbuffer, sizeof statbuffer, "SMP: Yes");
- } else {
- snprintf(buffer, sizeof buffer, "SMP : No");
- snprintf(statbuffer, sizeof statbuffer, "SMP: No");
- }
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- if (hardware->cpu.flags.lm) {
- snprintf(buffer, sizeof buffer, "x86_64 : Yes");
- snprintf(statbuffer, sizeof statbuffer,
- "x86_64 compatible processor: Yes");
- } else {
- snprintf(buffer, sizeof buffer, "X86_64 : No");
- snprintf(statbuffer, sizeof statbuffer,
- "X86_64 compatible processor: No");
- }
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.fpu)
- strcat(buffer1, "fpu ");
- if (hardware->cpu.flags.vme)
- strcat(buffer1, "vme ");
- if (hardware->cpu.flags.de)
- strcat(buffer1, "de ");
- if (hardware->cpu.flags.pse)
- strcat(buffer1, "pse ");
- if (hardware->cpu.flags.tsc)
- strcat(buffer1, "tsc ");
- if (hardware->cpu.flags.msr)
- strcat(buffer1, "msr ");
- if (hardware->cpu.flags.pae)
- strcat(buffer1, "pae ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.mce)
- strcat(buffer1, "mce ");
- if (hardware->cpu.flags.cx8)
- strcat(buffer1, "cx8 ");
- if (hardware->cpu.flags.apic)
- strcat(buffer1, "apic ");
- if (hardware->cpu.flags.sep)
- strcat(buffer1, "sep ");
- if (hardware->cpu.flags.mtrr)
- strcat(buffer1, "mtrr ");
- if (hardware->cpu.flags.pge)
- strcat(buffer1, "pge ");
- if (hardware->cpu.flags.mca)
- strcat(buffer1, "mca ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.cmov)
- strcat(buffer1, "cmov ");
- if (hardware->cpu.flags.pat)
- strcat(buffer1, "pat ");
- if (hardware->cpu.flags.pse_36)
- strcat(buffer1, "pse_36 ");
- if (hardware->cpu.flags.psn)
- strcat(buffer1, "psn ");
- if (hardware->cpu.flags.clflsh)
- strcat(buffer1, "clflsh ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.dts)
- strcat(buffer1, "dts ");
- if (hardware->cpu.flags.acpi)
- strcat(buffer1, "acpi ");
- if (hardware->cpu.flags.mmx)
- strcat(buffer1, "mmx ");
- if (hardware->cpu.flags.sse)
- strcat(buffer1, "sse ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.sse2)
- strcat(buffer1, "sse2 ");
- if (hardware->cpu.flags.ss)
- strcat(buffer1, "ss ");
- if (hardware->cpu.flags.htt)
- strcat(buffer1, "ht ");
- if (hardware->cpu.flags.acc)
- strcat(buffer1, "acc ");
- if (hardware->cpu.flags.syscall)
- strcat(buffer1, "syscall ");
- if (hardware->cpu.flags.mp)
- strcat(buffer1, "mp ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- buffer1[0] = '\0';
- if (hardware->cpu.flags.nx)
- strcat(buffer1, "nx ");
- if (hardware->cpu.flags.mmxext)
- strcat(buffer1, "mmxext ");
- if (hardware->cpu.flags.lm)
- strcat(buffer1, "lm ");
- if (hardware->cpu.flags.nowext)
- strcat(buffer1, "3dnowext ");
- if (hardware->cpu.flags.now)
- strcat(buffer1, "3dnow! ");
- if (hardware->cpu.flags.vmx)
- strcat(buffer1, "vmx ");
- if (hardware->cpu.flags.svm)
- strcat(buffer1, "svm ");
- snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
- snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- printf("MENU: Processor menu done (%d items)\n", menu->items_count);
+
+ buffer1[0] = '\0';
+ if (hardware->cpu.flags.mce)
+ strcat(buffer1, "mce ");
+ if (hardware->cpu.flags.cx8)
+ strcat(buffer1, "cx8 ");
+ if (hardware->cpu.flags.apic)
+ strcat(buffer1, "apic ");
+ if (hardware->cpu.flags.sep)
+ strcat(buffer1, "sep ");
+ if (hardware->cpu.flags.mtrr)
+ strcat(buffer1, "mtrr ");
+ if (hardware->cpu.flags.pge)
+ strcat(buffer1, "pge ");
+ if (hardware->cpu.flags.mca)
+ strcat(buffer1, "mca ");
+ snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
+ snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ buffer1[0] = '\0';
+ if (hardware->cpu.flags.cmov)
+ strcat(buffer1, "cmov ");
+ if (hardware->cpu.flags.pat)
+ strcat(buffer1, "pat ");
+ if (hardware->cpu.flags.pse_36)
+ strcat(buffer1, "pse_36 ");
+ if (hardware->cpu.flags.psn)
+ strcat(buffer1, "psn ");
+ if (hardware->cpu.flags.clflsh)
+ strcat(buffer1, "clflsh ");
+ snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
+ snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ buffer1[0] = '\0';
+ if (hardware->cpu.flags.dts)
+ strcat(buffer1, "dts ");
+ if (hardware->cpu.flags.acpi)
+ strcat(buffer1, "acpi ");
+ if (hardware->cpu.flags.mmx)
+ strcat(buffer1, "mmx ");
+ if (hardware->cpu.flags.sse)
+ strcat(buffer1, "sse ");
+ snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
+ snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ buffer1[0] = '\0';
+ if (hardware->cpu.flags.sse2)
+ strcat(buffer1, "sse2 ");
+ if (hardware->cpu.flags.ss)
+ strcat(buffer1, "ss ");
+ if (hardware->cpu.flags.htt)
+ strcat(buffer1, "ht ");
+ if (hardware->cpu.flags.acc)
+ strcat(buffer1, "acc ");
+ if (hardware->cpu.flags.syscall)
+ strcat(buffer1, "syscall ");
+ if (hardware->cpu.flags.mp)
+ strcat(buffer1, "mp ");
+ snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
+ snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ buffer1[0] = '\0';
+ if (hardware->cpu.flags.nx)
+ strcat(buffer1, "nx ");
+ if (hardware->cpu.flags.mmxext)
+ strcat(buffer1, "mmxext ");
+ if (hardware->cpu.flags.lm)
+ strcat(buffer1, "lm ");
+ if (hardware->cpu.flags.nowext)
+ strcat(buffer1, "3dnowext ");
+ if (hardware->cpu.flags.now)
+ strcat(buffer1, "3dnow! ");
+ if (hardware->cpu.flags.vmx)
+ strcat(buffer1, "vmx ");
+ if (hardware->cpu.flags.svm)
+ strcat(buffer1, "svm ");
+ snprintf(buffer, sizeof buffer, "Flags : %s", buffer1);
+ snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ printf("MENU: Processor menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu-pxe.c b/com32/hdt/hdt-menu-pxe.c
index 497fa776..930cf272 100644
--- a/com32/hdt/hdt-menu-pxe.c
+++ b/com32/hdt/hdt-menu-pxe.c
@@ -31,90 +31,85 @@
/* Main Kernel menu */
void compute_PXE(struct s_my_menu *menu, struct s_hardware *hardware)
{
- char buffer[SUBMENULEN + 1];
- char infobar[STATLEN + 1];
-
- if (hardware->is_pxe_valid == false)
- return;
-
- menu->menu = add_menu(" PXE ", -1);
- menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
-
- struct s_pxe *p = &hardware->pxe;
-
- if ((hardware->pci_ids_return_code == -ENOPCIIDS) || (p->pci_device==NULL)) {
- snprintf(buffer, sizeof buffer, "PCI Vendor : %d",
- p->vendor_id);
- snprintf(infobar, sizeof infobar, "PCI Vendor : %d",
- p->vendor_id);
- add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "PCI Product : %d",
- p->vendor_id);
- snprintf(infobar, sizeof infobar, "PCI Product : %d",
- p->vendor_id);
- add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "PCI SubVendor : %d",
- p->subvendor_id);
- snprintf(infobar, sizeof infobar, "PCI SubVendor : %d",
- p->subvendor_id);
- add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "PCI SubProduct : %d",
- p->subproduct_id);
- snprintf(infobar, sizeof infobar, "PCI SubProduct : %d",
- p->subproduct_id);
+ char buffer[SUBMENULEN + 1];
+ char infobar[STATLEN + 1];
+
+ if (hardware->is_pxe_valid == false)
+ return;
+
+ menu->menu = add_menu(" PXE ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+
+ struct s_pxe *p = &hardware->pxe;
+
+ if ((hardware->pci_ids_return_code == -ENOPCIIDS)
+ || (p->pci_device == NULL)) {
+ snprintf(buffer, sizeof buffer, "PCI Vendor : %d", p->vendor_id);
+ snprintf(infobar, sizeof infobar, "PCI Vendor : %d", p->vendor_id);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PCI Product : %d", p->vendor_id);
+ snprintf(infobar, sizeof infobar, "PCI Product : %d", p->vendor_id);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PCI SubVendor : %d", p->subvendor_id);
+ snprintf(infobar, sizeof infobar, "PCI SubVendor : %d",
+ p->subvendor_id);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PCI SubProduct : %d",
+ p->subproduct_id);
+ snprintf(infobar, sizeof infobar, "PCI SubProduct : %d",
+ p->subproduct_id);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PCI Revision : %d", p->rev);
+ snprintf(infobar, sizeof infobar, "PCI Revision : %d", p->rev);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer,
+ "PCI Bus Pos. : %02x:%02x.%02x", p->pci_bus,
+ p->pci_dev, p->pci_func);
+ snprintf(infobar, sizeof infobar,
+ "PCI Bus Pos. : %02x:%02x.%02x", p->pci_bus,
+ p->pci_dev, p->pci_func);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ } else {
+
+ snprintf(buffer, sizeof buffer, "Manufacturer : %s",
+ p->pci_device->dev_info->vendor_name);
+ snprintf(infobar, sizeof infobar, "Manufacturer : %s",
+ p->pci_device->dev_info->vendor_name);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Product : %s",
+ p->pci_device->dev_info->product_name);
+ snprintf(infobar, sizeof infobar, "Product : %s",
+ p->pci_device->dev_info->product_name);
+ add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
+ snprintf(buffer, sizeof buffer, "MAC Address : %s", p->mac_addr);
+ snprintf(infobar, sizeof infobar, "MAC Address : %s", p->mac_addr);
add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "PCI Revision : %d", p->rev);
- snprintf(infobar, sizeof infobar, "PCI Revision : %d",
- p->rev);
+ snprintf(buffer, sizeof buffer, "IP Address : %d.%d.%d.%d",
+ p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
+ snprintf(infobar, sizeof infobar, "IP Address : %d.%d.%d.%d",
+ p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- snprintf(buffer, sizeof buffer,
- "PCI Bus Pos. : %02x:%02x.%02x", p->pci_bus,
- p->pci_dev, p->pci_func);
- snprintf(infobar, sizeof infobar,
- "PCI Bus Pos. : %02x:%02x.%02x", p->pci_bus,
- p->pci_dev, p->pci_func);
- add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- } else {
-
- snprintf(buffer, sizeof buffer, "Manufacturer : %s",
- p->pci_device->dev_info->vendor_name);
- snprintf(infobar, sizeof infobar, "Manufacturer : %s",
- p->pci_device->dev_info->vendor_name);
- add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Product : %s",
- p->pci_device->dev_info->product_name);
- snprintf(infobar, sizeof infobar, "Product : %s",
- p->pci_device->dev_info->product_name);
- add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
-
- snprintf(buffer, sizeof buffer, "MAC Address : %s", p->mac_addr);
- snprintf(infobar, sizeof infobar, "MAC Address : %s", p->mac_addr);
- add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "IP Address : %d.%d.%d.%d",
- p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
- snprintf(infobar, sizeof infobar, "IP Address : %d.%d.%d.%d",
- p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
- add_item(buffer, infobar, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- printf("MENU: PXE menu done (%d items)\n", menu->items_count);
+ printf("MENU: PXE menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu-summary.c b/com32/hdt/hdt-menu-summary.c
index bd10cb23..53eaf61a 100644
--- a/com32/hdt/hdt-menu-summary.c
+++ b/com32/hdt/hdt-menu-summary.c
@@ -31,157 +31,148 @@
/* Computing Summary menu */
void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware)
{
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- menu->menu = add_menu(" Summary ", -1);
- menu->items_count = 0;
-
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
-
- snprintf(buffer, sizeof buffer, "CPU Vendor : %s",
- hardware->cpu.vendor);
- snprintf(statbuffer, sizeof statbuffer, "CPU Vendor: %s",
- hardware->cpu.vendor);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "CPU Model : %s",
- hardware->cpu.model);
- snprintf(statbuffer, sizeof statbuffer, "CPU Model: %s",
- hardware->cpu.model);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- add_item("", "", OPT_SEP, "", 0);
- if (hardware->is_dmi_valid == true) {
-
- snprintf(buffer, sizeof buffer, "System Vendor : %s",
- hardware->dmi.system.manufacturer);
- snprintf(statbuffer, sizeof statbuffer, "System Vendor: %s",
- hardware->dmi.system.manufacturer);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "System Product: %s",
- hardware->dmi.system.product_name);
- snprintf(statbuffer, sizeof statbuffer,
- "System Product Name: %s",
- hardware->dmi.system.product_name);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
- snprintf(buffer, sizeof buffer, "System Serial : %s",
- hardware->dmi.system.serial);
- snprintf(statbuffer, sizeof statbuffer,
- "System Serial Number: %s",
- hardware->dmi.system.serial);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ menu->menu = add_menu(" Summary ", -1);
+ menu->items_count = 0;
- add_item("", "", OPT_SEP, "", 0);
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
- snprintf(buffer, sizeof buffer, "Bios Version : %s",
- hardware->dmi.bios.version);
- snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s",
- hardware->dmi.bios.version);
+ snprintf(buffer, sizeof buffer, "CPU Vendor : %s", hardware->cpu.vendor);
+ snprintf(statbuffer, sizeof statbuffer, "CPU Vendor: %s",
+ hardware->cpu.vendor);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "Bios Release : %s",
- hardware->dmi.bios.release_date);
- snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s",
- hardware->dmi.bios.release_date);
+ snprintf(buffer, sizeof buffer, "CPU Model : %s", hardware->cpu.model);
+ snprintf(statbuffer, sizeof statbuffer, "CPU Model: %s",
+ hardware->cpu.model);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- }
-
- add_item("", "", OPT_SEP, "", 0);
- snprintf(buffer, sizeof buffer, "Memory Size : %lu MiB (%lu KiB)",
- (hardware->detected_memory_size + (1<<9))>>10,
- hardware->detected_memory_size);
- snprintf(statbuffer, sizeof statbuffer, "Detected Memory Size: %lu MiB (%lu KiB)",
- (hardware->detected_memory_size+(1<<9))>>10, hardware->detected_memory_size);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ add_item("", "", OPT_SEP, "", 0);
+ if (hardware->is_dmi_valid == true) {
+
+ snprintf(buffer, sizeof buffer, "System Vendor : %s",
+ hardware->dmi.system.manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "System Vendor: %s",
+ hardware->dmi.system.manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "System Product: %s",
+ hardware->dmi.system.product_name);
+ snprintf(statbuffer, sizeof statbuffer,
+ "System Product Name: %s", hardware->dmi.system.product_name);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "System Serial : %s",
+ hardware->dmi.system.serial);
+ snprintf(statbuffer, sizeof statbuffer,
+ "System Serial Number: %s", hardware->dmi.system.serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+
+ snprintf(buffer, sizeof buffer, "Bios Version : %s",
+ hardware->dmi.bios.version);
+ snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s",
+ hardware->dmi.bios.version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Bios Release : %s",
+ hardware->dmi.bios.release_date);
+ snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s",
+ hardware->dmi.bios.release_date);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
- add_item("", "", OPT_SEP, "", 0);
+ add_item("", "", OPT_SEP, "", 0);
- snprintf(buffer, sizeof buffer, "Nb PCI Devices: %d",
- hardware->nb_pci_devices);
- snprintf(statbuffer, sizeof statbuffer, "Number of PCI Devices: %d",
- hardware->nb_pci_devices);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ snprintf(buffer, sizeof buffer, "Memory Size : %lu MiB (%lu KiB)",
+ (hardware->detected_memory_size + (1 << 9)) >> 10,
+ hardware->detected_memory_size);
+ snprintf(statbuffer, sizeof statbuffer,
+ "Detected Memory Size: %lu MiB (%lu KiB)",
+ (hardware->detected_memory_size + (1 << 9)) >> 10,
+ hardware->detected_memory_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- if (hardware->is_pxe_valid == true) {
add_item("", "", OPT_SEP, "", 0);
- struct s_pxe *p = &hardware->pxe;
-
- snprintf(buffer, sizeof buffer, "PXE MAC Address: %s",
- p->mac_addr);
- snprintf(statbuffer, sizeof statbuffer, "PXE MAC Address: %s",
- p->mac_addr);
+ snprintf(buffer, sizeof buffer, "Nb PCI Devices: %d",
+ hardware->nb_pci_devices);
+ snprintf(statbuffer, sizeof statbuffer, "Number of PCI Devices: %d",
+ hardware->nb_pci_devices);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "PXE IP Address : %d.%d.%d.%d",
- p->ip_addr[0], p->ip_addr[1], p->ip_addr[2],
- p->ip_addr[3]);
- snprintf(statbuffer, sizeof statbuffer,
- "PXE IP Address: %d.%d.%d.%d", p->ip_addr[0],
- p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
+ if (hardware->is_pxe_valid == true) {
+ add_item("", "", OPT_SEP, "", 0);
- if (hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) {
- add_item("", "", OPT_SEP, "", 0);
+ struct s_pxe *p = &hardware->pxe;
+
+ snprintf(buffer, sizeof buffer, "PXE MAC Address: %s", p->mac_addr);
+ snprintf(statbuffer, sizeof statbuffer, "PXE MAC Address: %s",
+ p->mac_addr);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "PXE IP Address : %d.%d.%d.%d",
+ p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
+ snprintf(statbuffer, sizeof statbuffer,
+ "PXE IP Address: %d.%d.%d.%d", p->ip_addr[0],
+ p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
- bool kmod = false;
- struct pci_device *pci_device;
- char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
- MAX_KERNEL_MODULES_PER_PCI_DEVICE];
-
- /*
- * For every detected pci device, grab its kernel module to compute
- * this submenu
- */
- for_each_pci_func(pci_device, hardware->pci_domain) {
- memset(kernel_modules, 0, sizeof kernel_modules);
- for (int i = 0;
- i <
- pci_device->dev_info->linux_kernel_module_count;
- i++) {
- if (i > 0) {
- strncat(kernel_modules, " | ", 3);
- }
- strncat(kernel_modules,
- pci_device->dev_info->
- linux_kernel_module[i],
- LINUX_KERNEL_MODULE_SIZE - 1);
- }
- /* No need to add unknown kernel modules */
- if (strlen(kernel_modules) > 0) {
- snprintf(buffer, sizeof buffer, "%s (%s)",
- kernel_modules,
- pci_device->dev_info->class_name);
- snprintf(statbuffer, sizeof statbuffer,
- "%04x:%04x %s : %s",
- pci_device->vendor,
- pci_device->product,
- pci_device->dev_info->vendor_name,
- pci_device->dev_info->product_name);
-
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL,
- 0);
- menu->items_count++;
- kmod = true;
- }
+ if (hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) {
+ add_item("", "", OPT_SEP, "", 0);
+
+ bool kmod = false;
+ struct pci_device *pci_device;
+ char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
+ MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+
+ /*
+ * For every detected pci device, grab its kernel module to compute
+ * this submenu
+ */
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules, 0, sizeof kernel_modules);
+ for (int i = 0;
+ i < pci_device->dev_info->linux_kernel_module_count; i++) {
+ if (i > 0) {
+ strncat(kernel_modules, " | ", 3);
+ }
+ strncat(kernel_modules,
+ pci_device->dev_info->linux_kernel_module[i],
+ LINUX_KERNEL_MODULE_SIZE - 1);
+ }
+ /* No need to add unknown kernel modules */
+ if (strlen(kernel_modules) > 0) {
+ snprintf(buffer, sizeof buffer, "%s (%s)",
+ kernel_modules, pci_device->dev_info->class_name);
+ snprintf(statbuffer, sizeof statbuffer,
+ "%04x:%04x %s : %s",
+ pci_device->vendor,
+ pci_device->product,
+ pci_device->dev_info->vendor_name,
+ pci_device->dev_info->product_name);
+
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ kmod = true;
+ }
+ }
}
- }
- printf("MENU: Summary menu done (%d items)\n", menu->items_count);
+ printf("MENU: Summary menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu-syslinux.c b/com32/hdt/hdt-menu-syslinux.c
index 758274fe..c85bfbf4 100644
--- a/com32/hdt/hdt-menu-syslinux.c
+++ b/com32/hdt/hdt-menu-syslinux.c
@@ -32,55 +32,51 @@
/* Computing Syslinux menu */
void compute_syslinuxmenu(struct s_my_menu *menu, struct s_hardware *hardware)
{
- char syslinux_fs_menu[24];
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1];
+ char syslinux_fs_menu[24];
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
- memset(syslinux_fs_menu, 0, sizeof syslinux_fs_menu);
+ memset(syslinux_fs_menu, 0, sizeof syslinux_fs_menu);
- snprintf(syslinux_fs_menu, sizeof syslinux_fs_menu, " %s ",
- hardware->syslinux_fs);
- menu->menu = add_menu(syslinux_fs_menu, -1);
- menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
+ snprintf(syslinux_fs_menu, sizeof syslinux_fs_menu, " %s ",
+ hardware->syslinux_fs);
+ menu->menu = add_menu(syslinux_fs_menu, -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
- snprintf(buffer, sizeof buffer, "Bootloader : %s",
- hardware->syslinux_fs);
- snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s",
- hardware->syslinux_fs);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Bootloader : %s", hardware->syslinux_fs);
+ snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s",
+ hardware->syslinux_fs);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer, sizeof buffer, "Version : %s",
- hardware->sv->version_string + 2);
- snprintf(statbuffer, sizeof statbuffer, "Version: %s",
- hardware->sv->version_string + 2);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Version : %s",
+ hardware->sv->version_string + 2);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %s",
+ hardware->sv->version_string + 2);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer, sizeof buffer, "Version : %u",
- hardware->sv->version);
- snprintf(statbuffer, sizeof statbuffer, "Version: %u",
- hardware->sv->version);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Version : %u", hardware->sv->version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %u",
+ hardware->sv->version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer, sizeof buffer, "Max API : %u",
- hardware->sv->max_api);
- snprintf(statbuffer, sizeof statbuffer, "Max API: %u",
- hardware->sv->max_api);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Max API : %u", hardware->sv->max_api);
+ snprintf(statbuffer, sizeof statbuffer, "Max API: %u",
+ hardware->sv->max_api);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- add_item("", "", OPT_SEP, "", 0);
+ add_item("", "", OPT_SEP, "", 0);
- snprintf(buffer, sizeof buffer, "%s",
- hardware->sv->copyright_string + 1);
- /* Remove the trailing LF in the copyright string to avoid scrolling */
- snprintf(statbuffer, sizeof statbuffer, "%s",
- remove_trailing_lf(hardware->sv->copyright_string + 1));
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "%s", hardware->sv->copyright_string + 1);
+ /* Remove the trailing LF in the copyright string to avoid scrolling */
+ snprintf(statbuffer, sizeof statbuffer, "%s",
+ remove_trailing_lf(hardware->sv->copyright_string + 1));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- printf("MENU: Syslinux menu done (%d items)\n", menu->items_count);
+ printf("MENU: Syslinux menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu-vesa.c b/com32/hdt/hdt-menu-vesa.c
index ed03ff22..0fe06ab9 100644
--- a/com32/hdt/hdt-menu-vesa.c
+++ b/com32/hdt/hdt-menu-vesa.c
@@ -28,82 +28,102 @@
#include "hdt-menu.h"
-
/* Submenu for the vesa card */
-static void compute_vesa_card(struct s_my_menu *menu, struct s_hardware *hardware) {
- char buffer[SUBMENULEN+1];
- char statbuffer[STATLEN+1];
+static void compute_vesa_card(struct s_my_menu *menu,
+ struct s_hardware *hardware)
+{
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1];
- menu->menu = add_menu(" VESA Bios ",-1);
- menu->items_count=0;
- set_menu_pos(SUBMENU_Y,SUBMENU_X);
+ menu->menu = add_menu(" VESA Bios ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
- snprintf(buffer,sizeof buffer,"VESA Version: %d.%d",hardware->vesa.major_version,hardware->vesa.minor_version);
- snprintf(statbuffer,sizeof statbuffer,"Version: %d.%d",hardware->vesa.major_version,hardware->vesa.minor_version);
- add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "VESA Version: %d.%d",
+ hardware->vesa.major_version, hardware->vesa.minor_version);
+ snprintf(statbuffer, sizeof statbuffer, "Version: %d.%d",
+ hardware->vesa.major_version, hardware->vesa.minor_version);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer,sizeof buffer,"Vendor : %s",hardware->vesa.vendor);
- snprintf(statbuffer,sizeof statbuffer,"Vendor Name: %s",hardware->vesa.vendor);
- add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Vendor : %s", hardware->vesa.vendor);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor Name: %s",
+ hardware->vesa.vendor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer,sizeof buffer,"Product : %s",hardware->vesa.product);
- snprintf(statbuffer,sizeof statbuffer,"Product Name: %s",hardware->vesa.product);
- add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Product : %s", hardware->vesa.product);
+ snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
+ hardware->vesa.product);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer,sizeof buffer,"Product Rev.: %s",hardware->vesa.product_revision);
- snprintf(statbuffer,sizeof statbuffer,"Produt Revision: %s",hardware->vesa.product_revision);
- add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Product Rev.: %s",
+ hardware->vesa.product_revision);
+ snprintf(statbuffer, sizeof statbuffer, "Produt Revision: %s",
+ hardware->vesa.product_revision);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer,sizeof buffer,"Software Rev: %d",hardware->vesa.software_rev);
- snprintf(statbuffer,sizeof statbuffer,"Software Revision: %d",hardware->vesa.software_rev);
- add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Software Rev: %d",
+ hardware->vesa.software_rev);
+ snprintf(statbuffer, sizeof statbuffer, "Software Revision: %d",
+ hardware->vesa.software_rev);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- snprintf(buffer,sizeof buffer,"Memory (KB) : %d",hardware->vesa.total_memory*64);
- snprintf(statbuffer,sizeof statbuffer,"Memory (KB): %d",hardware->vesa.total_memory*64);
- add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Memory (KB) : %d",
+ hardware->vesa.total_memory * 64);
+ snprintf(statbuffer, sizeof statbuffer, "Memory (KB): %d",
+ hardware->vesa.total_memory * 64);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
}
/* Submenu for the vesa card */
-void compute_vesa_modes(struct s_my_menu *menu, struct s_hardware *hardware) {
- char buffer[56];
- char statbuffer[STATLEN];
+void compute_vesa_modes(struct s_my_menu *menu, struct s_hardware *hardware)
+{
+ char buffer[56];
+ char statbuffer[STATLEN];
- menu->menu = add_menu(" VESA Modes ",-1);
- menu->items_count=0;
- set_menu_pos(SUBMENU_Y,SUBMENU_X);
- for (int i=0;i<hardware->vesa.vmi_count;i++) {
- struct vesa_mode_info *mi=&hardware->vesa.vmi[i].mi;
- /* Sometimes, vesa bios reports 0x0 modes
- * We don't need to display that ones */
- if ((mi->h_res==0) || (mi->v_res==0)) continue;
- snprintf(buffer,sizeof buffer,"%4u x %4u x %2ubits vga=%3d",
- mi->h_res, mi->v_res, mi->bpp, hardware->vesa.vmi[i].mode+0x200);
- snprintf(statbuffer,sizeof statbuffer,"%4ux%4ux%2ubits vga=%3d",
- mi->h_res, mi->v_res, mi->bpp, hardware->vesa.vmi[i].mode+0x200);
- add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0);
- menu->items_count++;
- }
+ menu->menu = add_menu(" VESA Modes ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
+ for (int i = 0; i < hardware->vesa.vmi_count; i++) {
+ struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi;
+ /* Sometimes, vesa bios reports 0x0 modes
+ * We don't need to display that ones */
+ if ((mi->h_res == 0) || (mi->v_res == 0))
+ continue;
+ snprintf(buffer, sizeof buffer, "%4u x %4u x %2ubits vga=%3d",
+ mi->h_res, mi->v_res, mi->bpp,
+ hardware->vesa.vmi[i].mode + 0x200);
+ snprintf(statbuffer, sizeof statbuffer, "%4ux%4ux%2ubits vga=%3d",
+ mi->h_res, mi->v_res, mi->bpp,
+ hardware->vesa.vmi[i].mode + 0x200);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
}
/* Main VESA Menu*/
-int compute_VESA(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware) {
- char buffer[15];
- compute_vesa_card(&hdt_menu->vesa_card_menu,hardware);
- compute_vesa_modes(&hdt_menu->vesa_modes_menu,hardware);
- hdt_menu->vesa_menu.menu = add_menu(" VESA ",-1);
- hdt_menu->vesa_menu.items_count=0;
+int compute_VESA(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
+{
+ char buffer[15];
+ compute_vesa_card(&hdt_menu->vesa_card_menu, hardware);
+ compute_vesa_modes(&hdt_menu->vesa_modes_menu, hardware);
+ hdt_menu->vesa_menu.menu = add_menu(" VESA ", -1);
+ hdt_menu->vesa_menu.items_count = 0;
- add_item("VESA Bios","VESA Bios",OPT_SUBMENU,NULL,hdt_menu->vesa_card_menu.menu);
- hdt_menu->vesa_menu.items_count++;
- snprintf(buffer,sizeof buffer,"%s (%d)","Modes",hardware->vesa.vmi_count);
- add_item(buffer,"VESA Modes",OPT_SUBMENU,NULL,hdt_menu->vesa_modes_menu.menu);
- hdt_menu->vesa_menu.items_count++;
- printf("MENU: VESA menu done (%d items)\n",hdt_menu->vesa_menu.items_count);
- return 0;
+ add_item("VESA Bios", "VESA Bios", OPT_SUBMENU, NULL,
+ hdt_menu->vesa_card_menu.menu);
+ hdt_menu->vesa_menu.items_count++;
+ snprintf(buffer, sizeof buffer, "%s (%d)", "Modes",
+ hardware->vesa.vmi_count);
+ add_item(buffer, "VESA Modes", OPT_SUBMENU, NULL,
+ hdt_menu->vesa_modes_menu.menu);
+ hdt_menu->vesa_menu.items_count++;
+ printf("MENU: VESA menu done (%d items)\n",
+ hdt_menu->vesa_menu.items_count);
+ return 0;
}
diff --git a/com32/hdt/hdt-menu-vpd.c b/com32/hdt/hdt-menu-vpd.c
index 49caf8ea..d77a8235 100644
--- a/com32/hdt/hdt-menu-vpd.c
+++ b/com32/hdt/hdt-menu-vpd.c
@@ -33,82 +33,82 @@
**/
void compute_vpd(struct s_my_menu *menu, struct s_hardware *hardware)
{
- char buffer[SUBMENULEN + 1];
- char statbuffer[STATLEN + 1]; /* Status bar */
+ char buffer[SUBMENULEN + 1];
+ char statbuffer[STATLEN + 1]; /* Status bar */
- menu->menu = add_menu(" VPD ", -1);
- menu->items_count = 0;
- set_menu_pos(SUBMENU_Y, SUBMENU_X);
+ menu->menu = add_menu(" VPD ", -1);
+ menu->items_count = 0;
+ set_menu_pos(SUBMENU_Y, SUBMENU_X);
- snprintf(buffer, sizeof buffer, "Address : %s",
- hardware->vpd.base_address);
- snprintf(statbuffer, sizeof statbuffer, "Address: %s",
- hardware->cpu.vendor);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ snprintf(buffer, sizeof buffer, "Address : %s",
+ hardware->vpd.base_address);
+ snprintf(statbuffer, sizeof statbuffer, "Address: %s",
+ hardware->cpu.vendor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
- if (strlen(hardware->vpd.bios_build_id) > 0) {
- snprintf(buffer, sizeof buffer, "Bios Build ID : %s",
+ if (strlen(hardware->vpd.bios_build_id) > 0) {
+ snprintf(buffer, sizeof buffer, "Bios Build ID : %s",
hardware->vpd.bios_build_id);
- snprintf(statbuffer, sizeof statbuffer, "Bios Build ID: %s",
+ snprintf(statbuffer, sizeof statbuffer, "Bios Build ID: %s",
hardware->vpd.bios_build_id);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
- if (strlen(hardware->vpd.bios_release_date) > 0) {
- snprintf(buffer, sizeof buffer, "Bios Release Date : %s",
+ if (strlen(hardware->vpd.bios_release_date) > 0) {
+ snprintf(buffer, sizeof buffer, "Bios Release Date : %s",
hardware->vpd.bios_release_date);
- snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s",
+ snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s",
hardware->vpd.bios_release_date);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
- if (strlen(hardware->vpd.bios_version) > 0) {
- snprintf(buffer, sizeof buffer, "Bios Version : %s",
+ if (strlen(hardware->vpd.bios_version) > 0) {
+ snprintf(buffer, sizeof buffer, "Bios Version : %s",
hardware->vpd.bios_version);
- snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s",
+ snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s",
hardware->vpd.bios_version);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
- if (strlen(hardware->vpd.default_flash_filename) > 0) {
- snprintf(buffer, sizeof buffer, "Default Flash Filename : %s",
+ if (strlen(hardware->vpd.default_flash_filename) > 0) {
+ snprintf(buffer, sizeof buffer, "Default Flash Filename : %s",
hardware->vpd.default_flash_filename);
- snprintf(statbuffer, sizeof statbuffer, "Default Flash Filename: %s",
+ snprintf(statbuffer, sizeof statbuffer, "Default Flash Filename: %s",
hardware->vpd.default_flash_filename);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
- if (strlen(hardware->vpd.box_serial_number) > 0) {
- snprintf(buffer, sizeof buffer, "Box Serial Number : %s",
+ if (strlen(hardware->vpd.box_serial_number) > 0) {
+ snprintf(buffer, sizeof buffer, "Box Serial Number : %s",
hardware->vpd.box_serial_number);
- snprintf(statbuffer, sizeof statbuffer, "Box Serial Number: %s",
+ snprintf(statbuffer, sizeof statbuffer, "Box Serial Number: %s",
hardware->vpd.box_serial_number);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
- if (strlen(hardware->vpd.motherboard_serial_number) > 0) {
- snprintf(buffer, sizeof buffer, "Motherboard Serial Number: %s",
+ if (strlen(hardware->vpd.motherboard_serial_number) > 0) {
+ snprintf(buffer, sizeof buffer, "Motherboard Serial Number: %s",
hardware->vpd.motherboard_serial_number);
- snprintf(statbuffer, sizeof statbuffer, "Motherboard Serial Number: %s",
+ snprintf(statbuffer, sizeof statbuffer, "Motherboard Serial Number: %s",
hardware->vpd.motherboard_serial_number);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
- if (strlen(hardware->vpd.machine_type_model) > 0) {
- snprintf(buffer, sizeof buffer, "Machine Type/Model : %s",
+ if (strlen(hardware->vpd.machine_type_model) > 0) {
+ snprintf(buffer, sizeof buffer, "Machine Type/Model : %s",
hardware->vpd.machine_type_model);
- snprintf(statbuffer, sizeof statbuffer, "Machine Type/Model: %s",
+ snprintf(statbuffer, sizeof statbuffer, "Machine Type/Model: %s",
hardware->vpd.machine_type_model);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
- printf("MENU: VPD menu done (%d items)\n", menu->items_count);
+ printf("MENU: VPD menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu.c b/com32/hdt/hdt-menu.c
index 6e2b5945..db650fac 100644
--- a/com32/hdt/hdt-menu.c
+++ b/com32/hdt/hdt-menu.c
@@ -32,306 +32,301 @@
int start_menu_mode(struct s_hardware *hardware, char *version_string)
{
- struct s_hdt_menu hdt_menu;
+ struct s_hdt_menu hdt_menu;
- memset(&hdt_menu, 0, sizeof(hdt_menu));
+ memset(&hdt_menu, 0, sizeof(hdt_menu));
- /* Detect every kind of hardware */
- detect_hardware(hardware);
+ /* Detect every kind of hardware */
+ detect_hardware(hardware);
- /* Setup the menu system */
- setup_menu(version_string);
+ /* Setup the menu system */
+ setup_menu(version_string);
- /* Compute all submenus */
- compute_submenus(&hdt_menu, hardware);
+ /* Compute all submenus */
+ compute_submenus(&hdt_menu, hardware);
- /* Compute the main menu */
- compute_main_menu(&hdt_menu, hardware);
+ /* Compute the main menu */
+ compute_main_menu(&hdt_menu, hardware);
#ifdef WITH_MENU_DISPLAY
- t_menuitem *curr;
- char cmd[160];
-
- if (!quiet)
- more_printf("Starting Menu (%d menus)\n", hdt_menu.total_menu_count);
- curr = showmenus(hdt_menu.main_menu.menu);
- /* When we exit the menu, do we have something to do? */
- if (curr) {
- /* When want to execute something */
- if (curr->action == OPT_RUN) {
- /* Tweak, we want to switch to the cli */
- if (!strncmp
- (curr->data, HDT_SWITCH_TO_CLI,
- sizeof(HDT_SWITCH_TO_CLI))) {
- return HDT_RETURN_TO_CLI;
- }
- strcpy(cmd, curr->data);
-
- /* Use specific syslinux call if needed */
- if (issyslinux())
- runsyslinuxcmd(cmd);
- else
- csprint(cmd, 0x07);
- return 1; // Should not happen when run from SYSLINUX
+ t_menuitem *curr;
+ char cmd[160];
+
+ if (!quiet)
+ more_printf("Starting Menu (%d menus)\n", hdt_menu.total_menu_count);
+ curr = showmenus(hdt_menu.main_menu.menu);
+ /* When we exit the menu, do we have something to do? */
+ if (curr) {
+ /* When want to execute something */
+ if (curr->action == OPT_RUN) {
+ /* Tweak, we want to switch to the cli */
+ if (!strncmp
+ (curr->data, HDT_SWITCH_TO_CLI, sizeof(HDT_SWITCH_TO_CLI))) {
+ return HDT_RETURN_TO_CLI;
+ }
+ strcpy(cmd, curr->data);
+
+ /* Use specific syslinux call if needed */
+ if (issyslinux())
+ runsyslinuxcmd(cmd);
+ else
+ csprint(cmd, 0x07);
+ return 1; // Should not happen when run from SYSLINUX
+ }
}
- }
#endif
- return 0;
+ return 0;
}
/* In the menu system, what to do on keyboard timeout */
TIMEOUTCODE ontimeout()
{
- // beep();
- return CODE_WAIT;
+ // beep();
+ return CODE_WAIT;
}
/* Keyboard handler for the menu system */
-void keys_handler(t_menusystem * ms __attribute__ (( unused )), t_menuitem * mi, int scancode)
+void keys_handler(t_menusystem * ms
+ __attribute__ ((unused)), t_menuitem * mi, int scancode)
{
- int nr, nc;
-
- /* 0xFFFF is an invalid helpid */
- if (scancode == KEY_F1 && mi->helpid != 0xFFFF) {
- runhelpsystem(mi->helpid);
- }
-
- /*
- * If user hit TAB, and item is an "executable" item
- * and user has privileges to edit it, edit it in place.
- */
- if ((scancode == KEY_TAB) && (mi->action == OPT_RUN)) {
+ int nr, nc;
+
+ /* 0xFFFF is an invalid helpid */
+ if (scancode == KEY_F1 && mi->helpid != 0xFFFF) {
+ runhelpsystem(mi->helpid);
+ }
+
+ /*
+ * If user hit TAB, and item is an "executable" item
+ * and user has privileges to edit it, edit it in place.
+ */
+ if ((scancode == KEY_TAB) && (mi->action == OPT_RUN)) {
//(isallowed(username,"editcmd") || isallowed(username,"root"))) {
- if (getscreensize(1, &nr, &nc)) {
- /* Unknown screen size? */
- nc = 80;
- nr = 24;
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nc = 80;
+ nr = 24;
+ }
+ /* User typed TAB and has permissions to edit command line */
+ gotoxy(EDITPROMPT, 1);
+ csprint("Command line:", 0x07);
+ editstring(mi->data, ACTIONLEN);
+ gotoxy(EDITPROMPT, 1);
+ cprint(' ', 0x07, nc - 1);
}
- /* User typed TAB and has permissions to edit command line */
- gotoxy(EDITPROMPT, 1);
- csprint("Command line:", 0x07);
- editstring(mi->data, ACTIONLEN);
- gotoxy(EDITPROMPT, 1);
- cprint(' ', 0x07, nc - 1);
- }
}
/* Setup the Menu system */
void setup_menu(char *version)
{
- /* Creating the menu */
- init_menusystem(version);
- set_window_size(0, 0, 25, 80);
+ /* Creating the menu */
+ init_menusystem(version);
+ set_window_size(0, 0, 25, 80);
- /* Do not use inactive attributes - they make little sense for HDT */
- set_normal_attr(-1, -1, 0x17, 0x1F);
+ /* Do not use inactive attributes - they make little sense for HDT */
+ set_normal_attr(-1, -1, 0x17, 0x1F);
- /* Register the menusystem handler */
- // reg_handler(HDLR_SCREEN,&msys_handler);
- reg_handler(HDLR_KEYS, &keys_handler);
+ /* Register the menusystem handler */
+ // reg_handler(HDLR_SCREEN,&msys_handler);
+ reg_handler(HDLR_KEYS, &keys_handler);
- /* Register the ontimeout handler, with a time out of 10 seconds */
- reg_ontimeout(ontimeout, 1000, 0);
+ /* Register the ontimeout handler, with a time out of 10 seconds */
+ reg_ontimeout(ontimeout, 1000, 0);
}
/* Compute Main' submenus */
void compute_submenus(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
{
- /* Compute this menu if a DMI table exists */
- if (hardware->is_dmi_valid) {
- if (hardware->dmi.ipmi.filled == true)
- compute_ipmi(&hdt_menu->ipmi_menu, &hardware->dmi);
- if (hardware->dmi.base_board.filled == true)
- compute_motherboard(&(hdt_menu->mobo_menu),
- &(hardware->dmi));
- if (hardware->dmi.chassis.filled == true)
- compute_chassis(&(hdt_menu->chassis_menu),
- &(hardware->dmi));
- if (hardware->dmi.system.filled == true)
- compute_system(&(hdt_menu->system_menu),
- &(hardware->dmi));
- compute_memory(hdt_menu, &(hardware->dmi),hardware);
- if (hardware->dmi.bios.filled == true)
- compute_bios(&(hdt_menu->bios_menu), &(hardware->dmi));
- if (hardware->dmi.battery.filled == true)
- compute_battery(&(hdt_menu->battery_menu),
- &(hardware->dmi));
- }
-
- compute_processor(&(hdt_menu->cpu_menu), hardware);
- compute_vpd(&(hdt_menu->vpd_menu), hardware);
- compute_disks(hdt_menu, hardware);
+ /* Compute this menu if a DMI table exists */
+ if (hardware->is_dmi_valid) {
+ if (hardware->dmi.ipmi.filled == true)
+ compute_ipmi(&hdt_menu->ipmi_menu, &hardware->dmi);
+ if (hardware->dmi.base_board.filled == true)
+ compute_motherboard(&(hdt_menu->mobo_menu), &(hardware->dmi));
+ if (hardware->dmi.chassis.filled == true)
+ compute_chassis(&(hdt_menu->chassis_menu), &(hardware->dmi));
+ if (hardware->dmi.system.filled == true)
+ compute_system(&(hdt_menu->system_menu), &(hardware->dmi));
+ compute_memory(hdt_menu, &(hardware->dmi), hardware);
+ if (hardware->dmi.bios.filled == true)
+ compute_bios(&(hdt_menu->bios_menu), &(hardware->dmi));
+ if (hardware->dmi.battery.filled == true)
+ compute_battery(&(hdt_menu->battery_menu), &(hardware->dmi));
+ }
+
+ compute_processor(&(hdt_menu->cpu_menu), hardware);
+ compute_vpd(&(hdt_menu->vpd_menu), hardware);
+ compute_disks(hdt_menu, hardware);
#ifdef WITH_PCI
- compute_PCI(hdt_menu, hardware);
- compute_PXE(&(hdt_menu->pxe_menu), hardware);
- compute_kernel(&(hdt_menu->kernel_menu), hardware);
+ compute_PCI(hdt_menu, hardware);
+ compute_PXE(&(hdt_menu->pxe_menu), hardware);
+ compute_kernel(&(hdt_menu->kernel_menu), hardware);
#endif
- compute_summarymenu(&(hdt_menu->summary_menu), hardware);
- compute_syslinuxmenu(&(hdt_menu->syslinux_menu), hardware);
- compute_VESA(hdt_menu,hardware);
- compute_aboutmenu(&(hdt_menu->about_menu));
+ compute_summarymenu(&(hdt_menu->summary_menu), hardware);
+ compute_syslinuxmenu(&(hdt_menu->syslinux_menu), hardware);
+ compute_VESA(hdt_menu, hardware);
+ compute_aboutmenu(&(hdt_menu->about_menu));
}
void compute_main_menu(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
{
- char menu_item[64];
- /* Let's count the number of menus we have */
- hdt_menu->total_menu_count = 0;
- hdt_menu->main_menu.items_count = 0;
+ char menu_item[64];
+ /* Let's count the number of menus we have */
+ hdt_menu->total_menu_count = 0;
+ hdt_menu->main_menu.items_count = 0;
- hdt_menu->main_menu.menu = add_menu(" Main Menu ", -1);
- set_item_options(-1, 24);
+ hdt_menu->main_menu.menu = add_menu(" Main Menu ", -1);
+ set_item_options(-1, 24);
#ifdef WITH_PCI
- snprintf(menu_item, sizeof(menu_item), "PC<I> Devices(%2d)\n",
- hardware->nb_pci_devices);
- add_item(menu_item, "PCI Devices Menu", OPT_SUBMENU, NULL,
- hdt_menu->pci_menu.menu);
- hdt_menu->main_menu.items_count++;
- hdt_menu->total_menu_count += hdt_menu->pci_menu.items_count;
-#endif
- if (hdt_menu->disk_menu.items_count > 0) {
- snprintf(menu_item, sizeof(menu_item), "<D>isks (%2d)\n",
- hdt_menu->disk_menu.items_count);
- add_item(menu_item, "Disks Menu", OPT_SUBMENU, NULL,
- hdt_menu->disk_menu.menu);
+ snprintf(menu_item, sizeof(menu_item), "PC<I> Devices(%2d)\n",
+ hardware->nb_pci_devices);
+ add_item(menu_item, "PCI Devices Menu", OPT_SUBMENU, NULL,
+ hdt_menu->pci_menu.menu);
hdt_menu->main_menu.items_count++;
- hdt_menu->total_menu_count += hdt_menu->disk_menu.items_count;
- }
+ hdt_menu->total_menu_count += hdt_menu->pci_menu.items_count;
+#endif
+ if (hdt_menu->disk_menu.items_count > 0) {
+ snprintf(menu_item, sizeof(menu_item), "<D>isks (%2d)\n",
+ hdt_menu->disk_menu.items_count);
+ add_item(menu_item, "Disks Menu", OPT_SUBMENU, NULL,
+ hdt_menu->disk_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ hdt_menu->total_menu_count += hdt_menu->disk_menu.items_count;
+ }
snprintf(menu_item, sizeof(menu_item), "<M>emory\n");
add_item(menu_item, "Memory Menu", OPT_SUBMENU, NULL,
- hdt_menu->memory_menu.menu);
+ hdt_menu->memory_menu.menu);
hdt_menu->main_menu.items_count++;
hdt_menu->total_menu_count += hdt_menu->memory_menu.items_count;
add_item("<P>rocessor", "Main Processor Menu", OPT_SUBMENU, NULL,
- hdt_menu->cpu_menu.menu);
- hdt_menu->main_menu.items_count++;
-
- if (hardware->is_dmi_valid) {
- if (hardware->dmi.base_board.filled == true) {
- add_item("M<o>therboard", "Motherboard Menu",
- OPT_SUBMENU, NULL, hdt_menu->mobo_menu.menu);
- hdt_menu->main_menu.items_count++;
- }
+ hdt_menu->cpu_menu.menu);
+ hdt_menu->main_menu.items_count++;
- if (hardware->dmi.bios.filled == true) {
- add_item("<B>ios", "Bios Menu", OPT_SUBMENU, NULL,
- hdt_menu->bios_menu.menu);
- hdt_menu->main_menu.items_count++;
+ if (hardware->is_dmi_valid) {
+ if (hardware->dmi.base_board.filled == true) {
+ add_item("M<o>therboard", "Motherboard Menu",
+ OPT_SUBMENU, NULL, hdt_menu->mobo_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+
+ if (hardware->dmi.bios.filled == true) {
+ add_item("<B>ios", "Bios Menu", OPT_SUBMENU, NULL,
+ hdt_menu->bios_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+
+ if (hardware->dmi.chassis.filled == true) {
+ add_item("<C>hassis", "Chassis Menu", OPT_SUBMENU, NULL,
+ hdt_menu->chassis_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+
+ if (hardware->dmi.system.filled == true) {
+ add_item("<S>ystem", "System Menu", OPT_SUBMENU, NULL,
+ hdt_menu->system_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+
+ if (hardware->dmi.battery.filled == true) {
+ add_item("Ba<t>tery", "Battery Menu", OPT_SUBMENU, NULL,
+ hdt_menu->battery_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+ if (hardware->dmi.ipmi.filled == true) {
+ add_item("I<P>MI", "IPMI Menu", OPT_SUBMENU, NULL,
+ hdt_menu->ipmi_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
}
- if (hardware->dmi.chassis.filled == true) {
- add_item("<C>hassis", "Chassis Menu", OPT_SUBMENU, NULL,
- hdt_menu->chassis_menu.menu);
- hdt_menu->main_menu.items_count++;
+ if (hardware->is_vpd_valid == true) {
+ add_item("<V>PD", "VPD Information Menu", OPT_SUBMENU, NULL,
+ hdt_menu->vpd_menu.menu);
+ hdt_menu->main_menu.items_count++;
}
- if (hardware->dmi.system.filled == true) {
- add_item("<S>ystem", "System Menu", OPT_SUBMENU, NULL,
- hdt_menu->system_menu.menu);
- hdt_menu->main_menu.items_count++;
+ if (hardware->is_pxe_valid == true) {
+ add_item("P<X>E", "PXE Information Menu", OPT_SUBMENU, NULL,
+ hdt_menu->pxe_menu.menu);
+ hdt_menu->main_menu.items_count++;
}
- if (hardware->dmi.battery.filled == true) {
- add_item("Ba<t>tery", "Battery Menu", OPT_SUBMENU, NULL,
- hdt_menu->battery_menu.menu);
- hdt_menu->main_menu.items_count++;
- }
- if (hardware->dmi.ipmi.filled == true) {
- add_item("I<P>MI", "IPMI Menu", OPT_SUBMENU, NULL,
- hdt_menu->ipmi_menu.menu);
- hdt_menu->main_menu.items_count++;
+ if (hardware->is_vesa_valid == true) {
+ add_item("<V>ESA", "VESA Information Menu", OPT_SUBMENU, NULL,
+ hdt_menu->vesa_menu.menu);
+ hdt_menu->main_menu.items_count++;
}
- }
-
- if (hardware->is_vpd_valid == true) {
- add_item("<V>PD","VPD Information Menu", OPT_SUBMENU, NULL,
- hdt_menu->vpd_menu.menu);
- hdt_menu->main_menu.items_count++;
- }
- if (hardware->is_pxe_valid == true) {
- add_item("P<X>E", "PXE Information Menu", OPT_SUBMENU, NULL,
- hdt_menu->pxe_menu.menu);
+ add_item("", "", OPT_SEP, "", 0);
+#ifdef WITH_PCI
+ if ((hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) ||
+ (hardware->modules_alias_return_code != -ENOMODULESALIAS)) {
+ add_item("<K>ernel Modules", "Kernel Modules Menu", OPT_SUBMENU,
+ NULL, hdt_menu->kernel_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ }
+#endif
+ add_item("S<y>slinux", "Syslinux Information Menu", OPT_SUBMENU, NULL,
+ hdt_menu->syslinux_menu.menu);
+ hdt_menu->main_menu.items_count++;
+ add_item("S<u>mmary", "Summary Information Menu", OPT_SUBMENU, NULL,
+ hdt_menu->summary_menu.menu);
hdt_menu->main_menu.items_count++;
- }
- if (hardware->is_vesa_valid == true) {
- add_item("<V>ESA","VESA Information Menu", OPT_SUBMENU, NULL,
- hdt_menu->vesa_menu.menu);
- hdt_menu->main_menu.items_count++;
- }
+ add_item("", "", OPT_SEP, "", 0);
- add_item("", "", OPT_SEP, "", 0);
-#ifdef WITH_PCI
- if ((hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) ||
- (hardware->modules_alias_return_code != -ENOMODULESALIAS)) {
- add_item("<K>ernel Modules", "Kernel Modules Menu", OPT_SUBMENU,
- NULL, hdt_menu->kernel_menu.menu);
+ add_item("S<w>itch to CLI", "Switch to Command Line", OPT_RUN,
+ HDT_SWITCH_TO_CLI, 0);
+ add_item("<A>bout", "About Menu", OPT_SUBMENU, NULL,
+ hdt_menu->about_menu.menu);
+ add_item("<R>eboot", "Reboot", OPT_RUN, hardware->reboot_label, 0);
+ add_item("E<x>it", "Exit", OPT_EXITMENU, NULL, 0);
hdt_menu->main_menu.items_count++;
- }
-#endif
- add_item("S<y>slinux", "Syslinux Information Menu", OPT_SUBMENU, NULL,
- hdt_menu->syslinux_menu.menu);
- hdt_menu->main_menu.items_count++;
- add_item("S<u>mmary", "Summary Information Menu", OPT_SUBMENU, NULL,
- hdt_menu->summary_menu.menu);
- hdt_menu->main_menu.items_count++;
-
- add_item("", "", OPT_SEP, "", 0);
-
- add_item("S<w>itch to CLI", "Switch to Command Line", OPT_RUN,
- HDT_SWITCH_TO_CLI, 0);
- add_item("<A>bout", "About Menu", OPT_SUBMENU, NULL,
- hdt_menu->about_menu.menu);
- add_item("<R>eboot", "Reboot", OPT_RUN, hardware->reboot_label, 0);
- add_item("E<x>it","Exit", OPT_EXITMENU,NULL,0);
- hdt_menu->main_menu.items_count++;
-
- hdt_menu->total_menu_count += hdt_menu->main_menu.items_count;
+
+ hdt_menu->total_menu_count += hdt_menu->main_menu.items_count;
}
void detect_hardware(struct s_hardware *hardware)
{
- if (!quiet)
- more_printf("MEMORY: Detecting\n");
- hardware->detected_memory_size = detect_memsize();
-
- if (!quiet)
- more_printf("DMI: Detecting Table\n");
- if (detect_dmi(hardware) == -ENODMITABLE) {
- printf("DMI: ERROR ! Table not found ! \n");
- printf
- ("DMI: Many hardware components will not be detected ! \n");
- } else {
- if (!quiet)
- more_printf("DMI: Table found ! (version %u.%u)\n",
- hardware->dmi.dmitable.major_version,
- hardware->dmi.dmitable.minor_version);
- }
-
- if (!quiet)
- more_printf("CPU: Detecting\n");
- cpu_detect(hardware);
-
- if (!quiet)
- more_printf("DISKS: Detecting\n");
- detect_disks(hardware);
-
- if (!quiet)
- more_printf("VPD: Detecting\n");
- detect_vpd(hardware);
+ if (!quiet)
+ more_printf("MEMORY: Detecting\n");
+ hardware->detected_memory_size = detect_memsize();
+
+ if (!quiet)
+ more_printf("DMI: Detecting Table\n");
+ if (detect_dmi(hardware) == -ENODMITABLE) {
+ printf("DMI: ERROR ! Table not found ! \n");
+ printf("DMI: Many hardware components will not be detected ! \n");
+ } else {
+ if (!quiet)
+ more_printf("DMI: Table found ! (version %u.%u)\n",
+ hardware->dmi.dmitable.major_version,
+ hardware->dmi.dmitable.minor_version);
+ }
+
+ if (!quiet)
+ more_printf("CPU: Detecting\n");
+ cpu_detect(hardware);
+
+ if (!quiet)
+ more_printf("DISKS: Detecting\n");
+ detect_disks(hardware);
+
+ if (!quiet)
+ more_printf("VPD: Detecting\n");
+ detect_vpd(hardware);
#ifdef WITH_PCI
- detect_pci(hardware);
- if (!quiet)
- more_printf("PCI: %d Devices Found\n", hardware->nb_pci_devices);
+ detect_pci(hardware);
+ if (!quiet)
+ more_printf("PCI: %d Devices Found\n", hardware->nb_pci_devices);
#endif
- if (!quiet)
- more_printf("VESA: Detecting\n");
- detect_vesa(hardware);
+ if (!quiet)
+ more_printf("VESA: Detecting\n");
+ detect_vesa(hardware);
}
diff --git a/com32/hdt/hdt-menu.h b/com32/hdt/hdt-menu.h
index 8743da35..f10e5290 100644
--- a/com32/hdt/hdt-menu.h
+++ b/com32/hdt/hdt-menu.h
@@ -51,39 +51,40 @@
#define MAX_DISK_SUB_MENU 32
struct s_my_menu {
- unsigned char menu;
- int items_count;
+ unsigned char menu;
+ int items_count;
};
struct s_hdt_menu {
- struct s_my_menu main_menu;
- struct s_my_menu cpu_menu;
- struct s_my_menu mobo_menu;
- struct s_my_menu chassis_menu;
- struct s_my_menu bios_menu;
- struct s_my_menu ipmi_menu;
- struct s_my_menu system_menu;
- struct s_my_menu pci_menu;
- struct s_my_menu pci_sub_menu[MAX_PCI_SUB_MENU];
- struct s_my_menu kernel_menu;
- struct s_my_menu memory_menu;
- struct s_my_menu memory_sub_menu[MAX_MEMORY_SUB_MENU];
- struct s_my_menu disk_menu;
- struct s_my_menu disk_sub_menu[MAX_DISK_SUB_MENU];
- struct s_my_menu battery_menu;
- struct s_my_menu syslinux_menu;
- struct s_my_menu about_menu;
- struct s_my_menu summary_menu;
- struct s_my_menu pxe_menu;
- struct s_my_menu vesa_menu;
- struct s_my_menu vesa_card_menu;
- struct s_my_menu vesa_modes_menu;
- struct s_my_menu vpd_menu;
- int total_menu_count; // Sum of all menus we have
+ struct s_my_menu main_menu;
+ struct s_my_menu cpu_menu;
+ struct s_my_menu mobo_menu;
+ struct s_my_menu chassis_menu;
+ struct s_my_menu bios_menu;
+ struct s_my_menu ipmi_menu;
+ struct s_my_menu system_menu;
+ struct s_my_menu pci_menu;
+ struct s_my_menu pci_sub_menu[MAX_PCI_SUB_MENU];
+ struct s_my_menu kernel_menu;
+ struct s_my_menu memory_menu;
+ struct s_my_menu memory_sub_menu[MAX_MEMORY_SUB_MENU];
+ struct s_my_menu disk_menu;
+ struct s_my_menu disk_sub_menu[MAX_DISK_SUB_MENU];
+ struct s_my_menu battery_menu;
+ struct s_my_menu syslinux_menu;
+ struct s_my_menu about_menu;
+ struct s_my_menu summary_menu;
+ struct s_my_menu pxe_menu;
+ struct s_my_menu vesa_menu;
+ struct s_my_menu vesa_card_menu;
+ struct s_my_menu vesa_modes_menu;
+ struct s_my_menu vpd_menu;
+ int total_menu_count; // Sum of all menus we have
};
TIMEOUTCODE ontimeout();
-void keys_handler(t_menusystem * ms __attribute__ (( unused )), t_menuitem * mi, int scancode);
+void keys_handler(t_menusystem * ms
+ __attribute__ ((unused)), t_menuitem * mi, int scancode);
// PCI Stuff
int compute_PCI(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware);
@@ -100,7 +101,8 @@ void compute_battery(struct s_my_menu *menu, s_dmi * dmi);
void compute_system(struct s_my_menu *menu, s_dmi * dmi);
void compute_chassis(struct s_my_menu *menu, s_dmi * dmi);
void compute_bios(struct s_my_menu *menu, s_dmi * dmi);
-void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi, struct s_hardware *hardware);
+void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi,
+ struct s_hardware *hardware);
void compute_ipmi(struct s_my_menu *menu, s_dmi * dmi);
// VPD Stuff
@@ -127,7 +129,7 @@ int compute_VESA(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware);
int start_menu_mode(struct s_hardware *hardware, char *version_string);
void setup_menu(char *version);
void compute_main_menu(struct s_hdt_menu *hdt_menu,
- struct s_hardware *hardware);
+ struct s_hardware *hardware);
void compute_submenus(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware);
void detect_hardware(struct s_hardware *hardware);
#endif
diff --git a/com32/hdt/hdt-util.c b/com32/hdt/hdt-util.c
index 5bc566af..f96a943f 100644
--- a/com32/hdt/hdt-util.c
+++ b/com32/hdt/hdt-util.c
@@ -31,41 +31,42 @@
void sectors_to_size(int sectors, char *buffer)
{
- int b = (sectors / 2);
- int mib = b >> 10;
- int gib = mib >> 10;
- int tib = gib >> 10;
+ int b = (sectors / 2);
+ int mib = b >> 10;
+ int gib = mib >> 10;
+ int tib = gib >> 10;
- if (tib > 0)
- sprintf(buffer, "%3d TiB", tib);
- else if (gib > 0)
- sprintf(buffer, "%3d GiB", gib);
- else if (mib > 0)
- sprintf(buffer, "%3d MiB", mib);
- else
- sprintf(buffer, "%d b", b);
+ if (tib > 0)
+ sprintf(buffer, "%3d TiB", tib);
+ else if (gib > 0)
+ sprintf(buffer, "%3d GiB", gib);
+ else if (mib > 0)
+ sprintf(buffer, "%3d MiB", mib);
+ else
+ sprintf(buffer, "%d b", b);
}
-void sectors_to_size_dec(char *previous_unit, int *previous_size, char *unit, int *size, int sectors)
+void sectors_to_size_dec(char *previous_unit, int *previous_size, char *unit,
+ int *size, int sectors)
{
- *size = sectors / 2; // Converting to bytes
- strlcpy(unit, "KB", 2);
- strlcpy(previous_unit, unit, 2);
- *previous_size = *size;
+ *size = sectors / 2; // Converting to bytes
+ strlcpy(unit, "KB", 2);
+ strlcpy(previous_unit, unit, 2);
+ *previous_size = *size;
+ if (*size > 1000) {
+ *size = *size / 1000;
+ strlcpy(unit, "MB", 2);
if (*size > 1000) {
+ *previous_size = *size;
+ *size = *size / 1000;
+ strlcpy(previous_unit, unit, 2);
+ strlcpy(unit, "GB", 2);
+ if (*size > 1000) {
+ *previous_size = *size;
*size = *size / 1000;
- strlcpy(unit, "MB", 2);
- if (*size > 1000) {
- *previous_size = *size;
- *size = *size / 1000;
- strlcpy(previous_unit, unit, 2);
- strlcpy(unit, "GB", 2);
- if (*size > 1000) {
- *previous_size = *size;
- *size = *size / 1000;
- strlcpy(previous_unit, unit, 2);
- strlcpy(unit, "TB", 2);
- }
- }
+ strlcpy(previous_unit, unit, 2);
+ strlcpy(unit, "TB", 2);
+ }
}
+ }
}
diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c
index 66df130e..40323222 100644
--- a/com32/hdt/hdt.c
+++ b/com32/hdt/hdt.c
@@ -42,43 +42,44 @@ int display_line_nb = 0;
bool disable_more_printf = false;
/* Defines the number of lines in the console
* Default is 20 for a std console */
-int max_console_lines=20;
+int max_console_lines = 20;
int main(const int argc, const char *argv[])
{
- char version_string[256];
- const char *arg;
- struct s_hardware hardware;
+ char version_string[256];
+ const char *arg;
+ struct s_hardware hardware;
- snprintf(version_string, sizeof version_string, "%s %s (%s)",
- PRODUCT_NAME,VERSION, CODENAME);
+ snprintf(version_string, sizeof version_string, "%s %s (%s)",
+ PRODUCT_NAME, VERSION, CODENAME);
- /* Cleaning structures */
- init_hardware(&hardware);
+ /* Cleaning structures */
+ init_hardware(&hardware);
- /* Detecting Syslinux version */
- detect_syslinux(&hardware);
+ /* Detecting Syslinux version */
+ detect_syslinux(&hardware);
- /* Detecting parameters */
- detect_parameters(argc, argv, &hardware);
+ /* Detecting parameters */
+ detect_parameters(argc, argv, &hardware);
- /* Opening the Syslinux console */
- init_console(&hardware);
+ /* Opening the Syslinux console */
+ init_console(&hardware);
- /* Clear the screen and reset position of the cursor */
- clear_screen();
- printf("\033[1;1H");
+ /* Clear the screen and reset position of the cursor */
+ clear_screen();
+ printf("\033[1;1H");
- printf("%s\n", version_string);
+ printf("%s\n", version_string);
- if ((arg = find_argument(argv + 1, "nomenu")) || (find_argument(argv+1,"auto")))
- start_cli_mode(&hardware);
- else {
- int return_code = start_menu_mode(&hardware, version_string);
- if (return_code == HDT_RETURN_TO_CLI)
- start_cli_mode(&hardware);
- else
- return return_code;
- }
- return 0;
+ if ((arg = find_argument(argv + 1, "nomenu"))
+ || (find_argument(argv + 1, "auto")))
+ start_cli_mode(&hardware);
+ else {
+ int return_code = start_menu_mode(&hardware, version_string);
+ if (return_code == HDT_RETURN_TO_CLI)
+ start_cli_mode(&hardware);
+ else
+ return return_code;
+ }
+ return 0;
}