Changeset a06075995c5ea9c4c473820cba03033e9c945a41

Show
Ignore:
Timestamp:
11/24/09 09:26:28 (2 years ago)
Author:
Erwan Velu <erwan.velu@…>
Children:
2672e142b4b69ab5161d24261812d3509cb8915b
Parents:
990205b434e7652c835cdb2dd86ef1c43eab7b44, d8cf54da28e566e73809d772a65b8a1cb1b81f9c
git-committer:
Erwan Velu <erwan.velu@free.fr> / 2009-11-24T10:26:28Z+0100
Message:

Merge branch 'master' of  ssh://terminus.zytor.com//pub/git/users/erwan/hdt

Location:
com32
Files:
34 modified

Legend:

Unmodified
Added
Removed
  • com32/gplinclude/memory.h

    rd7ddef rd8cf54  
    4444int detect_memory_e801(int*, int*); 
    4545int detect_memory_88(int*); 
     46 
     47/* The following stuff could be merge once the addr_t will be set to 64bits. 
     48 * syslinux_scan_memory can be used for that purpose */ 
    4649unsigned long memsize_e820(struct e820entry *e820, int e820_nr); 
    4750int sanitize_e820_map(struct e820entry *orig_map, struct e820entry *new_bios, short old_nr); 
  • com32/gpllib/memory.c

    rd7ddef rd8cf54  
    223223 * Some e820 responses include overlapping entries.  The following  
    224224 * replaces the original e820 map with a new one, removing overlaps. 
    225  * 
     225 *  
     226 * The following stuff could be merge once the addr_t will be set to 64bits. 
     227 * syslinux_scan_memory can be used for that purpose  
    226228 */ 
    227229int sanitize_e820_map(struct e820entry *orig_map, struct e820entry *new_bios, 
     
    376378} 
    377379 
     380/* The following stuff could be merge once the addr_t will be set to 64bits. 
     381 * syslinux_scan_memory can be used for that purpose */ 
    378382unsigned long detect_memsize(void) { 
    379383        unsigned long memory_size=0; 
     
    400404} 
    401405 
     406/* The following stuff could be merge once the addr_t will be set to 64bits. 
     407 * syslinux_scan_memory can be used for that purpose */ 
    402408unsigned long memsize_e820(struct e820entry *e820, int e820_nr) { 
    403409        int i, n, nr; 
  • com32/hdt/hdt-ata.h

    rf04655 r990205  
    3535 
    3636struct ata_identify_device { 
    37   unsigned short words000_009[10]; 
    38   unsigned char serial_no[20]; 
    39   unsigned short words020_022[3]; 
    40   unsigned char fw_rev[8]; 
    41   unsigned char model[40]; 
    42   unsigned short words047_079[33]; 
    43   unsigned short major_rev_num; 
    44   unsigned short minor_rev_num; 
    45   unsigned short command_set_1; 
    46   unsigned short command_set_2; 
    47   unsigned short command_set_extension; 
    48   unsigned short cfs_enable_1; 
    49   unsigned short word086; 
    50   unsigned short csf_default; 
    51   unsigned short words088_255[168]; 
     37    unsigned short words000_009[10]; 
     38    unsigned char serial_no[20]; 
     39    unsigned short words020_022[3]; 
     40    unsigned char fw_rev[8]; 
     41    unsigned char model[40]; 
     42    unsigned short words047_079[33]; 
     43    unsigned short major_rev_num; 
     44    unsigned short minor_rev_num; 
     45    unsigned short command_set_1; 
     46    unsigned short command_set_2; 
     47    unsigned short command_set_extension; 
     48    unsigned short cfs_enable_1; 
     49    unsigned short word086; 
     50    unsigned short csf_default; 
     51    unsigned short words088_255[168]; 
    5252} ATTR_PACKED; 
    5353 
    5454struct ata_driveinfo { 
    55   struct ata_identify_device aid; /* IDENTIFY xxx DEVICE data */ 
    56   char host_bus_type[5]; 
    57   char interface_type[9]; 
    58   char interface_port; 
     55    struct ata_identify_device aid;     /* IDENTIFY xxx DEVICE data */ 
     56    char host_bus_type[5]; 
     57    char interface_type[9]; 
     58    char interface_port; 
    5959} ATTR_PACKED; 
    6060 
     
    6262#ifdef ATA 
    6363enum { 
    64   ATA_ID_FW_REV = 23, 
    65   ATA_ID_PROD = 27, 
    66   ATA_ID_FW_REV_LEN = 8, 
    67   ATA_ID_PROD_LEN = 40, 
     64    ATA_ID_FW_REV = 23, 
     65    ATA_ID_PROD = 27, 
     66    ATA_ID_FW_REV_LEN = 8, 
     67    ATA_ID_PROD_LEN = 40, 
    6868}; 
    6969void ata_id_c_string(const uint16_t * id, unsigned char *s, unsigned int ofs, 
    70                      unsigned int len); 
     70                     unsigned int len); 
    7171void ata_id_string(const uint16_t * id, unsigned char *s, unsigned int ofs, 
    72                    unsigned int len); 
     72                   unsigned int len); 
    7373void printregs(const com32sys_t * r); 
    7474#endif 
  • com32/hdt/hdt-cli-cpu.c

    r8ba991 r990205  
    3838                   struct s_hardware *hardware) 
    3939{ 
    40         cpu_detect(hardware); 
    41         detect_dmi(hardware); 
    42         more_printf("CPU\n"); 
    43         more_printf(" Manufacturer : %s \n", hardware->cpu.vendor); 
    44         more_printf(" Product      : %s \n", del_multi_spaces(hardware->cpu.model)); 
    45         if ((hardware->cpu.flags.lm == false) 
    46             && (hardware->cpu.flags.smp == false)) { 
    47                 more_printf(" Features     : %d MhZ : x86 32bits\n", 
    48                             hardware->dmi.processor.current_speed); 
    49         } else if ((hardware->cpu.flags.lm == false) 
    50                    && (hardware->cpu.flags.smp == true)) { 
    51                 more_printf(" Features     : %d MhZ : x86 32bits SMP\n", 
    52                             hardware->dmi.processor.current_speed); 
    53         } else if ((hardware->cpu.flags.lm == true) 
    54                    && (hardware->cpu.flags.smp == false)) { 
    55                 more_printf(" Features     : %d MhZ : x86_64 64bits\n", 
    56                             hardware->dmi.processor.current_speed); 
    57         } else { 
    58                 more_printf(" Features     : %d MhZ : x86_64 64bits SMP\n", 
    59                             hardware->dmi.processor.current_speed); 
    60         } 
     40    cpu_detect(hardware); 
     41    detect_dmi(hardware); 
     42    more_printf("CPU\n"); 
     43    more_printf(" Manufacturer : %s \n", hardware->cpu.vendor); 
     44    more_printf(" Product      : %s \n", del_multi_spaces(hardware->cpu.model)); 
     45    if ((hardware->cpu.flags.lm == false) 
     46        && (hardware->cpu.flags.smp == false)) { 
     47        more_printf(" Features     : %d MhZ : x86 32bits\n", 
     48                    hardware->dmi.processor.current_speed); 
     49    } else if ((hardware->cpu.flags.lm == false) 
     50               && (hardware->cpu.flags.smp == true)) { 
     51        more_printf(" Features     : %d MhZ : x86 32bits SMP\n", 
     52                    hardware->dmi.processor.current_speed); 
     53    } else if ((hardware->cpu.flags.lm == true) 
     54               && (hardware->cpu.flags.smp == false)) { 
     55        more_printf(" Features     : %d MhZ : x86_64 64bits\n", 
     56                    hardware->dmi.processor.current_speed); 
     57    } else { 
     58        more_printf(" Features     : %d MhZ : x86_64 64bits SMP\n", 
     59                    hardware->dmi.processor.current_speed); 
     60    } 
    6161} 
    6262 
     
    6464                     struct s_hardware *hardware) 
    6565{ 
    66         char buffer[81]; 
    67         char buffer1[81]; 
    68         reset_more_printf(); 
    69         more_printf("CPU\n"); 
    70         more_printf("Vendor    : %s\n", hardware->cpu.vendor); 
    71         more_printf("Model     : %s\n", hardware->cpu.model); 
    72         more_printf("Vendor ID : %d\n", hardware->cpu.vendor_id); 
    73         more_printf("Family ID : %d\n", hardware->cpu.family); 
    74         more_printf("Model  ID : %d\n", hardware->cpu.model_id); 
    75         more_printf("Stepping  : %d\n", hardware->cpu.stepping); 
    76         more_printf("FSB       : %d MHz\n", 
    77                     hardware->dmi.processor.external_clock); 
    78         more_printf("Cur. Speed: %d MHz\n", 
    79                     hardware->dmi.processor.current_speed); 
    80         more_printf("Max Speed : %d MHz\n", hardware->dmi.processor.max_speed); 
    81         more_printf("Upgrade   : %s\n", hardware->dmi.processor.upgrade); 
    82         if (hardware->cpu.flags.smp) { 
    83                 more_printf("SMP       : yes\n"); 
    84         } else { 
    85                 more_printf("SMP       : no\n"); 
    86         } 
    87         if (hardware->cpu.flags.lm) { 
    88                 more_printf("x86_64    : yes\n"); 
    89         } else { 
    90                 more_printf("x86_64    : no\n"); 
    91         } 
     66    char buffer[81]; 
     67    char buffer1[81]; 
     68    reset_more_printf(); 
     69    more_printf("CPU\n"); 
     70    more_printf("Vendor    : %s\n", hardware->cpu.vendor); 
     71    more_printf("Model     : %s\n", hardware->cpu.model); 
     72    more_printf("Vendor ID : %d\n", hardware->cpu.vendor_id); 
     73    more_printf("Family ID : %d\n", hardware->cpu.family); 
     74    more_printf("Model  ID : %d\n", hardware->cpu.model_id); 
     75    more_printf("Stepping  : %d\n", hardware->cpu.stepping); 
     76    more_printf("FSB       : %d MHz\n", hardware->dmi.processor.external_clock); 
     77    more_printf("Cur. Speed: %d MHz\n", hardware->dmi.processor.current_speed); 
     78    more_printf("Max Speed : %d MHz\n", hardware->dmi.processor.max_speed); 
     79    more_printf("Upgrade   : %s\n", hardware->dmi.processor.upgrade); 
     80    if (hardware->cpu.flags.smp) { 
     81        more_printf("SMP       : yes\n"); 
     82    } else { 
     83        more_printf("SMP       : no\n"); 
     84    } 
     85    if (hardware->cpu.flags.lm) { 
     86        more_printf("x86_64    : yes\n"); 
     87    } else { 
     88        more_printf("x86_64    : no\n"); 
     89    } 
    9290 
    93         memset(buffer, 0, sizeof(buffer)); 
    94         memset(buffer1, 0, sizeof(buffer1)); 
    95         if (hardware->cpu.flags.fpu) 
    96                 strcat(buffer1, "fpu "); 
    97         if (hardware->cpu.flags.vme) 
    98                 strcat(buffer1, "vme "); 
    99         if (hardware->cpu.flags.de) 
    100                 strcat(buffer1, "de "); 
    101         if (hardware->cpu.flags.pse) 
    102                 strcat(buffer1, "pse "); 
    103         if (hardware->cpu.flags.tsc) 
    104                 strcat(buffer1, "tsc "); 
    105         if (hardware->cpu.flags.msr) 
    106                 strcat(buffer1, "msr "); 
    107         if (hardware->cpu.flags.pae) 
    108                 strcat(buffer1, "pae "); 
    109         if (hardware->cpu.flags.mce) 
    110                 strcat(buffer1, "mce "); 
    111         if (hardware->cpu.flags.cx8) 
    112                 strcat(buffer1, "cx8 "); 
    113         if (hardware->cpu.flags.apic) 
    114                 strcat(buffer1, "apic "); 
    115         if (hardware->cpu.flags.sep) 
    116                 strcat(buffer1, "sep "); 
    117         if (hardware->cpu.flags.mtrr) 
    118                 strcat(buffer1, "mtrr "); 
    119         if (hardware->cpu.flags.pge) 
    120                 strcat(buffer1, "pge "); 
    121         if (hardware->cpu.flags.mca) 
    122                 strcat(buffer1, "mca "); 
    123         if (buffer1[0]) { 
    124                 snprintf(buffer, sizeof buffer, "Flags     : %s\n", buffer1); 
    125                 more_printf(buffer); 
    126         } 
     91    memset(buffer, 0, sizeof(buffer)); 
     92    memset(buffer1, 0, sizeof(buffer1)); 
     93    if (hardware->cpu.flags.fpu) 
     94        strcat(buffer1, "fpu "); 
     95    if (hardware->cpu.flags.vme) 
     96        strcat(buffer1, "vme "); 
     97    if (hardware->cpu.flags.de) 
     98        strcat(buffer1, "de "); 
     99    if (hardware->cpu.flags.pse) 
     100        strcat(buffer1, "pse "); 
     101    if (hardware->cpu.flags.tsc) 
     102        strcat(buffer1, "tsc "); 
     103    if (hardware->cpu.flags.msr) 
     104        strcat(buffer1, "msr "); 
     105    if (hardware->cpu.flags.pae) 
     106        strcat(buffer1, "pae "); 
     107    if (hardware->cpu.flags.mce) 
     108        strcat(buffer1, "mce "); 
     109    if (hardware->cpu.flags.cx8) 
     110        strcat(buffer1, "cx8 "); 
     111    if (hardware->cpu.flags.apic) 
     112        strcat(buffer1, "apic "); 
     113    if (hardware->cpu.flags.sep) 
     114        strcat(buffer1, "sep "); 
     115    if (hardware->cpu.flags.mtrr) 
     116        strcat(buffer1, "mtrr "); 
     117    if (hardware->cpu.flags.pge) 
     118        strcat(buffer1, "pge "); 
     119    if (hardware->cpu.flags.mca) 
     120        strcat(buffer1, "mca "); 
     121    if (buffer1[0]) { 
     122        snprintf(buffer, sizeof buffer, "Flags     : %s\n", buffer1); 
     123        more_printf(buffer); 
     124    } 
    127125 
    128         memset(buffer, 0, sizeof(buffer)); 
    129         memset(buffer1, 0, sizeof(buffer1)); 
    130         if (hardware->cpu.flags.cmov) 
    131                 strcat(buffer1, "cmov "); 
    132         if (hardware->cpu.flags.pat) 
    133                 strcat(buffer1, "pat "); 
    134         if (hardware->cpu.flags.pse_36) 
    135                 strcat(buffer1, "pse_36 "); 
    136         if (hardware->cpu.flags.psn) 
    137                 strcat(buffer1, "psn "); 
    138         if (hardware->cpu.flags.clflsh) 
    139                 strcat(buffer1, "clflsh "); 
    140         if (hardware->cpu.flags.dts) 
    141                 strcat(buffer1, "dts "); 
    142         if (hardware->cpu.flags.acpi) 
    143                 strcat(buffer1, "acpi "); 
    144         if (hardware->cpu.flags.mmx) 
    145                 strcat(buffer1, "mmx "); 
    146         if (hardware->cpu.flags.sse) 
    147                 strcat(buffer1, "sse "); 
    148         if (hardware->cpu.flags.sse2) 
    149                 strcat(buffer1, "sse2 "); 
    150         if (hardware->cpu.flags.ss) 
    151                 strcat(buffer1, "ss "); 
    152         if (buffer1[0]) { 
    153                 snprintf(buffer, sizeof buffer, "Flags     : %s\n", buffer1); 
    154                 more_printf(buffer); 
    155         } 
     126    memset(buffer, 0, sizeof(buffer)); 
     127    memset(buffer1, 0, sizeof(buffer1)); 
     128    if (hardware->cpu.flags.cmov) 
     129        strcat(buffer1, "cmov "); 
     130    if (hardware->cpu.flags.pat) 
     131        strcat(buffer1, "pat "); 
     132    if (hardware->cpu.flags.pse_36) 
     133        strcat(buffer1, "pse_36 "); 
     134    if (hardware->cpu.flags.psn) 
     135        strcat(buffer1, "psn "); 
     136    if (hardware->cpu.flags.clflsh) 
     137        strcat(buffer1, "clflsh "); 
     138    if (hardware->cpu.flags.dts) 
     139        strcat(buffer1, "dts "); 
     140    if (hardware->cpu.flags.acpi) 
     141        strcat(buffer1, "acpi "); 
     142    if (hardware->cpu.flags.mmx) 
     143        strcat(buffer1, "mmx "); 
     144    if (hardware->cpu.flags.sse) 
     145        strcat(buffer1, "sse "); 
     146    if (hardware->cpu.flags.sse2) 
     147        strcat(buffer1, "sse2 "); 
     148    if (hardware->cpu.flags.ss) 
     149        strcat(buffer1, "ss "); 
     150    if (buffer1[0]) { 
     151        snprintf(buffer, sizeof buffer, "Flags     : %s\n", buffer1); 
     152        more_printf(buffer); 
     153    } 
    156154 
    157         memset(buffer, 0, sizeof(buffer)); 
    158         memset(buffer1, 0, sizeof(buffer1)); 
    159         if (hardware->cpu.flags.htt) 
    160                 strcat(buffer1, "ht "); 
    161         if (hardware->cpu.flags.acc) 
    162                 strcat(buffer1, "acc "); 
    163         if (hardware->cpu.flags.syscall) 
    164                 strcat(buffer1, "syscall "); 
    165         if (hardware->cpu.flags.mp) 
    166                 strcat(buffer1, "mp "); 
    167         if (hardware->cpu.flags.nx) 
    168                 strcat(buffer1, "nx "); 
    169         if (hardware->cpu.flags.mmxext) 
    170                 strcat(buffer1, "mmxext "); 
    171         if (hardware->cpu.flags.lm) 
    172                 strcat(buffer1, "lm "); 
    173         if (hardware->cpu.flags.nowext) 
    174                 strcat(buffer1, "3dnowext "); 
    175         if (hardware->cpu.flags.now) 
    176                 strcat(buffer1, "3dnow! "); 
    177         if (hardware->cpu.flags.svm) 
    178                 strcat(buffer1, "svm "); 
    179         if (hardware->cpu.flags.vmx) 
    180                 strcat(buffer1, "vmx "); 
    181         if (buffer1[0]) { 
    182                 snprintf(buffer, sizeof buffer, "Flags     : %s\n", buffer1); 
    183                 more_printf(buffer); 
    184         } 
     155    memset(buffer, 0, sizeof(buffer)); 
     156    memset(buffer1, 0, sizeof(buffer1)); 
     157    if (hardware->cpu.flags.htt) 
     158        strcat(buffer1, "ht "); 
     159    if (hardware->cpu.flags.acc) 
     160        strcat(buffer1, "acc "); 
     161    if (hardware->cpu.flags.syscall) 
     162        strcat(buffer1, "syscall "); 
     163    if (hardware->cpu.flags.mp) 
     164        strcat(buffer1, "mp "); 
     165    if (hardware->cpu.flags.nx) 
     166        strcat(buffer1, "nx "); 
     167    if (hardware->cpu.flags.mmxext) 
     168        strcat(buffer1, "mmxext "); 
     169    if (hardware->cpu.flags.lm) 
     170        strcat(buffer1, "lm "); 
     171    if (hardware->cpu.flags.nowext) 
     172        strcat(buffer1, "3dnowext "); 
     173    if (hardware->cpu.flags.now) 
     174        strcat(buffer1, "3dnow! "); 
     175    if (hardware->cpu.flags.svm) 
     176        strcat(buffer1, "svm "); 
     177    if (hardware->cpu.flags.vmx) 
     178        strcat(buffer1, "vmx "); 
     179    if (buffer1[0]) { 
     180        snprintf(buffer, sizeof buffer, "Flags     : %s\n", buffer1); 
     181        more_printf(buffer); 
     182    } 
    185183} 
    186184 
    187185struct cli_module_descr cpu_show_modules = { 
    188         .modules = NULL, 
    189         .default_callback = show_cpu, 
     186    .modules = NULL, 
     187    .default_callback = show_cpu, 
    190188}; 
    191189 
    192190struct cli_mode_descr cpu_mode = { 
    193         .mode = CPU_MODE, 
    194         .name = CLI_CPU, 
    195         .default_modules = NULL, 
    196         .show_modules = &cpu_show_modules, 
    197         .set_modules = NULL, 
     191    .mode = CPU_MODE, 
     192    .name = CLI_CPU, 
     193    .default_modules = NULL, 
     194    .show_modules = &cpu_show_modules, 
     195    .set_modules = NULL, 
    198196}; 
  • com32/hdt/hdt-cli-disk.c

    r1682c7 r990205  
    5656                                       int nb_partitions_seen) 
    5757{ 
    58         char size[9]; 
    59         char bootloader_name[9]; 
    60         char *parttype; 
    61         unsigned int start, end; 
    62  
    63         int i = nb_partitions_seen; 
    64  
    65     reset_more_printf(); 
    66  
    67         start = partition_offset; 
    68         end = start + ptab->length - 1; 
    69  
    70         if (ptab->length > 0) 
    71                 sectors_to_size(ptab->length, size); 
    72         else 
    73                 memset(size, 0, sizeof size); 
    74  
    75         if (i == 1) 
    76                 more_printf(" #  B       Start         End    Size Id Type\n"); 
    77  
    78         get_label(ptab->ostype, &parttype); 
    79         more_printf("%2d  %s %11d %11d %s %02X %s", 
    80                     i, (ptab->active_flag == 0x80) ? "x" : " ", 
    81                     start, 
    82                     end, 
    83                     size, 
    84                     ptab->ostype, parttype); 
    85  
    86         /* Extra info */ 
    87         if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab)) 
    88                 more_printf("%s", " (Swsusp sig. detected)"); 
    89  
    90         if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0) 
    91                 more_printf("%-46s %s %s", " ", "Bootloader:", bootloader_name); 
    92  
    93         more_printf("\n"); 
    94  
    95         free(parttype); 
    96 } 
    97  
    98 void main_show_disk(int argc, char **argv, 
    99                     struct s_hardware *hardware) 
    100 { 
    101         if (!argc) { 
    102                 more_printf("Which disk?\n"); 
    103                 return; 
     58    char size[9]; 
     59    char bootloader_name[9]; 
     60    char *parttype; 
     61    unsigned int start, end; 
     62 
     63    int i = nb_partitions_seen; 
     64 
     65    reset_more_printf(); 
     66 
     67    start = partition_offset; 
     68    end = start + ptab->length - 1; 
     69 
     70    if (ptab->length > 0) 
     71        sectors_to_size(ptab->length, size); 
     72    else 
     73        memset(size, 0, sizeof size); 
     74 
     75    if (i == 1) 
     76        more_printf(" #  B       Start         End    Size Id Type\n"); 
     77 
     78    get_label(ptab->ostype, &parttype); 
     79    more_printf("%2d  %s %11d %11d %s %02X %s", 
     80                i, (ptab->active_flag == 0x80) ? "x" : " ", 
     81                start, end, size, ptab->ostype, parttype); 
     82 
     83    /* Extra info */ 
     84    if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab)) 
     85        more_printf("%s", " (Swsusp sig. detected)"); 
     86 
     87    if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0) 
     88        more_printf("%-46s %s %s", " ", "Bootloader:", bootloader_name); 
     89 
     90    more_printf("\n"); 
     91 
     92    free(parttype); 
     93} 
     94 
     95void main_show_disk(int argc, char **argv, struct s_hardware *hardware) 
     96{ 
     97    if (!argc) { 
     98        more_printf("Which disk?\n"); 
     99        return; 
     100    } 
     101 
     102    int drive = strtol(argv[0], (char **)NULL, 16); 
     103 
     104    if (drive < 0x80 || drive >= 0xff) { 
     105        more_printf("Invalid disk: %d.\n", drive); 
     106        return; 
     107    } 
     108 
     109    int i = drive - 0x80; 
     110    struct driveinfo *d = &hardware->disk_info[i]; 
     111    char disk_size[9]; 
     112    char mbr_name[50]; 
     113 
     114    detect_disks(hardware); 
     115    reset_more_printf(); 
     116 
     117    if (!hardware->disk_info[i].cbios) 
     118        return;                 /* Invalid geometry */ 
     119 
     120    get_mbr_string(hardware->mbr_ids[i], &mbr_name, 50); 
     121 
     122    if ((int)d->edd_params.sectors > 0) 
     123        sectors_to_size((int)d->edd_params.sectors, disk_size); 
     124    else 
     125        memset(disk_size, 0, sizeof disk_size); 
     126 
     127    more_printf("DISK 0x%X:\n" 
     128                "  C/H/S: %d cylinders, %d heads, %d sectors/track\n" 
     129                "    EDD: Version: %X\n" 
     130                "         Size: %s, %d bytes/sector, %d sectors/track\n" 
     131                "         Host bus: %s, Interface type: %s\n" 
     132                "    MBR: %s (id 0x%X)\n\n", 
     133                d->disk, 
     134                d->legacy_max_cylinder + 1, d->legacy_max_head + 1, 
     135                d->legacy_sectors_per_track, d->edd_version, disk_size, 
     136                (int)d->edd_params.bytes_per_sector, 
     137                (int)d->edd_params.sectors_per_track, 
     138                remove_spaces((char *)d->edd_params.host_bus_type), 
     139                remove_spaces((char *)d->edd_params.interface_type), mbr_name, 
     140                hardware->mbr_ids[i]); 
     141    display_line_nb += 6; 
     142 
     143    if (parse_partition_table(d, &show_partition_information)) { 
     144        if (errno_disk) { 
     145            fprintf(stderr, "I/O error parsing disk 0x%X\n", d->disk); 
     146            get_error("parse_partition_table"); 
     147        } else { 
     148            fprintf(stderr, "Disk 0x%X: unrecognized partition layout\n", 
     149                    d->disk); 
    104150        } 
    105  
    106         int drive = strtol(argv[0], (char**) NULL, 16); 
    107  
    108         if (drive < 0x80 || drive >= 0xff) { 
    109                 more_printf("Invalid disk: %d.\n", drive); 
    110                 return; 
     151        fprintf(stderr, "\n"); 
     152    } 
     153 
     154    more_printf("\n"); 
     155} 
     156 
     157void main_show_disks(int argc __unused, char **argv __unused, 
     158                     struct s_hardware *hardware) 
     159{ 
     160    reset_more_printf(); 
     161    detect_disks(hardware); 
     162 
     163    int first_one = 0; 
     164    for (int drive = 0x80; drive < 0xff; drive++) { 
     165        if (hardware->disk_info[drive - 0x80].cbios) { 
     166            if (!first_one) { 
     167                first_one = 1; 
     168            } else { 
     169                pause_printf(); 
     170            } 
     171            char buf[5] = ""; 
     172            sprintf(buf, "0x%x", drive); 
     173            char *argv[1] = { buf }; 
     174            main_show_disk(1, argv, hardware); 
    111175        } 
    112  
    113         int i = drive - 0x80; 
     176    } 
     177} 
     178 
     179void disks_summary(int argc __unused, char **argv __unused, 
     180                   struct s_hardware *hardware) 
     181{ 
     182    int i = -1; 
     183 
     184    detect_disks(hardware); 
     185    reset_more_printf(); 
     186 
     187    for (int drive = 0x80; drive < 0xff; drive++) { 
     188        i++; 
     189        if (!hardware->disk_info[i].cbios) 
     190            continue;           /* Invalid geometry */ 
    114191        struct driveinfo *d = &hardware->disk_info[i]; 
    115192        char disk_size[9]; 
    116         char mbr_name[50]; 
    117  
    118         detect_disks(hardware); 
    119     reset_more_printf(); 
    120  
    121         if (!hardware->disk_info[i].cbios) 
    122                 return; /* Invalid geometry */ 
    123  
    124         get_mbr_string(hardware->mbr_ids[i], &mbr_name, 50); 
    125  
    126         if ((int) d->edd_params.sectors > 0) 
    127                 sectors_to_size((int) d->edd_params.sectors, disk_size); 
     193 
     194        if ((int)d->edd_params.sectors > 0) 
     195            sectors_to_size((int)d->edd_params.sectors, disk_size); 
    128196        else 
    129                 memset(disk_size, 0, sizeof disk_size); 
    130  
    131         more_printf("DISK 0x%X:\n" 
    132                     "  C/H/S: %d cylinders, %d heads, %d sectors/track\n" 
    133                     "    EDD: Version: %X\n" 
    134                     "         Size: %s, %d bytes/sector, %d sectors/track\n" 
    135                     "         Host bus: %s, Interface type: %s\n" 
    136                     "    MBR: %s (id 0x%X)\n\n", 
    137                 d->disk, 
    138                 d->legacy_max_cylinder + 1, d->legacy_max_head + 1, d->legacy_sectors_per_track, 
    139                 d->edd_version, 
    140                 disk_size, (int) d->edd_params.bytes_per_sector, (int) d->edd_params.sectors_per_track, 
    141                 remove_spaces((char *) d->edd_params.host_bus_type), remove_spaces((char*) d->edd_params.interface_type), 
    142                 mbr_name, hardware->mbr_ids[i]); 
    143         display_line_nb += 6; 
    144  
    145         if (parse_partition_table(d, &show_partition_information)) { 
    146                 if (errno_disk) { 
    147                         fprintf(stderr, "I/O error parsing disk 0x%X\n", d->disk); 
    148                         get_error("parse_partition_table"); 
    149                 } else { 
    150                         fprintf(stderr, "Disk 0x%X: unrecognized partition layout\n", d->disk); 
    151                 } 
    152                 fprintf(stderr, "\n"); 
    153         } 
    154  
    155         more_printf("\n"); 
    156 } 
    157  
    158 void main_show_disks(int argc __unused, char **argv __unused, 
    159                      struct s_hardware *hardware) 
    160 { 
    161         reset_more_printf(); 
    162         detect_disks(hardware); 
    163  
    164     int first_one = 0; 
    165         for (int drive = 0x80; drive < 0xff; drive++) { 
    166                 if (hardware->disk_info[drive - 0x80].cbios) { 
    167             if (!first_one) { 
    168                     first_one = 1; 
    169             } else { 
    170                     pause_printf(); 
    171             } 
    172                         char buf[5] = ""; 
    173                         sprintf(buf, "0x%x", drive); 
    174                         char *argv[1] = { buf }; 
    175                         main_show_disk(1, argv, hardware); 
    176                 } 
    177         } 
    178 } 
    179  
    180 void disks_summary(int argc __unused, char** argv __unused, 
    181                    struct s_hardware *hardware) 
    182 { 
    183         int i = -1; 
    184  
    185         detect_disks(hardware); 
    186         reset_more_printf(); 
    187  
    188         for (int drive = 0x80; drive < 0xff; drive++) { 
    189                 i++; 
    190                 if (!hardware->disk_info[i].cbios) 
    191                         continue; /* Invalid geometry */ 
    192                 struct driveinfo *d = &hardware->disk_info[i]; 
    193                 char disk_size[9]; 
    194  
    195                 if ((int) d->edd_params.sectors > 0) 
    196                         sectors_to_size((int) d->edd_params.sectors, disk_size); 
    197                 else 
    198                         memset(disk_size, 0, sizeof disk_size); 
    199  
    200                 more_printf("DISK 0x%X:\n", d->disk); 
    201                 more_printf("  C/H/S: %d cylinders, %d heads, %d sectors/track\n", 
    202                         d->legacy_max_cylinder + 1, d->legacy_max_head + 1, 
    203                         d->legacy_sectors_per_track); 
    204                 more_printf("  EDD:   Version: %X, size: %s\n", d->edd_version, 
    205                         disk_size); 
    206                 more_printf("         Host bus: %s, Interface type: %s\n\n", 
    207                         remove_spaces((char*) d->edd_params.host_bus_type), 
    208                         remove_spaces((char*) d->edd_params.interface_type)); 
    209         } 
     197            memset(disk_size, 0, sizeof disk_size); 
     198 
     199        more_printf("DISK 0x%X:\n", d->disk); 
     200        more_printf("  C/H/S: %d cylinders, %d heads, %d sectors/track\n", 
     201                    d->legacy_max_cylinder + 1, d->legacy_max_head + 1, 
     202                    d->legacy_sectors_per_track); 
     203        more_printf("  EDD:   Version: %X, size: %s\n", d->edd_version, 
     204                    disk_size); 
     205        more_printf("         Host bus: %s, Interface type: %s\n\n", 
     206                    remove_spaces((char *)d->edd_params.host_bus_type), 
     207                    remove_spaces((char *)d->edd_params.interface_type)); 
     208    } 
    210209} 
    211210 
    212211struct cli_callback_descr list_disk_show_modules[] = { 
    213         { 
    214                 .name = "disks", 
    215                 .exec = main_show_disks, 
    216         }, 
    217         { 
    218                 .name = "disk", 
    219                 .exec = main_show_disk, 
    220         }, 
    221         { 
    222                 .name = NULL, 
    223                 .exec = NULL, 
    224         }, 
     212    { 
     213     .name = "disks", 
     214     .exec = main_show_disks, 
     215     }, 
     216    { 
     217     .name = "disk", 
     218     .exec = main_show_disk, 
     219     }, 
     220    { 
     221     .name = NULL, 
     222     .exec = NULL, 
     223     }, 
    225224}; 
    226225 
    227226struct cli_module_descr disk_show_modules = { 
    228         .modules = list_disk_show_modules, 
    229         .default_callback = disks_summary, 
     227    .modules = list_disk_show_modules, 
     228    .default_callback = disks_summary, 
    230229}; 
    231230 
    232231struct cli_mode_descr disk_mode = { 
    233         .mode = DISK_MODE, 
    234         .name = CLI_DISK, 
    235         .default_modules = NULL, 
    236         .show_modules = &disk_show_modules, 
    237         .set_modules = NULL, 
     232    .mode = DISK_MODE, 
     233    .name = CLI_DISK, 
     234    .default_modules = NULL, 
     235    .show_modules = &disk_show_modules, 
     236    .set_modules = NULL, 
    238237}; 
  • com32/hdt/hdt-cli-dmi.c

    r06a7af r990205  
    3535#include "hdt-common.h" 
    3636 
    37 static void show_dmi_modules(int argc __unused, char** argv __unused, 
    38                              struct s_hardware *hardware) 
    39 { 
    40   char available_dmi_commands[1024]; 
    41   reset_more_printf(); 
    42   memset(available_dmi_commands, 0, sizeof(available_dmi_commands)); 
    43  
    44   more_printf("Available DMI modules on your system:\n"); 
    45         if (hardware->dmi.base_board.filled == true) 
    46                 more_printf("\t%s\n", CLI_DMI_BASE_BOARD); 
    47         if (hardware->dmi.battery.filled == true) 
    48                 more_printf("\t%s\n", CLI_DMI_BATTERY); 
    49         if (hardware->dmi.bios.filled == true) 
    50                 more_printf("\t%s\n", CLI_DMI_BIOS); 
    51         if (hardware->dmi.chassis.filled == true) 
    52                 more_printf("\t%s\n", CLI_DMI_CHASSIS); 
    53         for (int i = 0; i < hardware->dmi.memory_count; i++) { 
    54                 if (hardware->dmi.memory[i].filled == true) { 
    55                         more_printf("\tbank <number>\n"); 
    56                         break; 
    57                 } 
    58         } 
    59         for (int i = 0; i < hardware->dmi.memory_module_count; i++) { 
    60                 if (hardware->dmi.memory_module[i].filled == true) { 
    61                         more_printf("\tmodule <number>\n"); 
    62                         break; 
    63                 } 
    64         } 
    65         if (hardware->dmi.processor.filled == true) 
    66                 more_printf("\t%s\n", CLI_DMI_PROCESSOR); 
    67         if (hardware->dmi.system.filled == true) 
    68                 more_printf("\t%s\n", CLI_DMI_SYSTEM); 
    69         if (hardware->dmi.ipmi.filled == true) 
    70                 more_printf("\t%s\n", CLI_DMI_IPMI); 
    71         if (hardware->dmi.cache_count) 
    72                 more_printf("\t%s\n", CLI_DMI_CACHE); 
    73         if (strlen(hardware->dmi.oem_strings)) 
    74                 more_printf("\t%s\n", CLI_DMI_OEM); 
    75         if (hardware->dmi.hardware_security.filled) 
    76                 more_printf("\t%s\n", CLI_DMI_SECURITY); 
    77 } 
    78  
    79 static void show_dmi_base_board(int argc __unused, char** argv __unused, 
    80                                 struct s_hardware *hardware) 
    81 { 
    82   if (hardware->dmi.base_board.filled == false) { 
    83     more_printf("base_board information not found on your system, see " 
    84            "`show list' to see which module is available.\n"); 
    85     return; 
    86   } 
    87   reset_more_printf(); 
    88   more_printf("Base board\n"); 
    89   more_printf(" Manufacturer : %s\n", 
    90         hardware->dmi.base_board.manufacturer); 
    91   more_printf(" Product Name : %s\n", 
    92         hardware->dmi.base_board.product_name); 
    93   more_printf(" Version      : %s\n", hardware->dmi.base_board.version); 
    94   more_printf(" Serial       : %s\n", hardware->dmi.base_board.serial); 
    95   more_printf(" Asset Tag    : %s\n", hardware->dmi.base_board.asset_tag); 
    96   more_printf(" Location     : %s\n", hardware->dmi.base_board.location); 
    97   more_printf(" Type         : %s\n", hardware->dmi.base_board.type); 
    98   for (int i = 0; i < BASE_BOARD_NB_ELEMENTS; i++) { 
    99     if (((bool *) (&hardware->dmi.base_board.features))[i] == true) { 
    100       more_printf(" %s\n", base_board_features_strings[i]); 
    101     } 
    102   } 
    103  
    104   for (unsigned int i=0; i<sizeof hardware->dmi.base_board.devices_information/sizeof *hardware->dmi.base_board.devices_information; i++) { 
    105     if (strlen(hardware->dmi.base_board.devices_information[i].type)) { 
    106       more_printf("On Board Device #%u Information\n", i) 
    107       more_printf("  Type        : %s\n", hardware->dmi.base_board.devices_information[i].type); 
    108       more_printf("  Status      : %s\n", hardware->dmi.base_board.devices_information[i].status ? "Enabled" : "Disabled"); 
    109       more_printf("  Description : %s\n", hardware->dmi.base_board.devices_information[i].description); 
    110     } 
    111   } 
    112 } 
    113  
    114 static void show_dmi_system(int argc __unused, char** argv __unused, 
    115                             struct s_hardware *hardware) 
    116 { 
    117   if (hardware->dmi.system.filled == false) { 
    118     more_printf("system information not found on your system, see " 
    119            "`show list' to see which module is available.\n"); 
    120     return; 
    121   } 
    122   reset_more_printf(); 
    123   more_printf("System\n"); 
    124   more_printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer); 
    125   more_printf(" Product Name : %s\n", hardware->dmi.system.product_name); 
    126   more_printf(" Version      : %s\n", hardware->dmi.system.version); 
    127   more_printf(" Serial       : %s\n", hardware->dmi.system.serial); 
    128   more_printf(" UUID         : %s\n", hardware->dmi.system.uuid); 
    129   more_printf(" Wakeup Type  : %s\n", hardware->dmi.system.wakeup_type); 
    130   more_printf(" SKU Number   : %s\n", hardware->dmi.system.sku_number); 
    131   more_printf(" Family       : %s\n", hardware->dmi.system.family); 
    132  
    133   if (strlen(hardware->dmi.system.configuration_options)) { 
    134     more_printf("System Configuration Options\n"); 
    135     more_printf("%s\n", hardware->dmi.system.configuration_options); 
    136   } 
    137  
    138   if (hardware->dmi.system.system_reset.filled) { 
    139     more_printf("System Reset\n"); 
    140     more_printf("  Status               : %s\n", 
    141            (hardware->dmi.system.system_reset.status ? "Enabled" : "Disabled")); 
    142     more_printf("  Watchdog Timer       : %s\n", 
    143            (hardware->dmi.system.system_reset.watchdog ? "Present" : "Not Present")); 
    144     if (strlen(hardware->dmi.system.system_reset.boot_option)) 
    145       more_printf("  Boot Option          : %s\n", hardware->dmi.system.system_reset.boot_option); 
    146     if (strlen(hardware->dmi.system.system_reset.boot_option_on_limit)) 
    147       more_printf("  Boot Option On Limit : %s\n", hardware->dmi.system.system_reset.boot_option_on_limit); 
    148     if (strlen(hardware->dmi.system.system_reset.reset_count)) 
    149       more_printf("  Reset Count          : %s\n", hardware->dmi.system.system_reset.reset_count); 
    150     if (strlen(hardware->dmi.system.system_reset.reset_limit)) 
    151       more_printf("  Reset Limit          : %s\n", hardware->dmi.system.system_reset.reset_limit); 
    152     if (strlen(hardware->dmi.system.system_reset.timer_interval)) 
    153       more_printf("  Timer Interval       : %s\n", hardware->dmi.system.system_reset.timer_interval); 
    154     if (strlen(hardware->dmi.system.system_reset.timeout)) 
    155       more_printf("  Timeout              : %s\n", hardware->dmi.system.system_reset.timeout); 
    156   } 
    157  
    158   more_printf("System Boot Information\n"); 
    159   more_printf(" Status       : %s\n", hardware->dmi.system.system_boot_status); 
    160 } 
    161  
    162 static void show_dmi_bios(int argc __unused, char** argv __unused, 
    163                           struct s_hardware *hardware) 
    164 { 
    165   if (hardware->dmi.bios.filled == false) { 
    166     more_printf("bios information not found on your system, see " 
    167            "`show list' to see which module is available.\n"); 
    168     return; 
    169   } 
    170   reset_more_printf(); 
    171   more_printf("BIOS\n"); 
    172   more_printf(" Vendor            : %s\n", hardware->dmi.bios.vendor); 
    173   more_printf(" Version           : %s\n", hardware->dmi.bios.version); 
    174   more_printf(" Release Date      : %s\n", 
    175         hardware->dmi.bios.release_date); 
    176   more_printf(" Bios Revision     : %s\n", 
    177         hardware->dmi.bios.bios_revision); 
    178         if (strlen(hardware->dmi.bios.firmware_revision)) 
    179                 more_printf(" Firmware Revision : %s\n", 
    180                             hardware->dmi.bios.firmware_revision); 
    181   more_printf(" Address           : 0x%04X0\n", 
    182         hardware->dmi.bios.address); 
    183   more_printf(" Runtime address   : %u %s\n", 
    184         hardware->dmi.bios.runtime_size, 
    185         hardware->dmi.bios.runtime_size_unit); 
    186   more_printf(" Rom size          : %u %s\n", hardware->dmi.bios.rom_size, 
    187         hardware->dmi.bios.rom_size_unit); 
    188  
    189   for (int i = 0; i < BIOS_CHAR_NB_ELEMENTS; i++) { 
    190     if (((bool *) (&hardware->dmi.bios.characteristics))[i] == true) { 
    191       more_printf(" %s\n", bios_charac_strings[i]); 
    192     } 
    193   } 
    194   for (int i = 0; i < BIOS_CHAR_X1_NB_ELEMENTS; i++) { 
    195     if (((bool *) (&hardware->dmi.bios.characteristics_x1))[i] == 
    196         true) { 
    197       more_printf(" %s\n", bios_charac_x1_strings[i]); 
    198     } 
    199   } 
    200  
    201   for (int i = 0; i < BIOS_CHAR_X2_NB_ELEMENTS; i++) { 
    202     if (((bool *) (&hardware->dmi.bios.characteristics_x2))[i] == 
    203         true) { 
    204       more_printf(" %s\n", bios_charac_x2_strings[i]); 
    205     } 
    206   } 
    207  
    208 } 
    209  
    210 static void show_dmi_chassis(int argc __unused, char** argv __unused, 
    211                              struct s_hardware *hardware) 
    212 { 
    213   if (hardware->dmi.chassis.filled == false) { 
    214     more_printf("chassis information not found on your system, see " 
    215            "`show list' to see which module is available.\n"); 
    216     return; 
    217   } 
    218   reset_more_printf(); 
    219   more_printf("Chassis\n"); 
    220   more_printf(" Manufacturer       : %s\n", 
    221         hardware->dmi.chassis.manufacturer); 
    222   more_printf(" Type               : %s\n", hardware->dmi.chassis.type); 
    223   more_printf(" Lock               : %s\n", hardware->dmi.chassis.lock); 
    224   more_printf(" Version            : %s\n", 
    225         hardware->dmi.chassis.version); 
    226   more_printf(" Serial             : %s\n", hardware->dmi.chassis.serial); 
    227   more_printf(" Asset Tag          : %s\n", 
    228         del_multi_spaces(hardware->dmi.chassis.asset_tag)); 
    229   more_printf(" Boot up state      : %s\n", 
    230         hardware->dmi.chassis.boot_up_state); 
    231   more_printf(" Power supply state : %s\n", 
    232         hardware->dmi.chassis.power_supply_state); 
    233   more_printf(" Thermal state      : %s\n", 
    234         hardware->dmi.chassis.thermal_state); 
    235   more_printf(" Security Status    : %s\n", 
    236         hardware->dmi.chassis.security_status); 
    237   more_printf(" OEM Information    : %s\n", 
    238         hardware->dmi.chassis.oem_information); 
    239   more_printf(" Height             : %u\n", hardware->dmi.chassis.height); 
    240   more_printf(" NB Power Cords     : %u\n", 
    241         hardware->dmi.chassis.nb_power_cords); 
     37static void show_dmi_modules(int argc __unused, char **argv __unused, 
     38                             struct s_hardware *hardware) 
     39{ 
     40    char available_dmi_commands[1024]; 
     41    reset_more_printf(); 
     42    memset(available_dmi_commands, 0, sizeof(available_dmi_commands)); 
     43 
     44    more_printf("Available DMI modules on your system:\n"); 
     45    if (hardware->dmi.base_board.filled == true) 
     46        more_printf("\t%s\n", CLI_DMI_BASE_BOARD); 
     47    if (hardware->dmi.battery.filled == true) 
     48        more_printf("\t%s\n", CLI_DMI_BATTERY); 
     49    if (hardware->dmi.bios.filled == true) 
     50        more_printf("\t%s\n", CLI_DMI_BIOS); 
     51    if (hardware->dmi.chassis.filled == true) 
     52        more_printf("\t%s\n", CLI_DMI_CHASSIS); 
     53    for (int i = 0; i < hardware->dmi.memory_count; i++) { 
     54        if (hardware->dmi.memory[i].filled == true) { 
     55            more_printf("\tbank <number>\n"); 
     56            break; 
     57        } 
     58    } 
     59    for (int i = 0; i < hardware->dmi.memory_module_count; i++) { 
     60        if (hardware->dmi.memory_module[i].filled == true) { 
     61            more_printf("\tmodule <number>\n"); 
     62            break; 
     63        } 
     64    } 
     65    if (hardware->dmi.processor.filled == true) 
     66        more_printf("\t%s\n", CLI_DMI_PROCESSOR); 
     67    if (hardware->dmi.system.filled == true) 
     68        more_printf("\t%s\n", CLI_DMI_SYSTEM); 
     69    if (hardware->dmi.ipmi.filled == true) 
     70        more_printf("\t%s\n", CLI_DMI_IPMI); 
     71    if (hardware->dmi.cache_count) 
     72        more_printf("\t%s\n", CLI_DMI_CACHE); 
     73    if (strlen(hardware->dmi.oem_strings)) 
     74        more_printf("\t%s\n", CLI_DMI_OEM); 
     75    if (hardware->dmi.hardware_security.filled) 
     76        more_printf("\t%s\n", CLI_DMI_SECURITY); 
     77} 
     78 
     79static void show_dmi_base_board(int argc __unused, char **argv __unused, 
     80                                struct s_hardware *hardware) 
     81{ 
     82    if (hardware->dmi.base_board.filled == false) { 
     83        more_printf("base_board information not found on your system, see " 
     84                    "`show list' to see which module is available.\n"); 
     85        return; 
     86    } 
     87    reset_more_printf(); 
     88    more_printf("Base board\n"); 
     89    more_printf(" Manufacturer : %s\n", hardware->dmi.base_board.manufacturer); 
     90    more_printf(" Product Name : %s\n", hardware->dmi.base_board.product_name); 
     91    more_printf(" Version      : %s\n", hardware->dmi.base_board.version); 
     92    more_printf(" Serial       : %s\n", hardware->dmi.base_board.serial); 
     93    more_printf(" Asset Tag    : %s\n", hardware->dmi.base_board.asset_tag); 
     94    more_printf(" Location     : %s\n", hardware->dmi.base_board.location); 
     95    more_printf(" Type         : %s\n", hardware->dmi.base_board.type); 
     96    for (int i = 0; i < BASE_BOARD_NB_ELEMENTS; i++) { 
     97        if (((bool *) (&hardware->dmi.base_board.features))[i] == true) { 
     98            more_printf(" %s\n", base_board_features_strings[i]); 
     99        } 
     100    } 
     101 
     102    for (unsigned int i = 0; 
     103         i < 
     104         sizeof hardware->dmi.base_board.devices_information / 
     105         sizeof *hardware->dmi.base_board.devices_information; i++) { 
     106        if (strlen(hardware->dmi.base_board.devices_information[i].type)) { 
     107            more_printf("On Board Device #%u Information\n", i) 
     108                more_printf("  Type        : %s\n", 
     109                            hardware->dmi.base_board.devices_information[i]. 
     110                            type); 
     111            more_printf("  Status      : %s\n", 
     112                        hardware->dmi.base_board.devices_information[i]. 
     113                        status ? "Enabled" : "Disabled"); 
     114            more_printf("  Description : %s\n", 
     115                        hardware->dmi.base_board.devices_information[i]. 
     116                        description); 
     117        } 
     118    } 
     119} 
     120 
     121static void show_dmi_system(int argc __unused, char **argv __unused, 
     122                            struct s_hardware *hardware) 
     123{ 
     124    if (hardware->dmi.system.filled == false) { 
     125        more_printf("system information not found on your system, see " 
     126                    "`show list' to see which module is available.\n"); 
     127        return; 
     128    } 
     129    reset_more_printf(); 
     130    more_printf("System\n"); 
     131    more_printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer); 
     132    more_printf(" Product Name : %s\n", hardware->dmi.system.product_name); 
     133    more_printf(" Version      : %s\n", hardware->dmi.system.version); 
     134    more_printf(" Serial       : %s\n", hardware->dmi.system.serial); 
     135    more_printf(" UUID         : %s\n", hardware->dmi.system.uuid); 
     136    more_printf(" Wakeup Type  : %s\n", hardware->dmi.system.wakeup_type); 
     137    more_printf(" SKU Number   : %s\n", hardware->dmi.system.sku_number); 
     138    more_printf(" Family       : %s\n", hardware->dmi.system.family); 
     139 
     140    if (strlen(hardware->dmi.system.configuration_options)) { 
     141        more_printf("System Configuration Options\n"); 
     142        more_printf("%s\n", hardware->dmi.system.configuration_options); 
     143    } 
     144 
     145    if (hardware->dmi.system.system_reset.filled) { 
     146        more_printf("System Reset\n"); 
     147        more_printf("  Status               : %s\n", 
     148                    (hardware->dmi.system.system_reset. 
     149                     status ? "Enabled" : "Disabled")); 
     150        more_printf("  Watchdog Timer       : %s\n", 
     151                    (hardware->dmi.system.system_reset. 
     152                     watchdog ? "Present" : "Not Present")); 
     153        if (strlen(hardware->dmi.system.system_reset.boot_option)) 
     154            more_printf("  Boot Option          : %s\n", 
     155                        hardware->dmi.system.system_reset.boot_option); 
     156        if (strlen(hardware->dmi.system.system_reset.boot_option_on_limit)) 
     157            more_printf("  Boot Option On Limit : %s\n", 
     158                        hardware->dmi.system.system_reset.boot_option_on_limit); 
     159        if (strlen(hardware->dmi.system.system_reset.reset_count)) 
     160            more_printf("  Reset Count          : %s\n", 
     161                        hardware->dmi.system.system_reset.reset_count); 
     162        if (strlen(hardware->dmi.system.system_reset.reset_limit)) 
     163            more_printf("  Reset Limit          : %s\n", 
     164                        hardware->dmi.system.system_reset.reset_limit); 
     165        if (strlen(hardware->dmi.system.system_reset.timer_interval)) 
     166            more_printf("  Timer Interval       : %s\n", 
     167                        hardware->dmi.system.system_reset.timer_interval); 
     168        if (strlen(hardware->dmi.system.system_reset.timeout)) 
     169            more_printf("  Timeout              : %s\n", 
     170                        hardware->dmi.system.system_reset.timeout); 
     171    } 
     172 
     173    more_printf("System Boot Information\n"); 
     174    more_printf(" Status       : %s\n", 
     175                hardware->dmi.system.system_boot_status); 
     176} 
     177 
     178static void show_dmi_bios(int argc __unused, char **argv __unused, 
     179                          struct s_hardware *hardware) 
     180{ 
     181    if (hardware->dmi.bios.filled == false) { 
     182        more_printf("bios information not found on your system, see " 
     183                    "`show list' to see which module is available.\n"); 
     184        return; 
     185    } 
     186    reset_more_printf(); 
     187    more_printf("BIOS\n"); 
     188    more_printf(" Vendor            : %s\n", hardware->dmi.bios.vendor); 
     189    more_printf(" Version           : %s\n", hardware->dmi.bios.version); 
     190    more_printf(" Release Date      : %s\n", hardware->dmi.bios.release_date); 
     191    more_printf(" Bios Revision     : %s\n", hardware->dmi.bios.bios_revision); 
     192    if (strlen(hardware->dmi.bios.firmware_revision)) 
     193        more_printf(" Firmware Revision : %s\n", 
     194                    hardware->dmi.bios.firmware_revision); 
     195    more_printf(" Address           : 0x%04X0\n", hardware->dmi.bios.address); 
     196    more_printf(" Runtime address   : %u %s\n", 
     197                hardware->dmi.bios.runtime_size, 
     198                hardware->dmi.bios.runtime_size_unit); 
     199    more_printf(" Rom size          : %u %s\n", hardware->dmi.bios.rom_size, 
     200                hardware->dmi.bios.rom_size_unit); 
     201 
     202    for (int i = 0; i < BIOS_CHAR_NB_ELEMENTS; i++) { 
     203        if (((bool *) (&hardware->dmi.bios.characteristics))[i] == true) { 
     204            more_printf(" %s\n", bios_charac_strings[i]); 
     205        } 
     206    } 
     207    for (int i = 0; i < BIOS_CHAR_X1_NB_ELEMENTS; i++) { 
     208        if (((bool *) (&hardware->dmi.bios.characteristics_x1))[i] == true) { 
     209            more_printf(" %s\n", bios_charac_x1_strings[i]); 
     210        } 
     211    } 
     212 
     213    for (int i = 0; i < BIOS_CHAR_X2_NB_ELEMENTS; i++) { 
     214        if (((bool *) (&hardware->dmi.bios.characteristics_x2))[i] == true) { 
     215            more_printf(" %s\n", bios_charac_x2_strings[i]); 
     216        } 
     217    } 
     218 
     219} 
     220 
     221static void show_dmi_chassis(int argc __unused, char **argv __unused, 
     222                             struct s_hardware *hardware) 
     223{ 
     224    if (hardware->dmi.chassis.filled == false) { 
     225        more_printf("chassis information not found on your system, see " 
     226                    "`show list' to see which module is available.\n"); 
     227        return; 
     228    } 
     229    reset_more_printf(); 
     230    more_printf("Chassis\n"); 
     231    more_printf(" Manufacturer       : %s\n", 
     232                hardware->dmi.chassis.manufacturer); 
     233    more_printf(" Type               : %s\n", hardware->dmi.chassis.type); 
     234    more_printf(" Lock               : %s\n", hardware->dmi.chassis.lock); 
     235    more_printf(" Version            : %s\n", hardware->dmi.chassis.version); 
     236    more_printf(" Serial             : %s\n", hardware->dmi.chassis.serial); 
     237    more_printf(" Asset Tag          : %s\n", 
     238                del_multi_spaces(hardware->dmi.chassis.asset_tag)); 
     239    more_printf(" Boot up state      : %s\n", 
     240                hardware->dmi.chassis.boot_up_state); 
     241    more_printf(" Power supply state : %s\n", 
     242                hardware->dmi.chassis.power_supply_state); 
     243    more_printf(" Thermal state      : %s\n", 
     244                hardware->dmi.chassis.thermal_state); 
     245    more_printf(" Security Status    : %s\n", 
     246                hardware->dmi.chassis.security_status); 
     247    more_printf(" OEM Information    : %s\n", 
     248                hardware->dmi.chassis.oem_information); 
     249    more_printf(" Height             : %u\n", hardware->dmi.chassis.height); 
     250    more_printf(" NB Power Cords     : %u\n", 
     251                hardware->dmi.chassis.nb_power_cords); 
    242252} 
    243253 
    244254static void show_dmi_ipmi(int argc __unused, char **argv __unused, 
    245                              struct s_hardware *hardware) 
    246 { 
    247   if (hardware->dmi.ipmi.filled == false) { 
    248     more_printf("IPMI module not available\n"); 
    249     return; 
    250   } 
    251   reset_more_printf(); 
    252   more_printf("IPMI\n"); 
    253   more_printf(" Interface Type     : %s\n", 
    254         hardware->dmi.ipmi.interface_type); 
    255   more_printf(" Specification Ver. : %u.%u\n", 
    256         hardware->dmi.ipmi.major_specification_version, 
    257         hardware->dmi.ipmi.minor_specification_version); 
    258   more_printf(" I2C Slave Address  : 0x%02x\n", 
    259         hardware->dmi.ipmi.I2C_slave_address); 
    260   more_printf(" Nv Storage Address : %u\n", 
    261         hardware->dmi.ipmi.nv_address); 
    262   uint32_t high = hardware->dmi.ipmi.base_address >> 32; 
    263   uint32_t low  = hardware->dmi.ipmi.base_address & 0xFFFF; 
    264   more_printf(" Base Address       : %08X%08X\n", 
    265         high,(low & ~1)); 
    266   more_printf(" IRQ                : %d\n", 
    267         hardware->dmi.ipmi.irq); 
    268 } 
    269  
    270 static void show_dmi_battery(int argc __unused, char** argv __unused, 
    271                              struct s_hardware *hardware) 
    272 { 
    273   if (hardware->dmi.battery.filled == false) { 
    274     more_printf("battery information not found on your system, see " 
    275            "`show list' to see which module is available.\n"); 
    276     return; 
    277   } 
    278   reset_more_printf(); 
    279   more_printf("Battery \n"); 
    280   more_printf(" Vendor             : %s\n", 
    281         hardware->dmi.battery.manufacturer); 
    282   more_printf(" Manufacture Date   : %s\n", 
    283         hardware->dmi.battery.manufacture_date); 
    284   more_printf(" Serial             : %s\n", hardware->dmi.battery.serial); 
    285   more_printf(" Name               : %s\n", hardware->dmi.battery.name); 
    286   more_printf(" Chemistry          : %s\n", 
    287         hardware->dmi.battery.chemistry); 
    288   more_printf(" Design Capacity    : %s\n", 
    289         hardware->dmi.battery.design_capacity); 
    290   more_printf(" Design Voltage     : %s\n", 
    291         hardware->dmi.battery.design_voltage); 
    292   more_printf(" SBDS               : %s\n", hardware->dmi.battery.sbds); 
    293   more_printf(" SBDS Manuf. Date   : %s\n", 
    294         hardware->dmi.battery.sbds_manufacture_date); 
    295   more_printf(" SBDS Chemistry     : %s\n", 
    296         hardware->dmi.battery.sbds_chemistry); 
    297   more_printf(" Maximum Error      : %s\n", 
    298         hardware->dmi.battery.maximum_error); 
    299   more_printf(" OEM Info           : %s\n", 
    300         hardware->dmi.battery.oem_info); 
    301 } 
    302  
    303 static void show_dmi_cpu(int argc __unused, char** argv __unused, 
    304                          struct s_hardware *hardware) 
    305 { 
    306   if (hardware->dmi.processor.filled == false) { 
    307     more_printf("processor information not found on your system, see " 
    308            "`show list' to see which module is available.\n"); 
    309     return; 
    310   } 
    311   reset_more_printf(); 
    312   more_printf("CPU\n"); 
    313   more_printf(" Socket Designation : %s\n", 
    314         hardware->dmi.processor.socket_designation); 
    315   more_printf(" Type               : %s\n", hardware->dmi.processor.type); 
    316   more_printf(" Family             : %s\n", 
    317         hardware->dmi.processor.family); 
    318   more_printf(" Manufacturer       : %s\n", 
    319         hardware->dmi.processor.manufacturer); 
    320   more_printf(" Version            : %s\n", 
    321         hardware->dmi.processor.version); 
    322   more_printf(" External Clock     : %u\n", 
    323         hardware->dmi.processor.external_clock); 
    324   more_printf(" Max Speed          : %u\n", 
    325         hardware->dmi.processor.max_speed); 
    326   more_printf(" Current Speed      : %u\n", 
    327         hardware->dmi.processor.current_speed); 
    328   more_printf(" Cpu Type           : %u\n", 
    329         hardware->dmi.processor.signature.type); 
    330   more_printf(" Cpu Family         : %u\n", 
    331         hardware->dmi.processor.signature.family); 
    332   more_printf(" Cpu Model          : %u\n", 
    333         hardware->dmi.processor.signature.model); 
    334   more_printf(" Cpu Stepping       : %u\n", 
    335         hardware->dmi.processor.signature.stepping); 
    336   more_printf(" Cpu Minor Stepping : %u\n", 
    337         hardware->dmi.processor.signature.minor_stepping); 
     255                          struct s_hardware *hardware) 
     256{ 
     257    if (hardware->dmi.ipmi.filled == false) { 
     258        more_printf("IPMI module not available\n"); 
     259        return; 
     260    } 
     261    reset_more_printf(); 
     262    more_printf("IPMI\n"); 
     263    more_printf(" Interface Type     : %s\n", 
     264                hardware->dmi.ipmi.interface_type); 
     265    more_printf(" Specification Ver. : %u.%u\n", 
     266                hardware->dmi.ipmi.major_specification_version, 
     267                hardware->dmi.ipmi.minor_specification_version); 
     268    more_printf(" I2C Slave Address  : 0x%02x\n", 
     269                hardware->dmi.ipmi.I2C_slave_address); 
     270    more_printf(" Nv Storage Address : %u\n", hardware->dmi.ipmi.nv_address); 
     271    uint32_t high = hardware->dmi.ipmi.base_address >> 32; 
     272    uint32_t low = hardware->dmi.ipmi.base_address & 0xFFFF; 
     273    more_printf(" Base Address       : %08X%08X\n", high, (low & ~1)); 
     274    more_printf(" IRQ                : %d\n", hardware->dmi.ipmi.irq); 
     275} 
     276 
     277static void show_dmi_battery(int argc __unused, char **argv __unused, 
     278                             struct s_hardware *hardware) 
     279{ 
     280    if (hardware->dmi.battery.filled == false) { 
     281        more_printf("battery information not found on your system, see " 
     282                    "`show list' to see which module is available.\n"); 
     283        return; 
     284    } 
     285    reset_more_printf(); 
     286    more_printf("Battery \n"); 
     287    more_printf(" Vendor             : %s\n", 
     288                hardware->dmi.battery.manufacturer); 
     289    more_printf(" Manufacture Date   : %s\n", 
     290                hardware->dmi.battery.manufacture_date); 
     291    more_printf(" Serial             : %s\n", hardware->dmi.battery.serial); 
     292    more_printf(" Name               : %s\n", hardware->dmi.battery.name); 
     293    more_printf(" Chemistry          : %s\n", hardware->dmi.battery.chemistry); 
     294    more_printf(" Design Capacity    : %s\n", 
     295                hardware->dmi.battery.design_capacity); 
     296    more_printf(" Design Voltage     : %s\n", 
     297                hardware->dmi.battery.design_voltage); 
     298    more_printf(" SBDS               : %s\n", hardware->dmi.battery.sbds); 
     299    more_printf(" SBDS Manuf. Date   : %s\n", 
     300                hardware->dmi.battery.sbds_manufacture_date); 
     301    more_printf(" SBDS Chemistry     : %s\n", 
     302                hardware->dmi.battery.sbds_chemistry); 
     303    more_printf(" Maximum Error      : %s\n", 
     304                hardware->dmi.battery.maximum_error); 
     305    more_printf(" OEM Info           : %s\n", hardware->dmi.battery.oem_info); 
     306} 
     307 
     308static void show_dmi_cpu(int argc __unused, char **argv __unused, 
     309                         struct s_hardware *hardware) 
     310{ 
     311    if (hardware->dmi.processor.filled == false) { 
     312        more_printf("processor information not found on your system, see " 
     313                    "`show list' to see which module is available.\n"); 
     314        return; 
     315    } 
     316    reset_more_printf(); 
     317    more_printf("CPU\n"); 
     318    more_printf(" Socket Designation : %s\n", 
     319                hardware->dmi.processor.socket_designation); 
     320    more_printf(" Type               : %s\n", hardware->dmi.processor.type); 
     321    more_printf(" Family             : %s\n", hardware->dmi.processor.family); 
     322    more_printf(" Manufacturer       : %s\n", 
     323                hardware->dmi.processor.manufacturer); 
     324    more_printf(" Version            : %s\n", hardware->dmi.processor.version); 
     325    more_printf(" External Clock     : %u\n", 
     326                hardware->dmi.processor.external_clock); 
     327    more_printf(" Max Speed          : %u\n", 
     328                hardware->dmi.processor.max_speed); 
     329    more_printf(" Current Speed      : %u\n", 
     330                hardware->dmi.processor.current_speed); 
     331    more_printf(" Cpu Type           : %u\n", 
     332                hardware->dmi.processor.signature.type); 
     333    more_printf(" Cpu Family         : %u\n", 
     334                hardware->dmi.processor.signature.family); 
     335    more_printf(" Cpu Model          : %u\n", 
     336                hardware->dmi.processor.signature.model); 
     337    more_printf(" Cpu Stepping       : %u\n", 
     338                hardware->dmi.processor.signature.stepping); 
     339    more_printf(" Cpu Minor Stepping : %u\n", 
     340                hardware->dmi.processor.signature.minor_stepping); 
    338341// more_printf(" Voltage            : %f\n",hardware->dmi.processor.voltage); 
    339   more_printf(" Status             : %s\n", 
    340         hardware->dmi.processor.status); 
    341   more_printf(" Upgrade            : %s\n", 
    342         hardware->dmi.processor.upgrade); 
    343   more_printf(" Cache L1 Handle    : %s\n", 
    344         hardware->dmi.processor.cache1); 
    345   more_printf(" Cache L2 Handle    : %s\n", 
    346         hardware->dmi.processor.cache2); 
    347   more_printf(" Cache L3 Handle    : %s\n", 
    348         hardware->dmi.processor.cache3); 
    349   more_printf(" Serial             : %s\n", 
    350         hardware->dmi.processor.serial); 
    351   more_printf(" Part Number        : %s\n", 
    352         hardware->dmi.processor.part_number); 
    353   more_printf(" ID                 : %s\n", hardware->dmi.processor.id); 
    354   for (int i = 0; i < PROCESSOR_FLAGS_ELEMENTS; i++) { 
    355     if (((bool *) (&hardware->dmi.processor.cpu_flags))[i] == true) { 
    356       more_printf(" %s\n", cpu_flags_strings[i]); 
    357     } 
    358   } 
    359 } 
    360  
    361 void show_dmi_memory_bank(int argc, char** argv, 
    362                                  struct s_hardware *hardware) 
    363 { 
    364   int bank = -1; 
    365  
    366   /* Sanitize arguments */ 
    367   if (argc > 0) 
    368     bank = strtol(argv[0], (char **)NULL, 10); 
    369  
    370   if (errno == ERANGE || bank < 0) { 
    371     more_printf("This bank number is incorrect\n"); 
    372     return; 
    373   } 
    374  
    375   if ((bank >= hardware->dmi.memory_count) || (bank < 0)) { 
    376     more_printf("Bank %d number doesn't exist\n", bank); 
    377     return; 
    378   } 
    379   if (hardware->dmi.memory[bank].filled == false) { 
    380     more_printf("Bank %d doesn't contain any information\n", bank); 
    381     return; 
    382   } 
    383  
    384   reset_more_printf(); 
    385   more_printf("Memory Bank %d\n", bank); 
    386   more_printf(" Form Factor  : %s\n", 
    387         hardware->dmi.memory[bank].form_factor); 
    388   more_printf(" Type         : %s\n", hardware->dmi.memory[bank].type); 
    389   more_printf(" Type Detail  : %s\n", 
    390         hardware->dmi.memory[bank].type_detail); 
    391   more_printf(" Speed        : %s\n", hardware->dmi.memory[bank].speed); 
    392   more_printf(" Size         : %s\n", hardware->dmi.memory[bank].size); 
    393   more_printf(" Device Set   : %s\n", 
    394         hardware->dmi.memory[bank].device_set); 
    395   more_printf(" Device Loc.  : %s\n", 
    396         hardware->dmi.memory[bank].device_locator); 
    397   more_printf(" Bank Locator : %s\n", 
    398         hardware->dmi.memory[bank].bank_locator); 
    399   more_printf(" Total Width  : %s\n", 
    400         hardware->dmi.memory[bank].total_width); 
    401   more_printf(" Data Width   : %s\n", 
    402         hardware->dmi.memory[bank].data_width); 
    403   more_printf(" Error        : %s\n", hardware->dmi.memory[bank].error); 
    404   more_printf(" Vendor       : %s\n", 
    405         hardware->dmi.memory[bank].manufacturer); 
    406   more_printf(" Serial       : %s\n", hardware->dmi.memory[bank].serial); 
    407   more_printf(" Asset Tag    : %s\n", 
    408         hardware->dmi.memory[bank].asset_tag); 
    409   more_printf(" Part Number  : %s\n", 
    410         hardware->dmi.memory[bank].part_number); 
    411 } 
    412  
    413 static void show_dmi_cache(int argc, char** argv, 
    414                            struct s_hardware *hardware) 
    415 { 
    416         if (!hardware->dmi.cache_count) { 
    417                 more_printf("cache information not found on your system, see " 
    418                        "`show list' to see which module is available.\n"); 
    419                 return; 
    420         } 
    421  
    422         int cache = strtol(argv[0], NULL, 10); 
    423  
    424         if (argc != 1 || cache > hardware->dmi.cache_count) { 
    425                 more_printf("show cache [0-%d]\n", hardware->dmi.cache_count-1); 
    426                 return; 
    427         } 
    428  
    429         reset_more_printf(); 
    430  
    431         more_printf("Cache Information #%d\n", cache); 
    432         more_printf("  Socket Designation    : %s\n", 
    433                     hardware->dmi.cache[cache].socket_designation); 
    434         more_printf("  Configuration         : %s\n", 
    435                     hardware->dmi.cache[cache].configuration); 
    436         more_printf("  Operational Mode      : %s\n", 
    437                     hardware->dmi.cache[cache].mode); 
    438         more_printf("  Location              : %s\n", 
    439                     hardware->dmi.cache[cache].location); 
    440         more_printf("  Installed Size        : %u KB", 
    441                     hardware->dmi.cache[cache].installed_size); 
    442         more_printf("\n"); 
    443         more_printf("  Maximum Size          : %u KB", 
    444                     hardware->dmi.cache[cache].max_size); 
    445         more_printf("\n"); 
    446         more_printf("  Supported SRAM Types  : %s", 
    447                     hardware->dmi.cache[cache].supported_sram_types); 
    448         more_printf("\n"); 
    449         more_printf("  Installed SRAM Type   : %s", 
    450                     hardware->dmi.cache[cache].installed_sram_types); 
    451         more_printf("\n"); 
    452         more_printf("  Speed                 : %u ns", 
    453                     hardware->dmi.cache[cache].speed); 
    454         more_printf("\n"); 
    455         more_printf("  Error Correction Type : %s\n", 
    456                     hardware->dmi.cache[cache].error_correction_type); 
    457         more_printf("  System Type           : %s\n", 
    458                     hardware->dmi.cache[cache].system_type); 
    459         more_printf("  Associativity         : %s\n", 
    460                     hardware->dmi.cache[cache].associativity); 
    461 } 
    462  
    463 void show_dmi_memory_module(int argc, char** argv, 
    464                             struct s_hardware *hardware) 
    465 { 
    466         int module = -1; 
    467  
    468         /* Sanitize arguments */ 
    469         if (argc > 0) 
    470                 module = strtol(argv[0], (char **)NULL, 10); 
    471  
    472         if (errno == ERANGE || module < 0) { 
    473                 more_printf("This module number is incorrect\n"); 
    474                 return; 
    475         } 
    476  
    477         if ((module >= hardware->dmi.memory_module_count) || (module < 0)) { 
    478                 more_printf("Module number %d doesn't exist\n", module); 
    479                 return; 
    480         } 
    481  
    482         if (hardware->dmi.memory_module[module].filled == false) { 
    483                 more_printf("Module %d doesn't contain any information\n", module); 
    484                 return; 
    485         } 
    486  
    487   reset_more_printf(); 
    488         more_printf("Memory Module %d\n", module); 
    489         more_printf(" Socket Designation : %s\n", 
     342    more_printf(" Status             : %s\n", hardware->dmi.processor.status); 
     343    more_printf(" Upgrade            : %s\n", hardware->dmi.processor.upgrade); 
     344    more_printf(" Cache L1 Handle    : %s\n", hardware->dmi.processor.cache1); 
     345    more_printf(" Cache L2 Handle    : %s\n", hardware->dmi.processor.cache2); 
     346    more_printf(" Cache L3 Handle    : %s\n", hardware->dmi.processor.cache3); 
     347    more_printf(" Serial             : %s\n", hardware->dmi.processor.serial); 
     348    more_printf(" Part Number        : %s\n", 
     349                hardware->dmi.processor.part_number); 
     350    more_printf(" ID                 : %s\n", hardware->dmi.processor.id); 
     351    for (int i = 0; i < PROCESSOR_FLAGS_ELEMENTS; i++) { 
     352        if (((bool *) (&hardware->dmi.processor.cpu_flags))[i] == true) { 
     353            more_printf(" %s\n", cpu_flags_strings[i]); 
     354        } 
     355    } 
     356} 
     357 
     358void show_dmi_memory_bank(int argc, char **argv, struct s_hardware *hardware) 
     359{ 
     360    int bank = -1; 
     361 
     362    /* Sanitize arguments */ 
     363    if (argc > 0) 
     364        bank = strtol(argv[0], (char **)NULL, 10); 
     365 
     366    if (errno == ERANGE || bank < 0) { 
     367        more_printf("This bank number is incorrect\n"); 
     368        return; 
     369    } 
     370 
     371    if ((bank >= hardware->dmi.memory_count) || (bank < 0)) { 
     372        more_printf("Bank %d number doesn't exist\n", bank); 
     373        return; 
     374    } 
     375    if (hardware->dmi.memory[bank].filled == false) { 
     376        more_printf("Bank %d doesn't contain any information\n", bank); 
     377        return; 
     378    } 
     379 
     380    reset_more_printf(); 
     381    more_printf("Memory Bank %d\n", bank); 
     382    more_printf(" Form Factor  : %s\n", hardware->dmi.memory[bank].form_factor); 
     383    more_printf(" Type         : %s\n", hardware->dmi.memory[bank].type); 
     384    more_printf(" Type Detail  : %s\n", hardware->dmi.memory[bank].type_detail); 
     385    more_printf(" Speed        : %s\n", hardware->dmi.memory[bank].speed); 
     386    more_printf(" Size         : %s\n", hardware->dmi.memory[bank].size); 
     387    more_printf(" Device Set   : %s\n", hardware->dmi.memory[bank].device_set); 
     388    more_printf(" Device Loc.  : %s\n", 
     389                hardware->dmi.memory[bank].device_locator); 
     390    more_printf(" Bank Locator : %s\n", 
     391                hardware->dmi.memory[bank].bank_locator); 
     392    more_printf(" Total Width  : %s\n", hardware->dmi.memory[bank].total_width); 
     393    more_printf(" Data Width   : %s\n", hardware->dmi.memory[bank].data_width); 
     394    more_printf(" Error        : %s\n", hardware->dmi.memory[bank].error); 
     395    more_printf(" Vendor       : %s\n", 
     396                hardware->dmi.memory[bank].manufacturer); 
     397    more_printf(" Serial       : %s\n", hardware->dmi.memory[bank].serial); 
     398    more_printf(" Asset Tag    : %s\n", hardware->dmi.memory[bank].asset_tag); 
     399    more_printf(" Part Number  : %s\n", hardware->dmi.memory[bank].part_number); 
     400} 
     401 
     402static void show_dmi_cache(int argc, char **argv, struct s_hardware *hardware) 
     403{ 
     404    if (!hardware->dmi.cache_count) { 
     405        more_printf("cache information not found on your system, see " 
     406                    "`show list' to see which module is available.\n"); 
     407        return; 
     408    } 
     409 
     410    int cache = strtol(argv[0], NULL, 10); 
     411 
     412    if (argc != 1 || cache > hardware->dmi.cache_count) { 
     413        more_printf("show cache [0-%d]\n", hardware->dmi.cache_count - 1); 
     414        return; 
     415    } 
     416 
     417    reset_more_printf(); 
     418 
     419    more_printf("Cache Information #%d\n", cache); 
     420    more_printf("  Socket Designation    : %s\n", 
     421                hardware->dmi.cache[cache].socket_designation); 
     422    more_printf("  Configuration         : %s\n", 
     423                hardware->dmi.cache[cache].configuration); 
     424    more_printf("  Operational Mode      : %s\n", 
     425                hardware->dmi.cache[cache].mode); 
     426    more_printf("  Location              : %s\n", 
     427                hardware->dmi.cache[cache].location); 
     428    more_printf("  Installed Size        : %u KB", 
     429                hardware->dmi.cache[cache].installed_size); 
     430    more_printf("\n"); 
     431    more_printf("  Maximum Size          : %u KB", 
     432                hardware->dmi.cache[cache].max_size); 
     433    more_printf("\n"); 
     434    more_printf("  Supported SRAM Types  : %s", 
     435                hardware->dmi.cache[cache].supported_sram_types); 
     436    more_printf("\n"); 
     437    more_printf("  Installed SRAM Type   : %s", 
     438                hardware->dmi.cache[cache].installed_sram_types); 
     439    more_printf("\n"); 
     440    more_printf("  Speed                 : %u ns", 
     441                hardware->dmi.cache[cache].speed); 
     442    more_printf("\n"); 
     443    more_printf("  Error Correction Type : %s\n", 
     444                hardware->dmi.cache[cache].error_correction_type); 
     445    more_printf("  System Type           : %s\n", 
     446                hardware->dmi.cache[cache].system_type); 
     447    more_printf("  Associativity         : %s\n", 
     448                hardware->dmi.cache[cache].associativity); 
     449} 
     450 
     451void show_dmi_memory_module(int argc, char **argv, struct s_hardware *hardware) 
     452{ 
     453    int module = -1; 
     454 
     455    /* Sanitize arguments */ 
     456    if (argc > 0) 
     457        module = strtol(argv[0], (char **)NULL, 10); 
     458 
     459    if (errno == ERANGE || module < 0) { 
     460        more_printf("This module number is incorrect\n"); 
     461        return; 
     462    } 
     463 
     464    if ((module >= hardware->dmi.memory_module_count) || (module < 0)) { 
     465        more_printf("Module number %d doesn't exist\n", module); 
     466        return; 
     467    } 
     468 
     469    if (hardware->dmi.memory_module[module].filled == false) { 
     470        more_printf("Module %d doesn't contain any information\n", module); 
     471        return; 
     472    } 
     473 
     474    reset_more_printf(); 
     475    more_printf("Memory Module %d\n", module); 
     476    more_printf(" Socket Designation : %s\n", 
    490477                hardware->dmi.memory_module[module].socket_designation); 
    491         more_printf(" Bank Connections   : %s\n", 
     478    more_printf(" Bank Connections   : %s\n", 
    492479                hardware->dmi.memory_module[module].bank_connections); 
    493         more_printf(" Current Speed      : %s\n", 
     480    more_printf(" Current Speed      : %s\n", 
    494481                hardware->dmi.memory_module[module].speed); 
    495         more_printf(" Type               : %s\n", 
     482    more_printf(" Type               : %s\n", 
    496483                hardware->dmi.memory_module[module].type); 
    497         more_printf(" Installed Size     : %s\n", 
     484    more_printf(" Installed Size     : %s\n", 
    498485                hardware->dmi.memory_module[module].installed_size); 
    499         more_printf(" Enabled Size       : %s\n", 
     486    more_printf(" Enabled Size       : %s\n", 
    500487                hardware->dmi.memory_module[module].enabled_size); 
    501         more_printf(" Error Status       : %s\n", 
     488    more_printf(" Error Status       : %s\n", 
    502489                hardware->dmi.memory_module[module].error_status); 
    503490} 
     
    507494{ 
    508495 
    509   detect_dmi(hardware); 
    510  
    511   if (hardware->is_dmi_valid == false) { 
    512     more_printf("No valid DMI table found, exiting.\n"); 
     496    detect_dmi(hardware); 
     497 
     498    if (hardware->is_dmi_valid == false) { 
     499        more_printf("No valid DMI table found, exiting.\n"); 
     500        return; 
     501    } 
     502    reset_more_printf(); 
     503    more_printf("DMI Table version %u.%u found\n", 
     504                hardware->dmi.dmitable.major_version, 
     505                hardware->dmi.dmitable.minor_version); 
     506 
     507    show_dmi_modules(0, NULL, hardware); 
     508} 
     509 
     510void show_dmi_memory_modules(int argc __unused, char **argv __unused, 
     511                             struct s_hardware *hardware) 
     512{ 
     513    /* Do we have so display unpopulated banks ? */ 
     514    int show_free_banks = 1; 
     515 
     516    /* Needed, if called by the memory mode */ 
     517    detect_dmi(hardware); 
     518 
     519    more_printf("Memory Size   : %lu MB (%lu KB)\n", 
     520                (hardware->detected_memory_size + (1 << 9)) >> 10, 
     521                hardware->detected_memory_size); 
     522 
     523    if ((hardware->dmi.memory_count <= 0) 
     524        && (hardware->dmi.memory_module_count <= 0)) { 
     525        more_printf("No memory bank found\n"); 
     526        return; 
     527    } 
     528 
     529    /* Sanitize arguments */ 
     530    if (argc > 0) { 
     531        /* When we display a summary, there is no need to show the unpopulated banks 
     532         * The first argv is set to define this behavior 
     533         */ 
     534        show_free_banks = strtol(argv[0], NULL, 10); 
     535        if (errno == ERANGE || show_free_banks < 0 || show_free_banks > 1) 
     536            goto usage; 
     537    } 
     538 
     539    reset_more_printf(); 
     540    /* If type 17 is available */ 
     541    if (hardware->dmi.memory_count > 0) { 
     542        char bank_number[255]; 
     543        more_printf("Memory Banks\n"); 
     544        for (int i = 0; i < hardware->dmi.memory_count; i++) { 
     545            if (hardware->dmi.memory[i].filled == true) { 
     546                memset(bank_number, 0, sizeof(bank_number)); 
     547                snprintf(bank_number, sizeof(bank_number), "%d ", i); 
     548                if (show_free_banks == false) { 
     549                    if (strncmp(hardware->dmi.memory[i].size, "Free", 4)) 
     550                        more_printf(" bank %02d      : %s %s@%s\n", 
     551                                    i, hardware->dmi.memory[i].size, 
     552                                    hardware->dmi.memory[i].type, 
     553                                    hardware->dmi.memory[i].speed); 
     554                } else { 
     555                    more_printf(" bank %02d      : %s %s@%s\n", i, 
     556                                hardware->dmi.memory[i].size, 
     557                                hardware->dmi.memory[i].type, 
     558                                hardware->dmi.memory[i].speed); 
     559                } 
     560            } 
     561        } 
     562    } else if (hardware->dmi.memory_module_count > 0) { 
     563        /* Let's use type 6 as a fallback of type 17 */ 
     564        more_printf("Memory Modules\n"); 
     565        for (int i = 0; i < hardware->dmi.memory_module_count; i++) { 
     566            if (hardware->dmi.memory_module[i].filled == true) { 
     567                more_printf(" module %02d    : %s %s@%s\n", i, 
     568                            hardware->dmi.memory_module[i].enabled_size, 
     569                            hardware->dmi.memory_module[i].type, 
     570                            hardware->dmi.memory_module[i].speed); 
     571            } 
     572        } 
     573    } 
     574 
    513575    return; 
    514   } 
    515   reset_more_printf(); 
    516   more_printf("DMI Table version %u.%u found\n", 
    517          hardware->dmi.dmitable.major_version, 
    518          hardware->dmi.dmitable.minor_version); 
    519  
    520   show_dmi_modules(0, NULL, hardware); 
    521 } 
    522  
    523 void show_dmi_memory_modules(int argc __unused, char** argv __unused, 
    524                              struct s_hardware *hardware) 
    525 { 
    526   /* Do we have so display unpopulated banks ?*/ 
    527   int show_free_banks = 1; 
    528  
    529   /* Needed, if called by the memory mode */ 
    530   detect_dmi(hardware); 
    531    
    532   more_printf("Memory Size   : %lu MB (%lu KB)\n",  
    533                   (hardware->detected_memory_size + (1<<9)) >>10, 
    534                   hardware->detected_memory_size); 
    535  
    536   if ((hardware->dmi.memory_count <= 0) && (hardware->dmi.memory_module_count <= 0)) { 
    537     more_printf("No memory bank found\n"); 
     576    //printf("Type 'show bank<bank_number>' for more details.\n"); 
     577 
     578usage: 
     579    more_printf("show memory <clear screen? <show free banks?>>\n"); 
    538580    return; 
    539   } 
    540  
    541   /* Sanitize arguments */ 
    542   if (argc > 0) { 
    543       /* When we display a summary, there is no need to show the unpopulated banks 
    544        * The first argv is set to define this behavior 
    545        */ 
    546       show_free_banks = strtol(argv[0], NULL, 10); 
    547       if (errno == ERANGE || show_free_banks < 0 || show_free_banks > 1) 
    548         goto usage; 
    549   } 
    550  
    551   reset_more_printf(); 
    552   /* If type 17 is available */ 
    553   if (hardware->dmi.memory_count>0) { 
    554    char bank_number[255]; 
    555    more_printf("Memory Banks\n"); 
    556    for (int i = 0; i < hardware->dmi.memory_count; i++) { 
    557     if (hardware->dmi.memory[i].filled == true) { 
    558       memset(bank_number, 0, sizeof(bank_number)); 
    559       snprintf(bank_number, sizeof(bank_number), "%d ", i); 
    560       if (show_free_banks == false) { 
    561         if (strncmp 
    562             (hardware->dmi.memory[i].size, "Free", 4)) 
    563           more_printf(" bank %02d      : %s %s@%s\n", 
    564                  i, hardware->dmi.memory[i].size, 
    565                  hardware->dmi.memory[i].type, 
    566                  hardware->dmi.memory[i].speed); 
    567       } else { 
    568         more_printf(" bank %02d      : %s %s@%s\n", i, 
    569                hardware->dmi.memory[i].size, 
    570                hardware->dmi.memory[i].type, 
    571                hardware->dmi.memory[i].speed); 
    572       } 
    573     } 
    574    } 
    575   } else if (hardware->dmi.memory_module_count>0) { 
    576    /* Let's use type 6 as a fallback of type 17*/ 
    577    more_printf("Memory Modules\n"); 
    578    for (int i = 0; i < hardware->dmi.memory_module_count; i++) { 
    579     if (hardware->dmi.memory_module[i].filled == true) { 
    580         more_printf(" module %02d    : %s %s@%s\n", i, 
    581                hardware->dmi.memory_module[i].enabled_size, 
    582                hardware->dmi.memory_module[i].type, 
    583                hardware->dmi.memory_module[i].speed); 
    584       } 
    585     } 
    586    } 
    587  
    588   return; 
    589   //printf("Type 'show bank<bank_number>' for more details.\n"); 
    590  
    591 usage: 
    592   more_printf("show memory <clear screen? <show free banks?>>\n"); 
    593   return; 
    594 } 
    595  
    596 void show_dmi_oem_strings(int argc __unused, char** argv __unused, 
    597                           struct s_hardware *hardware) 
    598 { 
    599         reset_more_printf(); 
    600  
    601         if (strlen(hardware->dmi.oem_strings)) 
    602                 more_printf("OEM Strings\n%s", hardware->dmi.oem_strings); 
    603 } 
    604  
    605 void show_dmi_hardware_security(int argc __unused, char** argv __unused, 
    606                                 struct s_hardware *hardware) 
    607 { 
    608         reset_more_printf(); 
    609  
    610         if (!hardware->dmi.hardware_security.filled) 
    611                 return; 
    612  
    613         more_printf("Hardware Security\n"); 
    614         more_printf("  Power-On Password Status      : %s\n", 
    615                     hardware->dmi.hardware_security.power_on_passwd_status); 
    616         more_printf("  Keyboard Password Status      : %s\n", 
    617                     hardware->dmi.hardware_security.keyboard_passwd_status); 
    618         more_printf("  Administrator Password Status : %s\n", 
    619                     hardware->dmi.hardware_security.administrator_passwd_status); 
    620         more_printf("  Front Panel Reset Status      : %s\n", 
    621                     hardware->dmi.hardware_security.front_panel_reset_status); 
     581} 
     582 
     583void show_dmi_oem_strings(int argc __unused, char **argv __unused, 
     584                          struct s_hardware *hardware) 
     585{ 
     586    reset_more_printf(); 
     587 
     588    if (strlen(hardware->dmi.oem_strings)) 
     589        more_printf("OEM Strings\n%s", hardware->dmi.oem_strings); 
     590} 
     591 
     592void show_dmi_hardware_security(int argc __unused, char **argv __unused, 
     593                                struct s_hardware *hardware) 
     594{ 
     595    reset_more_printf(); 
     596 
     597    if (!hardware->dmi.hardware_security.filled) 
     598        return; 
     599 
     600    more_printf("Hardware Security\n"); 
     601    more_printf("  Power-On Password Status      : %s\n", 
     602                hardware->dmi.hardware_security.power_on_passwd_status); 
     603    more_printf("  Keyboard Password Status      : %s\n", 
     604                hardware->dmi.hardware_security.keyboard_passwd_status); 
     605    more_printf("  Administrator Password Status : %s\n", 
     606                hardware->dmi.hardware_security.administrator_passwd_status); 
     607    more_printf("  Front Panel Reset Status      : %s\n", 
     608                hardware->dmi.hardware_security.front_panel_reset_status); 
    622609} 
    623610 
    624611struct cli_callback_descr list_dmi_show_modules[] = { 
    625   { 
    626     .name = CLI_DMI_BASE_BOARD, 
    627     .exec = show_dmi_base_board, 
    628   }, 
    629   { 
    630     .name = CLI_DMI_BIOS, 
    631     .exec = show_dmi_bios, 
    632   }, 
    633   { 
    634     .name = CLI_DMI_BATTERY, 
    635     .exec = show_dmi_battery, 
    636   }, 
    637   { 
    638     .name = CLI_DMI_CHASSIS, 
    639     .exec = show_dmi_chassis, 
    640   }, 
    641   { 
    642     .name = CLI_DMI_MEMORY, 
    643     .exec = show_dmi_memory_modules, 
    644   }, 
    645   { 
    646     .name = CLI_DMI_MEMORY_BANK, 
    647     .exec = show_dmi_memory_bank, 
    648   }, 
    649   { 
    650     .name = "module", 
    651     .exec = show_dmi_memory_module, 
    652   }, 
    653   { 
    654     .name = CLI_DMI_PROCESSOR, 
    655     .exec = show_dmi_cpu, 
    656   }, 
    657   { 
    658     .name = CLI_DMI_SYSTEM, 
    659     .exec = show_dmi_system, 
    660   }, 
    661   { 
    662     .name = CLI_DMI_OEM, 
    663     .exec = show_dmi_oem_strings, 
    664   }, 
    665   { 
    666     .name = CLI_DMI_SECURITY, 
    667     .exec = show_dmi_hardware_security, 
    668   }, 
    669   { 
    670     .name = CLI_DMI_IPMI, 
    671     .exec = show_dmi_ipmi, 
    672   }, 
    673   { 
    674     .name = CLI_DMI_CACHE, 
    675     .exec = show_dmi_cache, 
    676   }, 
    677   { 
    678     .name = CLI_DMI_LIST, 
    679     .exec = show_dmi_modules, 
    680   }, 
    681   { 
    682     .name = NULL, 
    683     .exec = NULL, 
    684   }, 
     612    { 
     613     .name = CLI_DMI_BASE_BOARD, 
     614     .exec = show_dmi_base_board, 
     615     }, 
     616    { 
     617     .name = CLI_DMI_BIOS, 
     618     .exec = show_dmi_bios, 
     619     }, 
     620    { 
     621     .name = CLI_DMI_BATTERY, 
     622     .exec = show_dmi_battery, 
     623     }, 
     624    { 
     625     .name = CLI_DMI_CHASSIS, 
     626     .exec = show_dmi_chassis, 
     627     }, 
     628    { 
     629     .name = CLI_DMI_MEMORY, 
     630     .exec = show_dmi_memory_modules, 
     631     }, 
     632    { 
     633     .name = CLI_DMI_MEMORY_BANK, 
     634     .exec = show_dmi_memory_bank, 
     635     }, 
     636    { 
     637     .name = "module", 
     638     .exec = show_dmi_memory_module, 
     639     }, 
     640    { 
     641     .name = CLI_DMI_PROCESSOR, 
     642     .exec = show_dmi_cpu, 
     643     }, 
     644    { 
     645     .name = CLI_DMI_SYSTEM, 
     646     .exec = show_dmi_system, 
     647     }, 
     648    { 
     649     .name = CLI_DMI_OEM, 
     650     .exec = show_dmi_oem_strings, 
     651     }, 
     652    { 
     653     .name = CLI_DMI_SECURITY, 
     654     .exec = show_dmi_hardware_security, 
     655     }, 
     656    { 
     657     .name = CLI_DMI_IPMI, 
     658     .exec = show_dmi_ipmi, 
     659     }, 
     660    { 
     661     .name = CLI_DMI_CACHE, 
     662     .exec = show_dmi_cache, 
     663     }, 
     664    { 
     665     .name = CLI_DMI_LIST, 
     666     .exec = show_dmi_modules, 
     667     }, 
     668    { 
     669     .name = NULL, 
     670     .exec = NULL, 
     671     }, 
    685672}; 
    686673 
    687674struct cli_module_descr dmi_show_modules = { 
    688         .modules = list_dmi_show_modules, 
    689         .default_callback = main_show_dmi, 
     675    .modules = list_dmi_show_modules, 
     676    .default_callback = main_show_dmi, 
    690677}; 
    691678 
    692679struct cli_mode_descr dmi_mode = { 
    693         .mode = DMI_MODE, 
    694         .name = CLI_DMI, 
    695         .default_modules = NULL, 
    696         .show_modules = &dmi_show_modules, 
    697         .set_modules = NULL, 
     680    .mode = DMI_MODE, 
     681    .name = CLI_DMI, 
     682    .default_modules = NULL, 
     683    .show_modules = &dmi_show_modules, 
     684    .set_modules = NULL, 
    698685}; 
  • com32/hdt/hdt-cli-hdt.c

    r3969cd r990205  
    3939 * cli_clear_screen - clear (erase) the entire screen 
    4040 **/ 
    41 static void cli_clear_screen(int argc __unused, char** argv __unused, 
     41static void cli_clear_screen(int argc __unused, char **argv __unused, 
    4242                             struct s_hardware *hardware __unused) 
    4343{ 
    44         clear_screen(); 
     44    clear_screen(); 
    4545} 
    4646 
     
    4848 * main_show_modes - show availables modes 
    4949 **/ 
    50 static void main_show_modes(int argc __unused, char** argv __unused, 
     50static void main_show_modes(int argc __unused, char **argv __unused, 
    5151                            struct s_hardware *hardware __unused) 
    5252{ 
    53         int i = 0; 
     53    int i = 0; 
    5454 
    5555    reset_more_printf(); 
    56         printf("Available modes:\n"); 
    57         while (list_modes[i]) { 
    58                 printf("%s ", list_modes[i]->name); 
    59                 i++; 
     56    printf("Available modes:\n"); 
     57    while (list_modes[i]) { 
     58        printf("%s ", list_modes[i]->name); 
     59        i++; 
     60    } 
     61    printf("\n"); 
     62} 
     63 
     64/** 
     65 * cli_set_mode - set the mode of the cli, in the cli 
     66 * 
     67 * The mode number must be supplied in argv, position 0. 
     68 **/ 
     69static void cli_set_mode(int argc, char **argv, struct s_hardware *hardware) 
     70{ 
     71    cli_mode_t new_mode; 
     72 
     73    reset_more_printf(); 
     74    if (argc <= 0) { 
     75        more_printf("Which mode?\n"); 
     76        return; 
     77    } 
     78 
     79    /* 
     80     * Note! argv[0] is a string representing the mode, we need the 
     81     * equivalent cli_mode_t to pass it to set_mode. 
     82     */ 
     83    new_mode = mode_s_to_mode_t(argv[0]); 
     84    set_mode(new_mode, hardware); 
     85} 
     86 
     87/** 
     88 * do_exit - shared helper to exit a mode 
     89 **/ 
     90static void do_exit(int argc __unused, char **argv __unused, 
     91                    struct s_hardware *hardware) 
     92{ 
     93    int new_mode = HDT_MODE; 
     94 
     95    switch (hdt_cli.mode) { 
     96    case HDT_MODE: 
     97        new_mode = EXIT_MODE; 
     98        break; 
     99    default: 
     100        new_mode = HDT_MODE; 
     101        break; 
     102    } 
     103 
     104    dprintf("CLI DEBUG: Switching from mode %d to mode %d\n", hdt_cli.mode, 
     105            new_mode); 
     106    set_mode(new_mode, hardware); 
     107} 
     108 
     109/** 
     110 * show_cli_help - shared helper to show available commands 
     111 **/ 
     112static void show_cli_help(int argc __unused, char **argv __unused, 
     113                          struct s_hardware *hardware __unused) 
     114{ 
     115    int j = 0; 
     116    struct cli_mode_descr *current_mode; 
     117    struct cli_callback_descr *associated_module = NULL; 
     118 
     119    find_cli_mode_descr(hdt_cli.mode, &current_mode); 
     120 
     121    printf("Available commands are:\n"); 
     122 
     123    /* List first default modules of the mode */ 
     124    if (current_mode->default_modules && current_mode->default_modules->modules) { 
     125        while (current_mode->default_modules->modules[j].name) { 
     126            printf("%s ", current_mode->default_modules->modules[j].name); 
     127            j++; 
    60128        } 
    61129        printf("\n"); 
    62 } 
    63  
    64 /** 
    65  * cli_set_mode - set the mode of the cli, in the cli 
    66  * 
    67  * The mode number must be supplied in argv, position 0. 
    68  **/ 
    69 static void cli_set_mode(int argc, char **argv, 
    70                          struct s_hardware *hardware) 
    71 { 
    72         cli_mode_t new_mode; 
    73  
    74     reset_more_printf(); 
    75         if (argc <= 0) { 
    76                 more_printf("Which mode?\n"); 
    77                 return; 
     130    } 
     131 
     132    /* List secondly the show modules of the mode */ 
     133    if (current_mode->show_modules && current_mode->show_modules->modules) { 
     134        printf("\nshow commands:\n"); 
     135        j = 0; 
     136        while (current_mode->show_modules->modules[j].name) { 
     137            printf("%s ", current_mode->show_modules->modules[j].name); 
     138            j++; 
    78139        } 
    79  
    80         /* 
    81          * Note! argv[0] is a string representing the mode, we need the 
    82          * equivalent cli_mode_t to pass it to set_mode. 
    83          */ 
    84         new_mode = mode_s_to_mode_t(argv[0]); 
    85         set_mode(new_mode, hardware); 
    86 } 
    87  
    88 /** 
    89  * do_exit - shared helper to exit a mode 
    90  **/ 
    91 static void do_exit(int argc __unused, char** argv __unused, 
    92                     struct s_hardware *hardware) 
    93 { 
    94         int new_mode = HDT_MODE; 
    95  
    96         switch (hdt_cli.mode) { 
    97         case HDT_MODE: 
    98                 new_mode = EXIT_MODE; 
    99                 break; 
    100         default: 
    101                 new_mode = HDT_MODE; 
    102                 break; 
     140        printf("\n"); 
     141    } 
     142 
     143    /* List thirdly the set modules of the mode */ 
     144    if (current_mode->set_modules && current_mode->set_modules->modules) { 
     145        printf("\nset commands:\n"); 
     146        j = 0; 
     147        while (current_mode->set_modules->modules[j].name) { 
     148            printf("%s ", current_mode->set_modules->modules[j].name); 
     149            j++; 
    103150        } 
    104  
    105         dprintf("CLI DEBUG: Switching from mode %d to mode %d\n", hdt_cli.mode, 
    106                                                                   new_mode); 
    107         set_mode(new_mode, hardware); 
     151        printf("\n"); 
     152    } 
     153 
     154    /* List finally the default modules of the hdt mode */ 
     155    if (current_mode->mode != hdt_mode.mode && 
     156        hdt_mode.default_modules && hdt_mode.default_modules->modules) { 
     157        j = 0; 
     158        while (hdt_mode.default_modules->modules[j].name) { 
     159            /* 
     160             * Any default command that is present in hdt mode but 
     161             * not in the current mode is available. A default 
     162             * command can be redefined in the current mode though. 
     163             * This next call test this use case: if it is 
     164             * overwritten, do not print it again. 
     165             */ 
     166            find_cli_callback_descr(hdt_mode.default_modules->modules[j].name, 
     167                                    current_mode->default_modules, 
     168                                    &associated_module); 
     169            if (associated_module == NULL) 
     170                printf("%s ", hdt_mode.default_modules->modules[j].name); 
     171            j++; 
     172        } 
     173        printf("\n"); 
     174    } 
     175 
     176    printf("\n"); 
     177    main_show_modes(argc, argv, hardware); 
    108178} 
    109179 
     
    111181 * show_cli_help - shared helper to show available commands 
    112182 **/ 
    113 static void show_cli_help(int argc __unused, char** argv __unused, 
    114                           struct s_hardware *hardware __unused) 
    115 { 
    116         int j = 0; 
    117         struct cli_mode_descr *current_mode; 
    118         struct cli_callback_descr* associated_module = NULL; 
    119  
    120         find_cli_mode_descr(hdt_cli.mode, &current_mode); 
    121  
    122         printf("Available commands are:\n"); 
    123  
    124         /* List first default modules of the mode */ 
    125         if (current_mode->default_modules && 
    126             current_mode->default_modules->modules) { 
    127                 while (current_mode->default_modules->modules[j].name) { 
    128                         printf("%s ", 
    129                                current_mode->default_modules->modules[j].name); 
    130                         j++; 
    131                 } 
    132                 printf("\n"); 
    133         } 
    134  
    135         /* List secondly the show modules of the mode */ 
    136         if (current_mode->show_modules && 
    137             current_mode->show_modules->modules) { 
    138                 printf("\nshow commands:\n"); 
    139                 j = 0; 
    140                 while (current_mode->show_modules->modules[j].name) { 
    141                         printf("%s ", 
    142                                current_mode->show_modules->modules[j].name); 
    143                         j++; 
    144                 } 
    145                 printf("\n"); 
    146         } 
    147  
    148         /* List thirdly the set modules of the mode */ 
    149         if (current_mode->set_modules && 
    150             current_mode->set_modules->modules) { 
    151                 printf("\nset commands:\n"); 
    152                 j = 0; 
    153                 while (current_mode->set_modules->modules[j].name) { 
    154                         printf("%s ", 
    155                                current_mode->set_modules->modules[j].name); 
    156                         j++; 
    157                 } 
    158                 printf("\n"); 
    159         } 
    160  
    161         /* List finally the default modules of the hdt mode */ 
    162         if (current_mode->mode != hdt_mode.mode && 
    163             hdt_mode.default_modules && 
    164             hdt_mode.default_modules->modules) { 
    165                 j = 0; 
    166                 while (hdt_mode.default_modules->modules[j].name) { 
    167                         /* 
    168                          * Any default command that is present in hdt mode but 
    169                          * not in the current mode is available. A default 
    170                          * command can be redefined in the current mode though. 
    171                          * This next call test this use case: if it is 
    172                          * overwritten, do not print it again. 
    173                          */ 
    174                         find_cli_callback_descr(hdt_mode.default_modules->modules[j].name, 
    175                                              current_mode->default_modules, 
    176                                              &associated_module); 
    177                         if (associated_module == NULL) 
    178                                 printf("%s ", 
    179                                        hdt_mode.default_modules->modules[j].name); 
    180                         j++; 
    181                 } 
    182                 printf("\n"); 
    183         } 
    184  
    185         printf("\n"); 
    186         main_show_modes(argc, argv, hardware); 
    187 } 
    188  
    189 /** 
    190  * show_cli_help - shared helper to show available commands 
    191  **/ 
    192 static void goto_menu(int argc __unused, char** argv __unused, 
     183static void goto_menu(int argc __unused, char **argv __unused, 
    193184                      struct s_hardware *hardware) 
    194185{ 
    195         char version_string[256]; 
    196         snprintf(version_string, sizeof version_string, "%s %s (%s)", 
    197                 PRODUCT_NAME, VERSION, CODENAME); 
    198         start_menu_mode(hardware, version_string); 
    199         return; 
     186    char version_string[256]; 
     187    snprintf(version_string, sizeof version_string, "%s %s (%s)", 
     188            PRODUCT_NAME, VERSION, CODENAME); 
     189    start_menu_mode(hardware, version_string); 
     190    return; 
    200191} 
    201192 
     
    206197                       struct s_hardware *hardware) 
    207198{ 
    208         detect_pci(hardware);   /* pxe is detected in the pci */ 
    209         detect_dmi(hardware); 
    210         cpu_detect(hardware); 
     199    detect_pci(hardware);       /* pxe is detected in the pci */ 
     200    detect_dmi(hardware); 
     201    cpu_detect(hardware); 
    211202    reset_more_printf(); 
    212         clear_screen(); 
    213         main_show_cpu(argc, argv, hardware); 
    214         if (hardware->is_dmi_valid) { 
    215                 more_printf("System\n"); 
    216                 more_printf(" Manufacturer : %s\n", 
    217                             hardware->dmi.system.manufacturer); 
    218                 more_printf(" Product Name : %s\n", 
    219                             hardware->dmi.system.product_name); 
    220                 more_printf(" Serial       : %s\n", 
    221                             hardware->dmi.system.serial); 
    222                 more_printf("Bios\n"); 
    223                 more_printf(" Version      : %s\n", hardware->dmi.bios.version); 
    224                 more_printf(" Release      : %s\n", 
    225                             hardware->dmi.bios.release_date); 
    226  
    227                 int argc = 1; 
    228                 char *argv[1] = { "0" }; 
    229                 show_dmi_memory_modules(argc, argv, hardware); 
    230         } 
    231         main_show_pci(argc, argv, hardware); 
    232  
    233         if (hardware->is_pxe_valid) 
    234                 main_show_pxe(argc, argv, hardware); 
    235  
    236         main_show_kernel(argc, argv, hardware); 
     203    clear_screen(); 
     204    main_show_cpu(argc, argv, hardware); 
     205    if (hardware->is_dmi_valid) { 
     206        more_printf("System\n"); 
     207        more_printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer); 
     208        more_printf(" Product Name : %s\n", hardware->dmi.system.product_name); 
     209        more_printf(" Serial       : %s\n", hardware->dmi.system.serial); 
     210        more_printf("Bios\n"); 
     211        more_printf(" Version      : %s\n", hardware->dmi.bios.version); 
     212        more_printf(" Release      : %s\n", hardware->dmi.bios.release_date); 
     213 
     214        int argc = 1; 
     215        char *argv[1] = { "0" }; 
     216        show_dmi_memory_modules(argc, argv, hardware); 
     217    } 
     218    main_show_pci(argc, argv, hardware); 
     219 
     220    if (hardware->is_pxe_valid) 
     221        main_show_pxe(argc, argv, hardware); 
     222 
     223    main_show_kernel(argc, argv, hardware); 
    237224} 
    238225 
     
    241228{ 
    242229    reset_more_printf(); 
    243         more_printf("HDT\n"); 
    244         more_printf(" Product        : %s\n", PRODUCT_NAME); 
    245         more_printf(" Version        : %s (%s)\n", VERSION, CODENAME); 
    246         more_printf(" Project Leader : %s\n", AUTHOR); 
    247         more_printf(" Contact        : %s\n", CONTACT); 
    248         more_printf(" Core Developer : %s\n", CORE_DEVELOPER); 
    249         char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS; 
    250         for (int c = 0; c < NB_CONTRIBUTORS; c++) { 
    251                 more_printf(" Contributor    : %s\n", contributors[c]); 
    252         } 
     230    more_printf("HDT\n"); 
     231    more_printf(" Product        : %s\n", PRODUCT_NAME); 
     232    more_printf(" Version        : %s (%s)\n", VERSION, CODENAME); 
     233    more_printf(" Project Leader : %s\n", AUTHOR); 
     234    more_printf(" Contact        : %s\n", CONTACT); 
     235    more_printf(" Core Developer : %s\n", CORE_DEVELOPER); 
     236    char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS; 
     237    for (int c = 0; c < NB_CONTRIBUTORS; c++) { 
     238        more_printf(" Contributor    : %s\n", contributors[c]); 
     239    } 
    253240} 
    254241 
     
    256243 * do_reboot - reboot the system 
    257244 **/ 
    258 static void do_reboot(int argc __unused, char** argv __unused, 
    259                           struct s_hardware *hardware) 
     245static void do_reboot(int argc __unused, char **argv __unused, 
     246                      struct s_hardware *hardware) 
    260247{ 
    261248    /* Use specific syslinux call if needed */ 
    262249    if (issyslinux()) 
    263         return runsyslinuxcmd(hardware->reboot_label); 
     250        return runsyslinuxcmd(hardware->reboot_label); 
    264251    else 
    265         return csprint(hardware->reboot_label, 0x07); 
     252        return csprint(hardware->reboot_label, 0x07); 
    266253} 
    267254 
    268255/* Default hdt mode */ 
    269256struct cli_callback_descr list_hdt_default_modules[] = { 
    270         { 
    271                 .name = CLI_CLEAR, 
    272                 .exec = cli_clear_screen, 
    273         }, 
    274         { 
    275                 .name = CLI_EXIT, 
    276                 .exec = do_exit, 
    277         }, 
    278         { 
    279                 .name = CLI_HELP, 
    280                 .exec = show_cli_help, 
    281         }, 
    282         { 
    283                 .name = CLI_MENU, 
    284                 .exec = goto_menu, 
    285         }, 
    286         { 
    287                 .name = CLI_REBOOT, 
    288                 .exec = do_reboot, 
    289         }, 
    290         { 
    291                 .name = NULL, 
    292                 .exec = NULL 
    293         }, 
     257    { 
     258     .name = CLI_CLEAR, 
     259     .exec = cli_clear_screen, 
     260     }, 
     261    { 
     262     .name = CLI_EXIT, 
     263     .exec = do_exit, 
     264     }, 
     265    { 
     266     .name = CLI_HELP, 
     267     .exec = show_cli_help, 
     268     }, 
     269    { 
     270     .name = CLI_MENU, 
     271     .exec = goto_menu, 
     272     }, 
     273    { 
     274     .name = CLI_REBOOT, 
     275     .exec = do_reboot, 
     276     }, 
     277    { 
     278     .name = NULL, 
     279     .exec = NULL}, 
    294280}; 
    295281 
    296282struct cli_callback_descr list_hdt_show_modules[] = { 
    297         { 
    298                 .name = CLI_SUMMARY, 
    299                 .exec = main_show_summary, 
    300         }, 
    301         { 
    302                 .name = CLI_PCI, 
    303                 .exec = main_show_pci, 
    304         }, 
    305         { 
    306                 .name = CLI_DMI, 
    307                 .exec = main_show_dmi, 
    308         }, 
    309         { 
    310                 .name = CLI_CPU, 
    311                 .exec = main_show_cpu, 
    312         }, 
    313         { 
    314                 .name = CLI_DISK, 
    315                 .exec = disks_summary, 
    316         }, 
    317         { 
    318                 .name = CLI_PXE, 
    319                 .exec = main_show_pxe, 
    320         }, 
    321         { 
    322                 .name = CLI_SYSLINUX, 
    323                 .exec = main_show_syslinux, 
    324         }, 
    325         { 
    326                 .name = CLI_KERNEL, 
    327                 .exec = main_show_kernel, 
    328         }, 
    329         { 
    330                 .name = CLI_VESA, 
    331                 .exec = main_show_vesa, 
    332         }, 
    333         { 
    334                 .name = CLI_HDT, 
    335                 .exec = main_show_hdt, 
    336         }, 
    337         { 
    338                 .name = CLI_VPD, 
    339                 .exec = main_show_vpd, 
    340         }, 
    341         { 
    342                 .name = CLI_MEMORY, 
    343                 .exec = show_dmi_memory_modules, 
    344         }, 
    345         { 
    346                 .name = "modes", 
    347                 .exec = main_show_modes, 
    348         }, 
    349         { 
    350                 .name = NULL, 
    351                 .exec = NULL, 
    352         }, 
     283    { 
     284     .name = CLI_SUMMARY, 
     285     .exec = main_show_summary, 
     286     }, 
     287    { 
     288     .name = CLI_PCI, 
     289     .exec = main_show_pci, 
     290     }, 
     291    { 
     292     .name = CLI_DMI, 
     293     .exec = main_show_dmi, 
     294     }, 
     295    { 
     296     .name = CLI_CPU, 
     297     .exec = main_show_cpu, 
     298     }, 
     299    { 
     300     .name = CLI_DISK, 
     301     .exec = disks_summary, 
     302     }, 
     303    { 
     304     .name = CLI_PXE, 
     305     .exec = main_show_pxe, 
     306     }, 
     307    { 
     308     .name = CLI_SYSLINUX, 
     309     .exec = main_show_syslinux, 
     310     }, 
     311    { 
     312     .name = CLI_KERNEL, 
     313     .exec = main_show_kernel, 
     314     }, 
     315    { 
     316     .name = CLI_VESA, 
     317     .exec = main_show_vesa, 
     318     }, 
     319    { 
     320     .name = CLI_HDT, 
     321     .exec = main_show_hdt, 
     322     }, 
     323    { 
     324     .name = CLI_VPD, 
     325     .exec = main_show_vpd, 
     326     }, 
     327    { 
     328     .name = CLI_MEMORY, 
     329     .exec = show_dmi_memory_modules, 
     330     }, 
     331    { 
     332     .name = "modes", 
     333     .exec = main_show_modes, 
     334     }, 
     335    { 
     336     .name = NULL, 
     337     .exec = NULL, 
     338     }, 
    353339}; 
    354340 
    355341struct cli_callback_descr list_hdt_set_modules[] = { 
    356         { 
    357                 .name = CLI_MODE, 
    358                 .exec = cli_set_mode, 
    359         }, 
    360         { 
    361                 .name = NULL, 
    362                 .exec = NULL, 
    363         }, 
     342    { 
     343     .name = CLI_MODE, 
     344     .exec = cli_set_mode, 
     345     }, 
     346    { 
     347     .name = NULL, 
     348     .exec = NULL, 
     349     }, 
    364350}; 
    365351 
    366352struct cli_module_descr hdt_default_modules = { 
    367         .modules = list_hdt_default_modules, 
     353    .modules = list_hdt_default_modules, 
    368354}; 
    369355 
    370356struct cli_module_descr hdt_show_modules = { 
    371         .modules = list_hdt_show_modules, 
    372         .default_callback = main_show_summary, 
     357    .modules = list_hdt_show_modules, 
     358    .default_callback = main_show_summary, 
    373359}; 
    374360 
    375361struct cli_module_descr hdt_set_modules = { 
    376         .modules = list_hdt_set_modules, 
     362    .modules = list_hdt_set_modules, 
    377363}; 
    378364 
    379365struct cli_mode_descr hdt_mode = { 
    380         .mode = HDT_MODE, 
    381         .name = CLI_HDT, 
    382         .default_modules = &hdt_default_modules, 
    383         .show_modules = &hdt_show_modules, 
    384         .set_modules = &hdt_set_modules, 
    385 }; 
     366    .mode = HDT_MODE, 
     367    .name = CLI_HDT, 
     368    .default_modules = &hdt_default_modules, 
     369    .show_modules = &hdt_show_modules, 
     370    .set_modules = &hdt_set_modules, 
     371}; 
  • com32/hdt/hdt-cli-kernel.c

    rdff898 r990205  
    3838                      struct s_hardware *hardware) 
    3939{ 
    40         char buffer[1024]; 
    41         struct pci_device *pci_device; 
    42         bool found = false; 
    43         char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
    44                             MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
     40    char buffer[1024]; 
     41    struct pci_device *pci_device; 
     42    bool found = false; 
     43    char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
     44                        MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
    4545 
    46         memset(buffer, 0, sizeof(buffer)); 
     46    memset(buffer, 0, sizeof(buffer)); 
    4747 
    48         detect_pci(hardware); 
     48    detect_pci(hardware); 
    4949    reset_more_printf(); 
    50         more_printf("Kernel modules\n"); 
     50    more_printf("Kernel modules\n"); 
    5151 
    5252// more_printf(" PCI device no: %d \n", p->pci_device_pos); 
    5353 
    54         if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) 
    55            && (hardware->modules_alias_return_code == -ENOMODULESALIAS)) { 
    56                 more_printf(" modules.pcimap and modules.alias files are missing\n"); 
    57                 return; 
     54    if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) 
     55        && (hardware->modules_alias_return_code == -ENOMODULESALIAS)) { 
     56        more_printf(" modules.pcimap and modules.alias files are missing\n"); 
     57        return; 
     58    } 
     59 
     60    /* For every detected pci device, compute its submenu */ 
     61    for_each_pci_func(pci_device, hardware->pci_domain) { 
     62        memset(kernel_modules, 0, sizeof kernel_modules); 
     63 
     64        for (int kmod = 0; 
     65             kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) { 
     66            if (kmod > 0) { 
     67                strncat(kernel_modules, " | ", 3); 
     68            } 
     69            strncat(kernel_modules, 
     70                    pci_device->dev_info->linux_kernel_module[kmod], 
     71                    LINUX_KERNEL_MODULE_SIZE - 1); 
    5872        } 
    5973 
    60         /* For every detected pci device, compute its submenu */ 
    61         for_each_pci_func(pci_device, hardware->pci_domain) { 
    62                 memset(kernel_modules, 0, sizeof kernel_modules); 
     74        if ((pci_device->dev_info->linux_kernel_module_count > 0) 
     75            && (!strstr(buffer, kernel_modules))) { 
     76            found = true; 
     77            if (pci_device->dev_info->linux_kernel_module_count > 1) 
     78                strncat(buffer, "(", 1); 
     79            strncat(buffer, kernel_modules, sizeof(kernel_modules)); 
     80            if (pci_device->dev_info->linux_kernel_module_count > 1) 
     81                strncat(buffer, ")", 1); 
     82            strncat(buffer, " # ", 3); 
     83        } 
    6384 
    64                 for (int kmod = 0; 
    65                      kmod < pci_device->dev_info->linux_kernel_module_count; 
    66                      kmod++) { 
    67                         if (kmod > 0) { 
    68                                 strncat(kernel_modules, " | ", 3); 
    69                         } 
    70                         strncat(kernel_modules, 
    71                                 pci_device->dev_info->linux_kernel_module[kmod], 
    72                                 LINUX_KERNEL_MODULE_SIZE - 1); 
    73                 } 
    74  
    75                 if ((pci_device->dev_info->linux_kernel_module_count > 0) 
    76                     && (!strstr(buffer, kernel_modules))) { 
    77                         found = true; 
    78                         if (pci_device->dev_info->linux_kernel_module_count > 1) 
    79                                 strncat(buffer, "(", 1); 
    80                         strncat(buffer, kernel_modules, sizeof(kernel_modules)); 
    81                         if (pci_device->dev_info->linux_kernel_module_count > 1) 
    82                                 strncat(buffer, ")", 1); 
    83                         strncat(buffer, " # ", 3); 
    84                 } 
    85  
    86         } 
    87         if (found == true) { 
    88                 strncat(buffer, "\n", 1); 
    89                 more_printf(buffer); 
    90         } 
     85    } 
     86    if (found == true) { 
     87        strncat(buffer, "\n", 1); 
     88        more_printf(buffer); 
     89    } 
    9190} 
    9291 
     
    9493                                struct s_hardware *hardware) 
    9594{ 
    96         struct pci_device *pci_device; 
    97         char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
    98                             MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
    99         bool nopciids = false; 
    100         bool nomodulespcimap = false; 
    101         char modules[MAX_PCI_CLASSES][256]; 
    102         char category_name[MAX_PCI_CLASSES][256]; 
     95    struct pci_device *pci_device; 
     96    char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
     97                        MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
     98    bool nopciids = false; 
     99    bool nomodulespcimap = false; 
     100    char modules[MAX_PCI_CLASSES][256]; 
     101    char category_name[MAX_PCI_CLASSES][256]; 
    103102 
    104         detect_pci(hardware); 
    105         memset(&modules, 0, sizeof(modules)); 
     103    detect_pci(hardware); 
     104    memset(&modules, 0, sizeof(modules)); 
    106105 
    107         if (hardware->pci_ids_return_code == -ENOPCIIDS) { 
    108                 nopciids = true; 
    109                 more_printf(" Missing pci.ids, we can't compute the list\n"); 
    110                 return; 
     106    if (hardware->pci_ids_return_code == -ENOPCIIDS) { 
     107        nopciids = true; 
     108        more_printf(" Missing pci.ids, we can't compute the list\n"); 
     109        return; 
     110    } 
     111 
     112    if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) { 
     113        nomodulespcimap = true; 
     114        more_printf(" Missing modules.pcimap, we can't compute the list\n"); 
     115        return; 
     116    } 
     117 
     118    reset_more_printf(); 
     119    for_each_pci_func(pci_device, hardware->pci_domain) { 
     120        memset(kernel_modules, 0, sizeof kernel_modules); 
     121 
     122        for (int kmod = 0; 
     123             kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) { 
     124            strncat(kernel_modules, 
     125                    pci_device->dev_info->linux_kernel_module[kmod], 
     126                    LINUX_KERNEL_MODULE_SIZE - 1); 
     127            strncat(kernel_modules, " ", 1); 
    111128        } 
    112129 
    113         if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) { 
    114                 nomodulespcimap = true; 
    115                 more_printf 
    116                     (" Missing modules.pcimap, we can't compute the list\n"); 
    117                 return; 
     130        if ((pci_device->dev_info->linux_kernel_module_count > 0) 
     131            && (!strstr(modules[pci_device->class[2]], kernel_modules))) { 
     132            strncat(modules[pci_device->class[2]], kernel_modules, 
     133                    sizeof(kernel_modules)); 
     134            snprintf(category_name[pci_device->class[2]], 
     135                     sizeof(category_name[pci_device->class[2]]), 
     136                     "%s", pci_device->dev_info->category_name); 
    118137        } 
    119  
    120     reset_more_printf(); 
    121         for_each_pci_func(pci_device, hardware->pci_domain) { 
    122                 memset(kernel_modules, 0, sizeof kernel_modules); 
    123  
    124                 for (int kmod = 0; 
    125                      kmod < pci_device->dev_info->linux_kernel_module_count; 
    126                      kmod++) { 
    127                         strncat(kernel_modules, 
    128                                 pci_device->dev_info->linux_kernel_module[kmod], 
    129                                 LINUX_KERNEL_MODULE_SIZE - 1); 
    130                         strncat(kernel_modules, " ", 1); 
    131                 } 
    132  
    133                 if ((pci_device->dev_info->linux_kernel_module_count > 0) 
    134                     && (!strstr(modules[pci_device->class[2]], kernel_modules))) { 
    135                         strncat(modules[pci_device->class[2]], kernel_modules, 
    136                                 sizeof(kernel_modules)); 
    137                         snprintf(category_name[pci_device->class[2]], 
    138                                  sizeof(category_name[pci_device->class[2]]), 
    139                                  "%s", pci_device->dev_info->category_name); 
    140                 } 
     138    } 
     139    /* Print the found items */ 
     140    for (int i = 0; i < MAX_PCI_CLASSES; i++) { 
     141        if (strlen(category_name[i]) > 1) { 
     142            more_printf("%s : %s\n", category_name[i], modules[i]); 
    141143        } 
    142         /* Print the found items */ 
    143         for (int i = 0; i < MAX_PCI_CLASSES; i++) { 
    144                 if (strlen(category_name[i]) > 1) { 
    145                         more_printf("%s : %s\n", category_name[i], modules[i]); 
    146                 } 
    147         } 
     144    } 
    148145} 
    149146 
    150147struct cli_module_descr kernel_show_modules = { 
    151         .modules = NULL, 
    152         .default_callback = show_kernel_modules, 
     148    .modules = NULL, 
     149    .default_callback = show_kernel_modules, 
    153150}; 
    154151 
    155152struct cli_mode_descr kernel_mode = { 
    156         .mode = KERNEL_MODE, 
    157         .name = CLI_KERNEL, 
    158         .default_modules = NULL, 
    159         .show_modules = &kernel_show_modules, 
    160         .set_modules = NULL, 
     153    .mode = KERNEL_MODE, 
     154    .name = CLI_KERNEL, 
     155    .default_modules = NULL, 
     156    .show_modules = &kernel_show_modules, 
     157    .set_modules = NULL, 
    161158}; 
  • com32/hdt/hdt-cli-memory.c

    r219c2a r990205  
    3535                             struct s_hardware *hardware __unused) 
    3636{ 
    37         struct e820entry map[E820MAX]; 
    38         unsigned long memsize=0; 
    39         int count = 0; 
    40         char type[14]; 
     37    struct e820entry map[E820MAX]; 
     38    unsigned long memsize = 0; 
     39    int count = 0; 
     40    char type[14]; 
    4141 
    42         detect_memory_e820(map, E820MAX, &count); 
    43         memsize=memsize_e820(map,count); 
    44         reset_more_printf(); 
    45         more_printf("Detected RAM                       : %lu MiB (%lu KiB)\n",(memsize+(1<<9))>>10,memsize); 
    46         more_printf("BIOS-provided physical RAM e820 map:\n"); 
    47         for (int i = 0; i < count; i++) { 
    48                 get_type(map[i].type, type, 14); 
    49                 more_printf("%016llx - %016llx %016llx (%s)\n", 
    50                             map[i].addr, map[i].size, map[i].addr+map[i].size, 
    51                             remove_spaces(type)); 
    52         } 
    53         struct e820entry nm[E820MAX]; 
     42    detect_memory_e820(map, E820MAX, &count); 
     43    memsize = memsize_e820(map, count); 
     44    reset_more_printf(); 
     45    more_printf("Detected RAM                       : %lu MiB (%lu KiB)\n", 
     46                (memsize + (1 << 9)) >> 10, memsize); 
     47    more_printf("BIOS-provided physical RAM e820 map:\n"); 
     48    for (int i = 0; i < count; i++) { 
     49        get_type(map[i].type, type, 14); 
     50        more_printf("%016llx - %016llx %016llx (%s)\n", 
     51                    map[i].addr, map[i].size, map[i].addr + map[i].size, 
     52                    remove_spaces(type)); 
     53    } 
     54    struct e820entry nm[E820MAX]; 
    5455 
    55         /* Clean up, adjust and copy the BIOS-supplied E820-map. */ 
    56         int nr = sanitize_e820_map(map, nm, count); 
     56    /* Clean up, adjust and copy the BIOS-supplied E820-map. */ 
     57    int nr = sanitize_e820_map(map, nm, count); 
    5758 
    58         more_printf("\n"); 
    59         more_printf("Sanitized e820 map:\n"); 
    60         for (int i = 0; i < nr; i++) { 
    61                 get_type(nm[i].type, type, 14); 
    62                 more_printf("%016llx - %016llx %016llx (%s)\n", 
    63                             nm[i].addr, nm[i].size, nm[i].addr+nm[i].size, 
    64                             remove_spaces(type)); 
    65         } 
     59    more_printf("\n"); 
     60    more_printf("Sanitized e820 map:\n"); 
     61    for (int i = 0; i < nr; i++) { 
     62        get_type(nm[i].type, type, 14); 
     63        more_printf("%016llx - %016llx %016llx (%s)\n", 
     64                    nm[i].addr, nm[i].size, nm[i].addr + nm[i].size, 
     65                    remove_spaces(type)); 
     66    } 
    6667} 
    6768 
     
    6970                             struct s_hardware *hardware __unused) 
    7071{ 
    71         int mem_low, mem_high = 0; 
     72    int mem_low, mem_high = 0; 
    7273 
    73         reset_more_printf(); 
    74         if (detect_memory_e801(&mem_low, &mem_high)) { 
    75                 more_printf("e801 bogus!\n"); 
    76         } else { 
    77                 more_printf("Detected RAM : %d MiB(%d KiB)\n",(mem_low>>10) + (mem_high>>4),mem_low+(mem_high << 6)); 
    78                 more_printf("e801 details : %d Kb (%d MiB) - %d Kb (%d MiB)\n", 
    79                 mem_low, mem_low >> 10, mem_high << 6, mem_high >> 4); 
    80         } 
     74    reset_more_printf(); 
     75    if (detect_memory_e801(&mem_low, &mem_high)) { 
     76        more_printf("e801 bogus!\n"); 
     77    } else { 
     78        more_printf("Detected RAM : %d MiB(%d KiB)\n", 
     79                    (mem_low >> 10) + (mem_high >> 4), 
     80                    mem_low + (mem_high << 6)); 
     81        more_printf("e801 details : %d Kb (%d MiB) - %d Kb (%d MiB)\n", mem_low, 
     82                    mem_low >> 10, mem_high << 6, mem_high >> 4); 
     83    } 
    8184} 
    8285 
     
    8487                           struct s_hardware *hardware __unused) 
    8588{ 
    86         int mem_size = 0; 
     89    int mem_size = 0; 
    8790 
    88         reset_more_printf(); 
    89         if (detect_memory_88(&mem_size)) { 
    90                 more_printf("8800h bogus!\n"); 
    91         } else { 
    92                 more_printf("8800h memory size: %d Kb (%d MiB)\n", mem_size, 
    93                                                                    mem_size >> 10); 
    94         } 
     91    reset_more_printf(); 
     92    if (detect_memory_88(&mem_size)) { 
     93        more_printf("8800h bogus!\n"); 
     94    } else { 
     95        more_printf("8800h memory size: %d Kb (%d MiB)\n", mem_size, 
     96                    mem_size >> 10); 
     97    } 
    9598} 
    9699 
    97100struct cli_callback_descr list_memory_show_modules[] = { 
    98         { 
    99                 .name = "e820", 
    100                 .exec = show_memory_e820, 
    101         }, 
    102         { 
    103                 .name = "e801", 
    104                 .exec = show_memory_e801, 
    105         }, 
    106         { 
    107                 .name = "88", 
    108                 .exec = show_memory_88, 
    109         }, 
    110         { 
    111                 .name = CLI_DMI_MEMORY_BANK, 
    112                 .exec = show_dmi_memory_bank, 
    113         }, 
    114         { 
    115                 .name = NULL, 
    116                 .exec = NULL, 
    117         }, 
     101    { 
     102     .name = "e820", 
     103     .exec = show_memory_e820, 
     104     }, 
     105    { 
     106     .name = "e801", 
     107     .exec = show_memory_e801, 
     108     }, 
     109    { 
     110     .name = "88", 
     111     .exec = show_memory_88, 
     112     }, 
     113    { 
     114     .name = CLI_DMI_MEMORY_BANK, 
     115     .exec = show_dmi_memory_bank, 
     116     }, 
     117    { 
     118     .name = NULL, 
     119     .exec = NULL, 
     120     }, 
    118121}; 
    119122 
    120123struct cli_module_descr memory_show_modules = { 
    121         .modules = list_memory_show_modules, 
    122         .default_callback = show_dmi_memory_modules, 
     124    .modules = list_memory_show_modules, 
     125    .default_callback = show_dmi_memory_modules, 
    123126}; 
    124127 
    125128struct cli_mode_descr memory_mode = { 
    126         .mode = MEMORY_MODE, 
    127         .name = CLI_MEMORY, 
    128         .default_modules = NULL, 
    129         .show_modules = &memory_show_modules, 
    130         .set_modules = NULL, 
     129    .mode = MEMORY_MODE, 
     130    .name = CLI_MEMORY, 
     131    .default_modules = NULL, 
     132    .show_modules = &memory_show_modules, 
     133    .set_modules = NULL, 
    131134}; 
  • com32/hdt/hdt-cli-pci.c

    r35c507 r990205  
    3737                   struct s_hardware *hardware) 
    3838{ 
    39         cli_detect_pci(hardware); 
    40         reset_more_printf(); 
    41         more_printf("PCI\n"); 
    42         more_printf(" NB Devices   : %d\n", hardware->nb_pci_devices); 
    43 } 
    44  
    45 static void show_pci_device(int argc, char **argv, 
    46                             struct s_hardware *hardware) 
    47 { 
    48         int i = 0; 
    49         struct pci_device *pci_device = NULL, *temp_pci_device; 
    50         int pcidev = -1; 
    51         bool nopciids = false; 
    52         bool nomodulespcimap = false; 
    53         bool nomodulesalias = false; 
    54         bool nomodulesfiles = false; 
    55         char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
    56                             MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
    57         int bus = 0, slot = 0, func = 0; 
    58  
     39    cli_detect_pci(hardware); 
    5940    reset_more_printf(); 
    60         /* Sanitize arguments */ 
    61         if (argc <= 0) { 
    62                 more_printf("show device <number>\n"); 
    63                 return; 
    64         } else 
    65                 pcidev = strtol(argv[0], (char **)NULL, 10); 
    66  
    67         if (errno == ERANGE) { 
    68                 more_printf("This PCI device number is incorrect\n"); 
    69                 return; 
    70         } 
    71         if ((pcidev > hardware->nb_pci_devices) || (pcidev <= 0)) { 
    72                 more_printf("PCI device %d doesn't exist\n", pcidev); 
    73                 return; 
    74         } 
    75         if (hardware->pci_ids_return_code == -ENOPCIIDS) { 
    76                 nopciids = true; 
    77         } 
    78         if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) { 
    79                 nomodulespcimap = true; 
    80         } 
    81         if (hardware->modules_alias_return_code == -ENOMODULESALIAS) { 
    82                 nomodulesalias = true; 
    83         } 
    84         nomodulesfiles=nomodulespcimap && nomodulesalias; 
    85         for_each_pci_func(temp_pci_device, hardware->pci_domain) { 
    86                 i++; 
    87                 if (i == pcidev) { 
    88                         bus = __pci_bus; 
    89                         slot = __pci_slot; 
    90                         func = __pci_func; 
    91                         pci_device = temp_pci_device; 
    92                 } 
    93         } 
    94  
    95         if (pci_device == NULL) { 
    96                 more_printf("We were enabled to find PCI device %d\n", pcidev); 
    97                 return; 
    98         } 
    99  
     41    more_printf("PCI\n"); 
     42    more_printf(" NB Devices   : %d\n", hardware->nb_pci_devices); 
     43} 
     44 
     45static void show_pci_device(int argc, char **argv, struct s_hardware *hardware) 
     46{ 
     47    int i = 0; 
     48    struct pci_device *pci_device = NULL, *temp_pci_device; 
     49    int pcidev = -1; 
     50    bool nopciids = false; 
     51    bool nomodulespcimap = false; 
     52    bool nomodulesalias = false; 
     53    bool nomodulesfiles = false; 
     54    char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
     55                        MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
     56    int bus = 0, slot = 0, func = 0; 
     57 
     58    reset_more_printf(); 
     59    /* Sanitize arguments */ 
     60    if (argc <= 0) { 
     61        more_printf("show device <number>\n"); 
     62        return; 
     63    } else 
     64        pcidev = strtol(argv[0], (char **)NULL, 10); 
     65 
     66    if (errno == ERANGE) { 
     67        more_printf("This PCI device number is incorrect\n"); 
     68        return; 
     69    } 
     70    if ((pcidev > hardware->nb_pci_devices) || (pcidev <= 0)) { 
     71        more_printf("PCI device %d doesn't exist\n", pcidev); 
     72        return; 
     73    } 
     74    if (hardware->pci_ids_return_code == -ENOPCIIDS) { 
     75        nopciids = true; 
     76    } 
     77    if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) { 
     78        nomodulespcimap = true; 
     79    } 
     80    if (hardware->modules_alias_return_code == -ENOMODULESALIAS) { 
     81        nomodulesalias = true; 
     82    } 
     83    nomodulesfiles = nomodulespcimap && nomodulesalias; 
     84    for_each_pci_func(temp_pci_device, hardware->pci_domain) { 
     85        i++; 
     86        if (i == pcidev) { 
     87            bus = __pci_bus; 
     88            slot = __pci_slot; 
     89            func = __pci_func; 
     90            pci_device = temp_pci_device; 
     91        } 
     92    } 
     93 
     94    if (pci_device == NULL) { 
     95        more_printf("We were enabled to find PCI device %d\n", pcidev); 
     96        return; 
     97    } 
     98 
     99    memset(kernel_modules, 0, sizeof kernel_modules); 
     100    for (int kmod = 0; 
     101         kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) { 
     102        if (kmod > 0) { 
     103            strncat(kernel_modules, " | ", 3); 
     104        } 
     105        strncat(kernel_modules, 
     106                pci_device->dev_info->linux_kernel_module[kmod], 
     107                LINUX_KERNEL_MODULE_SIZE - 1); 
     108    } 
     109    if (pci_device->dev_info->linux_kernel_module_count == 0) 
     110        strlcpy(kernel_modules, "unknown", 7); 
     111 
     112    more_printf("PCI Device %d\n", pcidev); 
     113 
     114    if (nopciids == false) { 
     115        more_printf("Vendor Name   : %s\n", pci_device->dev_info->vendor_name); 
     116        more_printf("Product Name  : %s\n", pci_device->dev_info->product_name); 
     117        more_printf("Class Name    : %s\n", pci_device->dev_info->class_name); 
     118    } 
     119 
     120    if (nomodulesfiles == false) { 
     121        more_printf("Kernel module : %s\n", kernel_modules); 
     122    } 
     123 
     124    more_printf("Vendor ID     : %04x\n", pci_device->vendor); 
     125    more_printf("Product ID    : %04x\n", pci_device->product); 
     126    more_printf("SubVendor ID  : %04x\n", pci_device->sub_vendor); 
     127    more_printf("SubProduct ID : %04x\n", pci_device->sub_product); 
     128    more_printf("Class ID      : %02x.%02x.%02x\n", pci_device->class[2], 
     129                pci_device->class[1], pci_device->class[0]); 
     130    more_printf("Revision      : %02x\n", pci_device->revision); 
     131    if ((pci_device->dev_info->irq > 0) 
     132        && (pci_device->dev_info->irq < 255)) 
     133        more_printf("IRQ           : %0d\n", pci_device->dev_info->irq); 
     134    more_printf("Latency       : %0d\n", pci_device->dev_info->latency); 
     135    more_printf("PCI Bus       : %02d\n", bus); 
     136    more_printf("PCI Slot      : %02d\n", slot); 
     137    more_printf("PCI Func      : %02d\n", func); 
     138 
     139    if (hardware->is_pxe_valid == true) { 
     140        if ((hardware->pxe.pci_device != NULL) 
     141            && (hardware->pxe.pci_device == pci_device)) { 
     142            more_printf("Mac Address   : %s\n", hardware->pxe.mac_addr); 
     143            more_printf("PXE           : Current boot device\n"); 
     144        } 
     145    } 
     146} 
     147 
     148static void show_pci_devices(int argc __unused, char **argv __unused, 
     149                             struct s_hardware *hardware) 
     150{ 
     151    int i = 1; 
     152    struct pci_device *pci_device; 
     153    char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
     154                        MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
     155    bool nopciids = false; 
     156    bool nomodulespcimap = false; 
     157    bool nomodulesalias = false; 
     158    bool nomodulesfile = false; 
     159    char first_line[81]; 
     160    char second_line[81]; 
     161 
     162    reset_more_printf(); 
     163    more_printf("%d PCI devices detected\n", hardware->nb_pci_devices); 
     164 
     165    if (hardware->pci_ids_return_code == -ENOPCIIDS) { 
     166        nopciids = true; 
     167    } 
     168    if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) { 
     169        nomodulespcimap = true; 
     170    } 
     171    if (hardware->modules_pcimap_return_code == -ENOMODULESALIAS) { 
     172        nomodulesalias = true; 
     173    } 
     174 
     175    nomodulesfile = nomodulespcimap && nomodulesalias; 
     176 
     177    /* For every detected pci device, compute its submenu */ 
     178    for_each_pci_func(pci_device, hardware->pci_domain) { 
    100179        memset(kernel_modules, 0, sizeof kernel_modules); 
    101180        for (int kmod = 0; 
    102181             kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) { 
    103                 if (kmod > 0) { 
    104                         strncat(kernel_modules, " | ", 3); 
    105                 } 
    106                 strncat(kernel_modules, 
    107                         pci_device->dev_info->linux_kernel_module[kmod], 
    108                         LINUX_KERNEL_MODULE_SIZE - 1); 
     182            if (kmod > 0) { 
     183                strncat(kernel_modules, " | ", 3); 
     184            } 
     185            strncat(kernel_modules, 
     186                    pci_device->dev_info->linux_kernel_module[kmod], 
     187                    LINUX_KERNEL_MODULE_SIZE - 1); 
    109188        } 
    110189        if (pci_device->dev_info->linux_kernel_module_count == 0) 
    111                 strlcpy(kernel_modules, "unknown", 7); 
    112  
    113         more_printf("PCI Device %d\n", pcidev); 
     190            strlcpy(kernel_modules, "unknown", 7); 
    114191 
    115192        if (nopciids == false) { 
    116                 more_printf("Vendor Name   : %s\n", 
    117                             pci_device->dev_info->vendor_name); 
    118                 more_printf("Product Name  : %s\n", 
    119                             pci_device->dev_info->product_name); 
    120                 more_printf("Class Name    : %s\n", 
    121                             pci_device->dev_info->class_name); 
    122         } 
    123  
    124         if (nomodulesfiles == false) { 
    125                 more_printf("Kernel module : %s\n", kernel_modules); 
    126         } 
    127  
    128         more_printf("Vendor ID     : %04x\n", pci_device->vendor); 
    129         more_printf("Product ID    : %04x\n", pci_device->product); 
    130         more_printf("SubVendor ID  : %04x\n", pci_device->sub_vendor); 
    131         more_printf("SubProduct ID : %04x\n", pci_device->sub_product); 
    132         more_printf("Class ID      : %02x.%02x.%02x\n", pci_device->class[2], 
    133                     pci_device->class[1], pci_device->class[0]); 
    134         more_printf("Revision      : %02x\n", pci_device->revision); 
    135         if ((pci_device->dev_info->irq > 0) 
    136             && (pci_device->dev_info->irq < 255)) 
    137                 more_printf("IRQ           : %0d\n", pci_device->dev_info->irq); 
    138         more_printf("Latency       : %0d\n", pci_device->dev_info->latency); 
    139         more_printf("PCI Bus       : %02d\n", bus); 
    140         more_printf("PCI Slot      : %02d\n", slot); 
    141         more_printf("PCI Func      : %02d\n", func); 
    142  
    143         if (hardware->is_pxe_valid == true) { 
    144                 if ((hardware->pxe.pci_device != NULL) 
    145                     && (hardware->pxe.pci_device == pci_device)) { 
    146                         more_printf("Mac Address   : %s\n", hardware->pxe.mac_addr); 
    147                         more_printf("PXE           : Current boot device\n"); 
    148                 } 
    149         } 
    150 } 
    151  
    152 static void show_pci_devices(int argc __unused, char **argv __unused, 
    153                              struct s_hardware *hardware) 
    154 { 
    155         int i = 1; 
    156         struct pci_device *pci_device; 
    157         char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
    158                             MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
    159         bool nopciids = false; 
    160         bool nomodulespcimap = false; 
    161         bool nomodulesalias = false; 
    162         bool nomodulesfile = false; 
    163         char first_line[81]; 
    164         char second_line[81]; 
    165  
    166         reset_more_printf(); 
    167         more_printf("%d PCI devices detected\n", hardware->nb_pci_devices); 
    168  
    169         if (hardware->pci_ids_return_code == -ENOPCIIDS) { 
    170                 nopciids = true; 
    171         } 
    172         if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) { 
    173                 nomodulespcimap = true; 
    174         } 
    175         if (hardware->modules_pcimap_return_code == -ENOMODULESALIAS) { 
    176                 nomodulesalias = true; 
    177         } 
    178  
    179         nomodulesfile = nomodulespcimap && nomodulesalias; 
    180  
    181         /* For every detected pci device, compute its submenu */ 
    182         for_each_pci_func(pci_device, hardware->pci_domain) { 
    183                 memset(kernel_modules, 0, sizeof kernel_modules); 
    184                 for (int kmod = 0; 
    185                      kmod < pci_device->dev_info->linux_kernel_module_count; 
    186                      kmod++) { 
    187                         if (kmod > 0) { 
    188                                 strncat(kernel_modules, " | ", 3); 
    189                         } 
    190                         strncat(kernel_modules, 
    191                                 pci_device->dev_info->linux_kernel_module[kmod], 
    192                                 LINUX_KERNEL_MODULE_SIZE - 1); 
    193                 } 
    194                 if (pci_device->dev_info->linux_kernel_module_count == 0) 
    195                         strlcpy(kernel_modules, "unknown", 7); 
    196  
    197                 if (nopciids == false) { 
    198                         snprintf(first_line, sizeof(first_line), 
    199                                  "%02d: %s %s \n", i, 
    200                                  pci_device->dev_info->vendor_name, 
    201                                  pci_device->dev_info->product_name); 
    202                         if (nomodulesfile == false) 
    203                                 snprintf(second_line, sizeof(second_line), 
    204                                          "    # %-25s # Kmod: %s\n", 
    205                                          pci_device->dev_info->class_name, 
    206                                          kernel_modules); 
    207                         else 
    208                                 snprintf(second_line, sizeof(second_line), 
    209                                          "    # %-25s # ID:%04x:%04x[%04x:%04x]\n", 
    210                                          pci_device->dev_info->class_name, 
    211                                          pci_device->vendor, 
    212                                          pci_device->product, 
    213                                          pci_device->sub_vendor, 
    214                                          pci_device->sub_product); 
    215  
    216                         more_printf(first_line); 
    217                         more_printf(second_line); 
    218                         more_printf("\n"); 
    219                 } else if (nopciids == true) { 
    220                         if (nomodulesfile == true) { 
    221                                 more_printf("%02d: %04x:%04x [%04x:%04x] \n", 
    222                                             i, pci_device->vendor, 
    223                                             pci_device->product, 
    224                                             pci_device->sub_vendor, 
    225                                             pci_device->sub_product); 
    226                         } else { 
    227                                 more_printf 
    228                                     ("%02d: %04x:%04x [%04x:%04x] Kmod:%s\n", i, 
    229                                      pci_device->vendor, pci_device->product, 
    230                                      pci_device->sub_vendor, 
    231                                      pci_device->sub_product, kernel_modules); 
    232                         } 
    233                 } 
    234                 i++; 
    235         } 
     193            snprintf(first_line, sizeof(first_line), 
     194                     "%02d: %s %s \n", i, 
     195                     pci_device->dev_info->vendor_name, 
     196                     pci_device->dev_info->product_name); 
     197            if (nomodulesfile == false) 
     198                snprintf(second_line, sizeof(second_line), 
     199                         "    # %-25s # Kmod: %s\n", 
     200                         pci_device->dev_info->class_name, kernel_modules); 
     201            else 
     202                snprintf(second_line, sizeof(second_line), 
     203                         "    # %-25s # ID:%04x:%04x[%04x:%04x]\n", 
     204                         pci_device->dev_info->class_name, 
     205                         pci_device->vendor, 
     206                         pci_device->product, 
     207                         pci_device->sub_vendor, pci_device->sub_product); 
     208 
     209            more_printf(first_line); 
     210            more_printf(second_line); 
     211            more_printf("\n"); 
     212        } else if (nopciids == true) { 
     213            if (nomodulesfile == true) { 
     214                more_printf("%02d: %04x:%04x [%04x:%04x] \n", 
     215                            i, pci_device->vendor, 
     216                            pci_device->product, 
     217                            pci_device->sub_vendor, pci_device->sub_product); 
     218            } else { 
     219                more_printf 
     220                    ("%02d: %04x:%04x [%04x:%04x] Kmod:%s\n", i, 
     221                     pci_device->vendor, pci_device->product, 
     222                     pci_device->sub_vendor, 
     223                     pci_device->sub_product, kernel_modules); 
     224            } 
     225        } 
     226        i++; 
     227    } 
    236228} 
    237229 
     
    239231                         struct s_hardware *hardware) 
    240232{ 
    241         struct pci_device *pci_device; 
    242         bool nopciids = false; 
    243  
    244         reset_more_printf(); 
    245         more_printf("%d PCI devices detected\n", hardware->nb_pci_devices); 
    246         more_printf("IRQ : product\n"); 
    247         more_printf("-------------\n"); 
    248  
     233    struct pci_device *pci_device; 
     234    bool nopciids = false; 
     235 
     236    reset_more_printf(); 
     237    more_printf("%d PCI devices detected\n", hardware->nb_pci_devices); 
     238    more_printf("IRQ : product\n"); 
     239    more_printf("-------------\n"); 
     240 
     241    if (hardware->pci_ids_return_code == -ENOPCIIDS) { 
     242        nopciids = true; 
     243    } 
     244 
     245    /* For every detected pci device, compute its submenu */ 
     246    for_each_pci_func(pci_device, hardware->pci_domain) { 
     247        /* Only display valid IRQs */ 
     248        if ((pci_device->dev_info->irq > 0) 
     249            && (pci_device->dev_info->irq < 255)) { 
     250            if (nopciids == false) { 
     251                more_printf("%02d  : %s %s \n", 
     252                            pci_device->dev_info->irq, 
     253                            pci_device->dev_info->vendor_name, 
     254                            pci_device->dev_info->product_name); 
     255            } else { 
     256                more_printf("%02d  : %04x:%04x [%04x:%04x] \n", 
     257                            pci_device->dev_info->irq, 
     258                            pci_device->vendor, 
     259                            pci_device->product, 
     260                            pci_device->sub_vendor, pci_device->sub_product); 
     261            } 
     262        } 
     263    } 
     264} 
     265 
     266struct cli_callback_descr list_pci_show_modules[] = { 
     267    { 
     268     .name = CLI_IRQ, 
     269     .exec = show_pci_irq, 
     270     }, 
     271    { 
     272     .name = CLI_PCI_DEVICE, 
     273     .exec = show_pci_device, 
     274     }, 
     275    { 
     276     .name = NULL, 
     277     .exec = NULL, 
     278     }, 
     279}; 
     280 
     281struct cli_module_descr pci_show_modules = { 
     282    .modules = list_pci_show_modules, 
     283    .default_callback = show_pci_devices, 
     284}; 
     285 
     286struct cli_mode_descr pci_mode = { 
     287    .mode = PCI_MODE, 
     288    .name = CLI_PCI, 
     289    .default_modules = NULL, 
     290    .show_modules = &pci_show_modules, 
     291    .set_modules = NULL, 
     292}; 
     293 
     294void cli_detect_pci(struct s_hardware *hardware) 
     295{ 
     296    bool error = false; 
     297    if (hardware->pci_detection == false) { 
     298        detect_pci(hardware); 
    249299        if (hardware->pci_ids_return_code == -ENOPCIIDS) { 
    250                 nopciids = true; 
    251         } 
    252  
    253         /* For every detected pci device, compute its submenu */ 
    254         for_each_pci_func(pci_device, hardware->pci_domain) { 
    255                 /* Only display valid IRQs */ 
    256                 if ((pci_device->dev_info->irq > 0) 
    257                     && (pci_device->dev_info->irq < 255)) { 
    258                         if (nopciids == false) { 
    259                                 more_printf("%02d  : %s %s \n", 
    260                                             pci_device->dev_info->irq, 
    261                                             pci_device->dev_info->vendor_name, 
    262                                             pci_device->dev_info->product_name); 
    263                         } else { 
    264                                 more_printf("%02d  : %04x:%04x [%04x:%04x] \n", 
    265                                             pci_device->dev_info->irq, 
    266                                             pci_device->vendor, 
    267                                             pci_device->product, 
    268                                             pci_device->sub_vendor, 
    269                                             pci_device->sub_product); 
    270                         } 
    271                 } 
    272         } 
    273 } 
    274  
    275 struct cli_callback_descr list_pci_show_modules[] = { 
    276         { 
    277          .name = CLI_IRQ, 
    278          .exec = show_pci_irq, 
    279          }, 
    280         { 
    281          .name = CLI_PCI_DEVICE, 
    282          .exec = show_pci_device, 
    283          }, 
    284         { 
    285          .name = NULL, 
    286          .exec = NULL, 
    287          }, 
    288 }; 
    289  
    290 struct cli_module_descr pci_show_modules = { 
    291         .modules = list_pci_show_modules, 
    292         .default_callback = show_pci_devices, 
    293 }; 
    294  
    295 struct cli_mode_descr pci_mode = { 
    296         .mode = PCI_MODE, 
    297         .name = CLI_PCI, 
    298         .default_modules = NULL, 
    299         .show_modules = &pci_show_modules, 
    300         .set_modules = NULL, 
    301 }; 
    302  
    303 void cli_detect_pci(struct s_hardware *hardware) 
    304 { 
    305         bool error = false; 
    306         if (hardware->pci_detection == false) { 
    307                 detect_pci(hardware); 
    308                 if (hardware->pci_ids_return_code == -ENOPCIIDS) { 
    309                         more_printf 
    310                             ("The pci.ids file is missing, device names can't be computed.\n"); 
    311                         more_printf("Please put one in same dir as hdt\n"); 
    312                         error = true; 
    313                 } 
    314                 if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) && 
    315                         (hardware->modules_alias_return_code == -ENOMODULESALIAS)) { 
    316                         more_printf 
    317                             ("The modules.pcimap or modules.alias files are missing, device names can't be computed.\n"); 
    318                         more_printf("Please put one of them in same dir as hdt\n"); 
    319                         error = true; 
    320                 } 
    321                 if (error == true) { 
    322                         char tempbuf[10]; 
    323                         more_printf("Press enter to continue\n"); 
    324                         fgets(tempbuf, sizeof(tempbuf), stdin); 
    325                 } 
    326         } 
    327 } 
     300            more_printf 
     301                ("The pci.ids file is missing, device names can't be computed.\n"); 
     302            more_printf("Please put one in same dir as hdt\n"); 
     303            error = true; 
     304        } 
     305        if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) && 
     306            (hardware->modules_alias_return_code == -ENOMODULESALIAS)) { 
     307            more_printf 
     308                ("The modules.pcimap or modules.alias files are missing, device names can't be computed.\n"); 
     309            more_printf("Please put one of them in same dir as hdt\n"); 
     310            error = true; 
     311        } 
     312        if (error == true) { 
     313            char tempbuf[10]; 
     314            more_printf("Press enter to continue\n"); 
     315            fgets(tempbuf, sizeof(tempbuf), stdin); 
     316        } 
     317    } 
     318} 
  • com32/hdt/hdt-cli-pxe.c

    rdff898 r990205  
    4040                   struct s_hardware *hardware) 
    4141{ 
    42         char buffer[81]; 
    43         memset(buffer, 0, sizeof(81)); 
     42    char buffer[81]; 
     43    memset(buffer, 0, sizeof(81)); 
    4444    reset_more_printf(); 
    45         if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) { 
    46                 more_printf("You are not currently using PXELINUX\n"); 
    47                 return; 
    48         } 
     45    if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) { 
     46        more_printf("You are not currently using PXELINUX\n"); 
     47        return; 
     48    } 
    4949 
    50         detect_pxe(hardware); 
    51         more_printf("PXE\n"); 
    52         if (hardware->is_pxe_valid == false) { 
    53                 more_printf(" No valid PXE ROM found\n"); 
    54                 return; 
    55         } 
     50    detect_pxe(hardware); 
     51    more_printf("PXE\n"); 
     52    if (hardware->is_pxe_valid == false) { 
     53        more_printf(" No valid PXE ROM found\n"); 
     54        return; 
     55    } 
    5656 
    57         struct s_pxe *p = &hardware->pxe; 
    58         more_printf(" PCI device no: %d \n", p->pci_device_pos); 
     57    struct s_pxe *p = &hardware->pxe; 
     58    more_printf(" PCI device no: %d \n", p->pci_device_pos); 
    5959 
    60         if (hardware->pci_ids_return_code == -ENOPCIIDS || 
    61             (p->pci_device == NULL)) { 
    62                 snprintf(buffer, sizeof(buffer), 
    63                          " PCI ID       : %04x:%04x[%04x:%04X] rev(%02x)\n", 
    64                          p->vendor_id, p->product_id, p->subvendor_id, 
    65                          p->subproduct_id, p->rev); 
    66                 snprintf(buffer, sizeof(buffer), 
    67                          " PCI Bus pos. : %02x:%02x.%02x\n", p->pci_bus, 
    68                          p->pci_dev, p->pci_func); 
    69                 more_printf(buffer); 
    70         } else { 
    71                 snprintf(buffer, sizeof(buffer), " Manufacturer : %s \n", 
    72                          p->pci_device->dev_info->vendor_name); 
    73                 more_printf(buffer); 
    74                 snprintf(buffer, sizeof(buffer), " Product      : %s \n", 
    75                          p->pci_device->dev_info->product_name); 
    76                 more_printf(buffer); 
    77         } 
    78         more_printf(" Addresses    : %d.%d.%d.%d @ %s\n", p->ip_addr[0], 
    79                     p->ip_addr[1], p->ip_addr[2], p->ip_addr[3], p->mac_addr); 
     60    if (hardware->pci_ids_return_code == -ENOPCIIDS || (p->pci_device == NULL)) { 
     61        snprintf(buffer, sizeof(buffer), 
     62                 " PCI ID       : %04x:%04x[%04x:%04X] rev(%02x)\n", 
     63                 p->vendor_id, p->product_id, p->subvendor_id, 
     64                 p->subproduct_id, p->rev); 
     65        snprintf(buffer, sizeof(buffer), 
     66                 " PCI Bus pos. : %02x:%02x.%02x\n", p->pci_bus, 
     67                 p->pci_dev, p->pci_func); 
     68        more_printf(buffer); 
     69    } else { 
     70        snprintf(buffer, sizeof(buffer), " Manufacturer : %s \n", 
     71                 p->pci_device->dev_info->vendor_name); 
     72        more_printf(buffer); 
     73        snprintf(buffer, sizeof(buffer), " Product      : %s \n", 
     74                 p->pci_device->dev_info->product_name); 
     75        more_printf(buffer); 
     76    } 
     77    more_printf(" Addresses    : %d.%d.%d.%d @ %s\n", p->ip_addr[0], 
     78                p->ip_addr[1], p->ip_addr[2], p->ip_addr[3], p->mac_addr); 
    8079} 
    8180 
    8281struct cli_module_descr pxe_show_modules = { 
    83         .modules = NULL, 
    84         .default_callback = main_show_pxe, 
     82    .modules = NULL, 
     83    .default_callback = main_show_pxe, 
    8584}; 
    8685 
    8786struct cli_mode_descr pxe_mode = { 
    88         .mode = PXE_MODE, 
    89         .name = CLI_PXE, 
    90         .default_modules = NULL, 
    91         .show_modules = &pxe_show_modules, 
    92         .set_modules = NULL, 
     87    .mode = PXE_MODE, 
     88    .name = CLI_PXE, 
     89    .default_modules = NULL, 
     90    .show_modules = &pxe_show_modules, 
     91    .set_modules = NULL, 
    9392}; 
  • com32/hdt/hdt-cli-syslinux.c

    rdff898 r990205  
    3838 
    3939void main_show_syslinux(int argc __unused, char **argv __unused, 
    40                         struct s_hardware *hardware) 
     40                        struct s_hardware *hardware) 
    4141{ 
    42   reset_more_printf(); 
    43   more_printf("SYSLINUX\n"); 
    44   more_printf(" Bootloader : %s\n", hardware->syslinux_fs); 
    45   more_printf(" Version    : %s\n", hardware->sv->version_string + 2); 
    46   more_printf(" Version    : %u\n", hardware->sv->version); 
    47   more_printf(" Max API    : %u\n", hardware->sv->max_api); 
    48   more_printf(" Copyright  : %s\n", hardware->sv->copyright_string + 1); 
     42    reset_more_printf(); 
     43    more_printf("SYSLINUX\n"); 
     44    more_printf(" Bootloader : %s\n", hardware->syslinux_fs); 
     45    more_printf(" Version    : %s\n", hardware->sv->version_string + 2); 
     46    more_printf(" Version    : %u\n", hardware->sv->version); 
     47    more_printf(" Max API    : %u\n", hardware->sv->max_api); 
     48    more_printf(" Copyright  : %s\n", hardware->sv->copyright_string + 1); 
    4949} 
    5050 
    5151struct cli_module_descr syslinux_show_modules = { 
    52         .modules = NULL, 
    53         .default_callback = main_show_syslinux, 
     52    .modules = NULL, 
     53    .default_callback = main_show_syslinux, 
    5454}; 
    5555 
    5656struct cli_mode_descr syslinux_mode = { 
    57         .mode = SYSLINUX_MODE, 
    58         .name = CLI_SYSLINUX, 
    59         .default_modules = NULL, 
    60         .show_modules = &syslinux_show_modules, 
    61         .set_modules = NULL, 
     57    .mode = SYSLINUX_MODE, 
     58    .name = CLI_SYSLINUX, 
     59    .default_modules = NULL, 
     60    .show_modules = &syslinux_show_modules, 
     61    .set_modules = NULL, 
    6262}; 
  • com32/hdt/hdt-cli-vesa.c

    rdff898 r990205  
    3838{ 
    3939    reset_more_printf(); 
    40         detect_vesa(hardware); 
    41         if (hardware->is_vesa_valid == false) { 
    42                 more_printf("No VESA BIOS detected\n"); 
    43                 return; 
    44         } 
    45         more_printf("VESA\n"); 
    46         more_printf(" Vesa version : %d.%d\n", hardware->vesa.major_version, 
    47                     hardware->vesa.minor_version); 
    48         more_printf(" Vendor       : %s\n", hardware->vesa.vendor); 
    49         more_printf(" Product      : %s\n", hardware->vesa.product); 
    50         more_printf(" Product rev. : %s\n", hardware->vesa.product_revision); 
    51         more_printf(" Software rev.: %d\n", hardware->vesa.software_rev); 
    52         more_printf(" Memory (KB)  : %d\n", hardware->vesa.total_memory * 64); 
    53         more_printf(" Modes        : %d\n", hardware->vesa.vmi_count); 
     40    detect_vesa(hardware); 
     41    if (hardware->is_vesa_valid == false) { 
     42        more_printf("No VESA BIOS detected\n"); 
     43        return; 
     44    } 
     45    more_printf("VESA\n"); 
     46    more_printf(" Vesa version : %d.%d\n", hardware->vesa.major_version, 
     47                hardware->vesa.minor_version); 
     48    more_printf(" Vendor       : %s\n", hardware->vesa.vendor); 
     49    more_printf(" Product      : %s\n", hardware->vesa.product); 
     50    more_printf(" Product rev. : %s\n", hardware->vesa.product_revision); 
     51    more_printf(" Software rev.: %d\n", hardware->vesa.software_rev); 
     52    more_printf(" Memory (KB)  : %d\n", hardware->vesa.total_memory * 64); 
     53    more_printf(" Modes        : %d\n", hardware->vesa.vmi_count); 
    5454} 
    5555 
     
    5757                            struct s_hardware *hardware) 
    5858{ 
    59         detect_vesa(hardware); 
    60         reset_more_printf(); 
    61         if (hardware->is_vesa_valid == false) { 
    62                 more_printf("No VESA BIOS detected\n"); 
    63                 return; 
    64         } 
    65         more_printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n"); 
    66         more_printf("----------------------------------------\n"); 
     59    detect_vesa(hardware); 
     60    reset_more_printf(); 
     61    if (hardware->is_vesa_valid == false) { 
     62        more_printf("No VESA BIOS detected\n"); 
     63        return; 
     64    } 
     65    more_printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n"); 
     66    more_printf("----------------------------------------\n"); 
    6767 
    68         for (int i = 0; i < hardware->vesa.vmi_count; i++) { 
    69                 struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi; 
    70                 /* 
    71                  * Sometimes, vesa bios reports 0x0 modes. 
    72                  * We don't need to display that ones. 
    73                  */ 
    74                 if ((mi->h_res == 0) || (mi->v_res == 0)) continue; 
    75                 more_printf("%5u %5u    %3u     %3d     0x%04x\n", 
    76                             mi->h_res, mi->v_res, mi->bpp, 
    77                             hardware->vesa.vmi[i].mode + 0x200, 
    78                             hardware->vesa.vmi[i].mode); 
    79         } 
     68    for (int i = 0; i < hardware->vesa.vmi_count; i++) { 
     69        struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi; 
     70        /* 
     71         * Sometimes, vesa bios reports 0x0 modes. 
     72         * We don't need to display that ones. 
     73         */ 
     74        if ((mi->h_res == 0) || (mi->v_res == 0)) 
     75            continue; 
     76        more_printf("%5u %5u    %3u     %3d     0x%04x\n", 
     77                    mi->h_res, mi->v_res, mi->bpp, 
     78                    hardware->vesa.vmi[i].mode + 0x200, 
     79                    hardware->vesa.vmi[i].mode); 
     80    } 
    8081} 
    8182 
    8283struct cli_callback_descr list_vesa_show_modules[] = { 
    83         { 
    84         .name = CLI_MODES, 
    85         .exec = show_vesa_modes, 
    86         }, 
    87         { 
    88         .name = NULL, 
    89         .exec = NULL, 
    90         }, 
     84    { 
     85    .name = CLI_MODES, 
     86    .exec = show_vesa_modes, 
     87    }, 
     88    { 
     89    .name = NULL, 
     90    .exec = NULL, 
     91    }, 
    9192}; 
    9293 
    9394struct cli_module_descr vesa_show_modules = { 
    94         .modules = list_vesa_show_modules, 
    95         .default_callback = main_show_vesa, 
     95    .modules = list_vesa_show_modules, 
     96    .default_callback = main_show_vesa, 
    9697}; 
    9798 
    9899struct cli_mode_descr vesa_mode = { 
    99         .mode = VESA_MODE, 
    100         .name = CLI_VESA, 
    101         .default_modules = NULL, 
    102         .show_modules = &vesa_show_modules, 
    103         .set_modules = NULL, 
     100    .mode = VESA_MODE, 
     101    .name = CLI_VESA, 
     102    .default_modules = NULL, 
     103    .show_modules = &vesa_show_modules, 
     104    .set_modules = NULL, 
    104105}; 
  • com32/hdt/hdt-cli-vpd.c

    rdff898 r990205  
    3636                   struct s_hardware *hardware) 
    3737{ 
    38         reset_more_printf(); 
    39         detect_vpd(hardware); 
     38    reset_more_printf(); 
     39    detect_vpd(hardware); 
    4040 
    41         if (!hardware->is_vpd_valid) { 
    42                 more_printf("No VPD structure detected.\n"); 
    43                 return; 
    44         } 
     41    if (!hardware->is_vpd_valid) { 
     42        more_printf("No VPD structure detected.\n"); 
     43        return; 
     44    } 
    4545 
    46         more_printf("VPD present at address : 0x%s\n", hardware->vpd.base_address); 
    47         if (strlen(hardware->vpd.bios_build_id) > 0) 
    48                 more_printf("Bios Build ID                 : %s\n", hardware->vpd.bios_build_id); 
    49         if (strlen(hardware->vpd.bios_release_date) > 0) 
    50                 more_printf("Bios Release Date             : %s\n", hardware->vpd.bios_release_date); 
    51         if (strlen(hardware->vpd.bios_version) > 0) 
    52                 more_printf("Bios Version                  : %s\n", hardware->vpd.bios_version); 
    53         if (strlen(hardware->vpd.default_flash_filename) > 0) 
    54                 more_printf("Default Flash Filename        : %s\n", hardware->vpd.default_flash_filename); 
    55         if (strlen(hardware->vpd.box_serial_number) > 0) 
    56                 more_printf("Box Serial Number             : %s\n", hardware->vpd.box_serial_number); 
    57         if (strlen(hardware->vpd.motherboard_serial_number) > 0) 
    58                 more_printf("Motherboard Serial Number     : %s\n", hardware->vpd.motherboard_serial_number); 
    59         if (strlen(hardware->vpd.machine_type_model) > 0) 
    60                 more_printf("Machine Type/Model            : %s\n", hardware->vpd.machine_type_model); 
     46    more_printf("VPD present at address : 0x%s\n", hardware->vpd.base_address); 
     47    if (strlen(hardware->vpd.bios_build_id) > 0) 
     48        more_printf("Bios Build ID                 : %s\n", 
     49                    hardware->vpd.bios_build_id); 
     50    if (strlen(hardware->vpd.bios_release_date) > 0) 
     51        more_printf("Bios Release Date             : %s\n", 
     52                    hardware->vpd.bios_release_date); 
     53    if (strlen(hardware->vpd.bios_version) > 0) 
     54        more_printf("Bios Version                  : %s\n", 
     55                    hardware->vpd.bios_version); 
     56    if (strlen(hardware->vpd.default_flash_filename) > 0) 
     57        more_printf("Default Flash Filename        : %s\n", 
     58                    hardware->vpd.default_flash_filename); 
     59    if (strlen(hardware->vpd.box_serial_number) > 0) 
     60        more_printf("Box Serial Number             : %s\n", 
     61                    hardware->vpd.box_serial_number); 
     62    if (strlen(hardware->vpd.motherboard_serial_number) > 0) 
     63        more_printf("Motherboard Serial Number     : %s\n", 
     64                    hardware->vpd.motherboard_serial_number); 
     65    if (strlen(hardware->vpd.machine_type_model) > 0) 
     66        more_printf("Machine Type/Model            : %s\n", 
     67                    hardware->vpd.machine_type_model); 
    6168} 
    6269 
    6370struct cli_module_descr vpd_show_modules = { 
    64         .modules = NULL, 
    65         .default_callback = main_show_vpd, 
     71    .modules = NULL, 
     72    .default_callback = main_show_vpd, 
    6673}; 
    6774 
    6875struct cli_mode_descr vpd_mode = { 
    69         .mode = VPD_MODE, 
    70         .name = CLI_VPD, 
    71         .default_modules = NULL, 
    72         .show_modules = &vpd_show_modules, 
    73         .set_modules = NULL, 
     76    .mode = VPD_MODE, 
     77    .name = CLI_VPD, 
     78    .default_modules = NULL, 
     79    .show_modules = &vpd_show_modules, 
     80    .set_modules = NULL, 
    7481}; 
  • com32/hdt/hdt-cli.c

    r865599 r990205  
    3535 
    3636struct cli_mode_descr *list_modes[] = { 
    37         &hdt_mode, 
    38         &dmi_mode, 
    39         &syslinux_mode, 
    40         &pxe_mode, 
    41         &kernel_mode, 
    42         &cpu_mode, 
    43         &pci_mode, 
    44         &vesa_mode, 
    45         &disk_mode, 
    46         &vpd_mode, 
    47         &memory_mode, 
    48         NULL, 
     37    &hdt_mode, 
     38    &dmi_mode, 
     39    &syslinux_mode, 
     40    &pxe_mode, 
     41    &kernel_mode, 
     42    &cpu_mode, 
     43    &pci_mode, 
     44    &vesa_mode, 
     45    &disk_mode, 
     46    &vpd_mode, 
     47    &memory_mode, 
     48    NULL, 
    4949}; 
    5050 
     
    5454 * strings first. 
    5555 */ 
    56 const char *exit_aliases[] = {"q", "quit"}; 
    57 const char *help_aliases[] = {"h", "?"}; 
     56const char *exit_aliases[] = { "q", "quit" }; 
     57const char *help_aliases[] = { "h", "?" }; 
    5858 
    5959/* List of aliases */ 
    6060struct cli_alias hdt_aliases[] = { 
    61         { 
    62                 .command = CLI_EXIT, 
    63                 .nb_aliases = 2, 
    64                 .aliases = exit_aliases, 
    65         }, 
    66         { 
    67                 .command = CLI_HELP, 
    68                 .nb_aliases = 2, 
    69                 .aliases = help_aliases, 
    70         }, 
     61    { 
     62     .command = CLI_EXIT, 
     63     .nb_aliases = 2, 
     64     .aliases = exit_aliases, 
     65     }, 
     66    { 
     67     .command = CLI_HELP, 
     68     .nb_aliases = 2, 
     69     .aliases = help_aliases, 
     70     }, 
    7171}; 
    7272 
     
    7575 
    7676struct autocomplete_list { 
    77         char autocomplete_token[MAX_LINE_SIZE]; 
    78         struct autocomplete_list *next; 
     77    char autocomplete_token[MAX_LINE_SIZE]; 
     78    struct autocomplete_list *next; 
    7979}; 
    80 struct autocomplete_list* autocomplete_head = NULL; 
    81 struct autocomplete_list* autocomplete_tail = NULL; 
    82 struct autocomplete_list* autocomplete_last_seen = NULL; 
     80struct autocomplete_list *autocomplete_head = NULL; 
     81struct autocomplete_list *autocomplete_tail = NULL; 
     82struct autocomplete_list *autocomplete_last_seen = NULL; 
    8383 
    8484static void autocomplete_add_token_to_list(const char *token) 
    8585{ 
    86         struct autocomplete_list *new = malloc(sizeof(struct autocomplete_list)); 
    87  
    88         strncpy(new->autocomplete_token, token, sizeof(new->autocomplete_token)); 
    89         new->next = NULL; 
    90         autocomplete_backlog++; 
    91  
    92         if (autocomplete_tail != NULL) 
    93                 autocomplete_tail->next = new; 
    94         if (autocomplete_head == NULL) 
    95                 autocomplete_head = new; 
    96         autocomplete_tail = new; 
     86    struct autocomplete_list *new = malloc(sizeof(struct autocomplete_list)); 
     87 
     88    strncpy(new->autocomplete_token, token, sizeof(new->autocomplete_token)); 
     89    new->next = NULL; 
     90    autocomplete_backlog++; 
     91 
     92    if (autocomplete_tail != NULL) 
     93        autocomplete_tail->next = new; 
     94    if (autocomplete_head == NULL) 
     95        autocomplete_head = new; 
     96    autocomplete_tail = new; 
    9797} 
    9898 
    9999static void autocomplete_destroy_list() 
    100100{ 
    101         struct autocomplete_list* tmp = NULL; 
    102  
    103         while (autocomplete_head != NULL) { 
    104                 tmp = autocomplete_head->next; 
    105                 free(autocomplete_head); 
    106                 autocomplete_head = tmp; 
    107         } 
    108         autocomplete_backlog = 0; 
    109         autocomplete_tail = NULL; 
    110         autocomplete_last_seen = NULL; 
     101    struct autocomplete_list *tmp = NULL; 
     102 
     103    while (autocomplete_head != NULL) { 
     104        tmp = autocomplete_head->next; 
     105        free(autocomplete_head); 
     106        autocomplete_head = tmp; 
     107    } 
     108    autocomplete_backlog = 0; 
     109    autocomplete_tail = NULL; 
     110    autocomplete_last_seen = NULL; 
    111111} 
    112112 
     
    117117 * Unlike cli_set_mode, this function is not used by the cli directly. 
    118118 **/ 
    119 void set_mode(cli_mode_t mode, struct s_hardware* hardware) 
    120 { 
    121         int i = 0; 
    122  
    123         switch (mode) { 
    124         case EXIT_MODE: 
    125                 hdt_cli.mode = mode; 
    126                 break; 
    127         case HDT_MODE: 
    128                 hdt_cli.mode = mode; 
    129                 snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", 
    130                          CLI_HDT); 
    131                 break; 
    132         case PXE_MODE: 
    133                 if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) { 
    134                         printf("You are not currently using PXELINUX\n"); 
    135                         break; 
    136                 } 
    137                 hdt_cli.mode = mode; 
    138                 snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", 
    139                          CLI_PXE); 
    140                 break; 
    141         case KERNEL_MODE: 
    142                 detect_pci(hardware); 
    143                 hdt_cli.mode = mode; 
    144                 snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", 
    145                          CLI_KERNEL); 
    146                 break; 
    147         case SYSLINUX_MODE: 
    148                 hdt_cli.mode = mode; 
    149                 snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", 
    150                          CLI_SYSLINUX); 
    151                 break; 
    152         case VESA_MODE: 
    153                 hdt_cli.mode = mode; 
    154                 snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", 
    155                          CLI_VESA); 
    156                 break; 
    157         case PCI_MODE: 
    158                 hdt_cli.mode = mode; 
    159                 snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", 
    160                          CLI_PCI); 
    161                 if (!hardware->pci_detection) 
    162                         cli_detect_pci(hardware); 
    163                 break; 
    164         case CPU_MODE: 
    165                 hdt_cli.mode = mode; 
    166                 snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", 
    167                          CLI_CPU); 
    168                 if (!hardware->dmi_detection) 
    169                         detect_dmi(hardware); 
    170                 if (!hardware->cpu_detection) 
    171                         cpu_detect(hardware); 
    172                 break; 
    173         case DMI_MODE: 
    174                 detect_dmi(hardware); 
    175                 if (!hardware->is_dmi_valid) { 
    176                         printf("No valid DMI table found, exiting.\n"); 
    177                         break; 
    178                 } 
    179                 hdt_cli.mode = mode; 
    180                 snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", 
    181                          CLI_DMI); 
    182                 break; 
    183         case DISK_MODE: 
    184                 detect_disks(hardware); 
    185                 hdt_cli.mode = mode; 
    186                 snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", 
    187                          CLI_DISK); 
    188                 break; 
    189         case VPD_MODE: 
    190                 detect_vpd(hardware); 
    191                 if (!hardware->is_vpd_valid) { 
    192                         printf("No valid VPD table found, exiting.\n"); 
    193                         break; 
    194                 } 
    195                 hdt_cli.mode = mode; 
    196                 snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", 
    197                          CLI_VPD); 
    198                 break; 
    199         case MEMORY_MODE: 
    200                 hdt_cli.mode = mode; 
    201                 snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", 
    202                          CLI_MEMORY); 
    203                 break; 
    204         default: 
    205                 /* Invalid mode */ 
    206                 printf("Unknown mode, please choose among:\n"); 
    207                 while (list_modes[i]) { 
    208                         printf("\t%s\n", list_modes[i]->name); 
    209                         i++; 
    210                 } 
    211         } 
    212  
    213         find_cli_mode_descr(hdt_cli.mode, &current_mode); 
    214         /* There is not cli_mode_descr struct for the exit mode */ 
    215         if (current_mode == NULL && hdt_cli.mode != EXIT_MODE) { 
    216                 /* Shouldn't get here... */ 
    217                 printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode); 
    218         } 
     119void set_mode(cli_mode_t mode, struct s_hardware *hardware) 
     120{ 
     121    int i = 0; 
     122 
     123    switch (mode) { 
     124    case EXIT_MODE: 
     125        hdt_cli.mode = mode; 
     126        break; 
     127    case HDT_MODE: 
     128        hdt_cli.mode = mode; 
     129        snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_HDT); 
     130        break; 
     131    case PXE_MODE: 
     132        if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) { 
     133            printf("You are not currently using PXELINUX\n"); 
     134            break; 
     135        } 
     136        hdt_cli.mode = mode; 
     137        snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_PXE); 
     138        break; 
     139    case KERNEL_MODE: 
     140        detect_pci(hardware); 
     141        hdt_cli.mode = mode; 
     142        snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_KERNEL); 
     143        break; 
     144    case SYSLINUX_MODE: 
     145        hdt_cli.mode = mode; 
     146        snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_SYSLINUX); 
     147        break; 
     148    case VESA_MODE: 
     149        hdt_cli.mode = mode; 
     150        snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_VESA); 
     151        break; 
     152    case PCI_MODE: 
     153        hdt_cli.mode = mode; 
     154        snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_PCI); 
     155        if (!hardware->pci_detection) 
     156            cli_detect_pci(hardware); 
     157        break; 
     158    case CPU_MODE: 
     159        hdt_cli.mode = mode; 
     160        snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_CPU); 
     161        if (!hardware->dmi_detection) 
     162            detect_dmi(hardware); 
     163        if (!hardware->cpu_detection) 
     164            cpu_detect(hardware); 
     165        break; 
     166    case DMI_MODE: 
     167        detect_dmi(hardware); 
     168        if (!hardware->is_dmi_valid) { 
     169            printf("No valid DMI table found, exiting.\n"); 
     170            break; 
     171        } 
     172        hdt_cli.mode = mode; 
     173        snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_DMI); 
     174        break; 
     175    case DISK_MODE: 
     176        detect_disks(hardware); 
     177        hdt_cli.mode = mode; 
     178        snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_DISK); 
     179        break; 
     180    case VPD_MODE: 
     181        detect_vpd(hardware); 
     182        if (!hardware->is_vpd_valid) { 
     183            printf("No valid VPD table found, exiting.\n"); 
     184            break; 
     185        } 
     186        hdt_cli.mode = mode; 
     187        snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_VPD); 
     188        break; 
     189    case MEMORY_MODE: 
     190        hdt_cli.mode = mode; 
     191        snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_MEMORY); 
     192        break; 
     193    default: 
     194        /* Invalid mode */ 
     195        printf("Unknown mode, please choose among:\n"); 
     196        while (list_modes[i]) { 
     197            printf("\t%s\n", list_modes[i]->name); 
     198            i++; 
     199        } 
     200    } 
     201 
     202    find_cli_mode_descr(hdt_cli.mode, &current_mode); 
     203    /* There is not cli_mode_descr struct for the exit mode */ 
     204    if (current_mode == NULL && hdt_cli.mode != EXIT_MODE) { 
     205        /* Shouldn't get here... */ 
     206        printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode); 
     207    } 
    219208} 
    220209 
     
    224213cli_mode_t mode_s_to_mode_t(char *name) 
    225214{ 
    226         int i = 0; 
    227  
    228         while (list_modes[i]) { 
    229                 if (!strncmp(name, list_modes[i]->name, 
    230                              sizeof(list_modes[i]->name))) 
    231                         break; 
    232                 i++; 
    233         } 
    234  
    235         if (!list_modes[i]) 
    236                 return INVALID_MODE; 
    237         else 
    238                 return list_modes[i]->mode; 
     215    int i = 0; 
     216 
     217    while (list_modes[i]) { 
     218        if (!strncmp(name, list_modes[i]->name, sizeof(list_modes[i]->name))) 
     219            break; 
     220        i++; 
     221    } 
     222 
     223    if (!list_modes[i]) 
     224        return INVALID_MODE; 
     225    else 
     226        return list_modes[i]->mode; 
    239227} 
    240228 
     
    250238void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found) 
    251239{ 
    252         int i = 0; 
    253  
    254         while (list_modes[i] && 
    255                list_modes[i]->mode != mode) 
    256                 i++; 
    257  
    258         /* Shouldn't get here... */ 
    259         if (!list_modes[i]) 
    260                 *mode_found = NULL; 
    261         else 
    262                 *mode_found = list_modes[i]; 
     240    int i = 0; 
     241 
     242    while (list_modes[i] && list_modes[i]->mode != mode) 
     243        i++; 
     244 
     245    /* Shouldn't get here... */ 
     246    if (!list_modes[i]) 
     247        *mode_found = NULL; 
     248    else 
     249        *mode_found = list_modes[i]; 
    263250} 
    264251 
     
    277264                           int *argc, char **argv) 
    278265{ 
    279         struct cli_mode_descr *mode; 
    280         int i, j; 
    281  
    282         find_cli_mode_descr(mode_s_to_mode_t(*command), &mode); 
    283         if (mode != NULL && *module == NULL) { 
    284                 /* 
    285                  * The user specified a mode instead of `set mode...', e.g. 
    286                  * `dmi' instead of `set mode dmi' 
    287                  */ 
    288  
    289                 /* *argv is NULL since *module is NULL */ 
    290                 *argc = 1; 
    291                 *argv = malloc(*argc * sizeof(char *)); 
    292                 argv[0] = malloc((sizeof(*command) + 1) * sizeof(char)); 
    293                 strncpy(argv[0], *command, sizeof(*command) + 1); 
     266    struct cli_mode_descr *mode; 
     267    int i, j; 
     268 
     269    find_cli_mode_descr(mode_s_to_mode_t(*command), &mode); 
     270    if (mode != NULL && *module == NULL) { 
     271        /* 
     272         * The user specified a mode instead of `set mode...', e.g. 
     273         * `dmi' instead of `set mode dmi' 
     274         */ 
     275 
     276        /* *argv is NULL since *module is NULL */ 
     277        *argc = 1; 
     278        *argv = malloc(*argc * sizeof(char *)); 
     279        argv[0] = malloc((sizeof(*command) + 1) * sizeof(char)); 
     280        strncpy(argv[0], *command, sizeof(*command) + 1); 
     281        dprintf("CLI DEBUG: ALIAS %s ", *command); 
     282 
     283        strncpy(*command, CLI_SET, sizeof(CLI_SET));    /* set */ 
     284 
     285        *module = malloc(sizeof(CLI_MODE) * sizeof(char)); 
     286        strncpy(*module, CLI_MODE, sizeof(CLI_MODE));   /* mode */ 
     287 
     288        dprintf("--> %s %s %s\n", *command, *module, argv[0]); 
     289        goto out; 
     290    } 
     291 
     292    /* Simple aliases mapping a single command to another one */ 
     293    for (i = 0; i < MAX_ALIASES; i++) { 
     294        for (j = 0; j < hdt_aliases[i].nb_aliases; j++) { 
     295            if (!strncmp(*command, hdt_aliases[i].aliases[j], 
     296                         sizeof(hdt_aliases[i].aliases[j]))) { 
    294297                dprintf("CLI DEBUG: ALIAS %s ", *command); 
    295  
    296                 strncpy(*command, CLI_SET, sizeof(CLI_SET));    /* set */ 
    297  
    298                 *module = malloc(sizeof(CLI_MODE) * sizeof(char)); 
    299                 strncpy(*module, CLI_MODE, sizeof(CLI_MODE));   /* mode */ 
    300  
    301                 dprintf("--> %s %s %s\n", *command, *module, argv[0]); 
    302                 goto out; 
    303         } 
    304  
    305         /* Simple aliases mapping a single command to another one */ 
    306         for (i = 0; i < MAX_ALIASES; i++) { 
    307                 for (j = 0; j < hdt_aliases[i].nb_aliases; j++) { 
    308                         if (!strncmp(*command, hdt_aliases[i].aliases[j], 
    309                             sizeof(hdt_aliases[i].aliases[j]))) { 
    310                                 dprintf("CLI DEBUG: ALIAS %s ", *command); 
    311                                 strncpy(*command, hdt_aliases[i].command, 
    312                                         sizeof(hdt_aliases[i].command) + 1); 
    313                                 dprintf("--> %s\n", *command); 
    314                                 goto out; /* Don't allow chaining aliases */ 
    315                         } 
    316                 } 
    317         } 
    318         return; 
     298                strncpy(*command, hdt_aliases[i].command, 
     299                        sizeof(hdt_aliases[i].command) + 1); 
     300                dprintf("--> %s\n", *command); 
     301                goto out;       /* Don't allow chaining aliases */ 
     302            } 
     303        } 
     304    } 
     305    return; 
    319306 
    320307out: 
    321         dprintf("CLI DEBUG: New parameters:\n"); 
    322         dprintf("CLI DEBUG: command = %s\n", *command); 
    323         dprintf("CLI DEBUG: module  = %s\n", *module); 
    324         dprintf("CLI DEBUG: argc    = %d\n", *argc); 
    325         for (i = 0; i < *argc; i++) 
    326                 dprintf("CLI DEBUG: argv[%d] = %s\n", i, argv[0]); 
    327         return; 
     308    dprintf("CLI DEBUG: New parameters:\n"); 
     309    dprintf("CLI DEBUG: command = %s\n", *command); 
     310    dprintf("CLI DEBUG: module  = %s\n", *module); 
     311    dprintf("CLI DEBUG: argc    = %d\n", *argc); 
     312    for (i = 0; i < *argc; i++) 
     313        dprintf("CLI DEBUG: argv[%d] = %s\n", i, argv[0]); 
     314    return; 
    328315} 
    329316 
     
    343330                               int *argc, char **argv) 
    344331{ 
    345         int argc_iter = 0, args_pos = 0, token_found = 0, token_len = 0; 
    346         int args_len = 0; 
    347         char *pch = NULL, *pch_next = NULL, *tmp_pch_next = NULL; 
    348  
    349         *command = NULL; 
    350         *module = NULL; 
    351         *argc = 0; 
    352  
    353         pch = line; 
    354         while (pch != NULL) { 
    355                 pch_next = strchr(pch + 1, ' '); 
    356                 tmp_pch_next = pch_next; 
    357  
    358                 /* 
    359                  * Skip whitespaces if the user entered 
    360                  * 'set   mode        foo' for 'set mode foo' 
    361                  *  ^   ^ 
    362                  *  |___|___ pch 
    363                  *      |___ pch_next <- wrong! 
    364                  * 
    365                  *  We still keep the position into tmp_pch_next to compute 
    366                  *  the lenght of the current token. 
    367                  */ 
    368                 while (pch_next != NULL && !strncmp(pch_next, CLI_SPACE, 1)) 
    369                         pch_next++; 
    370  
    371                 /* End of line guaranteed to be zeroed */ 
    372                 if (pch_next == NULL) { 
    373                         token_len = (int) (strchr(pch + 1, '\0') - pch); 
    374                         args_len = token_len; 
    375                 } 
    376                 else { 
    377                         token_len = (int) (tmp_pch_next - pch); 
    378                         args_len = (int) (pch_next - pch); 
    379                 } 
    380  
    381                 if (token_found == 0) { 
    382                         /* Main command to execute */ 
    383                         *command = malloc((token_len + 1) * sizeof(char)); 
    384                         strncpy(*command, pch, token_len); 
    385                         (*command)[token_len] = '\0'; 
    386                         dprintf("CLI DEBUG: command = %s\n", *command); 
    387                         args_pos += args_len; 
    388                 } else if (token_found == 1) { 
    389                         /* Module */ 
    390                         *module = malloc((token_len + 1) * sizeof(char)); 
    391                         strncpy(*module, pch, token_len); 
    392                         (*module)[token_len] = '\0'; 
    393                         dprintf("CLI DEBUG: module  = %s\n", *module); 
    394                         args_pos += args_len; 
    395                 } else 
    396                         (*argc)++; 
    397  
    398                 token_found++; 
    399                 pch = pch_next; 
    400         } 
    401         dprintf("CLI DEBUG: argc    = %d\n", *argc); 
    402  
    403         /* Skip arguments handling if none is supplied */ 
    404         if (!*argc) 
    405                 return; 
    406  
    407         /* Transform the arguments string into an array */ 
    408         *argv = malloc(*argc * sizeof(char *)); 
    409         pch = strtok(line + args_pos, CLI_SPACE); 
    410         while (pch != NULL) { 
    411                 dprintf("CLI DEBUG: argv[%d] = %s\n", argc_iter, pch); 
    412                 argv[argc_iter] = malloc(sizeof(pch) * sizeof(char)); 
    413                 strncpy(argv[argc_iter], pch, sizeof(pch)); 
    414                 argc_iter++; 
    415                 pch = strtok(NULL, CLI_SPACE); 
    416                 /* 
    417                  * strtok(NULL, CLI_SPACE) over a stream of spaces 
    418                  * will return an empty string 
    419                  */ 
    420                 while (pch != NULL && !strncmp(pch, "", 1)) 
    421                         pch = strtok(NULL, CLI_SPACE); 
    422         } 
     332    int argc_iter = 0, args_pos = 0, token_found = 0, token_len = 0; 
     333    int args_len = 0; 
     334    char *pch = NULL, *pch_next = NULL, *tmp_pch_next = NULL; 
     335 
     336    *command = NULL; 
     337    *module = NULL; 
     338    *argc = 0; 
     339 
     340    pch = line; 
     341    while (pch != NULL) { 
     342        pch_next = strchr(pch + 1, ' '); 
     343        tmp_pch_next = pch_next; 
     344 
     345        /* 
     346         * Skip whitespaces if the user entered 
     347         * 'set   mode        foo' for 'set mode foo' 
     348         *  ^   ^ 
     349         *  |___|___ pch 
     350         *      |___ pch_next <- wrong! 
     351         * 
     352         *  We still keep the position into tmp_pch_next to compute 
     353         *  the lenght of the current token. 
     354         */ 
     355        while (pch_next != NULL && !strncmp(pch_next, CLI_SPACE, 1)) 
     356            pch_next++; 
     357 
     358        /* End of line guaranteed to be zeroed */ 
     359        if (pch_next == NULL) { 
     360            token_len = (int)(strchr(pch + 1, '\0') - pch); 
     361            args_len = token_len; 
     362        } else { 
     363            token_len = (int)(tmp_pch_next - pch); 
     364            args_len = (int)(pch_next - pch); 
     365        } 
     366 
     367        if (token_found == 0) { 
     368            /* Main command to execute */ 
     369            *command = malloc((token_len + 1) * sizeof(char)); 
     370            strncpy(*command, pch, token_len); 
     371            (*command)[token_len] = '\0'; 
     372            dprintf("CLI DEBUG: command = %s\n", *command); 
     373            args_pos += args_len; 
     374        } else if (token_found == 1) { 
     375            /* Module */ 
     376            *module = malloc((token_len + 1) * sizeof(char)); 
     377            strncpy(*module, pch, token_len); 
     378            (*module)[token_len] = '\0'; 
     379            dprintf("CLI DEBUG: module  = %s\n", *module); 
     380            args_pos += args_len; 
     381        } else 
     382            (*argc)++; 
     383 
     384        token_found++; 
     385        pch = pch_next; 
     386    } 
     387    dprintf("CLI DEBUG: argc    = %d\n", *argc); 
     388 
     389    /* Skip arguments handling if none is supplied */ 
     390    if (!*argc) 
     391        return; 
     392 
     393    /* Transform the arguments string into an array */ 
     394    *argv = malloc(*argc * sizeof(char *)); 
     395    pch = strtok(line + args_pos, CLI_SPACE); 
     396    while (pch != NULL) { 
     397        dprintf("CLI DEBUG: argv[%d] = %s\n", argc_iter, pch); 
     398        argv[argc_iter] = malloc(sizeof(pch) * sizeof(char)); 
     399        strncpy(argv[argc_iter], pch, sizeof(pch)); 
     400        argc_iter++; 
     401        pch = strtok(NULL, CLI_SPACE); 
     402        /* 
     403         * strtok(NULL, CLI_SPACE) over a stream of spaces 
     404         * will return an empty string 
     405         */ 
     406        while (pch != NULL && !strncmp(pch, "", 1)) 
     407            pch = strtok(NULL, CLI_SPACE); 
     408    } 
    423409} 
    424410 
     
    432418 * module structure that matches the module name and store it in @module_found. 
    433419 **/ 
    434 void find_cli_callback_descr(const char* module_name, 
    435                              struct cli_module_descr* modules_list, 
    436                              struct cli_callback_descr** module_found) 
    437 { 
    438         int modules_iter = 0; 
    439  
    440         if (modules_list == NULL) 
    441                 goto not_found; 
    442  
    443         /* Find the callback to execute */ 
    444         while (modules_list->modules[modules_iter].name && 
    445                strcmp(module_name, 
    446                       modules_list->modules[modules_iter].name) != 0) 
    447                 modules_iter++; 
    448  
    449         if (modules_list->modules[modules_iter].name) { 
    450                 *module_found = &(modules_list->modules[modules_iter]); 
    451                 dprintf("CLI DEBUG: module %s found\n", (*module_found)->name); 
    452                 return; 
    453         } 
     420void find_cli_callback_descr(const char *module_name, 
     421                             struct cli_module_descr *modules_list, 
     422                             struct cli_callback_descr **module_found) 
     423{ 
     424    int modules_iter = 0; 
     425 
     426    if (modules_list == NULL) 
     427        goto not_found; 
     428 
     429    /* Find the callback to execute */ 
     430    while (modules_list->modules[modules_iter].name && 
     431           strcmp(module_name, modules_list->modules[modules_iter].name) != 0) 
     432        modules_iter++; 
     433 
     434    if (modules_list->modules[modules_iter].name) { 
     435        *module_found = &(modules_list->modules[modules_iter]); 
     436        dprintf("CLI DEBUG: module %s found\n", (*module_found)->name); 
     437        return; 
     438    } 
    454439 
    455440not_found: 
    456         *module_found = NULL; 
    457         return; 
     441    *module_found = NULL; 
     442    return; 
    458443} 
    459444 
     
    468453static void autocomplete_command(char *command) 
    469454{ 
    470         int j = 0; 
    471         struct cli_callback_descr* associated_module = NULL; 
    472  
    473         /* First take care of the two special commands: 'show' and 'set' */ 
    474         if (strncmp(CLI_SHOW, command, strlen(command)) == 0) { 
    475                 printf("%s\n", CLI_SHOW); 
    476                 autocomplete_add_token_to_list(CLI_SHOW); 
    477         } 
    478         if (strncmp(CLI_SET, command, strlen(command)) == 0) { 
    479                 printf("%s\n", CLI_SET); 
    480                 autocomplete_add_token_to_list(CLI_SET); 
    481         } 
    482  
     455    int j = 0; 
     456    struct cli_callback_descr *associated_module = NULL; 
     457 
     458    /* First take care of the two special commands: 'show' and 'set' */ 
     459    if (strncmp(CLI_SHOW, command, strlen(command)) == 0) { 
     460        printf("%s\n", CLI_SHOW); 
     461        autocomplete_add_token_to_list(CLI_SHOW); 
     462    } 
     463    if (strncmp(CLI_SET, command, strlen(command)) == 0) { 
     464        printf("%s\n", CLI_SET); 
     465        autocomplete_add_token_to_list(CLI_SET); 
     466    } 
     467 
     468    /* 
     469     * Then, go through the modes for the special case 
     470     *      '<mode>' -> 'set mode <mode>' 
     471     */ 
     472    while (list_modes[j]) { 
     473        if (strncmp(list_modes[j]->name, command, strlen(command)) == 0) { 
     474            printf("%s\n", list_modes[j]->name); 
     475            autocomplete_add_token_to_list(list_modes[j]->name); 
     476        } 
     477        j++; 
     478    } 
     479 
     480    /* 
     481     * Let's go now through the list of default_modules for the current mode 
     482     * (single token commands for the current_mode) 
     483     */ 
     484    j = 0; 
     485    if (current_mode->default_modules && current_mode->default_modules->modules) { 
     486        while (current_mode->default_modules->modules[j].name) { 
     487            if (strncmp(current_mode->default_modules->modules[j].name, 
     488                        command, strlen(command)) == 0) { 
     489                printf("%s\n", current_mode->default_modules->modules[j].name); 
     490                autocomplete_add_token_to_list(current_mode->default_modules-> 
     491                                               modules[j].name); 
     492            } 
     493            j++; 
     494        } 
     495    } 
     496 
     497    /* 
     498     * Finally, if the current_mode is not hdt, list the available 
     499     * default_modules of hdt (these are always available from any mode). 
     500     */ 
     501    if (current_mode->mode == HDT_MODE) 
     502        return; 
     503 
     504    if (!hdt_mode.default_modules || !hdt_mode.default_modules->modules) 
     505        return; 
     506 
     507    j = 0; 
     508    while (hdt_mode.default_modules && 
     509           hdt_mode.default_modules->modules[j].name) { 
    483510        /* 
    484          * Then, go through the modes for the special case 
    485          *      '<mode>' -> 'set mode <mode>' 
     511         * Any default command that is present in hdt mode but 
     512         * not in the current mode is available. A default 
     513         * command can be redefined in the current mode though. 
     514         * This next call tests this use case: if it is 
     515         * overwritten, do not print it again. 
    486516         */ 
    487         while (list_modes[j]) { 
    488                 if (strncmp(list_modes[j]->name, command, strlen(command)) == 0) { 
    489                         printf("%s\n", list_modes[j]->name); 
    490                         autocomplete_add_token_to_list(list_modes[j]->name); 
    491                 } 
    492                 j++; 
    493         } 
    494  
    495         /* 
    496          * Let's go now through the list of default_modules for the current mode 
    497          * (single token commands for the current_mode) 
    498          */ 
    499         j = 0; 
    500     if (current_mode->default_modules && 
    501         current_mode->default_modules->modules) { 
    502                 while (current_mode->default_modules->modules[j].name) { 
    503                         if (strncmp(current_mode->default_modules->modules[j].name, 
    504                                     command, 
    505                                     strlen(command)) == 0) { 
    506                                 printf("%s\n", 
    507                                         current_mode->default_modules->modules[j].name); 
    508                                 autocomplete_add_token_to_list(current_mode->default_modules->modules[j].name); 
    509                         } 
    510                         j++; 
    511                 } 
    512     } 
    513  
    514         /* 
    515          * Finally, if the current_mode is not hdt, list the available 
    516          * default_modules of hdt (these are always available from any mode). 
    517          */ 
    518         if (current_mode->mode == HDT_MODE) 
    519                 return; 
    520  
    521     if (!hdt_mode.default_modules || 
    522         !hdt_mode.default_modules->modules) 
    523         return; 
    524  
    525         j = 0; 
    526         while (hdt_mode.default_modules && 
    527            hdt_mode.default_modules->modules[j].name) { 
    528                 /* 
    529                  * Any default command that is present in hdt mode but 
    530                  * not in the current mode is available. A default 
    531                  * command can be redefined in the current mode though. 
    532                  * This next call tests this use case: if it is 
    533                  * overwritten, do not print it again. 
    534                  */ 
    535                 find_cli_callback_descr(hdt_mode.default_modules->modules[j].name, 
    536                                         current_mode->default_modules, 
    537                                         &associated_module); 
    538                 if (associated_module == NULL && 
    539                     strncmp(command, 
    540                             hdt_mode.default_modules->modules[j].name, 
    541                             strlen(command)) == 0) { 
    542                         printf("%s\n", 
    543                                 hdt_mode.default_modules->modules[j].name); 
    544                         autocomplete_add_token_to_list(hdt_mode.default_modules->modules[j].name); 
    545                 } 
    546                 j++; 
    547         } 
     517        find_cli_callback_descr(hdt_mode.default_modules->modules[j].name, 
     518                                current_mode->default_modules, 
     519                                &associated_module); 
     520        if (associated_module == NULL && 
     521            strncmp(command, 
     522                    hdt_mode.default_modules->modules[j].name, 
     523                    strlen(command)) == 0) { 
     524            printf("%s\n", hdt_mode.default_modules->modules[j].name); 
     525            autocomplete_add_token_to_list(hdt_mode.default_modules->modules[j]. 
     526                                           name); 
     527        } 
     528        j++; 
     529    } 
    548530} 
    549531 
     
    558540 * is not hdt). 
    559541 **/ 
    560 static void autocomplete_module(char *command, char* module) 
    561 { 
    562         int j = 0; 
    563         char autocomplete_full_line[MAX_LINE_SIZE]; 
    564  
    565         if (strncmp(CLI_SHOW, command, strlen(command)) == 0) { 
    566                 if (!current_mode->show_modules || 
    567             !current_mode->show_modules->modules) 
    568             return; 
    569  
    570         while (current_mode->show_modules->modules[j].name) { 
    571                         if (strncmp(current_mode->show_modules->modules[j].name, 
    572                                     module, 
    573                                     strlen(module)) == 0) { 
    574                                 printf("%s\n", 
    575                                         current_mode->show_modules->modules[j].name); 
    576                                 sprintf(autocomplete_full_line, "%s %s", 
    577                                         CLI_SHOW, current_mode->show_modules->modules[j].name); 
    578                                 autocomplete_add_token_to_list(autocomplete_full_line); 
    579                         } 
    580                 j++; 
    581                 } 
    582         } else if (strncmp(CLI_SET, command, strlen(command)) == 0) { 
    583                 j = 0; 
    584                 if (!current_mode->set_modules || 
    585             !current_mode->set_modules->modules) 
    586             return; 
    587  
    588                 while (current_mode->set_modules->modules[j].name) { 
    589                         if (strncmp(current_mode->set_modules->modules[j].name, 
    590                                     module, 
    591                                     strlen(module)) == 0) { 
    592                                 printf("%s\n", 
    593                                         current_mode->set_modules->modules[j].name); 
    594                                 sprintf(autocomplete_full_line, "%s %s", 
    595                                         CLI_SET, current_mode->set_modules->modules[j].name); 
    596                                 autocomplete_add_token_to_list(autocomplete_full_line); 
    597                         } 
    598                         j++; 
    599                 } 
    600         } 
     542static void autocomplete_module(char *command, char *module) 
     543{ 
     544    int j = 0; 
     545    char autocomplete_full_line[MAX_LINE_SIZE]; 
     546 
     547    if (strncmp(CLI_SHOW, command, strlen(command)) == 0) { 
     548        if (!current_mode->show_modules || !current_mode->show_modules->modules) 
     549            return; 
     550 
     551        while (current_mode->show_modules->modules[j].name) { 
     552            if (strncmp(current_mode->show_modules->modules[j].name, 
     553                        module, strlen(module)) == 0) { 
     554                printf("%s\n", current_mode->show_modules->modules[j].name); 
     555                sprintf(autocomplete_full_line, "%s %s", 
     556                        CLI_SHOW, current_mode->show_modules->modules[j].name); 
     557                autocomplete_add_token_to_list(autocomplete_full_line); 
     558            } 
     559            j++; 
     560        } 
     561    } else if (strncmp(CLI_SET, command, strlen(command)) == 0) { 
     562        j = 0; 
     563        if (!current_mode->set_modules || !current_mode->set_modules->modules) 
     564            return; 
     565 
     566        while (current_mode->set_modules->modules[j].name) { 
     567            if (strncmp(current_mode->set_modules->modules[j].name, 
     568                        module, strlen(module)) == 0) { 
     569                printf("%s\n", current_mode->set_modules->modules[j].name); 
     570                sprintf(autocomplete_full_line, "%s %s", 
     571                        CLI_SET, current_mode->set_modules->modules[j].name); 
     572                autocomplete_add_token_to_list(autocomplete_full_line); 
     573            } 
     574            j++; 
     575        } 
     576    } 
    601577} 
    602578 
     
    607583static void autocomplete(char *line) 
    608584{ 
    609         int i; 
    610         int argc = 0; 
    611         char *command = NULL, *module = NULL; 
    612         char **argv = NULL; 
    613  
    614         parse_command_line(line, &command, &module, &argc, argv); 
    615  
    616         /* If the user specified arguments, there is nothing we can complete */ 
    617         if (argc != 0) 
    618                 goto out; 
    619  
    620         /* No argument, (the start of) a module has been specified */ 
    621         if (module != NULL) { 
    622                 autocomplete_module(command, module); 
    623         free(module); 
    624                 goto out; 
    625         } 
    626  
    627         /* No argument, no module, (the start of) a command has been specified */ 
    628         if (command != NULL) { 
    629                 autocomplete_command(command); 
    630         free(command); 
    631                 goto out; 
    632         } 
     585    int i; 
     586    int argc = 0; 
     587    char *command = NULL, *module = NULL; 
     588    char **argv = NULL; 
     589 
     590    parse_command_line(line, &command, &module, &argc, argv); 
     591 
     592    /* If the user specified arguments, there is nothing we can complete */ 
     593    if (argc != 0) 
     594        goto out; 
     595 
     596    /* No argument, (the start of) a module has been specified */ 
     597    if (module != NULL) { 
     598        autocomplete_module(command, module); 
     599        free(module); 
     600        goto out; 
     601    } 
     602 
     603    /* No argument, no module, (the start of) a command has been specified */ 
     604    if (command != NULL) { 
     605        autocomplete_command(command); 
     606        free(command); 
     607        goto out; 
     608    } 
    633609 
    634610out: 
    635         /* Let's not forget to clean ourselves */ 
    636         for (i = 0; i < argc; i++) 
    637                 free(argv[i]); 
     611    /* Let's not forget to clean ourselves */ 
     612    for (i = 0; i < argc; i++) 
     613        free(argv[i]); 
    638614    if (argc > 0) 
    639         free(argv); 
    640         return; 
    641 } 
    642  
     615        free(argv); 
     616    return; 
     617} 
    643618 
    644619/** 
    645620 * exec_command - main logic to map the command line to callbacks 
    646621 **/ 
    647 static void exec_command(char *line, 
    648                          struct s_hardware *hardware) 
    649 { 
    650         int argc, i = 0; 
    651         char *command = NULL, *module = NULL; 
    652         char **argv = NULL; 
    653         struct cli_callback_descr* current_module = NULL; 
    654  
    655         /* This will allocate memory that will need to be freed */ 
    656         parse_command_line(line, &command, &module, &argc, argv); 
    657  
    658         /* Expand shortcuts, if needed */ 
    659         expand_aliases(line, &command, &module, &argc, argv); 
    660  
    661         if (module == NULL) { 
    662                 dprintf("CLI DEBUG: single command detected\n"); 
    663                 /* 
    664                  * A single word was specified: look at the list of default 
    665                  * commands in the current mode to see if there is a match. 
    666                  * If not, it may be a generic function (exit, help, ...). These 
    667                  * are stored in the list of default commands of the hdt mode. 
    668                  */ 
    669                 find_cli_callback_descr(command, current_mode->default_modules, 
    670                                         &current_module); 
    671                 if (current_module != NULL) 
    672                         return current_module->exec(argc, argv, hardware); 
    673                 else if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1) && 
    674                          current_mode->show_modules != NULL && 
    675                          current_mode->show_modules->default_callback != NULL) 
    676                         return current_mode->show_modules 
    677                                            ->default_callback(argc, 
    678                                                               argv, 
    679                                                               hardware); 
    680                 else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1) && 
    681                          current_mode->set_modules != NULL && 
    682                          current_mode->set_modules->default_callback != NULL) 
    683                         return current_mode->set_modules 
    684                                            ->default_callback(argc, 
    685                                                               argv, 
    686                                                               hardware); 
    687                 else { 
    688                         find_cli_callback_descr(command, hdt_mode.default_modules, 
    689                                                 &current_module); 
    690                         if (current_module != NULL) 
    691                                 return current_module->exec(argc, argv, hardware); 
    692                 } 
    693  
     622static void exec_command(char *line, struct s_hardware *hardware) 
     623{ 
     624    int argc, i = 0; 
     625    char *command = NULL, *module = NULL; 
     626    char **argv = NULL; 
     627    struct cli_callback_descr *current_module = NULL; 
     628 
     629    /* This will allocate memory for command and module */ 
     630    parse_command_line(line, &command, &module, &argc, argv); 
     631 
     632    /* 
     633     * Expand shortcuts, if needed 
     634     * This will allocate memory for argc/argv 
     635     */ 
     636    expand_aliases(line, &command, &module, &argc, argv); 
     637 
     638    if (module == NULL) { 
     639        dprintf("CLI DEBUG: single command detected\n"); 
     640        /* 
     641         * A single word was specified: look at the list of default 
     642         * commands in the current mode to see if there is a match. 
     643         * If not, it may be a generic function (exit, help, ...). These 
     644         * are stored in the list of default commands of the hdt mode. 
     645         */ 
     646        find_cli_callback_descr(command, current_mode->default_modules, 
     647                                &current_module); 
     648        if (current_module != NULL) 
     649            current_module->exec(argc, argv, hardware); 
     650        else if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1) && 
     651                 current_mode->show_modules != NULL && 
     652                 current_mode->show_modules->default_callback != NULL) 
     653            current_mode->show_modules->default_callback(argc, argv, hardware); 
     654        else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1) && 
     655                 current_mode->set_modules != NULL && 
     656                 current_mode->set_modules->default_callback != NULL) 
     657            current_mode->set_modules->default_callback(argc, argv, hardware); 
     658        else { 
     659            find_cli_callback_descr(command, hdt_mode.default_modules, 
     660                                    &current_module); 
     661            if (current_module != NULL) 
     662                current_module->exec(argc, argv, hardware); 
     663            else 
    694664                printf("unknown command: '%s'\n", command); 
    695                 return; 
    696         } 
    697  
     665        } 
     666    } else { 
    698667        /* 
    699668         * A module has been specified! We now need to find the type of command. 
     
    709678         */ 
    710679        if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1)) { 
    711                 dprintf("CLI DEBUG: %s command detected\n", CLI_SHOW); 
    712                 find_cli_callback_descr(module, current_mode->show_modules, 
     680            dprintf("CLI DEBUG: %s command detected\n", CLI_SHOW); 
     681            /* Look first for a 'show' callback in the current mode */ 
     682            find_cli_callback_descr(module, current_mode->show_modules, 
     683                                    &current_module); 
     684            /* Execute the callback, if found */ 
     685            if (current_module != NULL) 
     686                current_module->exec(argc, argv, hardware); 
     687            else { 
     688                /* Look now for a 'show' callback in the hdt mode */ 
     689                find_cli_callback_descr(module, hdt_mode.show_modules, 
    713690                                        &current_module); 
    714                 /* Execute the callback */ 
     691                /* Execute the callback, if found */ 
    715692                if (current_module != NULL) 
    716                         return current_module->exec(argc, argv, hardware); 
    717                 else { 
    718                         find_cli_callback_descr(module, hdt_mode.show_modules, 
    719                                                 &current_module); 
    720                         if (current_module != NULL) 
    721                                 return current_module->exec(argc, argv, hardware); 
    722                 } 
    723  
    724                 printf("unknown module: '%s'\n", module); 
    725                 return; 
    726  
     693                    current_module->exec(argc, argv, hardware); 
     694                else 
     695                    printf("unknown module: '%s'\n", module); 
     696            } 
    727697        } else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1)) { 
    728                 dprintf("CLI DEBUG: %s command detected\n", CLI_SET); 
    729                 find_cli_callback_descr(module, current_mode->set_modules, 
     698            dprintf("CLI DEBUG: %s command detected\n", CLI_SET); 
     699            /* Look now for a 'set' callback in the hdt mode */ 
     700            find_cli_callback_descr(module, current_mode->set_modules, 
     701                                    &current_module); 
     702            /* Execute the callback, if found */ 
     703            if (current_module != NULL) 
     704                current_module->exec(argc, argv, hardware); 
     705            else { 
     706                /* Look now for a 'set' callback in the hdt mode */ 
     707                find_cli_callback_descr(module, hdt_mode.set_modules, 
    730708                                        &current_module); 
    731                 /* Execute the callback */ 
     709                /* Execute the callback, if found */ 
    732710                if (current_module != NULL) 
    733                         return current_module->exec(argc, argv, hardware); 
    734                 else { 
    735                         find_cli_callback_descr(module, hdt_mode.set_modules, 
    736                                                 &current_module); 
    737                         if (current_module != NULL) 
    738                                 return current_module->exec(argc, argv, hardware); 
    739                 } 
    740  
    741                 printf("unknown module: '%s'\n", module); 
    742                 return; 
    743  
    744         } 
    745  
    746         printf("I don't understand: '%s'. Try 'help'.\n", line); 
    747  
    748         /* Let's not forget to clean ourselves */ 
     711                    current_module->exec(argc, argv, hardware); 
     712                else 
     713                    printf("unknown module: '%s'\n", module); 
     714            } 
     715        } 
     716    } 
     717 
     718out: 
     719    /* Let's not forget to clean ourselves */ 
     720    if (command != NULL) 
    749721        free(command); 
     722    if (module != NULL) 
    750723        free(module); 
    751         for (i = 0; i < argc; i++) 
    752                 free(argv[i]); 
     724    for (i = 0; i < argc; i++) 
     725        free(argv[i]); 
     726    if (argc > 0) 
    753727        free(argv); 
    754728} 
     
    756730static void reset_prompt() 
    757731{ 
    758         /* No need to display the prompt if we exit */ 
    759         if (hdt_cli.mode != EXIT_MODE) { 
    760                 printf("%s", hdt_cli.prompt); 
    761                 /* Reset the line */ 
    762                 memset(hdt_cli.input, '\0', MAX_LINE_SIZE); 
    763                 hdt_cli.cursor_pos = 0; 
    764         } 
     732    /* No need to display the prompt if we exit */ 
     733    if (hdt_cli.mode != EXIT_MODE) { 
     734        printf("%s", hdt_cli.prompt); 
     735        /* Reset the line */ 
     736        memset(hdt_cli.input, '\0', MAX_LINE_SIZE); 
     737        hdt_cli.cursor_pos = 0; 
     738    } 
    765739} 
    766740 
    767741void start_auto_mode(struct s_hardware *hardware) 
    768742{ 
    769         char *mypch; 
    770         int nb_commands=0; 
    771         char *commands[MAX_NB_AUTO_COMMANDS]; 
    772  
    773         if (!quiet) 
    774                 more_printf("\nEntering Auto mode\n"); 
    775  
    776         /* Protecting the auto_label from the strtok modifications */ 
    777         char *temp=strdup(hardware->auto_label); 
    778  
    779         /* Searching & saving all commands */ 
    780         mypch = strtok (temp,AUTO_SEPARATOR); 
    781         while (mypch != NULL) { 
    782                 if ((strlen(remove_spaces(mypch))>0) && 
    783                                 (remove_spaces(mypch)[0] != AUTO_SEPARATOR[0])) { 
    784                         nb_commands++; 
    785                         if ((commands[nb_commands]=malloc(AUTO_COMMAND_SIZE)) != NULL) { 
    786                                 sprintf(commands[nb_commands],"%s",remove_spaces(mypch)); 
    787                         } else 
    788                                 nb_commands--; 
    789                 } 
    790                mypch = strtok (NULL, AUTO_SEPARATOR); 
    791         } 
    792  
    793         /* Executing found commands */ 
    794         for (int i=1;i<=nb_commands;i++) { 
    795                 if (commands[i]) { 
    796                         if (!quiet)  
    797                                 more_printf("%s%s\n",hdt_cli.prompt,commands[i]); 
    798                         exec_command(commands[i], hardware); 
    799                         free(commands[i]); 
    800                 } 
    801         } 
     743    char *mypch; 
     744    int nb_commands = 0; 
     745    char *commands[MAX_NB_AUTO_COMMANDS]; 
    802746 
    803747    if (!quiet) 
    804         more_printf("\nExiting Auto mode\n"); 
     748        more_printf("\nEntering Auto mode\n"); 
     749 
     750    /* Protecting the auto_label from the strtok modifications */ 
     751    char *temp = strdup(hardware->auto_label); 
     752 
     753    /* Searching & saving all commands */ 
     754    mypch = strtok(temp, AUTO_SEPARATOR); 
     755    while (mypch != NULL) { 
     756        if ((strlen(remove_spaces(mypch)) > 0) && 
     757            (remove_spaces(mypch)[0] != AUTO_SEPARATOR[0])) { 
     758            nb_commands++; 
     759            if ((commands[nb_commands] = malloc(AUTO_COMMAND_SIZE)) != NULL) { 
     760                sprintf(commands[nb_commands], "%s", remove_spaces(mypch)); 
     761            } else 
     762                nb_commands--; 
     763        } 
     764        mypch = strtok(NULL, AUTO_SEPARATOR); 
     765    } 
     766 
     767    /* Executing found commands */ 
     768    for (int i = 1; i <= nb_commands; i++) { 
     769        if (commands[i]) { 
     770            if (!quiet) 
     771                more_printf("%s%s\n", hdt_cli.prompt, commands[i]); 
     772            exec_command(commands[i], hardware); 
     773            free(commands[i]); 
     774        } 
     775    } 
     776 
     777    if (!quiet) 
     778        more_printf("\nExiting Auto mode\n"); 
    805779 
    806780    more_printf("\n"); 
    807781} 
    808  
    809782 
    810783/* Code that manages the cli mode */ 
    811784void start_cli_mode(struct s_hardware *hardware) 
    812785{ 
    813         int current_key = 0; 
    814         int future_history_pos=1; /* Temp variable*/ 
    815         bool display_history=true; /* Temp Variable*/ 
    816         char temp_command[MAX_LINE_SIZE]; 
    817  
    818         hdt_cli.cursor_pos=0; 
    819         memset(hdt_cli.input, '\0', MAX_LINE_SIZE); 
    820         memset(hdt_cli.history, '\0', sizeof(hdt_cli.history)); 
    821         hdt_cli.history_pos=1; 
    822         hdt_cli.max_history_pos=1; 
    823  
    824         /* Find the mode selected */ 
    825         set_mode(HDT_MODE, hardware); 
    826         find_cli_mode_descr(hdt_cli.mode, &current_mode); 
    827         if (current_mode == NULL) { 
    828                 /* Shouldn't get here... */ 
    829                 printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode); 
    830                 return; 
    831         } 
    832  
    833         /* Start the auto mode if the command line is set*/ 
    834         if (strlen(hardware->auto_label) > 0) { 
    835                 start_auto_mode(hardware); 
    836         } 
    837  
    838         printf("Entering CLI mode\n"); 
    839  
    840         reset_prompt(); 
    841  
    842         while (hdt_cli.mode != EXIT_MODE) { 
    843  
    844                 /* Display the cursor */ 
    845                 display_cursor(true); 
    846  
    847                 /* Let's put the cursor blinking until we get an input */ 
    848                 set_cursor_blink(true); 
    849  
    850                 /* We wait endlessly for a keyboard input*/ 
    851                 current_key = get_key(stdin, 0); 
    852  
    853                 /* We have to cancel the blinking mode to prevent 
    854                  * input text to blink */ 
    855                 set_cursor_blink(false); 
    856  
    857                 /* Reset autocomplete buffer unless TAB is pressed */ 
    858                 if (current_key != KEY_TAB) 
    859                         autocomplete_destroy_list(); 
    860  
    861                 switch (current_key) { 
    862                         /* clear until then end of line */ 
    863                 case KEY_CTRL('k'): 
    864                         /* Clear the end of the line */ 
    865                         clear_end_of_line(); 
    866                         memset(&hdt_cli.input[hdt_cli.cursor_pos], 0, 
    867                                strlen(hdt_cli.input) - hdt_cli.cursor_pos); 
    868                         break; 
    869  
    870                 case KEY_CTRL('c'): 
    871                         printf("\n"); 
    872                         reset_prompt(); 
    873                         break; 
    874  
    875                 case KEY_LEFT: 
    876                         if (hdt_cli.cursor_pos > 0) { 
    877                                 move_cursor_left(1); 
    878                                 hdt_cli.cursor_pos--; 
    879                         } 
    880                         break; 
    881  
    882                 case KEY_RIGHT: 
    883                         if (hdt_cli.cursor_pos < (int)strlen(hdt_cli.input)) { 
    884                                 move_cursor_right(1); 
    885                                 hdt_cli.cursor_pos++; 
    886                         } 
    887                         break; 
    888  
    889                 case KEY_CTRL('e'): 
    890                 case KEY_END: 
    891                         /* Calling with a 0 value will make the cursor move */ 
    892                         /* So, let's move the cursor only if needed */ 
    893                         if ((strlen(hdt_cli.input) - hdt_cli.cursor_pos) > 0) { 
    894                                 /* Return to the begining of line */ 
    895                                 move_cursor_right(strlen(hdt_cli.input) - hdt_cli.cursor_pos); 
    896                                 hdt_cli.cursor_pos = strlen(hdt_cli.input); 
    897                         } 
    898                         break; 
    899  
    900                 case KEY_CTRL('a'): 
    901                 case KEY_HOME: 
    902                         /* Calling with a 0 value will make the cursor move */ 
    903                         /* So, let's move the cursor only if needed */ 
    904                         if (hdt_cli.cursor_pos > 0) { 
    905                                 /* Return to the begining of line */ 
    906                                 move_cursor_left(hdt_cli.cursor_pos); 
    907                                 hdt_cli.cursor_pos = 0; 
    908                         } 
    909                         break; 
    910  
    911                 case KEY_UP: 
    912                         /* We have to compute the next position*/ 
    913                         future_history_pos=hdt_cli.history_pos; 
    914                         if (future_history_pos==1) { 
    915                                 future_history_pos=MAX_HISTORY_SIZE-1; 
    916                         } else { 
    917                                 future_history_pos--; 
    918                         } 
    919                         /* Does the next position is valid */ 
    920                         if (strlen(hdt_cli.history[future_history_pos])==0) break; 
    921  
    922                         /* Let's make that future position the one we use*/ 
    923                         hdt_cli.history_pos=future_history_pos; 
    924  
    925                         /* Clear the line */ 
    926                         clear_line(); 
    927  
    928                         /* Move to the begining of line*/ 
    929                         move_cursor_to_column(0); 
    930  
    931                         reset_prompt(); 
    932                         printf("%s",hdt_cli.history[hdt_cli.history_pos]); 
    933                         strncpy(hdt_cli.input,hdt_cli.history[hdt_cli.history_pos],sizeof(hdt_cli.input)); 
    934                         hdt_cli.cursor_pos=strlen(hdt_cli.input); 
    935                         break; 
    936  
    937                 case KEY_DOWN: 
    938                         display_history=true; 
    939  
    940                         /* We have to compute the next position*/ 
    941                         future_history_pos=hdt_cli.history_pos; 
    942                         if (future_history_pos==MAX_HISTORY_SIZE-1) { 
    943                                 future_history_pos=1; 
    944                         } else { 
    945                                 future_history_pos++; 
    946                         } 
    947                         /* Does the next position is valid */ 
    948                         if (strlen(hdt_cli.history[future_history_pos])==0) display_history = false; 
    949  
    950                         /* An exception is made to reach the last empty line */ 
    951                         if (future_history_pos==hdt_cli.max_history_pos) display_history=true; 
    952                         if (display_history==false) break; 
    953  
    954                         /* Let's make that future position the one we use*/ 
    955                         hdt_cli.history_pos=future_history_pos; 
    956  
    957                         /* Clear the line */ 
    958                         clear_line(); 
    959  
    960                         /* Move to the begining of line*/ 
    961                         move_cursor_to_column(0); 
    962  
    963                         reset_prompt(); 
    964                         printf("%s",hdt_cli.history[hdt_cli.history_pos]); 
    965                         strncpy(hdt_cli.input,hdt_cli.history[hdt_cli.history_pos],sizeof(hdt_cli.input)); 
    966                         hdt_cli.cursor_pos=strlen(hdt_cli.input); 
    967                         break; 
    968  
    969                 case KEY_TAB: 
    970                         if (autocomplete_backlog) { 
    971                                 clear_line(); 
    972                                 /* Move to the begining of line*/ 
    973                                 move_cursor_to_column(0); 
    974                                 reset_prompt(); 
    975                                 printf("%s",autocomplete_last_seen->autocomplete_token); 
    976                                 strncpy(hdt_cli.input,autocomplete_last_seen->autocomplete_token,sizeof(hdt_cli.input)); 
    977                                 hdt_cli.cursor_pos=strlen(hdt_cli.input); 
    978  
    979                                 /* Cycle through the list */ 
    980                                 autocomplete_last_seen = autocomplete_last_seen->next; 
    981                                 if (autocomplete_last_seen == NULL) 
    982                                         autocomplete_last_seen = autocomplete_head; 
    983                         } else { 
    984                                 printf("\n"); 
    985                                 autocomplete(skip_spaces(hdt_cli.input)); 
    986                                 autocomplete_last_seen = autocomplete_head; 
    987  
    988                                 printf("%s%s", hdt_cli.prompt, hdt_cli.input); 
    989                         } 
    990                         break; 
    991  
    992                 case KEY_ENTER: 
    993                         printf("\n"); 
    994                         if (strlen(remove_spaces(hdt_cli.input)) < 1) { 
    995                                 reset_prompt(); 
    996                                 break; 
    997                         } 
    998                         if (hdt_cli.history_pos == MAX_HISTORY_SIZE-1) hdt_cli.history_pos=1; 
    999                         strncpy(hdt_cli.history[hdt_cli.history_pos],remove_spaces(hdt_cli.input),sizeof(hdt_cli.history[hdt_cli.history_pos])); 
    1000                         hdt_cli.history_pos++; 
    1001                         if (hdt_cli.history_pos>hdt_cli.max_history_pos) hdt_cli.max_history_pos=hdt_cli.history_pos; 
    1002                         exec_command(remove_spaces(hdt_cli.input), hardware); 
    1003                         reset_prompt(); 
    1004                         break; 
    1005  
    1006                 case KEY_CTRL('d'): 
    1007                 case KEY_DELETE: 
    1008                         /* No need to delete when input is empty */ 
    1009                         if (strlen(hdt_cli.input)==0) break; 
    1010                         /* Don't delete when cursor is at the end of the line */ 
    1011                         if (hdt_cli.cursor_pos>=strlen(hdt_cli.input)) break; 
    1012  
    1013                         for (int c = hdt_cli.cursor_pos; 
    1014                              c < (int)strlen(hdt_cli.input) - 1; c++) 
    1015                                 hdt_cli.input[c] = hdt_cli.input[c + 1]; 
    1016                         hdt_cli.input[strlen(hdt_cli.input) - 1] = '\0'; 
    1017  
    1018                         /* Clear the end of the line */ 
    1019                         clear_end_of_line(); 
    1020  
    1021                         /* Print the resulting buffer */ 
    1022                         printf("%s", hdt_cli.input + hdt_cli.cursor_pos); 
    1023  
    1024                         /* Replace the cursor at the proper place */ 
    1025                         if (strlen(hdt_cli.input + hdt_cli.cursor_pos)>0) 
    1026                                 move_cursor_left(strlen(hdt_cli.input + hdt_cli.cursor_pos)); 
    1027                         break; 
    1028  
    1029                 case KEY_DEL: 
    1030                 case KEY_BACKSPACE: 
    1031                         /* Don't delete prompt */ 
    1032                         if (hdt_cli.cursor_pos == 0) 
    1033                                 break; 
    1034  
    1035                         for (int c = hdt_cli.cursor_pos - 1; 
    1036                              c < (int)strlen(hdt_cli.input) - 1; c++) 
    1037                                 hdt_cli.input[c] = hdt_cli.input[c + 1]; 
    1038                         hdt_cli.input[strlen(hdt_cli.input) - 1] = '\0'; 
    1039  
    1040                         /* Get one char back */ 
    1041                         move_cursor_left(1); 
    1042  
    1043                         /* Clear the end of the line */ 
    1044                         clear_end_of_line(); 
    1045  
    1046                         /* Print the resulting buffer */ 
    1047                         printf("%s", hdt_cli.input + hdt_cli.cursor_pos - 1); 
    1048  
    1049                         /* Realing to a char before the place we were */ 
    1050                         hdt_cli.cursor_pos--; 
    1051                         move_cursor_to_column(strlen(hdt_cli.prompt)+hdt_cli.cursor_pos+1); 
    1052  
    1053                         break; 
    1054  
    1055                 case KEY_F1: 
    1056                         printf("\n"); 
    1057                         exec_command(CLI_HELP, hardware); 
    1058                         reset_prompt(); 
    1059                         break; 
    1060  
    1061                 default: 
    1062                         if ( ( current_key < 0x20 ) || ( current_key > 0x7e ) ) break; 
    1063                         /* Prevent overflow */ 
    1064                         if (hdt_cli.cursor_pos > MAX_LINE_SIZE - 2) 
    1065                                 break; 
    1066                         /* If we aren't at the end of the input line, let's insert */ 
    1067                         if (hdt_cli.cursor_pos < (int)strlen(hdt_cli.input)) { 
    1068                                 char key[2]; 
    1069                                 int trailing_chars = 
    1070                                     strlen(hdt_cli.input) - hdt_cli.cursor_pos; 
    1071                                 memset(temp_command, 0, sizeof(temp_command)); 
    1072                                 strncpy(temp_command, hdt_cli.input, 
    1073                                         hdt_cli.cursor_pos); 
    1074                                 sprintf(key, "%c", current_key); 
    1075                                 strncat(temp_command, key, 1); 
    1076                                 strncat(temp_command, 
    1077                                         hdt_cli.input + hdt_cli.cursor_pos, 
    1078                                         trailing_chars); 
    1079                                 memset(hdt_cli.input, 0, sizeof(hdt_cli.input)); 
    1080                                 snprintf(hdt_cli.input, sizeof(hdt_cli.input), "%s", 
    1081                                          temp_command); 
    1082  
    1083                                 /* Clear the end of the line */ 
    1084                                 clear_end_of_line(); 
    1085  
    1086                                 /* Print the resulting buffer */ 
    1087                                 printf("%s", hdt_cli.input + hdt_cli.cursor_pos); 
    1088  
    1089                                 /* Return where we must put the new char */ 
    1090                                 move_cursor_left(trailing_chars); 
    1091  
    1092                         } else { 
    1093                                 putchar(current_key); 
    1094                                 hdt_cli.input[hdt_cli.cursor_pos] = current_key; 
    1095                         } 
    1096                         hdt_cli.cursor_pos++; 
    1097                         break; 
    1098                 } 
    1099         } 
    1100 } 
     786    int current_key = 0; 
     787    int future_history_pos = 1; /* Temp variable */ 
     788    bool display_history = true;        /* Temp Variable */ 
     789    char temp_command[MAX_LINE_SIZE]; 
     790 
     791    hdt_cli.cursor_pos = 0; 
     792    memset(hdt_cli.input, '\0', MAX_LINE_SIZE); 
     793    memset(hdt_cli.history, '\0', sizeof(hdt_cli.history)); 
     794    hdt_cli.history_pos = 1; 
     795    hdt_cli.max_history_pos = 1; 
     796 
     797    /* Find the mode selected */ 
     798    set_mode(HDT_MODE, hardware); 
     799    find_cli_mode_descr(hdt_cli.mode, &current_mode); 
     800    if (current_mode == NULL) { 
     801        /* Shouldn't get here... */ 
     802        printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode); 
     803        return; 
     804    } 
     805 
     806    /* Start the auto mode if the command line is set */ 
     807    if (strlen(hardware->auto_label) > 0) { 
     808        start_auto_mode(hardware); 
     809    } 
     810 
     811    printf("Entering CLI mode\n"); 
     812 
     813    reset_prompt(); 
     814 
     815    while (hdt_cli.mode != EXIT_MODE) { 
     816 
     817        /* Display the cursor */ 
     818        display_cursor(true); 
     819 
     820        /* Let's put the cursor blinking until we get an input */ 
     821        set_cursor_blink(true); 
     822 
     823        /* We wait endlessly for a keyboard input */ 
     824        current_key = get_key(stdin, 0); 
     825 
     826        /* We have to cancel the blinking mode to prevent 
     827         * input text to blink */ 
     828        set_cursor_blink(false); 
     829 
     830        /* Reset autocomplete buffer unless TAB is pressed */ 
     831        if (current_key != KEY_TAB) 
     832            autocomplete_destroy_list(); 
     833 
     834        switch (current_key) { 
     835            /* clear until then end of line */ 
     836        case KEY_CTRL('k'): 
     837            /* Clear the end of the line */ 
     838            clear_end_of_line(); 
     839            memset(&hdt_cli.input[hdt_cli.cursor_pos], 0, 
     840                   strlen(hdt_cli.input) - hdt_cli.cursor_pos); 
     841            break; 
     842 
     843        case KEY_CTRL('c'): 
     844            printf("\n"); 
     845            reset_prompt(); 
     846            break; 
     847 
     848        case KEY_LEFT: 
     849            if (hdt_cli.cursor_pos > 0) { 
     850                move_cursor_left(1); 
     851                hdt_cli.cursor_pos--; 
     852            } 
     853            break; 
     854 
     855        case KEY_RIGHT: 
     856            if (hdt_cli.cursor_pos < (int)strlen(hdt_cli.input)) { 
     857                move_cursor_right(1); 
     858                hdt_cli.cursor_pos++; 
     859            } 
     860            break; 
     861 
     862        case KEY_CTRL('e'): 
     863        case KEY_END: 
     864            /* Calling with a 0 value will make the cursor move */ 
     865            /* So, let's move the cursor only if needed */ 
     866            if ((strlen(hdt_cli.input) - hdt_cli.cursor_pos) > 0) { 
     867                /* Return to the begining of line */ 
     868                move_cursor_right(strlen(hdt_cli.input) - hdt_cli.cursor_pos); 
     869                hdt_cli.cursor_pos = strlen(hdt_cli.input); 
     870            } 
     871            break; 
     872 
     873        case KEY_CTRL('a'): 
     874        case KEY_HOME: 
     875            /* Calling with a 0 value will make the cursor move */ 
     876            /* So, let's move the cursor only if needed */ 
     877            if (hdt_cli.cursor_pos > 0) { 
     878                /* Return to the begining of line */ 
     879                move_cursor_left(hdt_cli.cursor_pos); 
     880                hdt_cli.cursor_pos = 0; 
     881            } 
     882            break; 
     883 
     884        case KEY_UP: 
     885            /* We have to compute the next position */ 
     886            future_history_pos = hdt_cli.history_pos; 
     887            if (future_history_pos == 1) { 
     888                future_history_pos = MAX_HISTORY_SIZE - 1; 
     889            } else { 
     890                future_history_pos--; 
     891            } 
     892            /* Does the next position is valid */ 
     893            if (strlen(hdt_cli.history[future_history_pos]) == 0) 
     894                break; 
     895 
     896            /* Let's make that future position the one we use */ 
     897            hdt_cli.history_pos = future_history_pos; 
     898 
     899            /* Clear the line */ 
     900            clear_line(); 
     901 
     902            /* Move to the begining of line */ 
     903            move_cursor_to_column(0); 
     904 
     905            reset_prompt(); 
     906            printf("%s", hdt_cli.history[hdt_cli.history_pos]); 
     907            strncpy(hdt_cli.input, hdt_cli.history[hdt_cli.history_pos], 
     908                    sizeof(hdt_cli.input)); 
     909            hdt_cli.cursor_pos = strlen(hdt_cli.input); 
     910            break; 
     911 
     912        case KEY_DOWN: 
     913            display_history = true; 
     914 
     915            /* We have to compute the next position */ 
     916            future_history_pos = hdt_cli.history_pos; 
     917            if (future_history_pos == MAX_HISTORY_SIZE - 1) { 
     918                future_history_pos = 1; 
     919            } else { 
     920                future_history_pos++; 
     921            } 
     922            /* Does the next position is valid */ 
     923            if (strlen(hdt_cli.history[future_history_pos]) == 0) 
     924                display_history = false; 
     925 
     926            /* An exception is made to reach the last empty line */ 
     927            if (future_history_pos == hdt_cli.max_history_pos) 
     928                display_history = true; 
     929            if (display_history == false) 
     930                break; 
     931 
     932            /* Let's make that future position the one we use */ 
     933            hdt_cli.history_pos = future_history_pos; 
     934 
     935            /* Clear the line */ 
     936            clear_line(); 
     937 
     938            /* Move to the begining of line */ 
     939            move_cursor_to_column(0); 
     940 
     941            reset_prompt(); 
     942            printf("%s", hdt_cli.history[hdt_cli.history_pos]); 
     943            strncpy(hdt_cli.input, hdt_cli.history[hdt_cli.history_pos], 
     944                    sizeof(hdt_cli.input)); 
     945            hdt_cli.cursor_pos = strlen(hdt_cli.input); 
     946            break; 
     947 
     948        case KEY_TAB: 
     949            if (autocomplete_backlog) { 
     950                clear_line(); 
     951                /* Move to the begining of line */ 
     952                move_cursor_to_column(0); 
     953                reset_prompt(); 
     954                printf("%s", autocomplete_last_seen->autocomplete_token); 
     955                strncpy(hdt_cli.input, 
     956                        autocomplete_last_seen->autocomplete_token, 
     957                        sizeof(hdt_cli.input)); 
     958                hdt_cli.cursor_pos = strlen(hdt_cli.input); 
     959 
     960                /* Cycle through the list */ 
     961                autocomplete_last_seen = autocomplete_last_seen->next; 
     962                if (autocomplete_last_seen == NULL) 
     963                    autocomplete_last_seen = autocomplete_head; 
     964            } else { 
     965                printf("\n"); 
     966                autocomplete(skip_spaces(hdt_cli.input)); 
     967                autocomplete_last_seen = autocomplete_head; 
     968 
     969                printf("%s%s", hdt_cli.prompt, hdt_cli.input); 
     970            } 
     971            break; 
     972 
     973        case KEY_ENTER: 
     974            printf("\n"); 
     975            if (strlen(remove_spaces(hdt_cli.input)) < 1) { 
     976                reset_prompt(); 
     977                break; 
     978            } 
     979            if (hdt_cli.history_pos == MAX_HISTORY_SIZE - 1) 
     980                hdt_cli.history_pos = 1; 
     981            strncpy(hdt_cli.history[hdt_cli.history_pos], 
     982                    remove_spaces(hdt_cli.input), 
     983                    sizeof(hdt_cli.history[hdt_cli.history_pos])); 
     984            hdt_cli.history_pos++; 
     985            if (hdt_cli.history_pos > hdt_cli.max_history_pos) 
     986                hdt_cli.max_history_pos = hdt_cli.history_pos; 
     987            exec_command(remove_spaces(hdt_cli.input), hardware); 
     988            reset_prompt(); 
     989            break; 
     990 
     991        case KEY_CTRL('d'): 
     992        case KEY_DELETE: 
     993            /* No need to delete when input is empty */ 
     994            if (strlen(hdt_cli.input) == 0) 
     995                break; 
     996            /* Don't delete when cursor is at the end of the line */ 
     997            if (hdt_cli.cursor_pos >= strlen(hdt_cli.input)) 
     998                break; 
     999 
     1000            for (int c = hdt_cli.cursor_pos; 
     1001                 c < (int)strlen(hdt_cli.input) - 1; c++) 
     1002                hdt_cli.input[c] = hdt_cli.input[c + 1]; 
     1003            hdt_cli.input[strlen(hdt_cli.input) - 1] = '\0'; 
     1004 
     1005            /* Clear the end of the line */ 
     1006            clear_end_of_line(); 
     1007 
     1008            /* Print the resulting buffer */ 
     1009            printf("%s", hdt_cli.input + hdt_cli.cursor_pos); 
     1010 
     1011            /* Replace the cursor at the proper place */ 
     1012            if (strlen(hdt_cli.input + hdt_cli.cursor_pos) > 0) 
     1013                move_cursor_left(strlen(hdt_cli.input + hdt_cli.cursor_pos)); 
     1014            break; 
     1015 
     1016        case KEY_DEL: 
     1017        case KEY_BACKSPACE: 
     1018            /* Don't delete prompt */ 
     1019            if (hdt_cli.cursor_pos == 0) 
     1020                break; 
     1021 
     1022            for (int c = hdt_cli.cursor_pos - 1; 
     1023                 c < (int)strlen(hdt_cli.input) - 1; c++) 
     1024                hdt_cli.input[c] = hdt_cli.input[c + 1]; 
     1025            hdt_cli.input[strlen(hdt_cli.input) - 1] = '\0'; 
     1026 
     1027            /* Get one char back */ 
     1028            move_cursor_left(1); 
     1029 
     1030            /* Clear the end of the line */ 
     1031            clear_end_of_line(); 
     1032 
     1033            /* Print the resulting buffer */ 
     1034            printf("%s", hdt_cli.input + hdt_cli.cursor_pos - 1); 
     1035 
     1036            /* Realing to a char before the place we were */ 
     1037            hdt_cli.cursor_pos--; 
     1038            move_cursor_to_column(strlen(hdt_cli.prompt) + hdt_cli.cursor_pos + 
     1039                                  1); 
     1040 
     1041            break; 
     1042 
     1043        case KEY_F1: 
     1044            printf("\n"); 
     1045            exec_command(CLI_HELP, hardware); 
     1046            reset_prompt(); 
     1047            break; 
     1048 
     1049        default: 
     1050            if ((current_key < 0x20) || (current_key > 0x7e)) 
     1051                break; 
     1052            /* Prevent overflow */ 
     1053            if (hdt_cli.cursor_pos > MAX_LINE_SIZE - 2) 
     1054                break; 
     1055            /* If we aren't at the end of the input line, let's insert */ 
     1056            if (hdt_cli.cursor_pos < (int)strlen(hdt_cli.input)) { 
     1057                char key[2]; 
     1058                int trailing_chars = strlen(hdt_cli.input) - hdt_cli.cursor_pos; 
     1059                memset(temp_command, 0, sizeof(temp_command)); 
     1060                strncpy(temp_command, hdt_cli.input, hdt_cli.cursor_pos); 
     1061                sprintf(key, "%c", current_key); 
     1062                strncat(temp_command, key, 1); 
     1063                strncat(temp_command, 
     1064                        hdt_cli.input + hdt_cli.cursor_pos, trailing_chars); 
     1065                memset(hdt_cli.input, 0, sizeof(hdt_cli.input)); 
     1066                snprintf(hdt_cli.input, sizeof(hdt_cli.input), "%s", 
     1067                         temp_command); 
     1068 
     1069                /* Clear the end of the line */ 
     1070                clear_end_of_line(); 
     1071 
     1072                /* Print the resulting buffer */ 
     1073                printf("%s", hdt_cli.input + hdt_cli.cursor_pos); 
     1074 
     1075                /* Return where we must put the new char */ 
     1076                move_cursor_left(trailing_chars); 
     1077 
     1078            } else { 
     1079                putchar(current_key); 
     1080                hdt_cli.input[hdt_cli.cursor_pos] = current_key; 
     1081            } 
     1082            hdt_cli.cursor_pos++; 
     1083            break; 
     1084        } 
     1085    } 
     1086} 
  • com32/hdt/hdt-cli.h

    r35c507 r990205  
    7171 
    7272typedef enum { 
    73         INVALID_MODE, 
    74         EXIT_MODE, 
    75         HDT_MODE, 
    76         PCI_MODE, 
    77         DMI_MODE, 
    78         CPU_MODE, 
    79         PXE_MODE, 
    80         KERNEL_MODE, 
    81         SYSLINUX_MODE, 
    82         VESA_MODE, 
    83         DISK_MODE, 
    84         VPD_MODE, 
    85         MEMORY_MODE, 
     73    INVALID_MODE, 
     74    EXIT_MODE, 
     75    HDT_MODE, 
     76    PCI_MODE, 
     77    DMI_MODE, 
     78    CPU_MODE, 
     79    PXE_MODE, 
     80    KERNEL_MODE, 
     81    SYSLINUX_MODE, 
     82    VESA_MODE, 
     83    DISK_MODE, 
     84    VPD_MODE, 
     85    MEMORY_MODE, 
    8686} cli_mode_t; 
    8787 
     
    8989#define MAX_HISTORY_SIZE 32 
    9090struct s_cli { 
    91         cli_mode_t mode; 
    92         char prompt[PROMPT_SIZE]; 
    93         char input[MAX_LINE_SIZE]; 
    94         uint8_t cursor_pos; 
    95         char history[MAX_HISTORY_SIZE][MAX_LINE_SIZE]; 
    96         int history_pos; 
    97         int max_history_pos; 
     91    cli_mode_t mode; 
     92    char prompt[PROMPT_SIZE]; 
     93    char input[MAX_LINE_SIZE]; 
     94    uint8_t cursor_pos; 
     95    char history[MAX_HISTORY_SIZE][MAX_LINE_SIZE]; 
     96    int history_pos; 
     97    int max_history_pos; 
    9898}; 
    9999struct s_cli hdt_cli; 
     
    101101/* Describe a cli mode */ 
    102102struct cli_mode_descr { 
    103         const unsigned int mode; 
    104         const char* name; 
    105         /* Handle 1-token commands */ 
    106         struct cli_module_descr* default_modules; 
    107         /* Handle show <module> <args> */ 
    108         struct cli_module_descr* show_modules; 
    109         /* Handle set <module> <args> */ 
    110         struct cli_module_descr* set_modules; 
     103    const unsigned int mode; 
     104    const char *name; 
     105    /* Handle 1-token commands */ 
     106    struct cli_module_descr *default_modules; 
     107    /* Handle show <module> <args> */ 
     108    struct cli_module_descr *show_modules; 
     109    /* Handle set <module> <args> */ 
     110    struct cli_module_descr *set_modules; 
    111111}; 
    112112 
    113113/* Describe a subset of commands in a module (default, show, set, ...) */ 
    114114struct cli_module_descr { 
    115         struct cli_callback_descr* modules; 
    116         void ( * default_callback ) ( int argc, char** argv, struct s_hardware *hardware ); 
     115    struct cli_callback_descr *modules; 
     116    void (*default_callback) (int argc, char **argv, 
     117                              struct s_hardware * hardware); 
    117118}; 
    118119 
    119120/* Describe a callback (belongs to a mode and a module) */ 
    120121struct cli_callback_descr { 
    121         const char *name; 
    122         void ( * exec ) ( int argc, char** argv, struct s_hardware *hardware ); 
     122    const char *name; 
     123    void (*exec) (int argc, char **argv, struct s_hardware * hardware); 
    123124}; 
    124125 
     
    126127#define MAX_ALIASES 2 
    127128struct cli_alias { 
    128         const char *command;    /* Original command */ 
    129         const int nb_aliases;   /* Size of aliases array */ 
    130         const char **aliases;   /* List of aliases */ 
     129    const char *command;        /* Original command */ 
     130    const int nb_aliases;       /* Size of aliases array */ 
     131    const char **aliases;       /* List of aliases */ 
    131132}; 
    132133 
     
    172173#define CLI_DMI_LIST CLI_SHOW_LIST 
    173174void main_show_dmi(int argc, char **argv, struct s_hardware *hardware); 
    174 void show_dmi_memory_modules(int argc, char** argv, struct s_hardware *hardware); 
    175 void show_dmi_memory_bank(int argc, char** argv, struct s_hardware *hardware); 
     175void show_dmi_memory_modules(int argc, char **argv, 
     176                             struct s_hardware *hardware); 
     177void show_dmi_memory_bank(int argc, char **argv, struct s_hardware *hardware); 
    176178 
    177179// PCI STUFF 
     
    199201 
    200202// VPD STUFF 
    201 void main_show_vpd(int argc __unused, char **argv __unused, struct s_hardware *hardware); 
     203void main_show_vpd(int argc __unused, char **argv __unused, 
     204                   struct s_hardware *hardware); 
    202205#endif 
  • com32/hdt/hdt-common.c

    rbb88c6 r990205  
    3838 
    3939/* ISOlinux requires a 8.3 format */ 
    40 void convert_isolinux_filename(char *filename, struct s_hardware *hardware) { 
    41   /* Exit if we are not running ISOLINUX */ 
    42   if (hardware->sv->filesystem != SYSLINUX_FS_ISOLINUX) return; 
    43   /* Searching the dot */ 
    44   char *dot=strchr(filename,'.'); 
    45   /* Exiting if no dot exists in that string */ 
    46   if (dot==NULL) return; 
    47   /* Exiting if the extension is 3 char or less */ 
    48   if (strlen(dot)<=4) return; 
    49  
    50   /* We have an extension bigger than .blah 
    51    * so we have to shorten it to 3*/ 
    52   dot[4]='\0'; 
     40void convert_isolinux_filename(char *filename, struct s_hardware *hardware) 
     41{ 
     42    /* Exit if we are not running ISOLINUX */ 
     43    if (hardware->sv->filesystem != SYSLINUX_FS_ISOLINUX) 
     44        return; 
     45    /* Searching the dot */ 
     46    char *dot = strchr(filename, '.'); 
     47    /* Exiting if no dot exists in that string */ 
     48    if (dot == NULL) 
     49        return; 
     50    /* Exiting if the extension is 3 char or less */ 
     51    if (strlen(dot) <= 4) 
     52        return; 
     53 
     54    /* We have an extension bigger than .blah 
     55     * so we have to shorten it to 3*/ 
     56    dot[4] = '\0'; 
    5357} 
    5458 
    5559void detect_parameters(const int argc, const char *argv[], 
    56                        struct s_hardware *hardware) 
    57 { 
    58   /* Quiet mode - make the output more quiet */ 
    59   quiet = false; 
    60  
    61   /* Vesa mode isn't set until we explictly call it*/ 
    62   vesamode = false; 
    63  
    64   for (int i = 1; i < argc; i++) { 
    65     if (!strncmp(argv[i], "quiet", 5)) { 
    66         quiet = true; 
    67     } else if (!strncmp(argv[i], "modules_pcimap=", 15)) { 
    68       strncpy(hardware->modules_pcimap_path, argv[i] + 15, 
    69         sizeof(hardware->modules_pcimap_path)); 
    70       convert_isolinux_filename(hardware->modules_pcimap_path,hardware); 
    71     } else if (!strncmp(argv[i], "pciids=", 7)) { 
    72       strncpy(hardware->pciids_path, argv[i] + 7, 
    73         sizeof(hardware->pciids_path)); 
    74       convert_isolinux_filename(hardware->pciids_path,hardware); 
    75     } else if (!strncmp(argv[i], "modules_alias=", 14)) { 
    76       strncpy(hardware->modules_alias_path, argv[i] + 14, 
    77         sizeof(hardware->modules_alias_path)); 
    78       convert_isolinux_filename(hardware->modules_alias_path,hardware); 
    79     } else if (!strncmp(argv[i], "memtest=", 8)) { 
    80       strncpy(hardware->memtest_label, argv[i] + 8, 
    81         sizeof(hardware->memtest_label)); 
    82       convert_isolinux_filename(hardware->memtest_label,hardware); 
    83     } else if (!strncmp(argv[i], "reboot=", 7)) { 
    84       strncpy(hardware->reboot_label, argv[i] + 7, 
    85         sizeof(hardware->reboot_label)); 
    86       convert_isolinux_filename(hardware->reboot_label,hardware); 
    87     } else if (!strncmp(argv[i], "vesa", 4)) { 
    88         vesamode=true; 
    89         max_console_lines=24; 
    90         /* If the user defines a background image */ 
    91         if (!strncmp(argv[i], "vesa=", 5)) { 
    92          strncpy(hardware->vesa_background,argv[i]+5,sizeof(hardware->vesa_background)); 
     60                       struct s_hardware *hardware) 
     61{ 
     62    /* Quiet mode - make the output more quiet */ 
     63    quiet = false; 
     64 
     65    /* Vesa mode isn't set until we explictly call it */ 
     66    vesamode = false; 
     67 
     68    for (int i = 1; i < argc; i++) { 
     69        if (!strncmp(argv[i], "quiet", 5)) { 
     70            quiet = true; 
     71        } else if (!strncmp(argv[i], "modules_pcimap=", 15)) { 
     72            strncpy(hardware->modules_pcimap_path, argv[i] + 15, 
     73                    sizeof(hardware->modules_pcimap_path)); 
     74            convert_isolinux_filename(hardware->modules_pcimap_path, hardware); 
     75        } else if (!strncmp(argv[i], "pciids=", 7)) { 
     76            strncpy(hardware->pciids_path, argv[i] + 7, 
     77                    sizeof(hardware->pciids_path)); 
     78            convert_isolinux_filename(hardware->pciids_path, hardware); 
     79        } else if (!strncmp(argv[i], "modules_alias=", 14)) { 
     80            strncpy(hardware->modules_alias_path, argv[i] + 14, 
     81                    sizeof(hardware->modules_alias_path)); 
     82            convert_isolinux_filename(hardware->modules_alias_path, hardware); 
     83        } else if (!strncmp(argv[i], "memtest=", 8)) { 
     84            strncpy(hardware->memtest_label, argv[i] + 8, 
     85                    sizeof(hardware->memtest_label)); 
     86            convert_isolinux_filename(hardware->memtest_label, hardware); 
     87        } else if (!strncmp(argv[i], "reboot=", 7)) { 
     88            strncpy(hardware->reboot_label, argv[i] + 7, 
     89                    sizeof(hardware->reboot_label)); 
     90            convert_isolinux_filename(hardware->reboot_label, hardware); 
     91        } else if (!strncmp(argv[i], "vesa", 4)) { 
     92            vesamode = true; 
     93            max_console_lines = 24; 
     94            /* If the user defines a background image */ 
     95            if (!strncmp(argv[i], "vesa=", 5)) { 
     96                strncpy(hardware->vesa_background, argv[i] + 5, 
     97                        sizeof(hardware->vesa_background)); 
     98            } 
     99        } else if (!strncmp(argv[i], "auto=", 5)) { 
     100            /* The auto= parameter is separated in several argv[] 
     101             * as it can contains spaces. 
     102             * We use the AUTO_DELIMITER char to define the limits 
     103             * of this parameter. 
     104             * i.e auto='show dmi; show pci' 
     105             */ 
     106 
     107            /* Extracting the first parameter */ 
     108            strcpy(hardware->auto_label, argv[i] + 6); 
     109            strcat(hardware->auto_label, " "); 
     110            char *pos; 
     111            i++; 
     112 
     113            /* While we can't find the other AUTO_DELIMITER, let's process the argv[] */ 
     114            while (((pos = strstr(argv[i], AUTO_DELIMITER)) == NULL) 
     115                   && (i < argc)) { 
     116                strcat(hardware->auto_label, argv[i]); 
     117                strcat(hardware->auto_label, " "); 
     118                i++; 
     119            } 
     120 
     121            /* If we didn't reach the end of the line, let's grab the last item */ 
     122            if (i < argc) { 
     123                strcat(hardware->auto_label, argv[i]); 
     124                hardware->auto_label[strlen(hardware->auto_label) - 1] = 0; 
     125            } 
    93126        } 
    94     } else if (!strncmp(argv[i], "auto=", 5)) { 
    95                 /* The auto= parameter is separated in several argv[] 
    96                  * as it can contains spaces. 
    97                  * We use the AUTO_DELIMITER char to define the limits 
    98                  * of this parameter. 
    99                  * i.e auto='show dmi; show pci' 
    100                  */ 
    101  
    102                 /* Extracting the first parameter */ 
    103                 strcpy(hardware->auto_label, argv[i] + 6); 
    104                 strcat(hardware->auto_label," "); 
    105                 char *pos; 
    106                 i++; 
    107  
    108                 /* While we can't find the other AUTO_DELIMITER, let's process the argv[] */ 
    109                 while(((pos=strstr(argv[i],AUTO_DELIMITER)) == NULL) && (i<argc)) { 
    110                         strcat(hardware->auto_label,argv[i]); 
    111                         strcat(hardware->auto_label," "); 
    112                         i++; 
    113                 } 
    114  
    115                 /* If we didn't reach the end of the line, let's grab the last item */ 
    116                 if (i<argc)  { 
    117                         strcat(hardware->auto_label,argv[i]); 
    118                         hardware->auto_label[strlen(hardware->auto_label)-1]=0; 
    119                 } 
    120     } 
    121   } 
     127    } 
    122128} 
    123129 
    124130void detect_syslinux(struct s_hardware *hardware) 
    125131{ 
    126   hardware->sv = syslinux_version(); 
    127   switch (hardware->sv->filesystem) { 
    128   case SYSLINUX_FS_SYSLINUX: 
    129     strlcpy(hardware->syslinux_fs, "SYSlinux", 9); 
    130     break; 
    131   case SYSLINUX_FS_PXELINUX: 
    132     strlcpy(hardware->syslinux_fs, "PXElinux", 9); 
    133     break; 
    134   case SYSLINUX_FS_ISOLINUX: 
    135     strlcpy(hardware->syslinux_fs, "ISOlinux", 9); 
    136     break; 
    137   case SYSLINUX_FS_EXTLINUX: 
    138     strlcpy(hardware->syslinux_fs, "EXTlinux", 9); 
    139     break; 
    140   case SYSLINUX_FS_UNKNOWN: 
    141   default: 
    142     strlcpy(hardware->syslinux_fs, "Unknown Bootloader", 
    143       sizeof hardware->syslinux_fs); 
    144     break; 
    145   } 
     132    hardware->sv = syslinux_version(); 
     133    switch (hardware->sv->filesystem) { 
     134    case SYSLINUX_FS_SYSLINUX: 
     135        strlcpy(hardware->syslinux_fs, "SYSlinux", 9); 
     136        break; 
     137    case SYSLINUX_FS_PXELINUX: 
     138        strlcpy(hardware->syslinux_fs, "PXElinux", 9); 
     139        break; 
     140    case SYSLINUX_FS_ISOLINUX: 
     141        strlcpy(hardware->syslinux_fs, "ISOlinux", 9); 
     142        break; 
     143    case SYSLINUX_FS_EXTLINUX: 
     144        strlcpy(hardware->syslinux_fs, "EXTlinux", 9); 
     145        break; 
     146    case SYSLINUX_FS_UNKNOWN: 
     147    default: 
     148        strlcpy(hardware->syslinux_fs, "Unknown Bootloader", 
     149                sizeof hardware->syslinux_fs); 
     150        break; 
     151    } 
    146152} 
    147153 
    148154void init_hardware(struct s_hardware *hardware) 
    149155{ 
    150   hardware->pci_ids_return_code = 0; 
    151   hardware->modules_pcimap_return_code = 0; 
    152   hardware->modules_alias_return_code = 0; 
    153   hardware->cpu_detection = false; 
    154   hardware->pci_detection = false; 
    155   hardware->disk_detection = false; 
    156   hardware->disks_count=0; 
    157   hardware->dmi_detection = false; 
    158   hardware->pxe_detection = false; 
    159   hardware->vesa_detection = false; 
    160   hardware->vpd_detection = false; 
    161   hardware->nb_pci_devices = 0; 
    162   hardware->is_dmi_valid = false; 
    163   hardware->is_pxe_valid = false; 
    164   hardware->is_vpd_valid = false; 
    165   hardware->pci_domain = NULL; 
    166   hardware->detected_memory_size = 0; 
    167  
    168   /* Cleaning structures */ 
    169   memset(hardware->disk_info, 0, sizeof(hardware->disk_info)); 
    170   memset(hardware->mbr_ids, 0, sizeof(hardware->mbr_ids)); 
    171   memset(&hardware->dmi, 0, sizeof(s_dmi)); 
    172   memset(&hardware->cpu, 0, sizeof(s_cpu)); 
    173   memset(&hardware->pxe, 0, sizeof(struct s_pxe)); 
    174   memset(&hardware->vesa, 0, sizeof(struct s_vesa)); 
    175   memset(&hardware->vpd, 0, sizeof(s_vpd)); 
    176   memset(hardware->syslinux_fs, 0, sizeof hardware->syslinux_fs); 
    177   memset(hardware->pciids_path, 0, sizeof hardware->pciids_path); 
    178   memset(hardware->modules_pcimap_path, 0, 
    179          sizeof hardware->modules_pcimap_path); 
    180   memset(hardware->modules_alias_path, 0, 
    181          sizeof hardware->modules_alias_path); 
    182   memset(hardware->memtest_label, 0, sizeof hardware->memtest_label); 
    183   memset(hardware->reboot_label, 0, sizeof hardware->reboot_label); 
    184   memset(hardware->auto_label, 0, sizeof hardware->auto_label); 
    185   memset(hardware->vesa_background, 0, sizeof hardware->vesa_background); 
    186   strcat(hardware->pciids_path, "pci.ids"); 
    187   strcat(hardware->modules_pcimap_path, "modules.pcimap"); 
    188   strcat(hardware->modules_alias_path, "modules.alias"); 
    189   strcat(hardware->memtest_label, "memtest"); 
    190   strcat(hardware->reboot_label, "reboot.c32"); 
    191   strncpy(hardware->vesa_background,CLI_DEFAULT_BACKGROUND,sizeof(hardware->vesa_background)); 
     156    hardware->pci_ids_return_code = 0; 
     157    hardware->modules_pcimap_return_code = 0; 
     158    hardware->modules_alias_return_code = 0; 
     159    hardware->cpu_detection = false; 
     160    hardware->pci_detection = false; 
     161    hardware->disk_detection = false; 
     162    hardware->disks_count = 0; 
     163    hardware->dmi_detection = false; 
     164    hardware->pxe_detection = false; 
     165    hardware->vesa_detection = false; 
     166    hardware->vpd_detection = false; 
     167    hardware->nb_pci_devices = 0; 
     168    hardware->is_dmi_valid = false; 
     169    hardware->is_pxe_valid = false; 
     170    hardware->is_vpd_valid = false; 
     171    hardware->pci_domain = NULL; 
     172    hardware->detected_memory_size = 0; 
     173 
     174    /* Cleaning structures */ 
     175    memset(hardware->disk_info, 0, sizeof(hardware->disk_info)); 
     176    memset(hardware->mbr_ids, 0, sizeof(hardware->mbr_ids)); 
     177    memset(&hardware->dmi, 0, sizeof(s_dmi)); 
     178    memset(&hardware->cpu, 0, sizeof(s_cpu)); 
     179    memset(&hardware->pxe, 0, sizeof(struct s_pxe)); 
     180    memset(&hardware->vesa, 0, sizeof(struct s_vesa)); 
     181    memset(&hardware->vpd, 0, sizeof(s_vpd)); 
     182    memset(hardware->syslinux_fs, 0, sizeof hardware->syslinux_fs); 
     183    memset(hardware->pciids_path, 0, sizeof hardware->pciids_path); 
     184    memset(hardware->modules_pcimap_path, 0, 
     185           sizeof hardware->modules_pcimap_path); 
     186    memset(hardware->modules_alias_path, 0, 
     187           sizeof hardware->modules_alias_path); 
     188    memset(hardware->memtest_label, 0, sizeof hardware->memtest_label); 
     189    memset(hardware->reboot_label, 0, sizeof hardware->reboot_label); 
     190    memset(hardware->auto_label, 0, sizeof hardware->auto_label); 
     191    memset(hardware->vesa_background, 0, sizeof hardware->vesa_background); 
     192    strcat(hardware->pciids_path, "pci.ids"); 
     193    strcat(hardware->modules_pcimap_path, "modules.pcimap"); 
     194    strcat(hardware->modules_alias_path, "modules.alias"); 
     195    strcat(hardware->memtest_label, "memtest"); 
     196    strcat(hardware->reboot_label, "reboot.c32"); 
     197    strncpy(hardware->vesa_background, CLI_DEFAULT_BACKGROUND, 
     198            sizeof(hardware->vesa_background)); 
    192199} 
    193200 
     
    198205int detect_dmi(struct s_hardware *hardware) 
    199206{ 
    200   if (hardware->dmi_detection == true) 
    201     return -1; 
    202   hardware->dmi_detection = true; 
    203   if (dmi_iterate(&hardware->dmi) == -ENODMITABLE) { 
    204     hardware->is_dmi_valid = false; 
    205     return -ENODMITABLE; 
    206   } 
    207  
    208   parse_dmitable(&hardware->dmi); 
    209   hardware->is_dmi_valid = true; 
    210   return 0; 
     207    if (hardware->dmi_detection == true) 
     208        return -1; 
     209    hardware->dmi_detection = true; 
     210    if (dmi_iterate(&hardware->dmi) == -ENODMITABLE) { 
     211        hardware->is_dmi_valid = false; 
     212        return -ENODMITABLE; 
     213    } 
     214 
     215    parse_dmitable(&hardware->dmi); 
     216    hardware->is_dmi_valid = true; 
     217    return 0; 
    211218} 
    212219 
     
    221228int detect_vpd(struct s_hardware *hardware) 
    222229{ 
    223         if (hardware->vpd_detection) 
    224                 return -1; 
    225         else 
    226                 hardware->vpd_detection = true; 
    227  
    228         if (vpd_decode(&hardware->vpd) == -ENOVPDTABLE) { 
    229                 hardware->is_vpd_valid = false; 
    230                 return -ENOVPDTABLE; 
    231         } else { 
    232                 hardware->is_vpd_valid = true; 
    233                 return 0; 
    234         } 
     230    if (hardware->vpd_detection) 
     231        return -1; 
     232    else 
     233        hardware->vpd_detection = true; 
     234 
     235    if (vpd_decode(&hardware->vpd) == -ENOVPDTABLE) { 
     236        hardware->is_vpd_valid = false; 
     237        return -ENOVPDTABLE; 
     238    } else { 
     239        hardware->is_vpd_valid = true; 
     240        return 0; 
     241    } 
    235242} 
    236243 
    237244/* Detection vesa stuff*/ 
    238 int detect_vesa(struct s_hardware *hardware) { 
    239   static com32sys_t rm; 
    240   struct vesa_general_info *gi; 
    241   struct vesa_mode_info *mi; 
    242   uint16_t mode, *mode_ptr; 
    243   char *oem_ptr; 
    244  
    245   if (hardware->vesa_detection == true) return -1; 
    246  
    247   hardware->vesa_detection=true; 
    248   hardware->is_vesa_valid=false; 
    249  
    250   /* Allocate space in the bounce buffer for these structures */ 
    251   gi = &((struct vesa_info *)__com32.cs_bounce)->gi; 
    252   mi = &((struct vesa_info *)__com32.cs_bounce)->mi; 
    253  
    254   gi->signature = VBE2_MAGIC;   /* Get VBE2 extended data */ 
    255   rm.eax.w[0] = 0x4F00;         /* Get SVGA general information */ 
    256   rm.edi.w[0] = OFFS(gi); 
    257   rm.es      = SEG(gi); 
    258   __intcall(0x10, &rm, &rm); 
    259  
    260   if ( rm.eax.w[0] != 0x004F ) { 
    261     return -1; 
    262   }; 
    263  
    264   mode_ptr = GET_PTR(gi->video_mode_ptr); 
    265   oem_ptr = GET_PTR(gi->oem_vendor_name_ptr); 
    266   strncpy(hardware->vesa.vendor,oem_ptr,sizeof(hardware->vesa.vendor)); 
    267   oem_ptr = GET_PTR(gi->oem_product_name_ptr); 
    268   strncpy(hardware->vesa.product,oem_ptr,sizeof(hardware->vesa.product)); 
    269   oem_ptr = GET_PTR(gi->oem_product_rev_ptr); 
    270   strncpy(hardware->vesa.product_revision,oem_ptr,sizeof(hardware->vesa.product_revision)); 
    271  
    272   hardware->vesa.major_version=(gi->version >> 8) & 0xff; 
    273   hardware->vesa.minor_version=gi->version & 0xff; 
    274   hardware->vesa.total_memory=gi->total_memory; 
    275   hardware->vesa.software_rev=gi->oem_software_rev; 
    276  
    277   hardware->vesa.vmi_count=0; 
    278  
    279   while ((mode = *mode_ptr++) != 0xFFFF) { 
    280  
    281     rm.eax.w[0] = 0x4F01;       /* Get SVGA mode information */ 
    282     rm.ecx.w[0] = mode; 
    283     rm.edi.w[0] = OFFS(mi); 
    284     rm.es  = SEG(mi); 
     245int detect_vesa(struct s_hardware *hardware) 
     246{ 
     247    static com32sys_t rm; 
     248    struct vesa_general_info *gi; 
     249    struct vesa_mode_info *mi; 
     250    uint16_t mode, *mode_ptr; 
     251    char *oem_ptr; 
     252 
     253    if (hardware->vesa_detection == true) 
     254        return -1; 
     255 
     256    hardware->vesa_detection = true; 
     257    hardware->is_vesa_valid = false; 
     258 
     259    /* Allocate space in the bounce buffer for these structures */ 
     260    gi = &((struct vesa_info *)__com32.cs_bounce)->gi; 
     261    mi = &((struct vesa_info *)__com32.cs_bounce)->mi; 
     262 
     263    gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */ 
     264    rm.eax.w[0] = 0x4F00;       /* Get SVGA general information */ 
     265    rm.edi.w[0] = OFFS(gi); 
     266    rm.es = SEG(gi); 
    285267    __intcall(0x10, &rm, &rm); 
    286268 
    287     /* Must be a supported mode */ 
    288     if ( rm.eax.w[0] != 0x004f ) 
    289       continue; 
    290  
    291     /* Saving detected values*/ 
    292     memcpy(&hardware->vesa.vmi[hardware->vesa.vmi_count].mi, mi, 
    293            sizeof(struct vesa_mode_info)); 
    294     hardware->vesa.vmi[hardware->vesa.vmi_count].mode = mode; 
    295  
    296     hardware->vesa.vmi_count++; 
    297   } 
    298   hardware->is_vesa_valid = true; 
    299  return 0; 
     269    if (rm.eax.w[0] != 0x004F) { 
     270        return -1; 
     271    }; 
     272 
     273    mode_ptr = GET_PTR(gi->video_mode_ptr); 
     274    oem_ptr = GET_PTR(gi->oem_vendor_name_ptr); 
     275    strncpy(hardware->vesa.vendor, oem_ptr, sizeof(hardware->vesa.vendor)); 
     276    oem_ptr = GET_PTR(gi->oem_product_name_ptr); 
     277    strncpy(hardware->vesa.product, oem_ptr, sizeof(hardware->vesa.product)); 
     278    oem_ptr = GET_PTR(gi->oem_product_rev_ptr); 
     279    strncpy(hardware->vesa.product_revision, oem_ptr, 
     280            sizeof(hardware->vesa.product_revision)); 
     281 
     282    hardware->vesa.major_version = (gi->version >> 8) & 0xff; 
     283    hardware->vesa.minor_version = gi->version & 0xff; 
     284    hardware->vesa.total_memory = gi->total_memory; 
     285    hardware->vesa.software_rev = gi->oem_software_rev; 
     286 
     287    hardware->vesa.vmi_count = 0; 
     288 
     289    while ((mode = *mode_ptr++) != 0xFFFF) { 
     290 
     291        rm.eax.w[0] = 0x4F01;   /* Get SVGA mode information */ 
     292        rm.ecx.w[0] = mode; 
     293        rm.edi.w[0] = OFFS(mi); 
     294        rm.es = SEG(mi); 
     295        __intcall(0x10, &rm, &rm); 
     296 
     297        /* Must be a supported mode */ 
     298        if (rm.eax.w[0] != 0x004f) 
     299            continue; 
     300 
     301        /* Saving detected values */ 
     302        memcpy(&hardware->vesa.vmi[hardware->vesa.vmi_count].mi, mi, 
     303               sizeof(struct vesa_mode_info)); 
     304        hardware->vesa.vmi[hardware->vesa.vmi_count].mode = mode; 
     305 
     306        hardware->vesa.vmi_count++; 
     307    } 
     308    hardware->is_vesa_valid = true; 
     309    return 0; 
    300310} 
    301311 
     
    303313void detect_disks(struct s_hardware *hardware) 
    304314{ 
    305         int i = -1; 
    306         int err; 
    307  
    308         if (hardware->disk_detection) 
    309                 return; 
    310  
    311         hardware->disk_detection = true; 
    312         for (int drive = 0x80; drive < 0xff; drive++) { 
    313                 i++; 
    314                 hardware->disk_info[i].disk = drive; 
    315                 err = get_drive_parameters(&hardware->disk_info[i]); 
    316  
    317                 /* 
    318                  * Do not print output when drive does not exist or 
    319                  * doesn't support int13 (cdrom, ...) 
    320                  */ 
    321                 if (err == -1 || !hardware->disk_info[i].cbios) 
    322                         continue; 
    323  
    324                 /* Detect MBR */ 
    325                 hardware->mbr_ids[i] = get_mbr_id(&hardware->disk_info[i]); 
    326  
    327                 hardware->disks_count++; 
     315    int i = -1; 
     316    int err; 
     317 
     318    if (hardware->disk_detection) 
     319        return; 
     320 
     321    hardware->disk_detection = true; 
     322    for (int drive = 0x80; drive < 0xff; drive++) { 
     323        i++; 
     324        hardware->disk_info[i].disk = drive; 
     325        err = get_drive_parameters(&hardware->disk_info[i]); 
     326 
     327        /* 
     328         * Do not print output when drive does not exist or 
     329         * doesn't support int13 (cdrom, ...) 
     330         */ 
     331        if (err == -1 || !hardware->disk_info[i].cbios) 
     332            continue; 
     333 
     334        /* Detect MBR */ 
     335        hardware->mbr_ids[i] = get_mbr_id(&hardware->disk_info[i]); 
     336 
     337        hardware->disks_count++; 
     338    } 
     339} 
     340 
     341int detect_pxe(struct s_hardware *hardware) 
     342{ 
     343    void *dhcpdata; 
     344 
     345    size_t dhcplen; 
     346    t_PXENV_UNDI_GET_NIC_TYPE gnt; 
     347 
     348    if (hardware->pxe_detection == true) 
     349        return -1; 
     350    hardware->pxe_detection = true; 
     351    hardware->is_pxe_valid = false; 
     352    memset(&gnt, 0, sizeof(t_PXENV_UNDI_GET_NIC_TYPE)); 
     353    memset(&hardware->pxe, 0, sizeof(struct s_pxe)); 
     354 
     355    /* This code can only work if pxelinux is loaded */ 
     356    if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) { 
     357        return -1; 
     358    } 
     359// printf("PXE: PXElinux detected\n"); 
     360    if (!pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) { 
     361        pxe_bootp_t *dhcp = &hardware->pxe.dhcpdata; 
     362        memcpy(&hardware->pxe.dhcpdata, dhcpdata, 
     363               sizeof(hardware->pxe.dhcpdata)); 
     364        snprintf(hardware->pxe.mac_addr, sizeof(hardware->pxe.mac_addr), 
     365                 "%02x:%02x:%02x:%02x:%02x:%02x", dhcp->CAddr[0], 
     366                 dhcp->CAddr[1], dhcp->CAddr[2], dhcp->CAddr[3], 
     367                 dhcp->CAddr[4], dhcp->CAddr[5]); 
     368 
     369        /* Saving our IP address in a easy format */ 
     370        hardware->pxe.ip_addr[0] = hardware->pxe.dhcpdata.yip & 0xff; 
     371        hardware->pxe.ip_addr[1] = hardware->pxe.dhcpdata.yip >> 8 & 0xff; 
     372        hardware->pxe.ip_addr[2] = hardware->pxe.dhcpdata.yip >> 16 & 0xff; 
     373        hardware->pxe.ip_addr[3] = hardware->pxe.dhcpdata.yip >> 24 & 0xff; 
     374 
     375        if (!pxe_get_nic_type(&gnt)) { 
     376            switch (gnt.NicType) { 
     377            case PCI_NIC: 
     378                hardware->is_pxe_valid = true; 
     379                hardware->pxe.vendor_id = gnt.info.pci.Vendor_ID; 
     380                hardware->pxe.product_id = gnt.info.pci.Dev_ID; 
     381                hardware->pxe.subvendor_id = gnt.info.pci.SubVendor_ID; 
     382                hardware->pxe.subproduct_id = 
     383                    gnt.info.pci.SubDevice_ID, 
     384                    hardware->pxe.rev = gnt.info.pci.Rev; 
     385                hardware->pxe.pci_bus = (gnt.info.pci.BusDevFunc >> 8) & 0xff; 
     386                hardware->pxe.pci_dev = (gnt.info.pci.BusDevFunc >> 3) & 0x7; 
     387                hardware->pxe.pci_func = gnt.info.pci.BusDevFunc & 0x03; 
     388                hardware->pxe.base_class = gnt.info.pci.Base_Class; 
     389                hardware->pxe.sub_class = gnt.info.pci.Sub_Class; 
     390                hardware->pxe.prog_intf = gnt.info.pci.Prog_Intf; 
     391                hardware->pxe.nictype = gnt.NicType; 
     392                break; 
     393            case CardBus_NIC: 
     394                hardware->is_pxe_valid = true; 
     395                hardware->pxe.vendor_id = gnt.info.cardbus.Vendor_ID; 
     396                hardware->pxe.product_id = gnt.info.cardbus.Dev_ID; 
     397                hardware->pxe.subvendor_id = gnt.info.cardbus.SubVendor_ID; 
     398                hardware->pxe.subproduct_id = 
     399                    gnt.info.cardbus.SubDevice_ID, 
     400                    hardware->pxe.rev = gnt.info.cardbus.Rev; 
     401                hardware->pxe.pci_bus = 
     402                    (gnt.info.cardbus.BusDevFunc >> 8) & 0xff; 
     403                hardware->pxe.pci_dev = 
     404                    (gnt.info.cardbus.BusDevFunc >> 3) & 0x7; 
     405                hardware->pxe.pci_func = gnt.info.cardbus.BusDevFunc & 0x03; 
     406                hardware->pxe.base_class = gnt.info.cardbus.Base_Class; 
     407                hardware->pxe.sub_class = gnt.info.cardbus.Sub_Class; 
     408                hardware->pxe.prog_intf = gnt.info.cardbus.Prog_Intf; 
     409                hardware->pxe.nictype = gnt.NicType; 
     410                break; 
     411            case PnP_NIC: 
     412            default: 
     413                return -1; 
     414                break; 
     415            } 
     416            /* Let's try to find the associated pci device */ 
     417            detect_pci(hardware); 
     418 
     419            /* The firt pass try to find the exact pci device */ 
     420            hardware->pxe.pci_device = NULL; 
     421            hardware->pxe.pci_device_pos = 0; 
     422            struct pci_device *pci_device; 
     423            int pci_number = 0; 
     424            for_each_pci_func(pci_device, hardware->pci_domain) { 
     425                pci_number++; 
     426                if ((__pci_bus == hardware->pxe.pci_bus) && 
     427                    (__pci_slot == hardware->pxe.pci_dev) && 
     428                    (__pci_func == hardware->pxe.pci_func) && 
     429                    (pci_device->vendor == hardware->pxe.vendor_id) 
     430                    && (pci_device->product == hardware->pxe.product_id)) { 
     431                    hardware->pxe.pci_device = pci_device; 
     432                    hardware->pxe.pci_device_pos = pci_number; 
     433                    return 0; 
     434                } 
     435            } 
     436 
     437            /* If we reach that part, it means the pci device pointed by 
     438             * the pxe rom wasn't found in our list. 
     439             * Let's try to find the device only by its pci ids. 
     440             * The pci device we'll match is maybe not exactly the good one 
     441             * as we can have the same pci id several times. 
     442             * At least, the pci id, the vendor/product will be right. 
     443             * That's clearly a workaround for some weird cases. 
     444             * This should happend very unlikely */ 
     445            hardware->pxe.pci_device = NULL; 
     446            hardware->pxe.pci_device_pos = 0; 
     447            pci_number = 0; 
     448            for_each_pci_func(pci_device, hardware->pci_domain) { 
     449                pci_number++; 
     450                if ((pci_device->vendor == hardware->pxe.vendor_id) 
     451                    && (pci_device->product == hardware->pxe.product_id)) { 
     452                    hardware->pxe.pci_device = pci_device; 
     453                    hardware->pxe.pci_device_pos = pci_number; 
     454                    return 0; 
     455                } 
     456            } 
     457 
    328458        } 
    329 } 
    330  
    331 int detect_pxe(struct s_hardware *hardware) 
    332 { 
    333   void *dhcpdata; 
    334  
    335   size_t dhcplen; 
    336   t_PXENV_UNDI_GET_NIC_TYPE gnt; 
    337  
    338   if (hardware->pxe_detection == true) 
    339     return -1; 
    340   hardware->pxe_detection = true; 
    341   hardware->is_pxe_valid = false; 
    342   memset(&gnt, 0, sizeof(t_PXENV_UNDI_GET_NIC_TYPE)); 
    343   memset(&hardware->pxe, 0, sizeof(struct s_pxe)); 
    344  
    345   /* This code can only work if pxelinux is loaded */ 
    346   if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) { 
    347     return -1; 
    348   } 
    349 // printf("PXE: PXElinux detected\n"); 
    350   if (!pxe_get_cached_info 
    351       (PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) { 
    352     pxe_bootp_t *dhcp = &hardware->pxe.dhcpdata; 
    353     memcpy(&hardware->pxe.dhcpdata, dhcpdata, 
    354            sizeof(hardware->pxe.dhcpdata)); 
    355     snprintf(hardware->pxe.mac_addr, sizeof(hardware->pxe.mac_addr), 
    356        "%02x:%02x:%02x:%02x:%02x:%02x", dhcp->CAddr[0], 
    357        dhcp->CAddr[1], dhcp->CAddr[2], dhcp->CAddr[3], 
    358        dhcp->CAddr[4], dhcp->CAddr[5]); 
    359  
    360     /* Saving our IP address in a easy format */ 
    361     hardware->pxe.ip_addr[0] = hardware->pxe.dhcpdata.yip & 0xff; 
    362     hardware->pxe.ip_addr[1] = 
    363         hardware->pxe.dhcpdata.yip >> 8 & 0xff; 
    364     hardware->pxe.ip_addr[2] = 
    365         hardware->pxe.dhcpdata.yip >> 16 & 0xff; 
    366     hardware->pxe.ip_addr[3] = 
    367         hardware->pxe.dhcpdata.yip >> 24 & 0xff; 
    368  
    369     if (!pxe_get_nic_type(&gnt)) { 
    370       switch (gnt.NicType) { 
    371       case PCI_NIC: 
    372         hardware->is_pxe_valid = true; 
    373         hardware->pxe.vendor_id = 
    374             gnt.info.pci.Vendor_ID; 
    375         hardware->pxe.product_id = gnt.info.pci.Dev_ID; 
    376         hardware->pxe.subvendor_id = 
    377             gnt.info.pci.SubVendor_ID; 
    378         hardware->pxe.subproduct_id = 
    379             gnt.info.pci.SubDevice_ID, 
    380             hardware->pxe.rev = gnt.info.pci.Rev; 
    381         hardware->pxe.pci_bus = 
    382             (gnt.info.pci.BusDevFunc >> 8) & 0xff; 
    383         hardware->pxe.pci_dev = 
    384             (gnt.info.pci.BusDevFunc >> 3) & 0x7; 
    385         hardware->pxe.pci_func = 
    386             gnt.info.pci.BusDevFunc & 0x03; 
    387         hardware->pxe.base_class = 
    388             gnt.info.pci.Base_Class; 
    389         hardware->pxe.sub_class = 
    390             gnt.info.pci.Sub_Class; 
    391         hardware->pxe.prog_intf = 
    392             gnt.info.pci.Prog_Intf; 
    393         hardware->pxe.nictype = gnt.NicType; 
    394         break; 
    395       case CardBus_NIC: 
    396         hardware->is_pxe_valid = true; 
    397         hardware->pxe.vendor_id = 
    398             gnt.info.cardbus.Vendor_ID; 
    399         hardware->pxe.product_id = 
    400             gnt.info.cardbus.Dev_ID; 
    401         hardware->pxe.subvendor_id = 
    402             gnt.info.cardbus.SubVendor_ID; 
    403         hardware->pxe.subproduct_id = 
    404             gnt.info.cardbus.SubDevice_ID, 
    405             hardware->pxe.rev = gnt.info.cardbus.Rev; 
    406         hardware->pxe.pci_bus = 
    407             (gnt.info.cardbus.BusDevFunc >> 8) & 0xff; 
    408         hardware->pxe.pci_dev = 
    409             (gnt.info.cardbus.BusDevFunc >> 3) & 0x7; 
    410         hardware->pxe.pci_func = 
    411             gnt.info.cardbus.BusDevFunc & 0x03; 
    412         hardware->pxe.base_class = 
    413             gnt.info.cardbus.Base_Class; 
    414         hardware->pxe.sub_class = 
    415             gnt.info.cardbus.Sub_Class; 
    416         hardware->pxe.prog_intf = 
    417             gnt.info.cardbus.Prog_Intf; 
    418         hardware->pxe.nictype = gnt.NicType; 
    419         break; 
    420       case PnP_NIC: 
    421       default: 
    422         return -1; 
    423         break; 
    424       } 
    425       /* Let's try to find the associated pci device */ 
    426       detect_pci(hardware); 
    427  
    428       /* The firt pass try to find the exact pci device */ 
    429       hardware->pxe.pci_device = NULL; 
    430       hardware->pxe.pci_device_pos = 0; 
    431       struct pci_device *pci_device; 
    432       int pci_number = 0; 
    433       for_each_pci_func(pci_device, hardware->pci_domain) { 
    434         pci_number++; 
    435         if ((__pci_bus == hardware->pxe.pci_bus) && 
    436             (__pci_slot == hardware->pxe.pci_dev) && 
    437             (__pci_func == hardware->pxe.pci_func) && 
    438             (pci_device->vendor == 
    439              hardware->pxe.vendor_id) 
    440             && (pci_device->product == 
    441           hardware->pxe.product_id)) { 
    442           hardware->pxe.pci_device = pci_device; 
    443           hardware->pxe.pci_device_pos = 
    444               pci_number; 
    445               return 0; 
    446         } 
    447       } 
    448  
    449       /* If we reach that part, it means the pci device pointed by 
    450        * the pxe rom wasn't found in our list. 
    451        * Let's try to find the device only by its pci ids. 
    452        * The pci device we'll match is maybe not exactly the good one 
    453        * as we can have the same pci id several times. 
    454        * At least, the pci id, the vendor/product will be right. 
    455        * That's clearly a workaround for some weird cases. 
    456        * This should happend very unlikely */ 
    457       hardware->pxe.pci_device = NULL; 
    458       hardware->pxe.pci_device_pos = 0; 
    459       pci_number = 0; 
    460       for_each_pci_func(pci_device, hardware->pci_domain) { 
    461         pci_number++; 
    462         if ((pci_device->vendor == 
    463              hardware->pxe.vendor_id) 
    464             && (pci_device->product == 
    465           hardware->pxe.product_id)) { 
    466           hardware->pxe.pci_device = pci_device; 
    467           hardware->pxe.pci_device_pos = 
    468               pci_number; 
    469               return 0; 
    470         } 
    471       } 
    472  
    473     } 
    474   } 
    475   return 0; 
     459    } 
     460    return 0; 
    476461} 
    477462 
    478463void detect_pci(struct s_hardware *hardware) 
    479464{ 
    480   if (hardware->pci_detection == true) 
    481     return; 
    482   hardware->pci_detection = true; 
    483  
    484   hardware->nb_pci_devices = 0; 
    485  
    486   /* Scanning to detect pci buses and devices */ 
    487   hardware->pci_domain = pci_scan(); 
    488  
    489   if (!hardware->pci_domain) 
    490     return; 
    491  
    492   /* Gathering addtional information*/ 
    493   gather_additional_pci_config(hardware->pci_domain); 
    494  
    495   struct pci_device *pci_device; 
    496   for_each_pci_func(pci_device, hardware->pci_domain) { 
    497     hardware->nb_pci_devices++; 
    498   } 
    499  
    500   if (!quiet) { 
    501       more_printf("PCI: %d devices detected\n", hardware->nb_pci_devices); 
    502       more_printf("PCI: Resolving names\n"); 
    503   } 
    504   /* Assigning product & vendor name for each device */ 
    505   hardware->pci_ids_return_code = 
    506       get_name_from_pci_ids(hardware->pci_domain, hardware->pciids_path); 
    507  
    508   if (!quiet) 
    509       more_printf("PCI: Resolving class names\n"); 
    510   /* Assigning class name for each device */ 
    511   hardware->pci_ids_return_code = 
    512       get_class_name_from_pci_ids(hardware->pci_domain, 
    513           hardware->pciids_path); 
    514  
    515   if (!quiet) 
    516       more_printf("PCI: Resolving module names\n"); 
    517   /* Detecting which kernel module should match each device using modules.pcimap*/ 
    518   hardware->modules_pcimap_return_code = 
    519       get_module_name_from_pcimap(hardware->pci_domain, 
    520            hardware->modules_pcimap_path); 
    521  
    522   /* Detecting which kernel module should match each device using modules.alias*/ 
    523   hardware->modules_alias_return_code = 
    524       get_module_name_from_alias(hardware->pci_domain, 
    525            hardware->modules_alias_path); 
    526  
    527  
    528   /* We try to detect the pxe stuff to populate the PXE: field of pci devices */ 
    529   detect_pxe(hardware); 
     465    if (hardware->pci_detection == true) 
     466        return; 
     467    hardware->pci_detection = true; 
     468 
     469    hardware->nb_pci_devices = 0; 
     470 
     471    /* Scanning to detect pci buses and devices */ 
     472    hardware->pci_domain = pci_scan(); 
     473 
     474    if (!hardware->pci_domain) 
     475        return; 
     476 
     477    /* Gathering addtional information */ 
     478    gather_additional_pci_config(hardware->pci_domain); 
     479 
     480    struct pci_device *pci_device; 
     481    for_each_pci_func(pci_device, hardware->pci_domain) { 
     482        hardware->nb_pci_devices++; 
     483    } 
     484 
     485    if (!quiet) { 
     486        more_printf("PCI: %d devices detected\n", hardware->nb_pci_devices); 
     487        more_printf("PCI: Resolving names\n"); 
     488    } 
     489    /* Assigning product & vendor name for each device */ 
     490    hardware->pci_ids_return_code = 
     491        get_name_from_pci_ids(hardware->pci_domain, hardware->pciids_path); 
     492 
     493    if (!quiet) 
     494        more_printf("PCI: Resolving class names\n"); 
     495    /* Assigning class name for each device */ 
     496    hardware->pci_ids_return_code = 
     497        get_class_name_from_pci_ids(hardware->pci_domain, 
     498                                    hardware->pciids_path); 
     499 
     500    if (!quiet) 
     501        more_printf("PCI: Resolving module names\n"); 
     502    /* Detecting which kernel module should match each device using modules.pcimap */ 
     503    hardware->modules_pcimap_return_code = 
     504        get_module_name_from_pcimap(hardware->pci_domain, 
     505                                    hardware->modules_pcimap_path); 
     506 
     507    /* Detecting which kernel module should match each device using modules.alias */ 
     508    hardware->modules_alias_return_code = 
     509        get_module_name_from_alias(hardware->pci_domain, 
     510                                   hardware->modules_alias_path); 
     511 
     512    /* We try to detect the pxe stuff to populate the PXE: field of pci devices */ 
     513    detect_pxe(hardware); 
    530514} 
    531515 
    532516void cpu_detect(struct s_hardware *hardware) 
    533517{ 
    534   if (hardware->cpu_detection == true) 
    535     return; 
    536   detect_cpu(&hardware->cpu); 
    537   /* Old processors doesn't manage the identify commands  
    538    * Let's use the dmi value in that case */ 
    539   if (strlen(remove_spaces(hardware->cpu.model))==0) 
    540           strncpy(hardware->cpu.model,hardware->dmi.processor.version,sizeof(hardware->cpu.model)); 
    541   hardware->cpu_detection = true; 
     518    if (hardware->cpu_detection == true) 
     519        return; 
     520    detect_cpu(&hardware->cpu); 
     521    /* Old processors doesn't manage the identify commands  
     522     * Let's use the dmi value in that case */ 
     523    if (strlen(remove_spaces(hardware->cpu.model)) == 0) 
     524        strncpy(hardware->cpu.model, hardware->dmi.processor.version, 
     525                sizeof(hardware->cpu.model)); 
     526    hardware->cpu_detection = true; 
    542527} 
    543528 
     
    548533const char *find_argument(const char **argv, const char *argument) 
    549534{ 
    550   int la = strlen(argument); 
    551   const char **arg; 
    552   const char *ptr = NULL; 
    553  
    554   for (arg = argv; *arg; arg++) { 
    555     if (!memcmp(*arg, argument, la)) 
    556       ptr = *arg + la; 
    557   } 
    558  
    559   return ptr; 
     535    int la = strlen(argument); 
     536    const char **arg; 
     537    const char *ptr = NULL; 
     538 
     539    for (arg = argv; *arg; arg++) { 
     540        if (!memcmp(*arg, argument, la)) 
     541            ptr = *arg + la; 
     542    } 
     543 
     544    return ptr; 
    560545} 
    561546 
    562547void clear_screen(void) 
    563548{ 
    564   move_cursor_to_next_line(); 
    565   disable_utf8(); 
    566   set_g1_special_char(); 
    567   set_us_g0_charset(); 
    568   display_cursor(false); 
    569   clear_entire_screen(); 
    570   reset_more_printf(); 
     549    move_cursor_to_next_line(); 
     550    disable_utf8(); 
     551    set_g1_special_char(); 
     552    set_us_g0_charset(); 
     553    display_cursor(false); 
     554    clear_entire_screen(); 
     555    reset_more_printf(); 
    571556} 
    572557 
     
    574559char *skip_spaces(char *p) 
    575560{ 
    576   while (*p && *p <= ' ') { 
    577     p++; 
    578   } 
    579  
    580   return p; 
     561    while (*p && *p <= ' ') { 
     562        p++; 
     563    } 
     564 
     565    return p; 
    581566} 
    582567 
     
    584569char *remove_spaces(char *p) 
    585570{ 
    586   char *save=p; 
    587   p+=strlen(p)-1; 
    588   while (*p && *p <= ' ') { 
    589    *p='\0'; 
    590    p--; 
    591   } 
    592   p=save; 
    593   while (*p && *p <= ' ') { 
    594     p++; 
    595   } 
    596  
    597   return p; 
     571    char *save = p; 
     572    p += strlen(p) - 1; 
     573    while (*p && *p <= ' ') { 
     574        *p = '\0'; 
     575        p--; 
     576    } 
     577    p = save; 
     578    while (*p && *p <= ' ') { 
     579        p++; 
     580    } 
     581 
     582    return p; 
    598583} 
    599584 
     
    601586char *remove_trailing_lf(char *p) 
    602587{ 
    603   char *save=p; 
    604   p+=strlen(p)-1; 
    605   while (*p && *p == 10) { 
    606    *p='\0'; 
    607    p--; 
    608   } 
    609   p=save; 
    610  
    611   return p; 
     588    char *save = p; 
     589    p += strlen(p) - 1; 
     590    while (*p && *p == 10) { 
     591        *p = '\0'; 
     592        p--; 
     593    } 
     594    p = save; 
     595 
     596    return p; 
    612597} 
    613598 
    614599/* delete multiple spaces, one is enough */ 
    615 char *del_multi_spaces(char *p) { 
    616  /* Saving the original pointer*/ 
    617  char *save=p; 
    618  
    619  /* Let's parse the complete string 
    620   * As we search for a double spacing 
    621   * we have to be sure then string is 
    622   * long enough to be processed */ 
    623  while (*p && *p+1) { 
    624  
    625    /* If we have two consecutive spaces*/ 
    626    if ((*p == ' ') && (*(p+1) == ' ')) { 
    627  
    628     /* Let's copy to the current position 
    629      * the content from the second space*/ 
    630     strncpy(p,p+1,strlen(p+1)); 
    631  
    632     /* The string is 1 char smaller*/ 
    633     *(p+strlen(p)-1)='\0'; 
    634  
    635     /* Don't increment the pointer as we 
    636      * changed the content of the current position*/ 
    637     continue; 
    638    } 
    639  
    640    /* Nothing as been found, let's see on the next char*/ 
    641    p++; 
    642  } 
    643  /* Returning the original pointer*/ 
    644  return save; 
     600char *del_multi_spaces(char *p) 
     601{ 
     602    /* Saving the original pointer */ 
     603    char *save = p; 
     604 
     605    /* Let's parse the complete string 
     606     * As we search for a double spacing 
     607     * we have to be sure then string is 
     608     * long enough to be processed */ 
     609    while (*p && *p + 1) { 
     610 
     611        /* If we have two consecutive spaces */ 
     612        if ((*p == ' ') && (*(p + 1) == ' ')) { 
     613 
     614            /* Let's copy to the current position 
     615             * the content from the second space*/ 
     616            strncpy(p, p + 1, strlen(p + 1)); 
     617 
     618            /* The string is 1 char smaller */ 
     619            *(p + strlen(p) - 1) = '\0'; 
     620 
     621            /* Don't increment the pointer as we 
     622             * changed the content of the current position*/ 
     623            continue; 
     624        } 
     625 
     626        /* Nothing as been found, let's see on the next char */ 
     627        p++; 
     628    } 
     629    /* Returning the original pointer */ 
     630    return save; 
    645631} 
    646632 
    647633/* Reset the more_printf counter */ 
    648 void reset_more_printf() { 
    649   display_line_nb=0; 
     634void reset_more_printf() 
     635{ 
     636    display_line_nb = 0; 
    650637} 
    651638 
     
    653640{ 
    654641    if (!what) 
    655         return vesacon_default_background(); 
     642        return vesacon_default_background(); 
    656643    else 
    657         return vesacon_load_background(what); 
    658 } 
    659  
    660 void init_console(struct s_hardware *hardware) { 
    661   if (vesamode) { 
     644        return vesacon_load_background(what); 
     645} 
     646 
     647void init_console(struct s_hardware *hardware) 
     648{ 
     649    if (vesamode) { 
    662650        openconsole(&dev_rawcon_r, &dev_vesaserial_w); 
    663651        draw_background(hardware->vesa_background); 
    664   } 
    665   else console_ansi_raw(); 
    666 } 
     652    } else 
     653        console_ansi_raw(); 
     654} 
  • com32/hdt/hdt-common.h

    rbb88c6 r990205  
    112112static inline void printregs(const com32sys_t * r) 
    113113{ 
    114   printf("eflags = %08x  ds = %04x  es = %04x  fs = %04x  gs = %04x\n" 
    115          "eax = %08x  ebx = %08x  ecx = %08x  edx = %08x\n" 
    116          "ebp = %08x  esi = %08x  edi = %08x  esp = %08x\n", 
    117          r->eflags.l, r->ds, r->es, r->fs, r->gs, 
    118          r->eax.l, r->ebx.l, r->ecx.l, r->edx.l, 
    119          r->ebp.l, r->esi.l, r->edi.l, r->_unused_esp.l); 
     114    printf("eflags = %08x  ds = %04x  es = %04x  fs = %04x  gs = %04x\n" 
     115           "eax = %08x  ebx = %08x  ecx = %08x  edx = %08x\n" 
     116           "ebp = %08x  esi = %08x  edi = %08x  esp = %08x\n", 
     117           r->eflags.l, r->ds, r->es, r->fs, r->gs, 
     118           r->eax.l, r->ebx.l, r->ecx.l, r->edx.l, 
     119           r->ebp.l, r->esi.l, r->edi.l, r->_unused_esp.l); 
    120120} 
    121121 
    122122struct s_pxe { 
    123   uint16_t vendor_id; 
    124   uint16_t product_id; 
    125   uint16_t subvendor_id; 
    126   uint16_t subproduct_id; 
    127   uint8_t rev; 
    128   uint8_t pci_bus; 
    129   uint8_t pci_dev; 
    130   uint8_t pci_func; 
    131   uint8_t base_class; 
    132   uint8_t sub_class; 
    133   uint8_t prog_intf; 
    134   uint8_t nictype; 
    135   char mac_addr[18];              /* The current mac address */ 
    136   uint8_t ip_addr[4]; 
    137   pxe_bootp_t dhcpdata;           /* The dhcp answer */ 
    138   struct pci_device *pci_device;  /* The matching pci device */ 
    139   uint8_t pci_device_pos;         /* It position in our pci sorted list */ 
     123    uint16_t vendor_id; 
     124    uint16_t product_id; 
     125    uint16_t subvendor_id; 
     126    uint16_t subproduct_id; 
     127    uint8_t rev; 
     128    uint8_t pci_bus; 
     129    uint8_t pci_dev; 
     130    uint8_t pci_func; 
     131    uint8_t base_class; 
     132    uint8_t sub_class; 
     133    uint8_t prog_intf; 
     134    uint8_t nictype; 
     135    char mac_addr[18];          /* The current mac address */ 
     136    uint8_t ip_addr[4]; 
     137    pxe_bootp_t dhcpdata;       /* The dhcp answer */ 
     138    struct pci_device *pci_device;      /* The matching pci device */ 
     139    uint8_t pci_device_pos;     /* It position in our pci sorted list */ 
    140140}; 
    141141 
    142142struct s_vesa_mode_info { 
    143  struct vesa_mode_info mi; 
    144  uint16_t mode; 
     143    struct vesa_mode_info mi; 
     144    uint16_t mode; 
    145145}; 
    146146 
    147147struct s_vesa { 
    148  uint8_t major_version; 
    149  uint8_t minor_version; 
    150  struct s_vesa_mode_info vmi[MAX_VESA_MODES]; 
    151  uint8_t vmi_count; 
    152  uint16_t total_memory; 
    153  char vendor[256]; 
    154  char product[256]; 
    155  char product_revision[256]; 
    156  uint16_t software_rev; 
     148    uint8_t major_version; 
     149    uint8_t minor_version; 
     150    struct s_vesa_mode_info vmi[MAX_VESA_MODES]; 
     151    uint8_t vmi_count; 
     152    uint16_t total_memory; 
     153    char vendor[256]; 
     154    char product[256]; 
     155    char product_revision[256]; 
     156    uint16_t software_rev; 
    157157}; 
    158158 
    159159struct s_hardware { 
    160   s_dmi dmi;                      /* DMI table */ 
    161   s_cpu cpu;                      /* CPU information */ 
    162   s_vpd vpd;                      /* VPD information */ 
    163   struct pci_domain *pci_domain;  /* PCI Devices */ 
    164   struct driveinfo disk_info[256]; /* Disk Information */ 
    165   uint32_t mbr_ids[256];          /* MBR ids */ 
    166   int disks_count;                /* Number of detected disks */ 
    167   struct s_pxe pxe; 
    168   struct s_vesa vesa; 
    169   unsigned long detected_memory_size; /* The detected memory size (in KB) */ 
    170  
    171   int pci_ids_return_code; 
    172   int modules_pcimap_return_code; 
    173   int modules_alias_return_code; 
    174   int nb_pci_devices; 
    175   bool is_dmi_valid; 
    176   bool is_pxe_valid; 
    177   bool is_vesa_valid; 
    178   bool is_vpd_valid; 
    179  
    180   bool dmi_detection; /* Does the dmi stuff has already been detected? */ 
    181   bool pci_detection; /* Does the pci stuff has already been detected? */ 
    182   bool cpu_detection; /* Does the cpu stuff has already been detected? */ 
    183   bool disk_detection;/* Does the disk stuff has already been detected? */ 
    184   bool pxe_detection; /* Does the pxe stuff has already been detected? */ 
    185   bool vesa_detection;/* Does the vesa sutff have been already detected? */ 
    186   bool vpd_detection; /* Does the vpd stuff has already been detected? */ 
    187  
    188   char syslinux_fs[22]; 
    189   const struct syslinux_version *sv; 
    190   char modules_pcimap_path[255]; 
    191   char modules_alias_path[255]; 
    192   char pciids_path[255]; 
    193   char memtest_label[255]; 
    194   char reboot_label[255]; 
    195   char auto_label[AUTO_COMMAND_SIZE]; 
    196   char vesa_background[255]; 
     160    s_dmi dmi;                  /* DMI table */ 
     161    s_cpu cpu;                  /* CPU information */ 
     162    s_vpd vpd;                  /* VPD information */ 
     163    struct pci_domain *pci_domain;      /* PCI Devices */ 
     164    struct driveinfo disk_info[256];    /* Disk Information */ 
     165    uint32_t mbr_ids[256];      /* MBR ids */ 
     166    int disks_count;            /* Number of detected disks */ 
     167    struct s_pxe pxe; 
     168    struct s_vesa vesa; 
     169    unsigned long detected_memory_size; /* The detected memory size (in KB) */ 
     170 
     171    int pci_ids_return_code; 
     172    int modules_pcimap_return_code; 
     173    int modules_alias_return_code; 
     174    int nb_pci_devices; 
     175    bool is_dmi_valid; 
     176    bool is_pxe_valid; 
     177    bool is_vesa_valid; 
     178    bool is_vpd_valid; 
     179 
     180    bool dmi_detection;         /* Does the dmi stuff has already been detected? */ 
     181    bool pci_detection;         /* Does the pci stuff has already been detected? */ 
     182    bool cpu_detection;         /* Does the cpu stuff has already been detected? */ 
     183    bool disk_detection;        /* Does the disk stuff has already been detected? */ 
     184    bool pxe_detection;         /* Does the pxe stuff has already been detected? */ 
     185    bool vesa_detection;        /* Does the vesa sutff have been already detected? */ 
     186    bool vpd_detection;         /* Does the vpd stuff has already been detected? */ 
     187 
     188    char syslinux_fs[22]; 
     189    const struct syslinux_version *sv; 
     190    char modules_pcimap_path[255]; 
     191    char modules_alias_path[255]; 
     192    char pciids_path[255]; 
     193    char memtest_label[255]; 
     194    char reboot_label[255]; 
     195    char auto_label[AUTO_COMMAND_SIZE]; 
     196    char vesa_background[255]; 
    197197}; 
    198198 
     
    213213void detect_syslinux(struct s_hardware *hardware); 
    214214void detect_parameters(const int argc, const char *argv[], 
    215                        struct s_hardware *hardware); 
     215                       struct s_hardware *hardware); 
    216216int detect_vesa(struct s_hardware *hardware); 
    217217void init_console(struct s_hardware *hardware); 
  • com32/hdt/hdt-menu-about.c

    r291f05 r990205  
    3232void compute_aboutmenu(struct s_my_menu *menu) 
    3333{ 
    34   char buffer[SUBMENULEN + 1]; 
    35   char statbuffer[STATLEN + 1]; 
     34    char buffer[SUBMENULEN + 1]; 
     35    char statbuffer[STATLEN + 1]; 
    3636 
    37   menu->menu = add_menu(" About ", -1); 
    38   menu->items_count = 0; 
     37    menu->menu = add_menu(" About ", -1); 
     38    menu->items_count = 0; 
    3939 
    40   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     40    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    4141 
    42   snprintf(buffer, sizeof buffer, "Product        : %s", PRODUCT_NAME); 
    43   snprintf(statbuffer, sizeof statbuffer, "Product : %s", PRODUCT_NAME); 
    44   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    45   menu->items_count++; 
     42    snprintf(buffer, sizeof buffer, "Product        : %s", PRODUCT_NAME); 
     43    snprintf(statbuffer, sizeof statbuffer, "Product : %s", PRODUCT_NAME); 
     44    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     45    menu->items_count++; 
    4646 
    47   snprintf(buffer, sizeof buffer, "Version        : %s (%s)", VERSION, CODENAME); 
    48   snprintf(statbuffer, sizeof statbuffer, "Version : %s (%s)", VERSION,CODENAME); 
    49   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    50   menu->items_count++; 
     47    snprintf(buffer, sizeof buffer, "Version        : %s (%s)", VERSION, 
     48             CODENAME); 
     49    snprintf(statbuffer, sizeof statbuffer, "Version : %s (%s)", VERSION, 
     50             CODENAME); 
     51    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     52    menu->items_count++; 
    5153 
    52   snprintf(buffer, sizeof buffer, "Project Leader : %s", AUTHOR); 
    53   snprintf(statbuffer, sizeof statbuffer, "Project Leader  : %s", AUTHOR); 
    54   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    55   menu->items_count++; 
     54    snprintf(buffer, sizeof buffer, "Project Leader : %s", AUTHOR); 
     55    snprintf(statbuffer, sizeof statbuffer, "Project Leader  : %s", AUTHOR); 
     56    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     57    menu->items_count++; 
    5658 
    57   snprintf(buffer, sizeof buffer, "Contact        : %s", CONTACT); 
    58   snprintf(statbuffer, sizeof statbuffer, "Contact : %s", CONTACT); 
    59   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    60   menu->items_count++; 
     59    snprintf(buffer, sizeof buffer, "Contact        : %s", CONTACT); 
     60    snprintf(statbuffer, sizeof statbuffer, "Contact : %s", CONTACT); 
     61    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     62    menu->items_count++; 
    6163 
    62   snprintf(buffer, sizeof buffer, "Core Developer : %s", CORE_DEVELOPER); 
    63   snprintf(statbuffer, sizeof statbuffer, "Core Developer  : %s", CORE_DEVELOPER); 
    64   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    65   menu->items_count++; 
     64    snprintf(buffer, sizeof buffer, "Core Developer : %s", CORE_DEVELOPER); 
     65    snprintf(statbuffer, sizeof statbuffer, "Core Developer  : %s", 
     66             CORE_DEVELOPER); 
     67    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     68    menu->items_count++; 
    6669 
    67   char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS; 
    68   for (int c=0; c<NB_CONTRIBUTORS; c++) { 
    69    snprintf(buffer, sizeof buffer, "Contributor    : %s", contributors[c]); 
    70    snprintf(statbuffer, sizeof statbuffer, "Contributor : %s", contributors[c]); 
    71    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    72    menu->items_count++; 
    73   } 
     70    char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS; 
     71    for (int c = 0; c < NB_CONTRIBUTORS; c++) { 
     72        snprintf(buffer, sizeof buffer, "Contributor    : %s", contributors[c]); 
     73        snprintf(statbuffer, sizeof statbuffer, "Contributor : %s", 
     74                 contributors[c]); 
     75        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     76        menu->items_count++; 
     77    } 
    7478 
    75   printf("MENU: About menu done (%d items)\n", menu->items_count); 
     79    printf("MENU: About menu done (%d items)\n", menu->items_count); 
    7680} 
  • com32/hdt/hdt-menu-disk.c

    re9069c r990205  
    3535 
    3636static void show_partition_information(struct driveinfo *drive_info, 
    37                                        struct part_entry *ptab __unused, 
    38                                        int partition_offset __unused, 
    39                                        int nb_partitions_seen) 
    40 { 
    41         char menu_title[MENULEN + 1]; 
    42         char menu_title_ref[MENULEN + 1]; 
    43  
    44         if (nb_partitions_seen == 1) 
    45                 add_sep(); 
    46  
    47         memset(menu_title,0,sizeof menu_title); 
    48         memset(menu_title_ref,0,sizeof menu_title_ref); 
    49         snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d", 
    50                         drive_info[dn].disk, nb_partitions_seen); 
    51         snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen); 
    52  
    53         add_item(menu_title, "Partition information (start, end, length, type, ...)", 
    54                         OPT_SUBMENU, menu_title_ref, 0); 
    55 } 
     37                                       struct part_entry *ptab __unused, 
     38                                       int partition_offset __unused, 
     39                                       int nb_partitions_seen) 
     40{ 
     41    char menu_title[MENULEN + 1]; 
     42    char menu_title_ref[MENULEN + 1]; 
     43 
     44    if (nb_partitions_seen == 1) 
     45        add_sep(); 
     46 
     47    memset(menu_title, 0, sizeof menu_title); 
     48    memset(menu_title_ref, 0, sizeof menu_title_ref); 
     49    snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d", 
     50             drive_info[dn].disk, nb_partitions_seen); 
     51    snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen); 
     52 
     53    add_item(menu_title, 
     54             "Partition information (start, end, length, type, ...)", 
     55             OPT_SUBMENU, menu_title_ref, 0); 
     56} 
     57 
    5658/** 
    5759 * compute_partition_information - print information about a partition 
     
    7072 **/ 
    7173static void compute_partition_information(struct driveinfo *drive_info, 
    72                                           struct part_entry *ptab, 
    73                                           int partition_offset, 
    74                                           int nb_partitions_seen) 
    75 { 
    76         char size[9]; 
    77         char bootloader_name[9]; 
    78         char *parttype; 
    79         unsigned int start, end; 
    80         char buffer[SUBMENULEN+1]; 
    81         char statbuffer[STATLEN+1]; 
    82         char menu_title[MENULEN + 1]; 
    83         char menu_title_ref[MENULEN + 1]; 
    84  
    85         memset(buffer,0,sizeof buffer); 
    86         memset(statbuffer,0,sizeof statbuffer); 
    87         memset(menu_title,0,sizeof menu_title); 
    88         memset(menu_title_ref,0,sizeof menu_title_ref); 
    89         snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d", drive_info[dn].disk, nb_partitions_seen); 
    90         snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen); 
    91  
    92         add_named_menu(menu_title_ref,menu_title,-1); 
    93         set_menu_pos(SUBMENU_Y,SUBMENU_X); 
    94  
    95         start = partition_offset; 
    96         end = start + ptab->length - 1; 
    97  
    98         if (ptab->length > 0) 
    99                 sectors_to_size(ptab->length, size); 
    100         else 
    101                 memset(size, 0, sizeof size); 
    102  
    103         get_label(ptab->ostype, &parttype); 
    104  
    105         snprintf(buffer, sizeof buffer, "Size        : %s", 
    106                  remove_spaces(size)); 
    107         snprintf(statbuffer, sizeof statbuffer, "Size : %s", 
    108                  remove_spaces(size)); 
     74                                          struct part_entry *ptab, 
     75                                          int partition_offset, 
     76                                          int nb_partitions_seen) 
     77{ 
     78    char size[9]; 
     79    char bootloader_name[9]; 
     80    char *parttype; 
     81    unsigned int start, end; 
     82    char buffer[SUBMENULEN + 1]; 
     83    char statbuffer[STATLEN + 1]; 
     84    char menu_title[MENULEN + 1]; 
     85    char menu_title_ref[MENULEN + 1]; 
     86 
     87    memset(buffer, 0, sizeof buffer); 
     88    memset(statbuffer, 0, sizeof statbuffer); 
     89    memset(menu_title, 0, sizeof menu_title); 
     90    memset(menu_title_ref, 0, sizeof menu_title_ref); 
     91    snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d", 
     92             drive_info[dn].disk, nb_partitions_seen); 
     93    snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen); 
     94 
     95    add_named_menu(menu_title_ref, menu_title, -1); 
     96    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     97 
     98    start = partition_offset; 
     99    end = start + ptab->length - 1; 
     100 
     101    if (ptab->length > 0) 
     102        sectors_to_size(ptab->length, size); 
     103    else 
     104        memset(size, 0, sizeof size); 
     105 
     106    get_label(ptab->ostype, &parttype); 
     107 
     108    snprintf(buffer, sizeof buffer, "Size        : %s", remove_spaces(size)); 
     109    snprintf(statbuffer, sizeof statbuffer, "Size : %s", remove_spaces(size)); 
     110    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     111 
     112    snprintf(buffer, sizeof buffer, "Type        : %s", parttype); 
     113    snprintf(statbuffer, sizeof statbuffer, "Type: %s", parttype); 
     114    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     115 
     116    if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0) { 
     117        snprintf(buffer, sizeof buffer, "Bootloader  : %s", bootloader_name); 
     118        snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s", 
     119                 bootloader_name); 
    109120        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    110  
    111         snprintf(buffer, sizeof buffer, "Type        : %s", 
    112                  parttype); 
    113         snprintf(statbuffer, sizeof statbuffer, "Type: %s", 
    114                  parttype); 
     121    } 
     122 
     123    snprintf(buffer, sizeof buffer, "Bootable    : %s", 
     124             (ptab->active_flag == 0x80) ? "Yes" : "No"); 
     125    snprintf(statbuffer, sizeof statbuffer, "Bootable: %s", 
     126             (ptab->active_flag == 0x80) ? "Yes" : "No"); 
     127    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     128 
     129    snprintf(buffer, sizeof buffer, "Start       : %d", start); 
     130    snprintf(statbuffer, sizeof statbuffer, "Start: %d", start); 
     131    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     132 
     133    snprintf(buffer, sizeof buffer, "End         : %d", end); 
     134    snprintf(statbuffer, sizeof statbuffer, "End: %d", end); 
     135    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     136 
     137    snprintf(buffer, sizeof buffer, "Id          : %X", ptab->ostype); 
     138    snprintf(statbuffer, sizeof statbuffer, "Id: %X", ptab->ostype); 
     139    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     140 
     141    free(parttype); 
     142 
     143    /* Extra info */ 
     144    if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab) != -1) { 
     145        snprintf(buffer, sizeof buffer, "%s", "Swsusp sig  : detected"); 
     146        snprintf(statbuffer, sizeof statbuffer, "%s", "Swsusp sig  : detected"); 
    115147        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    116  
    117         if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0) { 
    118                 snprintf(buffer, sizeof buffer, "Bootloader  : %s", 
    119                          bootloader_name); 
    120                 snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s", 
    121                          bootloader_name); 
    122                 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    123         } 
    124  
    125         snprintf(buffer, sizeof buffer, "Bootable    : %s", 
    126                  (ptab->active_flag == 0x80) ? "Yes" : "No"); 
    127         snprintf(statbuffer, sizeof statbuffer, "Bootable: %s", 
    128                  (ptab->active_flag == 0x80) ? "Yes" : "No"); 
    129         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    130  
    131         snprintf(buffer, sizeof buffer, "Start       : %d", 
    132                  start); 
    133         snprintf(statbuffer, sizeof statbuffer, "Start: %d", 
    134                  start); 
    135         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    136  
    137         snprintf(buffer, sizeof buffer, "End         : %d", 
    138                  end); 
    139         snprintf(statbuffer, sizeof statbuffer, "End: %d", 
    140                  end); 
    141         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    142  
    143         snprintf(buffer, sizeof buffer, "Id          : %X", 
    144                  ptab->ostype); 
    145         snprintf(statbuffer, sizeof statbuffer, "Id: %X", 
    146                  ptab->ostype); 
    147         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    148  
    149  
    150         free(parttype); 
    151  
    152         /* Extra info */ 
    153         if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab) != -1) { 
    154                 snprintf(buffer, sizeof buffer, "%s","Swsusp sig  : detected"); 
    155                 snprintf(statbuffer, sizeof statbuffer, "%s","Swsusp sig  : detected"); 
    156                 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    157         } 
     148    } 
    158149} 
    159150 
    160151/* Compute the disk submenu */ 
    161152static int compute_disk_module(struct s_my_menu *menu, int nb_sub_disk_menu, 
    162                                const struct s_hardware *hardware, int disk_number) 
    163 { 
    164   char buffer[MENULEN + 1]; 
    165   char statbuffer[STATLEN + 1]; 
    166         char mbr_name[50]; 
    167         struct driveinfo *d = (struct driveinfo*) hardware->disk_info; 
    168  
    169   snprintf(buffer, sizeof buffer, " Disk <0x%X> (EDD %X)", d[disk_number].disk, 
    170                   d[disk_number].edd_version); 
    171   menu[nb_sub_disk_menu].menu = add_menu(buffer, -1); 
    172   menu[nb_sub_disk_menu].items_count = 0; 
    173  
    174   int previous_size, size; 
    175   char previous_unit[3], unit[3]; // GB 
    176   char size_iec[9]; // GiB 
    177   sectors_to_size_dec(previous_unit, &previous_size, unit, &size, d[disk_number].edd_params.sectors); 
    178   sectors_to_size(d[disk_number].edd_params.sectors, size_iec); 
    179  
    180   snprintf(buffer, sizeof buffer, "Size                 : %s/%d %s (%d %s)", remove_spaces(size_iec), 
    181      size, unit, previous_size, previous_unit); 
    182   snprintf(statbuffer, sizeof statbuffer, "Size: %s/%d %s (%d %s)", remove_spaces(size_iec), size, 
    183      unit, previous_size, previous_unit); 
    184   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    185   menu[nb_sub_disk_menu].items_count++; 
    186  
    187   snprintf(buffer, sizeof buffer, "Host Bus / Interface : %s / %s", 
    188      remove_spaces((char *) d[disk_number].edd_params.host_bus_type), 
    189      d[disk_number].edd_params.interface_type); 
    190   snprintf(statbuffer, sizeof statbuffer, "Host Bus / Interface: %s / %s", 
    191      remove_spaces((char *) d[disk_number].edd_params.host_bus_type), 
    192      d[disk_number].edd_params.interface_type); 
    193   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    194   menu[nb_sub_disk_menu].items_count++; 
    195  
    196   snprintf(buffer, sizeof buffer, "C / H / S            : %d / %d / %d", 
    197      d[disk_number].legacy_max_cylinder + 1, 
    198      d[disk_number].legacy_max_head + 1, 
    199      (int) d[disk_number].edd_params.sectors); 
    200   snprintf(statbuffer, sizeof statbuffer, "Cylinders / Heads / Sectors: %d / %d / %d", 
    201      d[disk_number].legacy_max_cylinder + 1, 
    202      d[disk_number].legacy_max_head + 1, 
    203      (int) d[disk_number].edd_params.sectors); 
    204   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    205   menu[nb_sub_disk_menu].items_count++; 
    206  
    207   snprintf(buffer, sizeof buffer, "Sectors/Track        : %d", 
    208      d[disk_number].legacy_sectors_per_track); 
    209   snprintf(statbuffer, sizeof statbuffer, "Sectors per Track: %d", 
    210      d[disk_number].legacy_sectors_per_track); 
    211   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    212   menu[nb_sub_disk_menu].items_count++; 
    213  
    214         get_mbr_string(hardware->mbr_ids[disk_number], &mbr_name, 50); 
    215  
    216         snprintf(buffer, sizeof buffer, "MBR                  : %s (0x%X)", 
    217                  remove_spaces(mbr_name), 
    218                  hardware->mbr_ids[disk_number]); 
    219         snprintf(statbuffer, sizeof statbuffer, "MBR: %s (id 0x%X)", 
    220                  remove_spaces(mbr_name), 
    221                  hardware->mbr_ids[disk_number]); 
    222         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    223         menu[nb_sub_disk_menu].items_count++; 
    224  
    225   dn=disk_number; 
    226  
    227   parse_partition_table(&d[disk_number], &show_partition_information); 
    228   if (!parse_partition_table(&d[disk_number], &compute_partition_information)) { 
     153                               const struct s_hardware *hardware, 
     154                               int disk_number) 
     155{ 
     156    char buffer[MENULEN + 1]; 
     157    char statbuffer[STATLEN + 1]; 
     158    char mbr_name[50]; 
     159    struct driveinfo *d = (struct driveinfo *)hardware->disk_info; 
     160 
     161    snprintf(buffer, sizeof buffer, " Disk <0x%X> (EDD %X)", 
     162             d[disk_number].disk, d[disk_number].edd_version); 
     163    menu[nb_sub_disk_menu].menu = add_menu(buffer, -1); 
     164    menu[nb_sub_disk_menu].items_count = 0; 
     165 
     166    int previous_size, size; 
     167    char previous_unit[3], unit[3];     // GB 
     168    char size_iec[9];           // GiB 
     169    sectors_to_size_dec(previous_unit, &previous_size, unit, &size, 
     170                        d[disk_number].edd_params.sectors); 
     171    sectors_to_size(d[disk_number].edd_params.sectors, size_iec); 
     172 
     173    snprintf(buffer, sizeof buffer, "Size                 : %s/%d %s (%d %s)", 
     174             remove_spaces(size_iec), size, unit, previous_size, previous_unit); 
     175    snprintf(statbuffer, sizeof statbuffer, "Size: %s/%d %s (%d %s)", 
     176             remove_spaces(size_iec), size, unit, previous_size, previous_unit); 
     177    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     178    menu[nb_sub_disk_menu].items_count++; 
     179 
     180    snprintf(buffer, sizeof buffer, "Host Bus / Interface : %s / %s", 
     181             remove_spaces((char *)d[disk_number].edd_params.host_bus_type), 
     182             d[disk_number].edd_params.interface_type); 
     183    snprintf(statbuffer, sizeof statbuffer, "Host Bus / Interface: %s / %s", 
     184             remove_spaces((char *)d[disk_number].edd_params.host_bus_type), 
     185             d[disk_number].edd_params.interface_type); 
     186    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     187    menu[nb_sub_disk_menu].items_count++; 
     188 
     189    snprintf(buffer, sizeof buffer, "C / H / S            : %d / %d / %d", 
     190             d[disk_number].legacy_max_cylinder + 1, 
     191             d[disk_number].legacy_max_head + 1, 
     192             (int)d[disk_number].edd_params.sectors); 
     193    snprintf(statbuffer, sizeof statbuffer, 
     194             "Cylinders / Heads / Sectors: %d / %d / %d", 
     195             d[disk_number].legacy_max_cylinder + 1, 
     196             d[disk_number].legacy_max_head + 1, 
     197             (int)d[disk_number].edd_params.sectors); 
     198    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     199    menu[nb_sub_disk_menu].items_count++; 
     200 
     201    snprintf(buffer, sizeof buffer, "Sectors/Track        : %d", 
     202             d[disk_number].legacy_sectors_per_track); 
     203    snprintf(statbuffer, sizeof statbuffer, "Sectors per Track: %d", 
     204             d[disk_number].legacy_sectors_per_track); 
     205    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     206    menu[nb_sub_disk_menu].items_count++; 
     207 
     208    get_mbr_string(hardware->mbr_ids[disk_number], &mbr_name, 50); 
     209 
     210    snprintf(buffer, sizeof buffer, "MBR                  : %s (0x%X)", 
     211             remove_spaces(mbr_name), hardware->mbr_ids[disk_number]); 
     212    snprintf(statbuffer, sizeof statbuffer, "MBR: %s (id 0x%X)", 
     213             remove_spaces(mbr_name), hardware->mbr_ids[disk_number]); 
     214    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     215    menu[nb_sub_disk_menu].items_count++; 
     216 
     217    dn = disk_number; 
     218 
     219    parse_partition_table(&d[disk_number], &show_partition_information); 
     220    if (!parse_partition_table(&d[disk_number], &compute_partition_information)) { 
    229221        get_error("parse_partition_table"); 
    230222        menu[nb_sub_disk_menu].items_count++; 
    231   } 
    232  
    233   return 0; 
     223    } 
     224 
     225    return 0; 
    234226} 
    235227 
     
    237229void compute_disks(struct s_hdt_menu *menu, struct s_hardware *hardware) 
    238230{ 
    239   char buffer[MENULEN + 1]; 
    240   int nb_sub_disk_menu = 0; 
    241  
    242   /* No need to compute that menu if no disks were detected */ 
    243   menu->disk_menu.items_count = 0; 
    244   if (hardware->disks_count == 0) return; 
    245  
    246   for (int i = 0; i < hardware->disks_count; i++) { 
    247     if (!hardware->disk_info[i].cbios) 
    248       continue; /* Invalid geometry */ 
    249     compute_disk_module 
    250         ((struct s_my_menu*) &(menu->disk_sub_menu), nb_sub_disk_menu, 
    251          hardware, i); 
    252     nb_sub_disk_menu++; 
    253   } 
    254  
    255   menu->disk_menu.menu = add_menu(" Disks ", -1); 
    256  
    257   for (int i = 0; i < nb_sub_disk_menu; i++) { 
    258     snprintf(buffer, sizeof buffer, " Disk <%d> ", i+1); 
    259     add_item(buffer, "Disk", OPT_SUBMENU, NULL, 
    260        menu->disk_sub_menu[i].menu); 
    261     menu->disk_menu.items_count++; 
    262   } 
    263   printf("MENU: Disks menu done (%d items)\n", 
    264         menu->disk_menu.items_count); 
    265 } 
     231    char buffer[MENULEN + 1]; 
     232    int nb_sub_disk_menu = 0; 
     233 
     234    /* No need to compute that menu if no disks were detected */ 
     235    menu->disk_menu.items_count = 0; 
     236    if (hardware->disks_count == 0) 
     237        return; 
     238 
     239    for (int i = 0; i < hardware->disks_count; i++) { 
     240        if (!hardware->disk_info[i].cbios) 
     241            continue;           /* Invalid geometry */ 
     242        compute_disk_module 
     243            ((struct s_my_menu *)&(menu->disk_sub_menu), nb_sub_disk_menu, 
     244             hardware, i); 
     245        nb_sub_disk_menu++; 
     246    } 
     247 
     248    menu->disk_menu.menu = add_menu(" Disks ", -1); 
     249 
     250    for (int i = 0; i < nb_sub_disk_menu; i++) { 
     251        snprintf(buffer, sizeof buffer, " Disk <%d> ", i + 1); 
     252        add_item(buffer, "Disk", OPT_SUBMENU, NULL, 
     253                 menu->disk_sub_menu[i].menu); 
     254        menu->disk_menu.items_count++; 
     255    } 
     256    printf("MENU: Disks menu done (%d items)\n", menu->disk_menu.items_count); 
     257} 
  • com32/hdt/hdt-menu-dmi.c

    rea541f r990205  
    3232void compute_system(struct s_my_menu *menu, s_dmi * dmi) 
    3333{ 
    34   char buffer[SUBMENULEN + 1]; 
    35   char statbuffer[STATLEN + 1]; 
    36  
    37   menu->menu = add_menu(" System ", -1); 
    38   menu->items_count = 0; 
    39   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    40  
    41   snprintf(buffer, sizeof buffer, "Vendor    : %s", 
    42      dmi->system.manufacturer); 
    43   snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", 
    44      dmi->system.manufacturer); 
    45   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    46   menu->items_count++; 
    47  
    48   snprintf(buffer, sizeof buffer, "Product   : %s", 
    49      dmi->system.product_name); 
    50   snprintf(statbuffer, sizeof statbuffer, "Product Name: %s", 
    51      dmi->system.product_name); 
    52   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    53   menu->items_count++; 
    54  
    55   snprintf(buffer, sizeof buffer, "Version   : %s", dmi->system.version); 
    56   snprintf(statbuffer, sizeof statbuffer, "Version: %s", 
    57      dmi->system.version); 
    58   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    59   menu->items_count++; 
    60  
    61   snprintf(buffer, sizeof buffer, "Serial    : %s", dmi->system.serial); 
    62   snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s", 
    63      dmi->system.serial); 
    64   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    65   menu->items_count++; 
    66  
    67   snprintf(buffer, sizeof buffer, "UUID      : %s", dmi->system.uuid); 
    68   snprintf(statbuffer, sizeof statbuffer, "UUID: %s", dmi->system.uuid); 
    69   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    70   menu->items_count++; 
    71  
    72   snprintf(buffer, sizeof buffer, "Wakeup    : %s", 
    73      dmi->system.wakeup_type); 
    74   snprintf(statbuffer, sizeof statbuffer, "Wakeup Type: %s", 
    75      dmi->system.wakeup_type); 
    76   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    77   menu->items_count++; 
    78  
    79   snprintf(buffer, sizeof buffer, "SKU Number: %s", 
    80      dmi->system.sku_number); 
    81   snprintf(statbuffer, sizeof statbuffer, "SKU Number: %s", 
    82      dmi->system.sku_number); 
    83   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    84   menu->items_count++; 
    85  
    86   snprintf(buffer, sizeof buffer, "Family    : %s", dmi->system.family); 
    87   snprintf(statbuffer, sizeof statbuffer, "Family: %s", 
    88      dmi->system.family); 
    89   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    90   menu->items_count++; 
    91  
    92   printf("MENU: System menu done (%d items)\n", menu->items_count); 
     34    char buffer[SUBMENULEN + 1]; 
     35    char statbuffer[STATLEN + 1]; 
     36 
     37    menu->menu = add_menu(" System ", -1); 
     38    menu->items_count = 0; 
     39    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     40 
     41    snprintf(buffer, sizeof buffer, "Vendor    : %s", dmi->system.manufacturer); 
     42    snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", 
     43             dmi->system.manufacturer); 
     44    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     45    menu->items_count++; 
     46 
     47    snprintf(buffer, sizeof buffer, "Product   : %s", dmi->system.product_name); 
     48    snprintf(statbuffer, sizeof statbuffer, "Product Name: %s", 
     49             dmi->system.product_name); 
     50    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     51    menu->items_count++; 
     52 
     53    snprintf(buffer, sizeof buffer, "Version   : %s", dmi->system.version); 
     54    snprintf(statbuffer, sizeof statbuffer, "Version: %s", dmi->system.version); 
     55    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     56    menu->items_count++; 
     57 
     58    snprintf(buffer, sizeof buffer, "Serial    : %s", dmi->system.serial); 
     59    snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s", 
     60             dmi->system.serial); 
     61    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     62    menu->items_count++; 
     63 
     64    snprintf(buffer, sizeof buffer, "UUID      : %s", dmi->system.uuid); 
     65    snprintf(statbuffer, sizeof statbuffer, "UUID: %s", dmi->system.uuid); 
     66    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     67    menu->items_count++; 
     68 
     69    snprintf(buffer, sizeof buffer, "Wakeup    : %s", dmi->system.wakeup_type); 
     70    snprintf(statbuffer, sizeof statbuffer, "Wakeup Type: %s", 
     71             dmi->system.wakeup_type); 
     72    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     73    menu->items_count++; 
     74 
     75    snprintf(buffer, sizeof buffer, "SKU Number: %s", dmi->system.sku_number); 
     76    snprintf(statbuffer, sizeof statbuffer, "SKU Number: %s", 
     77             dmi->system.sku_number); 
     78    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     79    menu->items_count++; 
     80 
     81    snprintf(buffer, sizeof buffer, "Family    : %s", dmi->system.family); 
     82    snprintf(statbuffer, sizeof statbuffer, "Family: %s", dmi->system.family); 
     83    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     84    menu->items_count++; 
     85 
     86    printf("MENU: System menu done (%d items)\n", menu->items_count); 
    9387} 
    9488 
     
    9690void compute_chassis(struct s_my_menu *menu, s_dmi * dmi) 
    9791{ 
    98   char buffer[SUBMENULEN + 1]; 
    99   char statbuffer[STATLEN + 1]; 
    100   menu->menu = add_menu(" Chassis ", -1); 
    101   menu->items_count = 0; 
    102   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    103  
    104   snprintf(buffer, sizeof buffer, "Vendor    : %s", 
    105      dmi->chassis.manufacturer); 
    106   snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", 
    107      dmi->chassis.manufacturer); 
    108   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    109   menu->items_count++; 
    110  
    111   snprintf(buffer, sizeof buffer, "Type      : %s", dmi->chassis.type); 
    112   snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->chassis.type); 
    113   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    114   menu->items_count++; 
    115  
    116   snprintf(buffer, sizeof buffer, "Version   : %s", dmi->chassis.version); 
    117   snprintf(statbuffer, sizeof statbuffer, "Version: %s", 
    118      dmi->chassis.version); 
    119   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    120   menu->items_count++; 
    121  
    122   snprintf(buffer, sizeof buffer, "Serial    : %s", dmi->chassis.serial); 
    123   snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s", 
    124      dmi->chassis.serial); 
    125   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    126   menu->items_count++; 
    127  
    128   snprintf(buffer, sizeof buffer, "Asset Tag : %s", 
    129      del_multi_spaces(dmi->chassis.asset_tag)); 
    130   snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s", 
    131      del_multi_spaces(dmi->chassis.asset_tag)); 
    132   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    133   menu->items_count++; 
    134  
    135   snprintf(buffer, sizeof buffer, "Lock      : %s", dmi->chassis.lock); 
    136   snprintf(statbuffer, sizeof statbuffer, "Lock: %s", dmi->chassis.lock); 
    137   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    138   menu->items_count++; 
    139  
    140   printf("MENU: Chassis menu done (%d items)\n", menu->items_count); 
     92    char buffer[SUBMENULEN + 1]; 
     93    char statbuffer[STATLEN + 1]; 
     94    menu->menu = add_menu(" Chassis ", -1); 
     95    menu->items_count = 0; 
     96    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     97 
     98    snprintf(buffer, sizeof buffer, "Vendor    : %s", 
     99             dmi->chassis.manufacturer); 
     100    snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", 
     101             dmi->chassis.manufacturer); 
     102    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     103    menu->items_count++; 
     104 
     105    snprintf(buffer, sizeof buffer, "Type      : %s", dmi->chassis.type); 
     106    snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->chassis.type); 
     107    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     108    menu->items_count++; 
     109 
     110    snprintf(buffer, sizeof buffer, "Version   : %s", dmi->chassis.version); 
     111    snprintf(statbuffer, sizeof statbuffer, "Version: %s", 
     112             dmi->chassis.version); 
     113    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     114    menu->items_count++; 
     115 
     116    snprintf(buffer, sizeof buffer, "Serial    : %s", dmi->chassis.serial); 
     117    snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s", 
     118             dmi->chassis.serial); 
     119    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     120    menu->items_count++; 
     121 
     122    snprintf(buffer, sizeof buffer, "Asset Tag : %s", 
     123             del_multi_spaces(dmi->chassis.asset_tag)); 
     124    snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s", 
     125             del_multi_spaces(dmi->chassis.asset_tag)); 
     126    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     127    menu->items_count++; 
     128 
     129    snprintf(buffer, sizeof buffer, "Lock      : %s", dmi->chassis.lock); 
     130    snprintf(statbuffer, sizeof statbuffer, "Lock: %s", dmi->chassis.lock); 
     131    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     132    menu->items_count++; 
     133 
     134    printf("MENU: Chassis menu done (%d items)\n", menu->items_count); 
    141135} 
    142136 
     
    144138void compute_bios(struct s_my_menu *menu, s_dmi * dmi) 
    145139{ 
    146   char buffer[SUBMENULEN + 1]; 
    147   char statbuffer[STATLEN + 1]; 
    148  
    149   menu->menu = add_menu(" BIOS ", -1); 
    150   menu->items_count = 0; 
    151   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    152  
    153   snprintf(buffer, sizeof buffer, "Vendor    : %s", dmi->bios.vendor); 
    154   snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", dmi->bios.vendor); 
    155   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    156   menu->items_count++; 
    157  
    158   snprintf(buffer, sizeof buffer, "Version   : %s", dmi->bios.version); 
    159   snprintf(statbuffer, sizeof statbuffer, "Version: %s", 
    160      dmi->bios.version); 
    161   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    162   menu->items_count++; 
    163  
    164   snprintf(buffer, sizeof buffer, "Release   : %s", 
    165      dmi->bios.release_date); 
    166   snprintf(statbuffer, sizeof statbuffer, "Release Date: %s", 
    167      dmi->bios.release_date); 
    168   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    169   menu->items_count++; 
    170  
    171   snprintf(buffer, sizeof buffer, "Bios Rev. : %s", 
    172      dmi->bios.bios_revision); 
    173   snprintf(statbuffer, sizeof statbuffer, "Bios Revision: %s", 
    174      dmi->bios.bios_revision); 
    175   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    176   menu->items_count++; 
    177  
    178   snprintf(buffer, sizeof buffer, "Fw.  Rev. : %s", 
    179      dmi->bios.firmware_revision); 
    180   snprintf(statbuffer, sizeof statbuffer, "Firmware Revision : %s", 
    181      dmi->bios.firmware_revision); 
    182   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    183  
    184   printf("MENU: BIOS menu done (%d items)\n", menu->items_count); 
     140    char buffer[SUBMENULEN + 1]; 
     141    char statbuffer[STATLEN + 1]; 
     142 
     143    menu->menu = add_menu(" BIOS ", -1); 
     144    menu->items_count = 0; 
     145    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     146 
     147    snprintf(buffer, sizeof buffer, "Vendor    : %s", dmi->bios.vendor); 
     148    snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", dmi->bios.vendor); 
     149    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     150    menu->items_count++; 
     151 
     152    snprintf(buffer, sizeof buffer, "Version   : %s", dmi->bios.version); 
     153    snprintf(statbuffer, sizeof statbuffer, "Version: %s", dmi->bios.version); 
     154    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     155    menu->items_count++; 
     156 
     157    snprintf(buffer, sizeof buffer, "Release   : %s", dmi->bios.release_date); 
     158    snprintf(statbuffer, sizeof statbuffer, "Release Date: %s", 
     159             dmi->bios.release_date); 
     160    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     161    menu->items_count++; 
     162 
     163    snprintf(buffer, sizeof buffer, "Bios Rev. : %s", dmi->bios.bios_revision); 
     164    snprintf(statbuffer, sizeof statbuffer, "Bios Revision: %s", 
     165             dmi->bios.bios_revision); 
     166    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     167    menu->items_count++; 
     168 
     169    snprintf(buffer, sizeof buffer, "Fw.  Rev. : %s", 
     170             dmi->bios.firmware_revision); 
     171    snprintf(statbuffer, sizeof statbuffer, "Firmware Revision : %s", 
     172             dmi->bios.firmware_revision); 
     173    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     174 
     175    printf("MENU: BIOS menu done (%d items)\n", menu->items_count); 
    185176} 
    186177 
     
    188179void compute_motherboard(struct s_my_menu *menu, s_dmi * dmi) 
    189180{ 
    190   char buffer[SUBMENULEN + 1]; 
    191   char statbuffer[STATLEN + 1]; 
    192  
    193   menu->menu = add_menu(" Motherboard ", -1); 
    194   menu->items_count = 0; 
    195   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    196  
    197   snprintf(buffer, sizeof buffer, "Vendor    : %s", 
    198      dmi->base_board.manufacturer); 
    199   snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", 
    200      dmi->base_board.manufacturer); 
    201   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    202   menu->items_count++; 
    203  
    204   snprintf(buffer, sizeof buffer, "Product   : %s", 
    205      dmi->base_board.product_name); 
    206   snprintf(statbuffer, sizeof statbuffer, "Product Name: %s", 
    207      dmi->base_board.product_name); 
    208   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    209   menu->items_count++; 
    210  
    211   snprintf(buffer, sizeof buffer, "Version   : %s", 
    212      dmi->base_board.version); 
    213   snprintf(statbuffer, sizeof statbuffer, "Version: %s", 
    214      dmi->base_board.version); 
    215   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    216   menu->items_count++; 
    217  
    218   snprintf(buffer, sizeof buffer, "Serial    : %s", 
    219      dmi->base_board.serial); 
    220   snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s", 
    221      dmi->base_board.serial); 
    222   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    223   menu->items_count++; 
    224  
    225   snprintf(buffer, sizeof buffer, "Asset Tag : %s", 
    226      dmi->base_board.asset_tag); 
    227   snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s", 
    228      dmi->base_board.asset_tag); 
    229   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    230   menu->items_count++; 
    231  
    232   snprintf(buffer, sizeof buffer, "Location  : %s", 
    233      dmi->base_board.location); 
    234   snprintf(statbuffer, sizeof statbuffer, "Location: %s", 
    235      dmi->base_board.location); 
    236   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    237   menu->items_count++; 
    238  
    239   snprintf(buffer, sizeof buffer, "Type      : %s", dmi->base_board.type); 
    240   snprintf(statbuffer, sizeof statbuffer, "Type: %s", 
    241      dmi->base_board.type); 
    242   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    243   menu->items_count++; 
    244  
    245   printf("MENU: Motherboard menu done (%d items)\n", menu->items_count); 
     181    char buffer[SUBMENULEN + 1]; 
     182    char statbuffer[STATLEN + 1]; 
     183 
     184    menu->menu = add_menu(" Motherboard ", -1); 
     185    menu->items_count = 0; 
     186    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     187 
     188    snprintf(buffer, sizeof buffer, "Vendor    : %s", 
     189             dmi->base_board.manufacturer); 
     190    snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", 
     191             dmi->base_board.manufacturer); 
     192    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     193    menu->items_count++; 
     194 
     195    snprintf(buffer, sizeof buffer, "Product   : %s", 
     196             dmi->base_board.product_name); 
     197    snprintf(statbuffer, sizeof statbuffer, "Product Name: %s", 
     198             dmi->base_board.product_name); 
     199    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     200    menu->items_count++; 
     201 
     202    snprintf(buffer, sizeof buffer, "Version   : %s", dmi->base_board.version); 
     203    snprintf(statbuffer, sizeof statbuffer, "Version: %s", 
     204             dmi->base_board.version); 
     205    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     206    menu->items_count++; 
     207 
     208    snprintf(buffer, sizeof buffer, "Serial    : %s", dmi->base_board.serial); 
     209    snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s", 
     210             dmi->base_board.serial); 
     211    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     212    menu->items_count++; 
     213 
     214    snprintf(buffer, sizeof buffer, "Asset Tag : %s", 
     215             dmi->base_board.asset_tag); 
     216    snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s", 
     217             dmi->base_board.asset_tag); 
     218    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     219    menu->items_count++; 
     220 
     221    snprintf(buffer, sizeof buffer, "Location  : %s", dmi->base_board.location); 
     222    snprintf(statbuffer, sizeof statbuffer, "Location: %s", 
     223             dmi->base_board.location); 
     224    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     225    menu->items_count++; 
     226 
     227    snprintf(buffer, sizeof buffer, "Type      : %s", dmi->base_board.type); 
     228    snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->base_board.type); 
     229    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     230    menu->items_count++; 
     231 
     232    printf("MENU: Motherboard menu done (%d items)\n", menu->items_count); 
    246233} 
    247234 
     
    249236void compute_ipmi(struct s_my_menu *menu, s_dmi * dmi) 
    250237{ 
    251   char buffer[SUBMENULEN + 1]; 
    252   char statbuffer[STATLEN + 1]; 
    253   menu->menu = add_menu(" IPMI ", -1); 
    254   menu->items_count = 0; 
    255   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    256  
    257   snprintf(buffer, sizeof buffer, "Interface Type  : %s", 
    258      dmi->ipmi.interface_type); 
    259   snprintf(statbuffer, sizeof statbuffer, "Interface Type: %s", 
    260      dmi->ipmi.interface_type); 
    261   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    262   menu->items_count++; 
    263  
    264   snprintf(buffer, sizeof buffer, "Spec. Version   : %u.%u", 
    265       dmi->ipmi.major_specification_version, 
    266       dmi->ipmi.minor_specification_version); 
    267   snprintf(statbuffer, sizeof statbuffer, "Specification Version: %u.%u", 
    268       dmi->ipmi.major_specification_version, 
    269       dmi->ipmi.minor_specification_version); 
    270   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    271   menu->items_count++; 
    272  
    273   snprintf(buffer, sizeof buffer, "I2C Slave @     : 0x%02x", 
    274      dmi->ipmi.I2C_slave_address); 
    275   snprintf(statbuffer, sizeof statbuffer, "I2C Slave Address: 0x%02x", 
    276      dmi->ipmi.I2C_slave_address); 
    277   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    278   menu->items_count++; 
    279  
    280   snprintf(buffer, sizeof buffer, "NV Storage @    : %u", 
    281      dmi->ipmi.nv_address); 
    282   snprintf(statbuffer, sizeof statbuffer, "NV Storage Address: %u", 
    283      dmi->ipmi.nv_address); 
    284   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    285   menu->items_count++; 
    286  
    287   uint32_t high = dmi->ipmi.base_address >> 32; 
    288   uint32_t low  = dmi->ipmi.base_address & 0xFFFF; 
    289  
    290   snprintf(buffer, sizeof buffer, "Base Address    : %08X%08X", 
    291      high,(low & ~1)); 
    292   snprintf(statbuffer, sizeof statbuffer, "Base Address : %08X%08X", 
    293      high,(low & ~1)); 
    294   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    295   menu->items_count++; 
    296  
    297   snprintf(buffer, sizeof buffer, "IRQ             : %d", 
    298      dmi->ipmi.irq); 
    299   snprintf(statbuffer, sizeof statbuffer, "IRQ : %d", 
    300      dmi->ipmi.irq); 
    301   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    302   menu->items_count++; 
    303  
    304   printf("MENU: IPMI menu done (%d items)\n", menu->items_count); 
     238    char buffer[SUBMENULEN + 1]; 
     239    char statbuffer[STATLEN + 1]; 
     240    menu->menu = add_menu(" IPMI ", -1); 
     241    menu->items_count = 0; 
     242    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     243 
     244    snprintf(buffer, sizeof buffer, "Interface Type  : %s", 
     245             dmi->ipmi.interface_type); 
     246    snprintf(statbuffer, sizeof statbuffer, "Interface Type: %s", 
     247             dmi->ipmi.interface_type); 
     248    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     249    menu->items_count++; 
     250 
     251    snprintf(buffer, sizeof buffer, "Spec. Version   : %u.%u", 
     252             dmi->ipmi.major_specification_version, 
     253             dmi->ipmi.minor_specification_version); 
     254    snprintf(statbuffer, sizeof statbuffer, "Specification Version: %u.%u", 
     255             dmi->ipmi.major_specification_version, 
     256             dmi->ipmi.minor_specification_version); 
     257    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     258    menu->items_count++; 
     259 
     260    snprintf(buffer, sizeof buffer, "I2C Slave @     : 0x%02x", 
     261             dmi->ipmi.I2C_slave_address); 
     262    snprintf(statbuffer, sizeof statbuffer, "I2C Slave Address: 0x%02x", 
     263             dmi->ipmi.I2C_slave_address); 
     264    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     265    menu->items_count++; 
     266 
     267    snprintf(buffer, sizeof buffer, "NV Storage @    : %u", 
     268             dmi->ipmi.nv_address); 
     269    snprintf(statbuffer, sizeof statbuffer, "NV Storage Address: %u", 
     270             dmi->ipmi.nv_address); 
     271    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     272    menu->items_count++; 
     273 
     274    uint32_t high = dmi->ipmi.base_address >> 32; 
     275    uint32_t low = dmi->ipmi.base_address & 0xFFFF; 
     276 
     277    snprintf(buffer, sizeof buffer, "Base Address    : %08X%08X", 
     278             high, (low & ~1)); 
     279    snprintf(statbuffer, sizeof statbuffer, "Base Address : %08X%08X", 
     280             high, (low & ~1)); 
     281    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     282    menu->items_count++; 
     283 
     284    snprintf(buffer, sizeof buffer, "IRQ             : %d", dmi->ipmi.irq); 
     285    snprintf(statbuffer, sizeof statbuffer, "IRQ : %d", dmi->ipmi.irq); 
     286    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     287    menu->items_count++; 
     288 
     289    printf("MENU: IPMI menu done (%d items)\n", menu->items_count); 
    305290} 
    306291 
     
    308293void compute_battery(struct s_my_menu *menu, s_dmi * dmi) 
    309294{ 
    310   char buffer[SUBMENULEN + 1]; 
    311   char statbuffer[STATLEN + 1]; 
    312   menu->menu = add_menu(" Battery ", -1); 
    313   menu->items_count = 0; 
    314   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    315  
    316   snprintf(buffer, sizeof buffer, "Vendor          : %s", 
    317      dmi->battery.manufacturer); 
    318   snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", 
    319      dmi->battery.manufacturer); 
    320   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    321   menu->items_count++; 
    322  
    323   snprintf(buffer, sizeof buffer, "Manufacture Date: %s", 
    324      dmi->battery.manufacture_date); 
    325   snprintf(statbuffer, sizeof statbuffer, "Manufacture Date: %s", 
    326      dmi->battery.manufacture_date); 
    327   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    328   menu->items_count++; 
    329  
    330   snprintf(buffer, sizeof buffer, "Serial          : %s", 
    331      dmi->battery.serial); 
    332   snprintf(statbuffer, sizeof statbuffer, "Serial: %s", 
    333      dmi->battery.serial); 
    334   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    335   menu->items_count++; 
    336  
    337   snprintf(buffer, sizeof buffer, "Name            : %s", 
    338      dmi->battery.name); 
    339   snprintf(statbuffer, sizeof statbuffer, "Name: %s", dmi->battery.name); 
    340   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    341   menu->items_count++; 
    342  
    343   snprintf(buffer, sizeof buffer, "Chemistry       : %s", 
    344      dmi->battery.chemistry); 
    345   snprintf(statbuffer, sizeof statbuffer, "Chemistry: %s", 
    346      dmi->battery.chemistry); 
    347   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    348   menu->items_count++; 
    349  
    350   snprintf(buffer, sizeof buffer, "Design Capacity : %s", 
    351      dmi->battery.design_capacity); 
    352   snprintf(statbuffer, sizeof statbuffer, "Design Capacity: %s", 
    353      dmi->battery.design_capacity); 
    354   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    355   menu->items_count++; 
    356  
    357   snprintf(buffer, sizeof buffer, "Design Voltage  : %s", 
    358      dmi->battery.design_voltage); 
    359   snprintf(statbuffer, sizeof statbuffer, "Design Voltage : %s", 
    360      dmi->battery.design_voltage); 
    361   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    362   menu->items_count++; 
    363  
    364   snprintf(buffer, sizeof buffer, "SBDS            : %s", 
    365      dmi->battery.sbds); 
    366   snprintf(statbuffer, sizeof statbuffer, "SBDS: %s", dmi->battery.sbds); 
    367   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    368   menu->items_count++; 
    369  
    370   snprintf(buffer, sizeof buffer, "SBDS Manuf. Date: %s", 
    371      dmi->battery.sbds_manufacture_date); 
    372   snprintf(statbuffer, sizeof statbuffer, "SBDS Manufacture Date: %s", 
    373      dmi->battery.sbds_manufacture_date); 
    374   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    375   menu->items_count++; 
    376  
    377   snprintf(buffer, sizeof buffer, "SBDS Chemistry  : %s", 
    378      dmi->battery.sbds_chemistry); 
    379   snprintf(statbuffer, sizeof statbuffer, "SBDS Chemistry : %s", 
    380      dmi->battery.sbds_chemistry); 
    381   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    382   menu->items_count++; 
    383  
    384   snprintf(buffer, sizeof buffer, "Maximum Error   : %s", 
    385      dmi->battery.maximum_error); 
    386   snprintf(statbuffer, sizeof statbuffer, "Maximum Error (percent) : %s", 
    387      dmi->battery.maximum_error); 
    388   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    389   menu->items_count++; 
    390  
    391   snprintf(buffer, sizeof buffer, "OEM Info        : %s", 
    392      dmi->battery.oem_info); 
    393   snprintf(statbuffer, sizeof statbuffer, "OEM Info: %s", 
    394      dmi->battery.oem_info); 
    395   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    396   menu->items_count++; 
    397  
    398   printf("MENU: Battery menu done (%d items)\n", menu->items_count); 
    399 } 
     295    char buffer[SUBMENULEN + 1]; 
     296    char statbuffer[STATLEN + 1]; 
     297    menu->menu = add_menu(" Battery ", -1); 
     298    menu->items_count = 0; 
     299    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     300 
     301    snprintf(buffer, sizeof buffer, "Vendor          : %s", 
     302             dmi->battery.manufacturer); 
     303    snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", 
     304             dmi->battery.manufacturer); 
     305    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     306    menu->items_count++; 
     307 
     308    snprintf(buffer, sizeof buffer, "Manufacture Date: %s", 
     309             dmi->battery.manufacture_date); 
     310    snprintf(statbuffer, sizeof statbuffer, "Manufacture Date: %s", 
     311             dmi->battery.manufacture_date); 
     312    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     313    menu->items_count++; 
     314 
     315    snprintf(buffer, sizeof buffer, "Serial          : %s", 
     316             dmi->battery.serial); 
     317    snprintf(statbuffer, sizeof statbuffer, "Serial: %s", dmi->battery.serial); 
     318    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     319    menu->items_count++; 
     320 
     321    snprintf(buffer, sizeof buffer, "Name            : %s", dmi->battery.name); 
     322    snprintf(statbuffer, sizeof statbuffer, "Name: %s", dmi->battery.name); 
     323    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     324    menu->items_count++; 
     325 
     326    snprintf(buffer, sizeof buffer, "Chemistry       : %s", 
     327             dmi->battery.chemistry); 
     328    snprintf(statbuffer, sizeof statbuffer, "Chemistry: %s", 
     329             dmi->battery.chemistry); 
     330    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     331    menu->items_count++; 
     332 
     333    snprintf(buffer, sizeof buffer, "Design Capacity : %s", 
     334             dmi->battery.design_capacity); 
     335    snprintf(statbuffer, sizeof statbuffer, "Design Capacity: %s", 
     336             dmi->battery.design_capacity); 
     337    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     338    menu->items_count++; 
     339 
     340    snprintf(buffer, sizeof buffer, "Design Voltage  : %s", 
     341             dmi->battery.design_voltage); 
     342    snprintf(statbuffer, sizeof statbuffer, "Design Voltage : %s", 
     343             dmi->battery.design_voltage); 
     344    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     345    menu->items_count++; 
     346 
     347    snprintf(buffer, sizeof buffer, "SBDS            : %s", dmi->battery.sbds); 
     348    snprintf(statbuffer, sizeof statbuffer, "SBDS: %s", dmi->battery.sbds); 
     349    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     350    menu->items_count++; 
     351 
     352    snprintf(buffer, sizeof buffer, "SBDS Manuf. Date: %s", 
     353             dmi->battery.sbds_manufacture_date); 
     354    snprintf(statbuffer, sizeof statbuffer, "SBDS Manufacture Date: %s", 
     355             dmi->battery.sbds_manufacture_date); 
     356    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     357    menu->items_count++; 
     358 
     359    snprintf(buffer, sizeof buffer, "SBDS Chemistry  : %s", 
     360             dmi->battery.sbds_chemistry); 
     361    snprintf(statbuffer, sizeof statbuffer, "SBDS Chemistry : %s", 
     362             dmi->battery.sbds_chemistry); 
     363    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     364    menu->items_count++; 
     365 
     366    snprintf(buffer, sizeof buffer, "Maximum Error   : %s", 
     367             dmi->battery.maximum_error); 
     368    snprintf(statbuffer, sizeof statbuffer, "Maximum Error (percent) : %s", 
     369             dmi->battery.maximum_error); 
     370    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     371    menu->items_count++; 
     372 
     373    snprintf(buffer, sizeof buffer, "OEM Info        : %s", 
     374             dmi->battery.oem_info); 
     375    snprintf(statbuffer, sizeof statbuffer, "OEM Info: %s", 
     376             dmi->battery.oem_info); 
     377    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     378    menu->items_count++; 
     379 
     380    printf("MENU: Battery menu done (%d items)\n", menu->items_count); 
     381} 
  • com32/hdt/hdt-menu-kernel.c

    r8e7362 r990205  
    3232void compute_kernel(struct s_my_menu *menu, struct s_hardware *hardware) 
    3333{ 
    34   char buffer[SUBMENULEN + 1]; 
    35   char infobar[STATLEN + 1]; 
    36   char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
    37           MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
    38   struct pci_device *pci_device; 
     34    char buffer[SUBMENULEN + 1]; 
     35    char infobar[STATLEN + 1]; 
     36    char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
     37                        MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
     38    struct pci_device *pci_device; 
    3939 
    40   menu->menu = add_menu(" Kernel Modules ", -1); 
    41   menu->items_count = 0; 
    42   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     40    menu->menu = add_menu(" Kernel Modules ", -1); 
     41    menu->items_count = 0; 
     42    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    4343 
    44   if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) && 
    45      (hardware->modules_alias_return_code == -ENOMODULESALIAS)) { 
    46     add_item("The modules.{pcimap|alias} file is missing", 
    47        "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0); 
    48     add_item("Kernel modules can't be computed.", 
    49        "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0); 
    50     add_item("Please put one of them in same dir as hdt", 
    51        "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0); 
    52     add_item("", "", OPT_SEP, "", 0); 
    53   } else { 
    54     /* 
    55      * For every detected pci device, grab its kernel module to 
    56      * compute this submenu 
    57      */ 
    58     for_each_pci_func(pci_device, hardware->pci_domain) { 
    59       memset(kernel_modules, 0, sizeof kernel_modules); 
    60       for (int i = 0; 
    61            i < 
    62            pci_device->dev_info->linux_kernel_module_count; 
    63            i++) { 
    64         if (i > 0) { 
    65           strncat(kernel_modules, " | ", 3); 
    66         } 
    67         strncat(kernel_modules, 
    68           pci_device->dev_info-> 
    69           linux_kernel_module[i], 
    70           LINUX_KERNEL_MODULE_SIZE - 1); 
    71       } 
    72       /* No need to add unknown kernel modules */ 
    73       if (strlen(kernel_modules) > 0) { 
    74         snprintf(buffer, sizeof buffer, "%s (%s)", 
    75            kernel_modules, 
    76            pci_device->dev_info->class_name); 
    77         snprintf(infobar, sizeof infobar, 
    78            "%04x:%04x %s : %s", 
    79            pci_device->vendor, 
    80            pci_device->product, 
    81            pci_device->dev_info->vendor_name, 
    82            pci_device->dev_info->product_name); 
     44    if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) && 
     45        (hardware->modules_alias_return_code == -ENOMODULESALIAS)) { 
     46        add_item("The modules.{pcimap|alias} file is missing", 
     47                 "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0); 
     48        add_item("Kernel modules can't be computed.", 
     49                 "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0); 
     50        add_item("Please put one of them in same dir as hdt", 
     51                 "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0); 
     52        add_item("", "", OPT_SEP, "", 0); 
     53    } else { 
     54        /* 
     55         * For every detected pci device, grab its kernel module to 
     56         * compute this submenu 
     57         */ 
     58        for_each_pci_func(pci_device, hardware->pci_domain) { 
     59            memset(kernel_modules, 0, sizeof kernel_modules); 
     60            for (int i = 0; 
     61                 i < pci_device->dev_info->linux_kernel_module_count; i++) { 
     62                if (i > 0) { 
     63                    strncat(kernel_modules, " | ", 3); 
     64                } 
     65                strncat(kernel_modules, 
     66                        pci_device->dev_info->linux_kernel_module[i], 
     67                        LINUX_KERNEL_MODULE_SIZE - 1); 
     68            } 
     69            /* No need to add unknown kernel modules */ 
     70            if (strlen(kernel_modules) > 0) { 
     71                snprintf(buffer, sizeof buffer, "%s (%s)", 
     72                         kernel_modules, pci_device->dev_info->class_name); 
     73                snprintf(infobar, sizeof infobar, 
     74                         "%04x:%04x %s : %s", 
     75                         pci_device->vendor, 
     76                         pci_device->product, 
     77                         pci_device->dev_info->vendor_name, 
     78                         pci_device->dev_info->product_name); 
    8379 
    84         add_item(buffer, infobar, OPT_INACTIVE, NULL, 
    85            0); 
    86         menu->items_count++; 
    87       } 
     80                add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
     81                menu->items_count++; 
     82            } 
     83        } 
    8884    } 
    89   } 
    9085 
    91   printf("MENU: Kernel menu done (%d items)\n", menu->items_count); 
     86    printf("MENU: Kernel menu done (%d items)\n", menu->items_count); 
    9287} 
  • com32/hdt/hdt-menu-memory.c

    r219c2a r990205  
    3434static void compute_e820(struct s_my_menu *menu) 
    3535{ 
    36   char buffer[MENULEN + 1]; 
    37   char statbuffer[STATLEN + 1]; 
    38  
    39   sprintf(buffer, " e820 Physical RAM map "); 
    40   menu->items_count = 0; 
    41   menu->menu = add_menu(buffer, -1); 
    42  
    43   struct e820entry map[E820MAX]; 
    44   int  count = 0; 
    45   char type[14]; 
    46  
    47   detect_memory_e820(map, E820MAX, &count); 
    48   unsigned long memory_size = memsize_e820(map, count); 
    49   snprintf(buffer, sizeof buffer,"Detected Memory  - %lu MiB (%lu KiB)", 
    50                   memory_size>>10, memory_size); 
    51   snprintf(statbuffer, sizeof statbuffer,"Detected Memory : %lu MiB (%lu KiB)", 
    52                   memory_size>>10, memory_size); 
    53   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    54   add_item("", "", OPT_SEP, "", 0); 
    55  
    56   for (int j = 0; j < count; j++) { 
     36    char buffer[MENULEN + 1]; 
     37    char statbuffer[STATLEN + 1]; 
     38 
     39    sprintf(buffer, " e820 Physical RAM map "); 
     40    menu->items_count = 0; 
     41    menu->menu = add_menu(buffer, -1); 
     42 
     43    struct e820entry map[E820MAX]; 
     44    int count = 0; 
     45    char type[14]; 
     46 
     47    detect_memory_e820(map, E820MAX, &count); 
     48    unsigned long memory_size = memsize_e820(map, count); 
     49    snprintf(buffer, sizeof buffer, "Detected Memory  - %lu MiB (%lu KiB)", 
     50             memory_size >> 10, memory_size); 
     51    snprintf(statbuffer, sizeof statbuffer, 
     52             "Detected Memory : %lu MiB (%lu KiB)", memory_size >> 10, 
     53             memory_size); 
     54    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     55    add_item("", "", OPT_SEP, "", 0); 
     56 
     57    for (int j = 0; j < count; j++) { 
    5758        get_type(map[j].type, type, 14); 
    58         snprintf(buffer, sizeof buffer, 
    59                 "%016llx - %016llx (%s)", 
    60                 map[j].addr, map[j].size, 
    61                 remove_spaces(type)); 
     59        snprintf(buffer, sizeof buffer, 
     60                 "%016llx - %016llx (%s)", 
     61                 map[j].addr, map[j].size, remove_spaces(type)); 
    6262        snprintf(statbuffer, sizeof statbuffer, 
    63                 "%016llx - %016llx (%s)", 
    64                 map[j].addr, map[j].size, 
    65                 remove_spaces(type)); 
    66         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    67         menu->items_count++; 
    68   } 
     63                 "%016llx - %016llx (%s)", 
     64                 map[j].addr, map[j].size, remove_spaces(type)); 
     65        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     66        menu->items_count++; 
     67    } 
    6968} 
    7069 
     
    7271static void compute_e801(struct s_my_menu *menu) 
    7372{ 
    74   char buffer[MENULEN + 1]; 
    75   char statbuffer[STATLEN + 1]; 
    76  
    77   sprintf(buffer, " e801 information "); 
    78   menu->items_count = 0; 
    79   menu->menu = add_menu(buffer, -1); 
    80  
    81  
    82   int mem_low, mem_high = 0; 
    83   if (detect_memory_e801(&mem_low, &mem_high)) { 
    84         snprintf(buffer, sizeof buffer, "%s", "e801 output is bogus"); 
    85         snprintf(statbuffer, sizeof statbuffer, "%s", "e801 output is bogus"); 
    86         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    87         menu->items_count++; 
    88   } else { 
     73    char buffer[MENULEN + 1]; 
     74    char statbuffer[STATLEN + 1]; 
     75 
     76    sprintf(buffer, " e801 information "); 
     77    menu->items_count = 0; 
     78    menu->menu = add_menu(buffer, -1); 
     79 
     80    int mem_low, mem_high = 0; 
     81    if (detect_memory_e801(&mem_low, &mem_high)) { 
     82        snprintf(buffer, sizeof buffer, "%s", "e801 output is bogus"); 
     83        snprintf(statbuffer, sizeof statbuffer, "%s", "e801 output is bogus"); 
     84        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     85        menu->items_count++; 
     86    } else { 
    8987        snprintf(buffer, sizeof buffer, "Detected Memory  : %d MiB (%d KiB)", 
    90                 (mem_high >> 4)+(mem_low >> 10),mem_low+(mem_high << 6)); 
    91         snprintf(statbuffer, sizeof statbuffer,"Detected Memory : %d MiB (%d KiB)", 
    92                 (mem_high >> 4)+(mem_low >> 10),mem_low+(mem_high << 6)); 
    93         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    94  
    95         add_item("", "", OPT_SEP, "", 0); 
    96         snprintf(buffer, sizeof buffer, "Low Memory       : %d KiB (%d MiB)", 
    97                 mem_low, mem_low >> 10); 
    98         snprintf(statbuffer, sizeof statbuffer, "Low Memory : %d KiB (%d MiB)", 
    99                 mem_low, mem_low >> 10); 
    100         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     88                 (mem_high >> 4) + (mem_low >> 10), mem_low + (mem_high << 6)); 
     89        snprintf(statbuffer, sizeof statbuffer, 
     90                 "Detected Memory : %d MiB (%d KiB)", 
     91                 (mem_high >> 4) + (mem_low >> 10), mem_low + (mem_high << 6)); 
     92        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     93 
     94        add_item("", "", OPT_SEP, "", 0); 
     95        snprintf(buffer, sizeof buffer, "Low Memory       : %d KiB (%d MiB)", 
     96                 mem_low, mem_low >> 10); 
     97        snprintf(statbuffer, sizeof statbuffer, "Low Memory : %d KiB (%d MiB)", 
     98                 mem_low, mem_low >> 10); 
     99        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    101100 
    102101        snprintf(buffer, sizeof buffer, "High Memory      : %d KiB (%d MiB)", 
    103                 mem_high << 6, mem_high >> 4); 
    104         snprintf(statbuffer, sizeof statbuffer, "High Memory : %d KiB (%d MiB)", 
    105                 mem_high << 6, mem_high >> 4); 
    106         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    107  
    108   } 
    109   menu->items_count++; 
     102                mem_high << 6, mem_high >> 4); 
     103        snprintf(statbuffer, sizeof statbuffer, "High Memory : %d KiB (%d MiB)", 
     104                mem_high << 6, mem_high >> 4); 
     105        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     106 
     107    } 
     108    menu->items_count++; 
    110109} 
    111110 
     
    113112static void compute_88(struct s_my_menu *menu) 
    114113{ 
    115   char buffer[MENULEN + 1]; 
    116   char statbuffer[STATLEN + 1]; 
    117  
    118   sprintf(buffer, " 88 information "); 
    119   menu->items_count = 0; 
    120   menu->menu = add_menu(buffer, -1); 
    121  
    122   int mem_size = 0; 
    123   if (detect_memory_88(&mem_size)) { 
    124         snprintf(buffer, sizeof buffer, "%s", "88 output is bogus"); 
    125         snprintf(statbuffer, sizeof statbuffer, "%s", "88 output is bogus"); 
    126         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    127         menu->items_count++; 
    128   } else { 
    129         snprintf(buffer, sizeof buffer, "Detected Memory : %d MiB (%d KiB)", 
    130                         mem_size >> 10, mem_size); 
    131         snprintf(statbuffer, sizeof statbuffer, "Detected Memory : %d MiB (%d KiB)", 
    132                         mem_size >> 10, mem_size); 
    133         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    134   } 
    135   menu->items_count++; 
     114    char buffer[MENULEN + 1]; 
     115    char statbuffer[STATLEN + 1]; 
     116 
     117    sprintf(buffer, " 88 information "); 
     118    menu->items_count = 0; 
     119    menu->menu = add_menu(buffer, -1); 
     120 
     121    int mem_size = 0; 
     122    if (detect_memory_88(&mem_size)) { 
     123        snprintf(buffer, sizeof buffer, "%s", "88 output is bogus"); 
     124        snprintf(statbuffer, sizeof statbuffer, "%s", "88 output is bogus"); 
     125        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     126        menu->items_count++; 
     127    } else { 
     128        snprintf(buffer, sizeof buffer, "Detected Memory : %d MiB (%d KiB)", 
     129                 mem_size >> 10, mem_size); 
     130        snprintf(statbuffer, sizeof statbuffer, 
     131                 "Detected Memory : %d MiB (%d KiB)", mem_size >> 10, mem_size); 
     132        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     133    } 
     134    menu->items_count++; 
    136135} 
    137136 
    138137/* Compute the Memory submenu */ 
    139138static void compute_memory_module(struct s_my_menu *menu, s_dmi * dmi, 
    140                                   int slot_number) 
    141 { 
    142   int i = slot_number; 
    143   char buffer[MENULEN + 1]; 
    144   char statbuffer[STATLEN + 1]; 
    145  
    146   sprintf(buffer, " Bank <%d> ", i); 
    147   menu->items_count = 0; 
    148   menu->menu = add_menu(buffer, -1); 
    149  
    150   snprintf(buffer, sizeof buffer, "Form Factor  : %s", 
    151      dmi->memory[i].form_factor); 
    152   snprintf(statbuffer, sizeof statbuffer, "Form Factor: %s", 
    153      dmi->memory[i].form_factor); 
    154   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    155   menu->items_count++; 
    156  
    157   snprintf(buffer, sizeof buffer, "Type         : %s", 
    158      dmi->memory[i].type); 
    159   snprintf(statbuffer, sizeof statbuffer, "Type: %s", 
    160      dmi->memory[i].type); 
    161   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    162   menu->items_count++; 
    163  
    164   snprintf(buffer, sizeof buffer, "Type Details : %s", 
    165      dmi->memory[i].type_detail); 
    166   snprintf(statbuffer, sizeof statbuffer, "Type Details: %s", 
    167      dmi->memory[i].type_detail); 
    168   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    169   menu->items_count++; 
    170  
    171   snprintf(buffer, sizeof buffer, "Speed        : %s", 
    172      dmi->memory[i].speed); 
    173   snprintf(statbuffer, sizeof statbuffer, "Speed (Mhz): %s", 
    174      dmi->memory[i].speed); 
    175   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    176   menu->items_count++; 
    177  
    178   snprintf(buffer, sizeof buffer, "Size         : %s", 
    179      dmi->memory[i].size); 
    180   snprintf(statbuffer, sizeof statbuffer, "Size: %s", 
    181      dmi->memory[i].size); 
    182   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    183   menu->items_count++; 
    184  
    185   snprintf(buffer, sizeof buffer, "Device Set   : %s", 
    186      dmi->memory[i].device_set); 
    187   snprintf(statbuffer, sizeof statbuffer, "Device Set: %s", 
    188      dmi->memory[i].device_set); 
    189   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    190   menu->items_count++; 
    191  
    192   snprintf(buffer, sizeof buffer, "Device Loc.  : %s", 
    193      dmi->memory[i].device_locator); 
    194   snprintf(statbuffer, sizeof statbuffer, "Device Location: %s", 
    195      dmi->memory[i].device_locator); 
    196   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    197   menu->items_count++; 
    198  
    199   snprintf(buffer, sizeof buffer, "Bank Locator : %s", 
    200      dmi->memory[i].bank_locator); 
    201   snprintf(statbuffer, sizeof statbuffer, "Bank Locator: %s", 
    202      dmi->memory[i].bank_locator); 
    203   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    204   menu->items_count++; 
    205  
    206   snprintf(buffer, sizeof buffer, "Total Width  : %s", 
    207      dmi->memory[i].total_width); 
    208   snprintf(statbuffer, sizeof statbuffer, "Total bit Width: %s", 
    209      dmi->memory[i].total_width); 
    210   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    211   menu->items_count++; 
    212  
    213   snprintf(buffer, sizeof buffer, "Data Width   : %s", 
    214      dmi->memory[i].data_width); 
    215   snprintf(statbuffer, sizeof statbuffer, "Data bit Width: %s", 
    216      dmi->memory[i].data_width); 
    217   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    218   menu->items_count++; 
    219  
    220   snprintf(buffer, sizeof buffer, "Error        : %s", 
    221      dmi->memory[i].error); 
    222   snprintf(statbuffer, sizeof statbuffer, "Error: %s", 
    223      dmi->memory[i].error); 
    224   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    225   menu->items_count++; 
    226  
    227   snprintf(buffer, sizeof buffer, "Vendor       : %s", 
    228      dmi->memory[i].manufacturer); 
    229   snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", 
    230      dmi->memory[i].manufacturer); 
    231   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    232   menu->items_count++; 
    233  
    234   snprintf(buffer, sizeof buffer, "Serial       : %s", 
    235      dmi->memory[i].serial); 
    236   snprintf(statbuffer, sizeof statbuffer, "Serial: %s", 
    237      dmi->memory[i].serial); 
    238   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    239   menu->items_count++; 
    240  
    241   snprintf(buffer, sizeof buffer, "Asset Tag    : %s", 
    242      dmi->memory[i].asset_tag); 
    243   snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s", 
    244      dmi->memory[i].asset_tag); 
    245   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    246   menu->items_count++; 
    247  
    248   snprintf(buffer, sizeof buffer, "Part Number  : %s", 
    249      dmi->memory[i].part_number); 
    250   snprintf(buffer, sizeof statbuffer, "Part Number: %s", 
    251      dmi->memory[i].part_number); 
    252   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    253   menu->items_count++; 
     139                                  int slot_number) 
     140{ 
     141    int i = slot_number; 
     142    char buffer[MENULEN + 1]; 
     143    char statbuffer[STATLEN + 1]; 
     144 
     145    sprintf(buffer, " Bank <%d> ", i); 
     146    menu->items_count = 0; 
     147    menu->menu = add_menu(buffer, -1); 
     148 
     149    snprintf(buffer, sizeof buffer, "Form Factor  : %s", 
     150             dmi->memory[i].form_factor); 
     151    snprintf(statbuffer, sizeof statbuffer, "Form Factor: %s", 
     152             dmi->memory[i].form_factor); 
     153    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     154    menu->items_count++; 
     155 
     156    snprintf(buffer, sizeof buffer, "Type         : %s", dmi->memory[i].type); 
     157    snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->memory[i].type); 
     158    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     159    menu->items_count++; 
     160 
     161    snprintf(buffer, sizeof buffer, "Type Details : %s", 
     162             dmi->memory[i].type_detail); 
     163    snprintf(statbuffer, sizeof statbuffer, "Type Details: %s", 
     164             dmi->memory[i].type_detail); 
     165    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     166    menu->items_count++; 
     167 
     168    snprintf(buffer, sizeof buffer, "Speed        : %s", dmi->memory[i].speed); 
     169    snprintf(statbuffer, sizeof statbuffer, "Speed (Mhz): %s", 
     170             dmi->memory[i].speed); 
     171    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     172    menu->items_count++; 
     173 
     174    snprintf(buffer, sizeof buffer, "Size         : %s", dmi->memory[i].size); 
     175    snprintf(statbuffer, sizeof statbuffer, "Size: %s", dmi->memory[i].size); 
     176    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     177    menu->items_count++; 
     178 
     179    snprintf(buffer, sizeof buffer, "Device Set   : %s", 
     180             dmi->memory[i].device_set); 
     181    snprintf(statbuffer, sizeof statbuffer, "Device Set: %s", 
     182             dmi->memory[i].device_set); 
     183    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     184    menu->items_count++; 
     185 
     186    snprintf(buffer, sizeof buffer, "Device Loc.  : %s", 
     187             dmi->memory[i].device_locator); 
     188    snprintf(statbuffer, sizeof statbuffer, "Device Location: %s", 
     189             dmi->memory[i].device_locator); 
     190    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     191    menu->items_count++; 
     192 
     193    snprintf(buffer, sizeof buffer, "Bank Locator : %s", 
     194             dmi->memory[i].bank_locator); 
     195    snprintf(statbuffer, sizeof statbuffer, "Bank Locator: %s", 
     196             dmi->memory[i].bank_locator); 
     197    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     198    menu->items_count++; 
     199 
     200    snprintf(buffer, sizeof buffer, "Total Width  : %s", 
     201             dmi->memory[i].total_width); 
     202    snprintf(statbuffer, sizeof statbuffer, "Total bit Width: %s", 
     203             dmi->memory[i].total_width); 
     204    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     205    menu->items_count++; 
     206 
     207    snprintf(buffer, sizeof buffer, "Data Width   : %s", 
     208             dmi->memory[i].data_width); 
     209    snprintf(statbuffer, sizeof statbuffer, "Data bit Width: %s", 
     210             dmi->memory[i].data_width); 
     211    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     212    menu->items_count++; 
     213 
     214    snprintf(buffer, sizeof buffer, "Error        : %s", dmi->memory[i].error); 
     215    snprintf(statbuffer, sizeof statbuffer, "Error: %s", dmi->memory[i].error); 
     216    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     217    menu->items_count++; 
     218 
     219    snprintf(buffer, sizeof buffer, "Vendor       : %s", 
     220             dmi->memory[i].manufacturer); 
     221    snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", 
     222             dmi->memory[i].manufacturer); 
     223    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     224    menu->items_count++; 
     225 
     226    snprintf(buffer, sizeof buffer, "Serial       : %s", dmi->memory[i].serial); 
     227    snprintf(statbuffer, sizeof statbuffer, "Serial: %s", 
     228             dmi->memory[i].serial); 
     229    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     230    menu->items_count++; 
     231 
     232    snprintf(buffer, sizeof buffer, "Asset Tag    : %s", 
     233             dmi->memory[i].asset_tag); 
     234    snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s", 
     235             dmi->memory[i].asset_tag); 
     236    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     237    menu->items_count++; 
     238 
     239    snprintf(buffer, sizeof buffer, "Part Number  : %s", 
     240             dmi->memory[i].part_number); 
     241    snprintf(buffer, sizeof statbuffer, "Part Number: %s", 
     242             dmi->memory[i].part_number); 
     243    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     244    menu->items_count++; 
    254245 
    255246} 
     
    257248/* Compute the Memory submenu when type 6 is used*/ 
    258249static void compute_memory_module_type6(struct s_my_menu *menu, s_dmi * dmi, 
    259                                   int slot_number) 
    260 { 
    261   int i = slot_number; 
    262   char buffer[MENULEN + 1]; 
    263   char statbuffer[STATLEN + 1]; 
    264  
    265   sprintf(buffer, " Bank <%d> ", i); 
    266   menu->items_count = 0; 
    267   menu->menu = add_menu(buffer, -1); 
    268  
    269   snprintf(buffer, sizeof buffer, "Socket Designation : %s", 
    270      dmi->memory_module[i].socket_designation); 
    271   snprintf(statbuffer, sizeof statbuffer, "Socket Designation : %s", 
    272      dmi->memory_module[i].socket_designation); 
    273   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    274   menu->items_count++; 
    275  
    276   snprintf(buffer, sizeof buffer, "Bank Connections   : %s", 
    277      dmi->memory_module[i].bank_connections); 
    278   snprintf(statbuffer, sizeof statbuffer, "Bank Connections: %s", 
    279      dmi->memory_module[i].bank_connections); 
    280   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    281   menu->items_count++; 
    282  
    283   snprintf(buffer, sizeof buffer, "Type               : %s", 
    284      dmi->memory_module[i].type); 
    285   snprintf(statbuffer, sizeof statbuffer, "Type : %s", 
    286      dmi->memory_module[i].type); 
    287   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    288   menu->items_count++; 
    289  
    290   snprintf(buffer, sizeof buffer, "Current Speed      : %s", 
    291      dmi->memory_module[i].speed); 
    292   snprintf(statbuffer, sizeof statbuffer, "Current Speed : %s", 
    293      dmi->memory_module[i].speed); 
    294   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    295   menu->items_count++; 
    296  
    297   snprintf(buffer, sizeof buffer, "Installed Size     : %s", 
    298      dmi->memory_module[i].installed_size); 
    299   snprintf(statbuffer, sizeof statbuffer, "Installed Size : %s", 
    300      dmi->memory_module[i].installed_size); 
    301   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    302   menu->items_count++; 
    303  
    304   snprintf(buffer, sizeof buffer, "Enabled Size       : %s", 
    305      dmi->memory_module[i].enabled_size); 
    306   snprintf(statbuffer, sizeof statbuffer, "Enabled Size : %s", 
    307      dmi->memory_module[i].enabled_size); 
    308   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    309   menu->items_count++; 
    310  
    311   snprintf(buffer, sizeof buffer, "Error Status       : %s", 
    312      dmi->memory_module[i].error_status); 
    313   snprintf(statbuffer, sizeof statbuffer, "Error Status : %s", 
    314      dmi->memory_module[i].error_status); 
    315   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    316   menu->items_count++; 
     250                                        int slot_number) 
     251{ 
     252    int i = slot_number; 
     253    char buffer[MENULEN + 1]; 
     254    char statbuffer[STATLEN + 1]; 
     255 
     256    sprintf(buffer, " Bank <%d> ", i); 
     257    menu->items_count = 0; 
     258    menu->menu = add_menu(buffer, -1); 
     259 
     260    snprintf(buffer, sizeof buffer, "Socket Designation : %s", 
     261             dmi->memory_module[i].socket_designation); 
     262    snprintf(statbuffer, sizeof statbuffer, "Socket Designation : %s", 
     263             dmi->memory_module[i].socket_designation); 
     264    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     265    menu->items_count++; 
     266 
     267    snprintf(buffer, sizeof buffer, "Bank Connections   : %s", 
     268             dmi->memory_module[i].bank_connections); 
     269    snprintf(statbuffer, sizeof statbuffer, "Bank Connections: %s", 
     270             dmi->memory_module[i].bank_connections); 
     271    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     272    menu->items_count++; 
     273 
     274    snprintf(buffer, sizeof buffer, "Type               : %s", 
     275             dmi->memory_module[i].type); 
     276    snprintf(statbuffer, sizeof statbuffer, "Type : %s", 
     277             dmi->memory_module[i].type); 
     278    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     279    menu->items_count++; 
     280 
     281    snprintf(buffer, sizeof buffer, "Current Speed      : %s", 
     282             dmi->memory_module[i].speed); 
     283    snprintf(statbuffer, sizeof statbuffer, "Current Speed : %s", 
     284             dmi->memory_module[i].speed); 
     285    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     286    menu->items_count++; 
     287 
     288    snprintf(buffer, sizeof buffer, "Installed Size     : %s", 
     289             dmi->memory_module[i].installed_size); 
     290    snprintf(statbuffer, sizeof statbuffer, "Installed Size : %s", 
     291             dmi->memory_module[i].installed_size); 
     292    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     293    menu->items_count++; 
     294 
     295    snprintf(buffer, sizeof buffer, "Enabled Size       : %s", 
     296             dmi->memory_module[i].enabled_size); 
     297    snprintf(statbuffer, sizeof statbuffer, "Enabled Size : %s", 
     298             dmi->memory_module[i].enabled_size); 
     299    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     300    menu->items_count++; 
     301 
     302    snprintf(buffer, sizeof buffer, "Error Status       : %s", 
     303             dmi->memory_module[i].error_status); 
     304    snprintf(statbuffer, sizeof statbuffer, "Error Status : %s", 
     305             dmi->memory_module[i].error_status); 
     306    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     307    menu->items_count++; 
    317308 
    318309} 
    319310 
    320311/* Compute the Memory menu */ 
    321 void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi, struct s_hardware *hardware) 
    322 { 
    323   char buffer[MENULEN + 1]; 
    324   int i=0; 
    325   int memory_count=0; 
    326  
    327   /* If memory type 17 is available */ 
    328   if (dmi->memory_count >0) { 
    329         memory_count=dmi->memory_count; 
     312void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi, 
     313                    struct s_hardware *hardware) 
     314{ 
     315    char buffer[MENULEN + 1]; 
     316    int i = 0; 
     317    int memory_count = 0; 
     318 
     319    /* If memory type 17 is available */ 
     320    if (dmi->memory_count > 0) { 
     321        memory_count = dmi->memory_count; 
    330322        for (i = 0; i < dmi->memory_count; i++) { 
    331                   compute_memory_module(&(menu->memory_sub_menu[i]), dmi, i); 
    332         } 
    333   } else if (dmi->memory_module_count >0) { 
    334         memory_count=dmi->memory_module_count; 
     323            compute_memory_module(&(menu->memory_sub_menu[i]), dmi, i); 
     324        } 
     325    } else if (dmi->memory_module_count > 0) { 
     326        memory_count = dmi->memory_module_count; 
    335327        /* Memory Type 17 isn't available, let's fallback on type 6 */ 
    336328        for (i = 0; i < dmi->memory_module_count; i++) { 
    337                   compute_memory_module_type6(&(menu->memory_sub_menu[i]), dmi, i); 
    338         } 
    339   } 
    340  
    341   compute_e820(&(menu->memory_sub_menu[++i])); 
    342   compute_e801(&(menu->memory_sub_menu[++i])); 
    343   compute_88(&(menu->memory_sub_menu[++i])); 
    344  
    345   menu->memory_menu.menu = add_menu(" Memory ", -1); 
    346   menu->memory_menu.items_count = 0; 
    347  
    348   snprintf(buffer, sizeof(buffer), " %lu MB detected ", 
    349         (hardware->detected_memory_size+(1<<9))>>10); 
    350   add_item(buffer, "Detected Memory", OPT_INACTIVE, NULL,menu->memory_sub_menu[0].menu); 
    351   menu->memory_menu.items_count++; 
    352  
    353   add_item("", "", OPT_SEP, "", 0); 
    354  
    355   if (memory_count==0) { 
     329            compute_memory_module_type6(&(menu->memory_sub_menu[i]), dmi, i); 
     330        } 
     331    } 
     332 
     333    compute_e820(&(menu->memory_sub_menu[++i])); 
     334    compute_e801(&(menu->memory_sub_menu[++i])); 
     335    compute_88(&(menu->memory_sub_menu[++i])); 
     336 
     337    menu->memory_menu.menu = add_menu(" Memory ", -1); 
     338    menu->memory_menu.items_count = 0; 
     339 
     340    snprintf(buffer, sizeof(buffer), " %lu MB detected ", 
     341             (hardware->detected_memory_size + (1 << 9)) >> 10); 
     342    add_item(buffer, "Detected Memory", OPT_INACTIVE, NULL, 
     343             menu->memory_sub_menu[0].menu); 
     344    menu->memory_menu.items_count++; 
     345 
     346    add_item("", "", OPT_SEP, "", 0); 
     347 
     348    if (memory_count == 0) { 
    356349        snprintf(buffer, sizeof buffer, " No memory bank detected "); 
    357350        add_item(buffer, "Memory Bank", OPT_INACTIVE, NULL, 
    358         menu->memory_sub_menu[1].menu); 
     351                 menu->memory_sub_menu[1].menu); 
    359352        menu->memory_menu.items_count++; 
    360   } else for (i = 0; i < memory_count; i++) { 
    361         snprintf(buffer, sizeof buffer, " Bank <%d> ", i); 
    362         add_item(buffer, "Memory Bank", OPT_SUBMENU, NULL, 
    363         menu->memory_sub_menu[i].menu); 
    364         menu->memory_menu.items_count++; 
    365   } 
    366  
    367   add_item("", "", OPT_SEP, "", 0); 
    368  
    369   snprintf(buffer, sizeof buffer, " e820 "); 
    370   add_item(buffer, "e820 mapping", OPT_SUBMENU, NULL, 
    371        menu->memory_sub_menu[++i].menu); 
    372   menu->memory_menu.items_count++; 
    373  
    374   snprintf(buffer, sizeof buffer, " e801 "); 
    375   add_item(buffer, "e801 information", OPT_SUBMENU, NULL, 
    376        menu->memory_sub_menu[++i].menu); 
    377   menu->memory_menu.items_count++; 
    378  
    379   snprintf(buffer, sizeof buffer, " 88 "); 
    380   add_item(buffer, "88 information", OPT_SUBMENU, NULL, 
    381        menu->memory_sub_menu[++i].menu); 
    382   menu->memory_menu.items_count++; 
    383  
    384   add_item("", "", OPT_SEP, "", 0); 
    385   printf("MENU: Memory menu done (%d items)\n", 
    386          menu->memory_menu.items_count); 
    387   add_item("Run Test", "Run Test", OPT_RUN, hardware->memtest_label, 0); 
    388 } 
     353    } else 
     354        for (i = 0; i < memory_count; i++) { 
     355            snprintf(buffer, sizeof buffer, " Bank <%d> ", i); 
     356            add_item(buffer, "Memory Bank", OPT_SUBMENU, NULL, 
     357                     menu->memory_sub_menu[i].menu); 
     358            menu->memory_menu.items_count++; 
     359        } 
     360 
     361    add_item("", "", OPT_SEP, "", 0); 
     362 
     363    snprintf(buffer, sizeof buffer, " e820 "); 
     364    add_item(buffer, "e820 mapping", OPT_SUBMENU, NULL, 
     365             menu->memory_sub_menu[++i].menu); 
     366    menu->memory_menu.items_count++; 
     367 
     368    snprintf(buffer, sizeof buffer, " e801 "); 
     369    add_item(buffer, "e801 information", OPT_SUBMENU, NULL, 
     370             menu->memory_sub_menu[++i].menu); 
     371    menu->memory_menu.items_count++; 
     372 
     373    snprintf(buffer, sizeof buffer, " 88 "); 
     374    add_item(buffer, "88 information", OPT_SUBMENU, NULL, 
     375             menu->memory_sub_menu[++i].menu); 
     376    menu->memory_menu.items_count++; 
     377 
     378    add_item("", "", OPT_SEP, "", 0); 
     379    printf("MENU: Memory menu done (%d items)\n", 
     380           menu->memory_menu.items_count); 
     381    add_item("Run Test", "Run Test", OPT_RUN, hardware->memtest_label, 0); 
     382} 
  • com32/hdt/hdt-menu-pci.c

    r8e7362 r990205  
    3131/* Dynamic submenu for pci devices */ 
    3232static void compute_pci_device(struct s_my_menu *menu, 
    33                                struct pci_device *pci_device, 
    34                                int pci_bus, int pci_slot, int pci_func, 
     33                               struct pci_device *pci_device, 
     34                               int pci_bus, int pci_slot, int pci_func, 
    3535                               struct s_hardware *hardware) 
    3636{ 
    37   char buffer[56]; 
    38   char statbuffer[STATLEN]; 
    39   char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
    40           MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
    41  
    42   menu->menu = add_menu(" Details ", -1); 
    43   menu->items_count = 0; 
    44   set_menu_pos(5, 17); 
    45  
    46   snprintf(buffer, sizeof buffer, "Vendor  : %s", 
    47      pci_device->dev_info->vendor_name); 
    48   snprintf(statbuffer, sizeof statbuffer, "Vendor Name: %s", 
    49      pci_device->dev_info->vendor_name); 
    50   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    51   menu->items_count++; 
    52  
    53   snprintf(buffer, sizeof buffer, "Product : %s", 
    54      pci_device->dev_info->product_name); 
    55   snprintf(statbuffer, sizeof statbuffer, "Product Name  %s", 
    56      pci_device->dev_info->product_name); 
    57   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    58   menu->items_count++; 
    59  
    60   snprintf(buffer, sizeof buffer, "Class   : %s", 
    61      pci_device->dev_info->class_name); 
    62   snprintf(statbuffer, sizeof statbuffer, "Class Name: %s", 
    63      pci_device->dev_info->class_name); 
    64   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    65   menu->items_count++; 
    66  
    67   snprintf(buffer, sizeof buffer, "Location: %02x:%02x.%01x", pci_bus, 
    68      pci_slot, pci_func); 
    69   snprintf(statbuffer, sizeof statbuffer, 
    70      "Location on the PCI Bus: %02x:%02x.%01x", pci_bus, pci_slot, 
    71      pci_func); 
    72   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    73   menu->items_count++; 
    74  
    75   snprintf(buffer, sizeof buffer, "PCI ID  : %04x:%04x[%04x:%04x]", 
    76      pci_device->vendor, pci_device->product, 
    77      pci_device->sub_vendor, pci_device->sub_product); 
    78   snprintf(statbuffer, sizeof statbuffer, 
    79      "vendor:product[sub_vendor:sub_product] : %04x:%04x[%04x:%04x]", 
    80      pci_device->vendor, pci_device->product, 
    81      pci_device->sub_vendor, pci_device->sub_product); 
    82   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    83   menu->items_count++; 
    84  
    85   if ((pci_device->dev_info->irq>0) && (pci_device->dev_info->irq<255)) { 
    86     snprintf(buffer, sizeof buffer,"IRQ     : %d", pci_device->dev_info->irq); 
    87     snprintf(statbuffer, sizeof statbuffer,"IRQ : %d", pci_device->dev_info->irq); 
    88     add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    89     menu->items_count++; 
    90   } 
    91  
    92   snprintf(buffer, sizeof buffer, "Latency : %d",pci_device->dev_info->latency); 
    93   snprintf(statbuffer,sizeof statbuffer,"Latency : %d",pci_device->dev_info->latency); 
    94   add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); 
    95   menu->items_count++; 
    96  
    97   memset(kernel_modules,0,sizeof(kernel_modules)); 
    98  
    99   if (pci_device->dev_info->linux_kernel_module_count > 1) { 
    100     for (int i = 0; 
    101          i < pci_device->dev_info->linux_kernel_module_count; i++) { 
    102       if (i > 0) { 
    103         strncat(kernel_modules, " | ", 3); 
    104       } 
    105       strncat(kernel_modules, 
    106         pci_device->dev_info->linux_kernel_module[i], 
    107         LINUX_KERNEL_MODULE_SIZE - 1); 
    108     } 
    109     snprintf(buffer, sizeof buffer, "Modules : %s", kernel_modules); 
    110     snprintf(statbuffer, sizeof statbuffer, "Kernel Modules: %s", 
    111        kernel_modules); 
    112   } else { 
    113     snprintf(buffer, sizeof buffer, "Module  : %s", 
    114        pci_device->dev_info->linux_kernel_module[0]); 
    115     snprintf(statbuffer, sizeof statbuffer, "Kernel Module: %s", 
    116        pci_device->dev_info->linux_kernel_module[0]); 
    117   } 
    118   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    119   menu->items_count++; 
    120  
    121   if (hardware->is_pxe_valid == true) { 
    122     if ((hardware->pxe.pci_device != NULL) 
    123        && (hardware->pxe.pci_device == pci_device)) { 
    124  
    125        snprintf(buffer,sizeof buffer,"MAC Addr: %s",hardware->pxe.mac_addr); 
    126        snprintf(statbuffer,sizeof statbuffer,"MAC Address : %s",hardware->pxe.mac_addr); 
    127        add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); 
    128        menu->items_count++; 
    129  
    130        snprintf(buffer,sizeof buffer,"PXE     : %s","Current Boot device"); 
    131        snprintf(statbuffer,sizeof statbuffer,"PXE : %s","Current Boot device"); 
    132        add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); 
    133        menu->items_count++; 
    134      } 
    135   } 
     37    char buffer[56]; 
     38    char statbuffer[STATLEN]; 
     39    char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
     40                        MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
     41 
     42    menu->menu = add_menu(" Details ", -1); 
     43    menu->items_count = 0; 
     44    set_menu_pos(5, 17); 
     45 
     46    snprintf(buffer, sizeof buffer, "Vendor  : %s", 
     47             pci_device->dev_info->vendor_name); 
     48    snprintf(statbuffer, sizeof statbuffer, "Vendor Name: %s", 
     49             pci_device->dev_info->vendor_name); 
     50    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     51    menu->items_count++; 
     52 
     53    snprintf(buffer, sizeof buffer, "Product : %s", 
     54             pci_device->dev_info->product_name); 
     55    snprintf(statbuffer, sizeof statbuffer, "Product Name  %s", 
     56             pci_device->dev_info->product_name); 
     57    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     58    menu->items_count++; 
     59 
     60    snprintf(buffer, sizeof buffer, "Class   : %s", 
     61             pci_device->dev_info->class_name); 
     62    snprintf(statbuffer, sizeof statbuffer, "Class Name: %s", 
     63             pci_device->dev_info->class_name); 
     64    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     65    menu->items_count++; 
     66 
     67    snprintf(buffer, sizeof buffer, "Location: %02x:%02x.%01x", pci_bus, 
     68             pci_slot, pci_func); 
     69    snprintf(statbuffer, sizeof statbuffer, 
     70             "Location on the PCI Bus: %02x:%02x.%01x", pci_bus, pci_slot, 
     71             pci_func); 
     72    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     73    menu->items_count++; 
     74 
     75    snprintf(buffer, sizeof buffer, "PCI ID  : %04x:%04x[%04x:%04x]", 
     76             pci_device->vendor, pci_device->product, 
     77             pci_device->sub_vendor, pci_device->sub_product); 
     78    snprintf(statbuffer, sizeof statbuffer, 
     79             "vendor:product[sub_vendor:sub_product] : %04x:%04x[%04x:%04x]", 
     80             pci_device->vendor, pci_device->product, 
     81             pci_device->sub_vendor, pci_device->sub_product); 
     82    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     83    menu->items_count++; 
     84 
     85    if ((pci_device->dev_info->irq > 0) && (pci_device->dev_info->irq < 255)) { 
     86        snprintf(buffer, sizeof buffer, "IRQ     : %d", 
     87                 pci_device->dev_info->irq); 
     88        snprintf(statbuffer, sizeof statbuffer, "IRQ : %d", 
     89                 pci_device->dev_info->irq); 
     90        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     91        menu->items_count++; 
     92    } 
     93 
     94    snprintf(buffer, sizeof buffer, "Latency : %d", 
     95             pci_device->dev_info->latency); 
     96    snprintf(statbuffer, sizeof statbuffer, "Latency : %d", 
     97             pci_device->dev_info->latency); 
     98    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     99    menu->items_count++; 
     100 
     101    memset(kernel_modules, 0, sizeof(kernel_modules)); 
     102 
     103    if (pci_device->dev_info->linux_kernel_module_count > 1) { 
     104        for (int i = 0; 
     105             i < pci_device->dev_info->linux_kernel_module_count; i++) { 
     106            if (i > 0) { 
     107                strncat(kernel_modules, " | ", 3); 
     108            } 
     109            strncat(kernel_modules, 
     110                    pci_device->dev_info->linux_kernel_module[i], 
     111                    LINUX_KERNEL_MODULE_SIZE - 1); 
     112        } 
     113        snprintf(buffer, sizeof buffer, "Modules : %s", kernel_modules); 
     114        snprintf(statbuffer, sizeof statbuffer, "Kernel Modules: %s", 
     115                 kernel_modules); 
     116    } else { 
     117        snprintf(buffer, sizeof buffer, "Module  : %s", 
     118                 pci_device->dev_info->linux_kernel_module[0]); 
     119        snprintf(statbuffer, sizeof statbuffer, "Kernel Module: %s", 
     120                 pci_device->dev_info->linux_kernel_module[0]); 
     121    } 
     122    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     123    menu->items_count++; 
     124 
     125    if (hardware->is_pxe_valid == true) { 
     126        if ((hardware->pxe.pci_device != NULL) 
     127            && (hardware->pxe.pci_device == pci_device)) { 
     128 
     129            snprintf(buffer, sizeof buffer, "MAC Addr: %s", 
     130                     hardware->pxe.mac_addr); 
     131            snprintf(statbuffer, sizeof statbuffer, "MAC Address : %s", 
     132                     hardware->pxe.mac_addr); 
     133            add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     134            menu->items_count++; 
     135 
     136            snprintf(buffer, sizeof buffer, "PXE     : %s", 
     137                     "Current Boot device"); 
     138            snprintf(statbuffer, sizeof statbuffer, "PXE : %s", 
     139                     "Current Boot device"); 
     140            add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     141            menu->items_count++; 
     142        } 
     143    } 
    136144} 
    137145 
     
    139147int compute_PCI(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware) 
    140148{ 
    141   int i = 0; 
    142   char menuname[255][MENULEN + 1]; 
    143   char infobar[255][STATLEN + 1]; 
    144   struct pci_device *pci_device; 
    145   char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
    146           MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
    147  
    148   /* For every detected pci device, compute its submenu */ 
    149   for_each_pci_func(pci_device, hardware->pci_domain) { 
    150     memset(kernel_modules, 0, sizeof kernel_modules); 
    151     for (int kmod = 0; 
    152          kmod < pci_device->dev_info->linux_kernel_module_count; 
    153          kmod++) { 
    154       if (kmod > 0) { 
    155         strncat(kernel_modules, " | ", 3); 
    156       } 
    157       strncat(kernel_modules, 
    158         pci_device->dev_info->linux_kernel_module[kmod], 
    159         LINUX_KERNEL_MODULE_SIZE - 1); 
    160     } 
    161     if (pci_device->dev_info->linux_kernel_module_count == 0) 
    162       strlcpy(kernel_modules, "unknown", 7); 
    163  
    164     compute_pci_device(&(hdt_menu->pci_sub_menu[i]), pci_device, 
    165            __pci_bus, __pci_slot, __pci_func, hardware); 
    166     snprintf(menuname[i], 59, "%s|%s", 
    167        pci_device->dev_info->vendor_name, 
    168        pci_device->dev_info->product_name); 
    169     snprintf(infobar[i], STATLEN, 
    170        "%02x:%02x.%01x # %s # ID:%04x:%04x[%04x:%04x] # Kmod:%s", 
    171        __pci_bus, __pci_slot, __pci_func, 
    172        pci_device->dev_info->class_name, pci_device->vendor, 
    173        pci_device->product, pci_device->sub_vendor, 
    174        pci_device->sub_product, kernel_modules); 
    175     i++; 
    176   } 
    177  
    178   hdt_menu->pci_menu.menu = add_menu(" PCI Devices ", -1); 
    179   hdt_menu->pci_menu.items_count = 0; 
    180   if (hardware->pci_ids_return_code == -ENOPCIIDS) { 
    181     add_item("The pci.ids file is missing", "Missing pci.ids file", 
    182        OPT_INACTIVE, NULL, 0); 
    183     add_item("PCI Device names  can't be computed.", 
    184        "Missing pci.ids file", OPT_INACTIVE, NULL, 0); 
    185     add_item("Please put one in same dir as hdt", 
    186        "Missing pci.ids file", OPT_INACTIVE, NULL, 0); 
    187     add_item("", "", OPT_SEP, "", 0); 
    188   } 
    189   for (int j = 0; j < i; j++) { 
    190     add_item(menuname[j], infobar[j], OPT_SUBMENU, NULL, 
    191        hdt_menu->pci_sub_menu[j].menu); 
    192     hdt_menu->pci_menu.items_count++; 
    193   } 
    194   printf("MENU: PCI menu done (%d items)\n", 
    195          hdt_menu->pci_menu.items_count); 
    196   return 0; 
     149    int i = 0; 
     150    char menuname[255][MENULEN + 1]; 
     151    char infobar[255][STATLEN + 1]; 
     152    struct pci_device *pci_device; 
     153    char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
     154                        MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
     155 
     156    /* For every detected pci device, compute its submenu */ 
     157    for_each_pci_func(pci_device, hardware->pci_domain) { 
     158        memset(kernel_modules, 0, sizeof kernel_modules); 
     159        for (int kmod = 0; 
     160             kmod < pci_device->dev_info->linux_kernel_module_count; kmod++) { 
     161            if (kmod > 0) { 
     162                strncat(kernel_modules, " | ", 3); 
     163            } 
     164            strncat(kernel_modules, 
     165                    pci_device->dev_info->linux_kernel_module[kmod], 
     166                    LINUX_KERNEL_MODULE_SIZE - 1); 
     167        } 
     168        if (pci_device->dev_info->linux_kernel_module_count == 0) 
     169            strlcpy(kernel_modules, "unknown", 7); 
     170 
     171        compute_pci_device(&(hdt_menu->pci_sub_menu[i]), pci_device, 
     172                           __pci_bus, __pci_slot, __pci_func, hardware); 
     173        snprintf(menuname[i], 59, "%s|%s", 
     174                 pci_device->dev_info->vendor_name, 
     175                 pci_device->dev_info->product_name); 
     176        snprintf(infobar[i], STATLEN, 
     177                 "%02x:%02x.%01x # %s # ID:%04x:%04x[%04x:%04x] # Kmod:%s", 
     178                 __pci_bus, __pci_slot, __pci_func, 
     179                 pci_device->dev_info->class_name, pci_device->vendor, 
     180                 pci_device->product, pci_device->sub_vendor, 
     181                 pci_device->sub_product, kernel_modules); 
     182        i++; 
     183    } 
     184 
     185    hdt_menu->pci_menu.menu = add_menu(" PCI Devices ", -1); 
     186    hdt_menu->pci_menu.items_count = 0; 
     187    if (hardware->pci_ids_return_code == -ENOPCIIDS) { 
     188        add_item("The pci.ids file is missing", "Missing pci.ids file", 
     189                 OPT_INACTIVE, NULL, 0); 
     190        add_item("PCI Device names  can't be computed.", 
     191                 "Missing pci.ids file", OPT_INACTIVE, NULL, 0); 
     192        add_item("Please put one in same dir as hdt", 
     193                 "Missing pci.ids file", OPT_INACTIVE, NULL, 0); 
     194        add_item("", "", OPT_SEP, "", 0); 
     195    } 
     196    for (int j = 0; j < i; j++) { 
     197        add_item(menuname[j], infobar[j], OPT_SUBMENU, NULL, 
     198                 hdt_menu->pci_sub_menu[j].menu); 
     199        hdt_menu->pci_menu.items_count++; 
     200    } 
     201    printf("MENU: PCI menu done (%d items)\n", hdt_menu->pci_menu.items_count); 
     202    return 0; 
    197203} 
  • com32/hdt/hdt-menu-processor.c

    r8ba991 r990205  
    3232void compute_processor(struct s_my_menu *menu, struct s_hardware *hardware) 
    3333{ 
    34   char buffer[SUBMENULEN + 1]; 
    35   char buffer1[SUBMENULEN + 1]; 
    36   char statbuffer[STATLEN + 1]; 
    37  
    38   menu->menu = add_menu(" Main Processor ", -1); 
    39   menu->items_count = 0; 
    40   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    41  
    42   snprintf(buffer, sizeof buffer, "Vendor    : %s", hardware->cpu.vendor); 
    43   snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", 
    44      hardware->cpu.vendor); 
    45   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    46   menu->items_count++; 
    47  
    48   snprintf(buffer, sizeof buffer, "Model     : %s", del_multi_spaces(hardware->cpu.model)); 
    49   snprintf(statbuffer, sizeof statbuffer, "Model: %s", 
    50      del_multi_spaces(hardware->cpu.model)); 
    51   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    52   menu->items_count++; 
    53  
    54   snprintf(buffer, sizeof buffer, "Vendor ID : %d", 
    55      hardware->cpu.vendor_id); 
    56   snprintf(statbuffer, sizeof statbuffer, "Vendor ID: %d", 
    57      hardware->cpu.vendor_id); 
    58   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    59   menu->items_count++; 
    60  
    61   snprintf(buffer, sizeof buffer, "Family ID : %d", hardware->cpu.family); 
    62   snprintf(statbuffer, sizeof statbuffer, "Family ID: %d", 
    63      hardware->cpu.family); 
    64   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    65   menu->items_count++; 
    66  
    67   snprintf(buffer, sizeof buffer, "Model  ID : %d", 
    68      hardware->cpu.model_id); 
    69   snprintf(statbuffer, sizeof statbuffer, "Model  ID: %d", 
    70      hardware->cpu.model_id); 
    71   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    72   menu->items_count++; 
    73  
    74   snprintf(buffer, sizeof buffer, "Stepping  : %d", 
    75      hardware->cpu.stepping); 
    76   snprintf(statbuffer, sizeof statbuffer, "Stepping: %d", 
    77      hardware->cpu.stepping); 
    78   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    79   menu->items_count++; 
    80  
    81   if (hardware->is_dmi_valid) { 
    82     snprintf(buffer, sizeof buffer, "FSB       : %d", 
    83        hardware->dmi.processor.external_clock); 
    84     snprintf(statbuffer, sizeof statbuffer, 
    85        "Front Side Bus (MHz): %d", 
    86        hardware->dmi.processor.external_clock); 
    87     add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    88     menu->items_count++; 
    89  
    90     snprintf(buffer, sizeof buffer, "Cur. Speed: %d", 
    91        hardware->dmi.processor.current_speed); 
    92     snprintf(statbuffer, sizeof statbuffer, 
    93        "Current Speed (MHz): %d", 
    94        hardware->dmi.processor.current_speed); 
    95     add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    96     menu->items_count++; 
    97  
    98     snprintf(buffer, sizeof buffer, "Max Speed : %d", 
    99        hardware->dmi.processor.max_speed); 
    100     snprintf(statbuffer, sizeof statbuffer, "Max Speed (MHz): %d", 
    101        hardware->dmi.processor.max_speed); 
    102     add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    103     menu->items_count++; 
    104  
    105     snprintf(buffer, sizeof buffer, "Upgrade   : %s", 
    106        hardware->dmi.processor.upgrade); 
    107     snprintf(statbuffer, sizeof statbuffer, "Upgrade: %s", 
    108        hardware->dmi.processor.upgrade); 
    109     add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    110     menu->items_count++; 
    111   } 
    112  
    113   if (hardware->cpu.flags.smp) { 
    114     snprintf(buffer, sizeof buffer, "SMP       : Yes"); 
    115     snprintf(statbuffer, sizeof statbuffer, "SMP: Yes"); 
    116   } else { 
    117     snprintf(buffer, sizeof buffer, "SMP       : No"); 
    118     snprintf(statbuffer, sizeof statbuffer, "SMP: No"); 
    119   } 
    120   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    121   menu->items_count++; 
    122  
    123   if (hardware->cpu.flags.lm) { 
    124     snprintf(buffer, sizeof buffer, "x86_64    : Yes"); 
    125     snprintf(statbuffer, sizeof statbuffer, 
    126        "x86_64 compatible processor: Yes"); 
    127   } else { 
    128     snprintf(buffer, sizeof buffer, "X86_64    : No"); 
    129     snprintf(statbuffer, sizeof statbuffer, 
    130        "X86_64 compatible processor: No"); 
    131   } 
    132   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    133   menu->items_count++; 
    134  
    135   buffer1[0] = '\0'; 
    136   if (hardware->cpu.flags.fpu) 
    137     strcat(buffer1, "fpu "); 
    138   if (hardware->cpu.flags.vme) 
    139     strcat(buffer1, "vme "); 
    140   if (hardware->cpu.flags.de) 
    141     strcat(buffer1, "de "); 
    142   if (hardware->cpu.flags.pse) 
    143     strcat(buffer1, "pse "); 
    144   if (hardware->cpu.flags.tsc) 
    145     strcat(buffer1, "tsc "); 
    146   if (hardware->cpu.flags.msr) 
    147     strcat(buffer1, "msr "); 
    148   if (hardware->cpu.flags.pae) 
    149     strcat(buffer1, "pae "); 
    150   snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
    151   snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
    152   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    153   menu->items_count++; 
    154  
    155   buffer1[0] = '\0'; 
    156   if (hardware->cpu.flags.mce) 
    157     strcat(buffer1, "mce "); 
    158   if (hardware->cpu.flags.cx8) 
    159     strcat(buffer1, "cx8 "); 
    160   if (hardware->cpu.flags.apic) 
    161     strcat(buffer1, "apic "); 
    162   if (hardware->cpu.flags.sep) 
    163     strcat(buffer1, "sep "); 
    164   if (hardware->cpu.flags.mtrr) 
    165     strcat(buffer1, "mtrr "); 
    166   if (hardware->cpu.flags.pge) 
    167     strcat(buffer1, "pge "); 
    168   if (hardware->cpu.flags.mca) 
    169     strcat(buffer1, "mca "); 
    170   snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
    171   snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
    172   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    173   menu->items_count++; 
    174  
    175   buffer1[0] = '\0'; 
    176   if (hardware->cpu.flags.cmov) 
    177     strcat(buffer1, "cmov "); 
    178   if (hardware->cpu.flags.pat) 
    179     strcat(buffer1, "pat "); 
    180   if (hardware->cpu.flags.pse_36) 
    181     strcat(buffer1, "pse_36 "); 
    182   if (hardware->cpu.flags.psn) 
    183     strcat(buffer1, "psn "); 
    184   if (hardware->cpu.flags.clflsh) 
    185     strcat(buffer1, "clflsh "); 
    186   snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
    187   snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
    188   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    189   menu->items_count++; 
    190  
    191   buffer1[0] = '\0'; 
    192   if (hardware->cpu.flags.dts) 
    193     strcat(buffer1, "dts "); 
    194   if (hardware->cpu.flags.acpi) 
    195     strcat(buffer1, "acpi "); 
    196   if (hardware->cpu.flags.mmx) 
    197     strcat(buffer1, "mmx "); 
    198   if (hardware->cpu.flags.sse) 
    199     strcat(buffer1, "sse "); 
    200   snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
    201   snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
    202   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    203   menu->items_count++; 
    204  
    205   buffer1[0] = '\0'; 
    206   if (hardware->cpu.flags.sse2) 
    207     strcat(buffer1, "sse2 "); 
    208   if (hardware->cpu.flags.ss) 
    209     strcat(buffer1, "ss "); 
    210   if (hardware->cpu.flags.htt) 
    211     strcat(buffer1, "ht "); 
    212   if (hardware->cpu.flags.acc) 
    213     strcat(buffer1, "acc "); 
    214   if (hardware->cpu.flags.syscall) 
    215     strcat(buffer1, "syscall "); 
    216   if (hardware->cpu.flags.mp) 
    217     strcat(buffer1, "mp "); 
    218   snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
    219   snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
    220   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    221   menu->items_count++; 
    222  
    223   buffer1[0] = '\0'; 
    224   if (hardware->cpu.flags.nx) 
    225     strcat(buffer1, "nx "); 
    226   if (hardware->cpu.flags.mmxext) 
    227     strcat(buffer1, "mmxext "); 
    228   if (hardware->cpu.flags.lm) 
    229     strcat(buffer1, "lm "); 
    230   if (hardware->cpu.flags.nowext) 
    231     strcat(buffer1, "3dnowext "); 
    232   if (hardware->cpu.flags.now) 
    233     strcat(buffer1, "3dnow! "); 
    234   if (hardware->cpu.flags.vmx) 
    235     strcat(buffer1, "vmx "); 
    236   if (hardware->cpu.flags.svm) 
    237     strcat(buffer1, "svm "); 
    238   snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
    239   snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
    240   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    241   menu->items_count++; 
    242  
    243   printf("MENU: Processor menu done (%d items)\n", menu->items_count); 
     34    char buffer[SUBMENULEN + 1]; 
     35    char buffer1[SUBMENULEN + 1]; 
     36    char statbuffer[STATLEN + 1]; 
     37 
     38    menu->menu = add_menu(" Main Processor ", -1); 
     39    menu->items_count = 0; 
     40    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     41 
     42    snprintf(buffer, sizeof buffer, "Vendor    : %s", hardware->cpu.vendor); 
     43    snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", hardware->cpu.vendor); 
     44    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     45    menu->items_count++; 
     46 
     47    snprintf(buffer, sizeof buffer, "Model     : %s", 
     48             del_multi_spaces(hardware->cpu.model)); 
     49    snprintf(statbuffer, sizeof statbuffer, "Model: %s", 
     50             del_multi_spaces(hardware->cpu.model)); 
     51    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     52    menu->items_count++; 
     53 
     54    snprintf(buffer, sizeof buffer, "Vendor ID : %d", hardware->cpu.vendor_id); 
     55    snprintf(statbuffer, sizeof statbuffer, "Vendor ID: %d", 
     56             hardware->cpu.vendor_id); 
     57    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     58    menu->items_count++; 
     59 
     60    snprintf(buffer, sizeof buffer, "Family ID : %d", hardware->cpu.family); 
     61    snprintf(statbuffer, sizeof statbuffer, "Family ID: %d", 
     62             hardware->cpu.family); 
     63    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     64    menu->items_count++; 
     65 
     66    snprintf(buffer, sizeof buffer, "Model  ID : %d", hardware->cpu.model_id); 
     67    snprintf(statbuffer, sizeof statbuffer, "Model  ID: %d", 
     68             hardware->cpu.model_id); 
     69    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     70    menu->items_count++; 
     71 
     72    snprintf(buffer, sizeof buffer, "Stepping  : %d", hardware->cpu.stepping); 
     73    snprintf(statbuffer, sizeof statbuffer, "Stepping: %d", 
     74             hardware->cpu.stepping); 
     75    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     76    menu->items_count++; 
     77 
     78    if (hardware->is_dmi_valid) { 
     79        snprintf(buffer, sizeof buffer, "FSB       : %d", 
     80                 hardware->dmi.processor.external_clock); 
     81        snprintf(statbuffer, sizeof statbuffer, 
     82                 "Front Side Bus (MHz): %d", 
     83                 hardware->dmi.processor.external_clock); 
     84        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     85        menu->items_count++; 
     86 
     87        snprintf(buffer, sizeof buffer, "Cur. Speed: %d", 
     88                 hardware->dmi.processor.current_speed); 
     89        snprintf(statbuffer, sizeof statbuffer, 
     90                 "Current Speed (MHz): %d", 
     91                 hardware->dmi.processor.current_speed); 
     92        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     93        menu->items_count++; 
     94 
     95        snprintf(buffer, sizeof buffer, "Max Speed : %d", 
     96                 hardware->dmi.processor.max_speed); 
     97        snprintf(statbuffer, sizeof statbuffer, "Max Speed (MHz): %d", 
     98                 hardware->dmi.processor.max_speed); 
     99        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     100        menu->items_count++; 
     101 
     102        snprintf(buffer, sizeof buffer, "Upgrade   : %s", 
     103                 hardware->dmi.processor.upgrade); 
     104        snprintf(statbuffer, sizeof statbuffer, "Upgrade: %s", 
     105                 hardware->dmi.processor.upgrade); 
     106        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     107        menu->items_count++; 
     108    } 
     109 
     110    if (hardware->cpu.flags.smp) { 
     111        snprintf(buffer, sizeof buffer, "SMP       : Yes"); 
     112        snprintf(statbuffer, sizeof statbuffer, "SMP: Yes"); 
     113    } else { 
     114        snprintf(buffer, sizeof buffer, "SMP       : No"); 
     115        snprintf(statbuffer, sizeof statbuffer, "SMP: No"); 
     116    } 
     117    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     118    menu->items_count++; 
     119 
     120    if (hardware->cpu.flags.lm) { 
     121        snprintf(buffer, sizeof buffer, "x86_64    : Yes"); 
     122        snprintf(statbuffer, sizeof statbuffer, 
     123                 "x86_64 compatible processor: Yes"); 
     124    } else { 
     125        snprintf(buffer, sizeof buffer, "X86_64    : No"); 
     126        snprintf(statbuffer, sizeof statbuffer, 
     127                 "X86_64 compatible processor: No"); 
     128    } 
     129    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     130    menu->items_count++; 
     131 
     132    buffer1[0] = '\0'; 
     133    if (hardware->cpu.flags.fpu) 
     134        strcat(buffer1, "fpu "); 
     135    if (hardware->cpu.flags.vme) 
     136        strcat(buffer1, "vme "); 
     137    if (hardware->cpu.flags.de) 
     138        strcat(buffer1, "de "); 
     139    if (hardware->cpu.flags.pse) 
     140        strcat(buffer1, "pse "); 
     141    if (hardware->cpu.flags.tsc) 
     142        strcat(buffer1, "tsc "); 
     143    if (hardware->cpu.flags.msr) 
     144        strcat(buffer1, "msr "); 
     145    if (hardware->cpu.flags.pae) 
     146        strcat(buffer1, "pae "); 
     147    snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
     148    snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
     149    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     150    menu->items_count++; 
     151 
     152    buffer1[0] = '\0'; 
     153    if (hardware->cpu.flags.mce) 
     154        strcat(buffer1, "mce "); 
     155    if (hardware->cpu.flags.cx8) 
     156        strcat(buffer1, "cx8 "); 
     157    if (hardware->cpu.flags.apic) 
     158        strcat(buffer1, "apic "); 
     159    if (hardware->cpu.flags.sep) 
     160        strcat(buffer1, "sep "); 
     161    if (hardware->cpu.flags.mtrr) 
     162        strcat(buffer1, "mtrr "); 
     163    if (hardware->cpu.flags.pge) 
     164        strcat(buffer1, "pge "); 
     165    if (hardware->cpu.flags.mca) 
     166        strcat(buffer1, "mca "); 
     167    snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
     168    snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
     169    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     170    menu->items_count++; 
     171 
     172    buffer1[0] = '\0'; 
     173    if (hardware->cpu.flags.cmov) 
     174        strcat(buffer1, "cmov "); 
     175    if (hardware->cpu.flags.pat) 
     176        strcat(buffer1, "pat "); 
     177    if (hardware->cpu.flags.pse_36) 
     178        strcat(buffer1, "pse_36 "); 
     179    if (hardware->cpu.flags.psn) 
     180        strcat(buffer1, "psn "); 
     181    if (hardware->cpu.flags.clflsh) 
     182        strcat(buffer1, "clflsh "); 
     183    snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
     184    snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
     185    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     186    menu->items_count++; 
     187 
     188    buffer1[0] = '\0'; 
     189    if (hardware->cpu.flags.dts) 
     190        strcat(buffer1, "dts "); 
     191    if (hardware->cpu.flags.acpi) 
     192        strcat(buffer1, "acpi "); 
     193    if (hardware->cpu.flags.mmx) 
     194        strcat(buffer1, "mmx "); 
     195    if (hardware->cpu.flags.sse) 
     196        strcat(buffer1, "sse "); 
     197    snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
     198    snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
     199    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     200    menu->items_count++; 
     201 
     202    buffer1[0] = '\0'; 
     203    if (hardware->cpu.flags.sse2) 
     204        strcat(buffer1, "sse2 "); 
     205    if (hardware->cpu.flags.ss) 
     206        strcat(buffer1, "ss "); 
     207    if (hardware->cpu.flags.htt) 
     208        strcat(buffer1, "ht "); 
     209    if (hardware->cpu.flags.acc) 
     210        strcat(buffer1, "acc "); 
     211    if (hardware->cpu.flags.syscall) 
     212        strcat(buffer1, "syscall "); 
     213    if (hardware->cpu.flags.mp) 
     214        strcat(buffer1, "mp "); 
     215    snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
     216    snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
     217    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     218    menu->items_count++; 
     219 
     220    buffer1[0] = '\0'; 
     221    if (hardware->cpu.flags.nx) 
     222        strcat(buffer1, "nx "); 
     223    if (hardware->cpu.flags.mmxext) 
     224        strcat(buffer1, "mmxext "); 
     225    if (hardware->cpu.flags.lm) 
     226        strcat(buffer1, "lm "); 
     227    if (hardware->cpu.flags.nowext) 
     228        strcat(buffer1, "3dnowext "); 
     229    if (hardware->cpu.flags.now) 
     230        strcat(buffer1, "3dnow! "); 
     231    if (hardware->cpu.flags.vmx) 
     232        strcat(buffer1, "vmx "); 
     233    if (hardware->cpu.flags.svm) 
     234        strcat(buffer1, "svm "); 
     235    snprintf(buffer, sizeof buffer, "Flags     : %s", buffer1); 
     236    snprintf(statbuffer, sizeof statbuffer, "Flags: %s", buffer1); 
     237    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     238    menu->items_count++; 
     239 
     240    printf("MENU: Processor menu done (%d items)\n", menu->items_count); 
    244241} 
  • com32/hdt/hdt-menu-pxe.c

    r3dd64d r990205  
    3232void compute_PXE(struct s_my_menu *menu, struct s_hardware *hardware) 
    3333{ 
    34   char buffer[SUBMENULEN + 1]; 
    35   char infobar[STATLEN + 1]; 
     34    char buffer[SUBMENULEN + 1]; 
     35    char infobar[STATLEN + 1]; 
    3636 
    37   if (hardware->is_pxe_valid == false) 
    38     return; 
     37    if (hardware->is_pxe_valid == false) 
     38        return; 
    3939 
    40   menu->menu = add_menu(" PXE ", -1); 
    41   menu->items_count = 0; 
    42   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     40    menu->menu = add_menu(" PXE ", -1); 
     41    menu->items_count = 0; 
     42    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    4343 
    44   struct s_pxe *p = &hardware->pxe; 
     44    struct s_pxe *p = &hardware->pxe; 
    4545 
    46   if ((hardware->pci_ids_return_code == -ENOPCIIDS) || (p->pci_device==NULL))  { 
    47     snprintf(buffer, sizeof buffer, "PCI Vendor    : %d", 
    48        p->vendor_id); 
    49     snprintf(infobar, sizeof infobar, "PCI Vendor    : %d", 
    50        p->vendor_id); 
     46    if ((hardware->pci_ids_return_code == -ENOPCIIDS) 
     47        || (p->pci_device == NULL)) { 
     48        snprintf(buffer, sizeof buffer, "PCI Vendor    : %d", p->vendor_id); 
     49        snprintf(infobar, sizeof infobar, "PCI Vendor    : %d", p->vendor_id); 
     50        add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
     51        menu->items_count++; 
     52 
     53        snprintf(buffer, sizeof buffer, "PCI Product   : %d", p->vendor_id); 
     54        snprintf(infobar, sizeof infobar, "PCI Product   : %d", p->vendor_id); 
     55        add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
     56        menu->items_count++; 
     57 
     58        snprintf(buffer, sizeof buffer, "PCI SubVendor  : %d", p->subvendor_id); 
     59        snprintf(infobar, sizeof infobar, "PCI SubVendor  : %d", 
     60                 p->subvendor_id); 
     61        add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
     62        menu->items_count++; 
     63 
     64        snprintf(buffer, sizeof buffer, "PCI SubProduct : %d", 
     65                 p->subproduct_id); 
     66        snprintf(infobar, sizeof infobar, "PCI SubProduct : %d", 
     67                 p->subproduct_id); 
     68        add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
     69        menu->items_count++; 
     70 
     71        snprintf(buffer, sizeof buffer, "PCI Revision   : %d", p->rev); 
     72        snprintf(infobar, sizeof infobar, "PCI Revision   : %d", p->rev); 
     73        add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
     74        menu->items_count++; 
     75 
     76        snprintf(buffer, sizeof buffer, 
     77                 "PCI Bus Pos.   : %02x:%02x.%02x", p->pci_bus, 
     78                 p->pci_dev, p->pci_func); 
     79        snprintf(infobar, sizeof infobar, 
     80                 "PCI Bus Pos.   : %02x:%02x.%02x", p->pci_bus, 
     81                 p->pci_dev, p->pci_func); 
     82        add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
     83        menu->items_count++; 
     84 
     85    } else { 
     86 
     87        snprintf(buffer, sizeof buffer, "Manufacturer : %s", 
     88                 p->pci_device->dev_info->vendor_name); 
     89        snprintf(infobar, sizeof infobar, "Manufacturer : %s", 
     90                 p->pci_device->dev_info->vendor_name); 
     91        add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
     92        menu->items_count++; 
     93 
     94        snprintf(buffer, sizeof buffer, "Product      : %s", 
     95                 p->pci_device->dev_info->product_name); 
     96        snprintf(infobar, sizeof infobar, "Product      : %s", 
     97                 p->pci_device->dev_info->product_name); 
     98        add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
     99        menu->items_count++; 
     100    } 
     101 
     102    snprintf(buffer, sizeof buffer, "MAC Address  : %s", p->mac_addr); 
     103    snprintf(infobar, sizeof infobar, "MAC Address  : %s", p->mac_addr); 
    51104    add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
    52105    menu->items_count++; 
    53106 
    54     snprintf(buffer, sizeof buffer, "PCI Product   : %d", 
    55        p->vendor_id); 
    56     snprintf(infobar, sizeof infobar, "PCI Product   : %d", 
    57        p->vendor_id); 
     107    snprintf(buffer, sizeof buffer, "IP Address   : %d.%d.%d.%d", 
     108             p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]); 
     109    snprintf(infobar, sizeof infobar, "IP Address   : %d.%d.%d.%d", 
     110             p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]); 
    58111    add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
    59112    menu->items_count++; 
    60113 
    61     snprintf(buffer, sizeof buffer, "PCI SubVendor  : %d", 
    62        p->subvendor_id); 
    63     snprintf(infobar, sizeof infobar, "PCI SubVendor  : %d", 
    64        p->subvendor_id); 
    65     add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
    66     menu->items_count++; 
    67  
    68     snprintf(buffer, sizeof buffer, "PCI SubProduct : %d", 
    69        p->subproduct_id); 
    70     snprintf(infobar, sizeof infobar, "PCI SubProduct : %d", 
    71        p->subproduct_id); 
    72     add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
    73     menu->items_count++; 
    74  
    75     snprintf(buffer, sizeof buffer, "PCI Revision   : %d", p->rev); 
    76     snprintf(infobar, sizeof infobar, "PCI Revision   : %d", 
    77        p->rev); 
    78     add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
    79     menu->items_count++; 
    80  
    81     snprintf(buffer, sizeof buffer, 
    82        "PCI Bus Pos.   : %02x:%02x.%02x", p->pci_bus, 
    83        p->pci_dev, p->pci_func); 
    84     snprintf(infobar, sizeof infobar, 
    85        "PCI Bus Pos.   : %02x:%02x.%02x", p->pci_bus, 
    86        p->pci_dev, p->pci_func); 
    87     add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
    88     menu->items_count++; 
    89  
    90   } else { 
    91  
    92     snprintf(buffer, sizeof buffer, "Manufacturer : %s", 
    93        p->pci_device->dev_info->vendor_name); 
    94     snprintf(infobar, sizeof infobar, "Manufacturer : %s", 
    95        p->pci_device->dev_info->vendor_name); 
    96     add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
    97     menu->items_count++; 
    98  
    99     snprintf(buffer, sizeof buffer, "Product      : %s", 
    100        p->pci_device->dev_info->product_name); 
    101     snprintf(infobar, sizeof infobar, "Product      : %s", 
    102        p->pci_device->dev_info->product_name); 
    103     add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
    104     menu->items_count++; 
    105   } 
    106  
    107   snprintf(buffer, sizeof buffer, "MAC Address  : %s", p->mac_addr); 
    108   snprintf(infobar, sizeof infobar, "MAC Address  : %s", p->mac_addr); 
    109   add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
    110   menu->items_count++; 
    111  
    112   snprintf(buffer, sizeof buffer, "IP Address   : %d.%d.%d.%d", 
    113      p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]); 
    114   snprintf(infobar, sizeof infobar, "IP Address   : %d.%d.%d.%d", 
    115      p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]); 
    116   add_item(buffer, infobar, OPT_INACTIVE, NULL, 0); 
    117   menu->items_count++; 
    118  
    119   printf("MENU: PXE menu done (%d items)\n", menu->items_count); 
     114    printf("MENU: PXE menu done (%d items)\n", menu->items_count); 
    120115} 
  • com32/hdt/hdt-menu-summary.c

    r06a7af r990205  
    3232void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware) 
    3333{ 
    34   char buffer[SUBMENULEN + 1]; 
    35   char statbuffer[STATLEN + 1]; 
     34    char buffer[SUBMENULEN + 1]; 
     35    char statbuffer[STATLEN + 1]; 
    3636 
    37   menu->menu = add_menu(" Summary ", -1); 
    38   menu->items_count = 0; 
     37    menu->menu = add_menu(" Summary ", -1); 
     38    menu->items_count = 0; 
    3939 
    40   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     40    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    4141 
    42   snprintf(buffer, sizeof buffer, "CPU Vendor    : %s", 
    43      hardware->cpu.vendor); 
    44   snprintf(statbuffer, sizeof statbuffer, "CPU Vendor: %s", 
    45      hardware->cpu.vendor); 
    46   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    47   menu->items_count++; 
    48  
    49   snprintf(buffer, sizeof buffer, "CPU Model     : %s", 
    50      hardware->cpu.model); 
    51   snprintf(statbuffer, sizeof statbuffer, "CPU Model: %s", 
    52      hardware->cpu.model); 
    53   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    54   menu->items_count++; 
    55  
    56   add_item("", "", OPT_SEP, "", 0); 
    57   if (hardware->is_dmi_valid == true) { 
    58  
    59     snprintf(buffer, sizeof buffer, "System Vendor : %s", 
    60        hardware->dmi.system.manufacturer); 
    61     snprintf(statbuffer, sizeof statbuffer, "System Vendor: %s", 
    62        hardware->dmi.system.manufacturer); 
     42    snprintf(buffer, sizeof buffer, "CPU Vendor    : %s", hardware->cpu.vendor); 
     43    snprintf(statbuffer, sizeof statbuffer, "CPU Vendor: %s", 
     44             hardware->cpu.vendor); 
    6345    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    6446    menu->items_count++; 
    6547 
    66     snprintf(buffer, sizeof buffer, "System Product: %s", 
    67        hardware->dmi.system.product_name); 
    68     snprintf(statbuffer, sizeof statbuffer, 
    69        "System Product Name: %s", 
    70        hardware->dmi.system.product_name); 
     48    snprintf(buffer, sizeof buffer, "CPU Model     : %s", hardware->cpu.model); 
     49    snprintf(statbuffer, sizeof statbuffer, "CPU Model: %s", 
     50             hardware->cpu.model); 
    7151    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    7252    menu->items_count++; 
    7353 
    74     snprintf(buffer, sizeof buffer, "System Serial : %s", 
    75        hardware->dmi.system.serial); 
     54    add_item("", "", OPT_SEP, "", 0); 
     55    if (hardware->is_dmi_valid == true) { 
     56 
     57        snprintf(buffer, sizeof buffer, "System Vendor : %s", 
     58                 hardware->dmi.system.manufacturer); 
     59        snprintf(statbuffer, sizeof statbuffer, "System Vendor: %s", 
     60                 hardware->dmi.system.manufacturer); 
     61        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     62        menu->items_count++; 
     63 
     64        snprintf(buffer, sizeof buffer, "System Product: %s", 
     65                 hardware->dmi.system.product_name); 
     66        snprintf(statbuffer, sizeof statbuffer, 
     67                 "System Product Name: %s", hardware->dmi.system.product_name); 
     68        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     69        menu->items_count++; 
     70 
     71        snprintf(buffer, sizeof buffer, "System Serial : %s", 
     72                 hardware->dmi.system.serial); 
     73        snprintf(statbuffer, sizeof statbuffer, 
     74                 "System Serial Number: %s", hardware->dmi.system.serial); 
     75        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     76        menu->items_count++; 
     77 
     78        add_item("", "", OPT_SEP, "", 0); 
     79 
     80        snprintf(buffer, sizeof buffer, "Bios Version  : %s", 
     81                 hardware->dmi.bios.version); 
     82        snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s", 
     83                 hardware->dmi.bios.version); 
     84        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     85        menu->items_count++; 
     86 
     87        snprintf(buffer, sizeof buffer, "Bios Release  : %s", 
     88                 hardware->dmi.bios.release_date); 
     89        snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s", 
     90                 hardware->dmi.bios.release_date); 
     91        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     92        menu->items_count++; 
     93    } 
     94 
     95    add_item("", "", OPT_SEP, "", 0); 
     96 
     97    snprintf(buffer, sizeof buffer, "Memory Size   : %lu MiB (%lu KiB)", 
     98             (hardware->detected_memory_size + (1 << 9)) >> 10, 
     99             hardware->detected_memory_size); 
    76100    snprintf(statbuffer, sizeof statbuffer, 
    77        "System Serial Number: %s", 
    78        hardware->dmi.system.serial); 
     101             "Detected Memory Size: %lu MiB (%lu KiB)", 
     102             (hardware->detected_memory_size + (1 << 9)) >> 10, 
     103             hardware->detected_memory_size); 
    79104    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    80105    menu->items_count++; 
     
    82107    add_item("", "", OPT_SEP, "", 0); 
    83108 
    84     snprintf(buffer, sizeof buffer, "Bios Version  : %s", 
    85        hardware->dmi.bios.version); 
    86     snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s", 
    87        hardware->dmi.bios.version); 
     109    snprintf(buffer, sizeof buffer, "Nb PCI Devices: %d", 
     110             hardware->nb_pci_devices); 
     111    snprintf(statbuffer, sizeof statbuffer, "Number of PCI Devices: %d", 
     112             hardware->nb_pci_devices); 
    88113    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    89114    menu->items_count++; 
    90115 
    91     snprintf(buffer, sizeof buffer, "Bios Release  : %s", 
    92        hardware->dmi.bios.release_date); 
    93     snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s", 
    94        hardware->dmi.bios.release_date); 
    95     add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    96     menu->items_count++; 
    97   } 
     116    if (hardware->is_pxe_valid == true) { 
     117        add_item("", "", OPT_SEP, "", 0); 
    98118 
    99   add_item("", "", OPT_SEP, "", 0); 
     119        struct s_pxe *p = &hardware->pxe; 
    100120 
    101   snprintf(buffer, sizeof buffer,   "Memory Size   : %lu MiB (%lu KiB)", 
    102        (hardware->detected_memory_size + (1<<9))>>10, 
    103        hardware->detected_memory_size); 
    104   snprintf(statbuffer, sizeof statbuffer, "Detected Memory Size: %lu MiB (%lu KiB)", 
    105        (hardware->detected_memory_size+(1<<9))>>10, hardware->detected_memory_size); 
    106   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    107   menu->items_count++; 
     121        snprintf(buffer, sizeof buffer, "PXE MAC Address: %s", p->mac_addr); 
     122        snprintf(statbuffer, sizeof statbuffer, "PXE MAC Address: %s", 
     123                 p->mac_addr); 
     124        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     125        menu->items_count++; 
    108126 
    109   add_item("", "", OPT_SEP, "", 0); 
     127        snprintf(buffer, sizeof buffer, "PXE IP Address : %d.%d.%d.%d", 
     128                 p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]); 
     129        snprintf(statbuffer, sizeof statbuffer, 
     130                 "PXE IP Address: %d.%d.%d.%d", p->ip_addr[0], 
     131                 p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]); 
     132        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     133        menu->items_count++; 
     134    } 
    110135 
    111   snprintf(buffer, sizeof buffer, "Nb PCI Devices: %d", 
    112      hardware->nb_pci_devices); 
    113   snprintf(statbuffer, sizeof statbuffer, "Number of PCI Devices: %d", 
    114      hardware->nb_pci_devices); 
    115   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    116     menu->items_count++; 
     136    if (hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) { 
     137        add_item("", "", OPT_SEP, "", 0); 
    117138 
    118   if (hardware->is_pxe_valid == true) { 
    119     add_item("", "", OPT_SEP, "", 0); 
     139        bool kmod = false; 
     140        struct pci_device *pci_device; 
     141        char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
     142                            MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
    120143 
    121     struct s_pxe *p = &hardware->pxe; 
     144        /* 
     145         * For every detected pci device, grab its kernel module to compute 
     146         * this submenu 
     147         */ 
     148        for_each_pci_func(pci_device, hardware->pci_domain) { 
     149            memset(kernel_modules, 0, sizeof kernel_modules); 
     150            for (int i = 0; 
     151                 i < pci_device->dev_info->linux_kernel_module_count; i++) { 
     152                if (i > 0) { 
     153                    strncat(kernel_modules, " | ", 3); 
     154                } 
     155                strncat(kernel_modules, 
     156                        pci_device->dev_info->linux_kernel_module[i], 
     157                        LINUX_KERNEL_MODULE_SIZE - 1); 
     158            } 
     159            /* No need to add unknown kernel modules */ 
     160            if (strlen(kernel_modules) > 0) { 
     161                snprintf(buffer, sizeof buffer, "%s (%s)", 
     162                         kernel_modules, pci_device->dev_info->class_name); 
     163                snprintf(statbuffer, sizeof statbuffer, 
     164                         "%04x:%04x %s : %s", 
     165                         pci_device->vendor, 
     166                         pci_device->product, 
     167                         pci_device->dev_info->vendor_name, 
     168                         pci_device->dev_info->product_name); 
    122169 
    123     snprintf(buffer, sizeof buffer, "PXE MAC Address: %s", 
    124        p->mac_addr); 
    125     snprintf(statbuffer, sizeof statbuffer, "PXE MAC Address: %s", 
    126        p->mac_addr); 
    127     add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    128     menu->items_count++; 
     170                add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     171                menu->items_count++; 
     172                kmod = true; 
     173            } 
     174        } 
     175    } 
    129176 
    130     snprintf(buffer, sizeof buffer, "PXE IP Address : %d.%d.%d.%d", 
    131        p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], 
    132        p->ip_addr[3]); 
    133     snprintf(statbuffer, sizeof statbuffer, 
    134        "PXE IP Address: %d.%d.%d.%d", p->ip_addr[0], 
    135        p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]); 
    136     add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    137     menu->items_count++; 
    138   } 
    139  
    140   if (hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) { 
    141     add_item("", "", OPT_SEP, "", 0); 
    142  
    143     bool kmod = false; 
    144     struct pci_device *pci_device; 
    145     char kernel_modules[LINUX_KERNEL_MODULE_SIZE * 
    146             MAX_KERNEL_MODULES_PER_PCI_DEVICE]; 
    147  
    148     /* 
    149      * For every detected pci device, grab its kernel module to compute 
    150      * this submenu 
    151      */ 
    152     for_each_pci_func(pci_device, hardware->pci_domain) { 
    153       memset(kernel_modules, 0, sizeof kernel_modules); 
    154       for (int i = 0; 
    155            i < 
    156            pci_device->dev_info->linux_kernel_module_count; 
    157            i++) { 
    158         if (i > 0) { 
    159           strncat(kernel_modules, " | ", 3); 
    160         } 
    161         strncat(kernel_modules, 
    162           pci_device->dev_info-> 
    163           linux_kernel_module[i], 
    164           LINUX_KERNEL_MODULE_SIZE - 1); 
    165       } 
    166       /* No need to add unknown kernel modules */ 
    167       if (strlen(kernel_modules) > 0) { 
    168         snprintf(buffer, sizeof buffer, "%s (%s)", 
    169            kernel_modules, 
    170            pci_device->dev_info->class_name); 
    171         snprintf(statbuffer, sizeof statbuffer, 
    172            "%04x:%04x %s : %s", 
    173            pci_device->vendor, 
    174            pci_device->product, 
    175            pci_device->dev_info->vendor_name, 
    176            pci_device->dev_info->product_name); 
    177  
    178         add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 
    179            0); 
    180         menu->items_count++; 
    181         kmod = true; 
    182       } 
    183     } 
    184   } 
    185  
    186   printf("MENU: Summary menu done (%d items)\n", menu->items_count); 
     177    printf("MENU: Summary menu done (%d items)\n", menu->items_count); 
    187178} 
  • com32/hdt/hdt-menu-syslinux.c

    r8e7362 r990205  
    3333void compute_syslinuxmenu(struct s_my_menu *menu, struct s_hardware *hardware) 
    3434{ 
    35   char syslinux_fs_menu[24]; 
    36   char buffer[SUBMENULEN + 1]; 
    37   char statbuffer[STATLEN + 1]; 
     35    char syslinux_fs_menu[24]; 
     36    char buffer[SUBMENULEN + 1]; 
     37    char statbuffer[STATLEN + 1]; 
    3838 
    39   memset(syslinux_fs_menu, 0, sizeof syslinux_fs_menu); 
     39    memset(syslinux_fs_menu, 0, sizeof syslinux_fs_menu); 
    4040 
    41   snprintf(syslinux_fs_menu, sizeof syslinux_fs_menu, " %s ", 
    42      hardware->syslinux_fs); 
    43   menu->menu = add_menu(syslinux_fs_menu, -1); 
    44   menu->items_count = 0; 
    45   set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     41    snprintf(syslinux_fs_menu, sizeof syslinux_fs_menu, " %s ", 
     42             hardware->syslinux_fs); 
     43    menu->menu = add_menu(syslinux_fs_menu, -1); 
     44    menu->items_count = 0; 
     45    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    4646 
    47   snprintf(buffer, sizeof buffer, "Bootloader : %s", 
    48      hardware->syslinux_fs); 
    49   snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s", 
    50      hardware->syslinux_fs); 
    51   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    52   menu->items_count++; 
     47    snprintf(buffer, sizeof buffer, "Bootloader : %s", hardware->syslinux_fs); 
     48    snprintf(statbuffer, sizeof statbuffer, "Bootloader: %s", 
     49             hardware->syslinux_fs); 
     50    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     51    menu->items_count++; 
    5352 
    54   snprintf(buffer, sizeof buffer, "Version    : %s", 
    55      hardware->sv->version_string + 2); 
    56   snprintf(statbuffer, sizeof statbuffer, "Version: %s", 
    57      hardware->sv->version_string + 2); 
    58   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    59   menu->items_count++; 
     53    snprintf(buffer, sizeof buffer, "Version    : %s", 
     54             hardware->sv->version_string + 2); 
     55    snprintf(statbuffer, sizeof statbuffer, "Version: %s", 
     56             hardware->sv->version_string + 2); 
     57    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     58    menu->items_count++; 
    6059 
    61   snprintf(buffer, sizeof buffer, "Version    : %u", 
    62      hardware->sv->version); 
    63   snprintf(statbuffer, sizeof statbuffer, "Version: %u", 
    64      hardware->sv->version); 
    65   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    66   menu->items_count++; 
     60    snprintf(buffer, sizeof buffer, "Version    : %u", hardware->sv->version); 
     61    snprintf(statbuffer, sizeof statbuffer, "Version: %u", 
     62             hardware->sv->version); 
     63    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     64    menu->items_count++; 
    6765 
    68   snprintf(buffer, sizeof buffer, "Max API    : %u", 
    69      hardware->sv->max_api); 
    70   snprintf(statbuffer, sizeof statbuffer, "Max API: %u", 
    71      hardware->sv->max_api); 
    72   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    73   menu->items_count++; 
     66    snprintf(buffer, sizeof buffer, "Max API    : %u", hardware->sv->max_api); 
     67    snprintf(statbuffer, sizeof statbuffer, "Max API: %u", 
     68             hardware->sv->max_api); 
     69    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     70    menu->items_count++; 
    7471 
    75   add_item("", "", OPT_SEP, "", 0); 
     72    add_item("", "", OPT_SEP, "", 0); 
    7673 
    77   snprintf(buffer, sizeof buffer, "%s", 
    78      hardware->sv->copyright_string + 1); 
    79   /* Remove the trailing LF in the copyright string to avoid scrolling */ 
    80   snprintf(statbuffer, sizeof statbuffer, "%s", 
    81      remove_trailing_lf(hardware->sv->copyright_string + 1)); 
    82   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    83   menu->items_count++; 
     74    snprintf(buffer, sizeof buffer, "%s", hardware->sv->copyright_string + 1); 
     75    /* Remove the trailing LF in the copyright string to avoid scrolling */ 
     76    snprintf(statbuffer, sizeof statbuffer, "%s", 
     77             remove_trailing_lf(hardware->sv->copyright_string + 1)); 
     78    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     79    menu->items_count++; 
    8480 
    85   printf("MENU: Syslinux menu done (%d items)\n", menu->items_count); 
     81    printf("MENU: Syslinux menu done (%d items)\n", menu->items_count); 
    8682} 
  • com32/hdt/hdt-menu-vesa.c

    r91d9f6 r990205  
    2929#include "hdt-menu.h" 
    3030 
     31/* Submenu for the vesa card */ 
     32static void compute_vesa_card(struct s_my_menu *menu, 
     33                              struct s_hardware *hardware) 
     34{ 
     35    char buffer[SUBMENULEN + 1]; 
     36    char statbuffer[STATLEN + 1]; 
    3137 
    32 /* Submenu for the vesa card */ 
    33 static void compute_vesa_card(struct s_my_menu *menu, struct s_hardware *hardware) { 
    34   char buffer[SUBMENULEN+1]; 
    35   char statbuffer[STATLEN+1]; 
     38    menu->menu = add_menu(" VESA Bios ", -1); 
     39    menu->items_count = 0; 
     40    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    3641 
    37    menu->menu = add_menu(" VESA Bios ",-1); 
    38    menu->items_count=0; 
    39    set_menu_pos(SUBMENU_Y,SUBMENU_X); 
     42    snprintf(buffer, sizeof buffer, "VESA Version: %d.%d", 
     43             hardware->vesa.major_version, hardware->vesa.minor_version); 
     44    snprintf(statbuffer, sizeof statbuffer, "Version: %d.%d", 
     45             hardware->vesa.major_version, hardware->vesa.minor_version); 
     46    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     47    menu->items_count++; 
    4048 
    41    snprintf(buffer,sizeof buffer,"VESA Version: %d.%d",hardware->vesa.major_version,hardware->vesa.minor_version); 
    42    snprintf(statbuffer,sizeof statbuffer,"Version: %d.%d",hardware->vesa.major_version,hardware->vesa.minor_version); 
    43    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); 
    44    menu->items_count++; 
     49    snprintf(buffer, sizeof buffer, "Vendor      : %s", hardware->vesa.vendor); 
     50    snprintf(statbuffer, sizeof statbuffer, "Vendor Name: %s", 
     51             hardware->vesa.vendor); 
     52    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     53    menu->items_count++; 
    4554 
    46    snprintf(buffer,sizeof buffer,"Vendor      : %s",hardware->vesa.vendor); 
    47    snprintf(statbuffer,sizeof statbuffer,"Vendor Name: %s",hardware->vesa.vendor); 
    48    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); 
    49    menu->items_count++; 
     55    snprintf(buffer, sizeof buffer, "Product     : %s", hardware->vesa.product); 
     56    snprintf(statbuffer, sizeof statbuffer, "Product Name: %s", 
     57             hardware->vesa.product); 
     58    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     59    menu->items_count++; 
    5060 
    51    snprintf(buffer,sizeof buffer,"Product     : %s",hardware->vesa.product); 
    52    snprintf(statbuffer,sizeof statbuffer,"Product Name: %s",hardware->vesa.product); 
    53    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); 
    54    menu->items_count++; 
     61    snprintf(buffer, sizeof buffer, "Product Rev.: %s", 
     62             hardware->vesa.product_revision); 
     63    snprintf(statbuffer, sizeof statbuffer, "Produt Revision: %s", 
     64             hardware->vesa.product_revision); 
     65    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     66    menu->items_count++; 
    5567 
    56    snprintf(buffer,sizeof buffer,"Product Rev.: %s",hardware->vesa.product_revision); 
    57    snprintf(statbuffer,sizeof statbuffer,"Produt Revision: %s",hardware->vesa.product_revision); 
    58    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); 
    59    menu->items_count++; 
     68    snprintf(buffer, sizeof buffer, "Software Rev: %d", 
     69             hardware->vesa.software_rev); 
     70    snprintf(statbuffer, sizeof statbuffer, "Software Revision: %d", 
     71             hardware->vesa.software_rev); 
     72    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     73    menu->items_count++; 
    6074 
    61    snprintf(buffer,sizeof buffer,"Software Rev: %d",hardware->vesa.software_rev); 
    62    snprintf(statbuffer,sizeof statbuffer,"Software Revision: %d",hardware->vesa.software_rev); 
    63    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); 
    64    menu->items_count++; 
    65  
    66    snprintf(buffer,sizeof buffer,"Memory (KB) : %d",hardware->vesa.total_memory*64); 
    67    snprintf(statbuffer,sizeof statbuffer,"Memory (KB): %d",hardware->vesa.total_memory*64); 
    68    add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); 
    69    menu->items_count++; 
     75    snprintf(buffer, sizeof buffer, "Memory (KB) : %d", 
     76             hardware->vesa.total_memory * 64); 
     77    snprintf(statbuffer, sizeof statbuffer, "Memory (KB): %d", 
     78             hardware->vesa.total_memory * 64); 
     79    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     80    menu->items_count++; 
    7081} 
    7182 
    7283/* Submenu for the vesa card */ 
    73 void compute_vesa_modes(struct s_my_menu *menu, struct s_hardware *hardware) { 
    74   char buffer[56]; 
    75   char statbuffer[STATLEN]; 
     84void compute_vesa_modes(struct s_my_menu *menu, struct s_hardware *hardware) 
     85{ 
     86    char buffer[56]; 
     87    char statbuffer[STATLEN]; 
    7688 
    77    menu->menu = add_menu(" VESA Modes ",-1); 
    78    menu->items_count=0; 
    79    set_menu_pos(SUBMENU_Y,SUBMENU_X); 
    80    for (int i=0;i<hardware->vesa.vmi_count;i++) { 
    81     struct vesa_mode_info *mi=&hardware->vesa.vmi[i].mi; 
    82     /* Sometimes, vesa bios reports 0x0 modes 
    83      * We don't need to display that ones */ 
    84     if ((mi->h_res==0) || (mi->v_res==0)) continue; 
    85     snprintf(buffer,sizeof buffer,"%4u x %4u x %2ubits vga=%3d", 
    86                  mi->h_res, mi->v_res, mi->bpp, hardware->vesa.vmi[i].mode+0x200); 
    87     snprintf(statbuffer,sizeof statbuffer,"%4ux%4ux%2ubits vga=%3d", 
    88                  mi->h_res, mi->v_res, mi->bpp, hardware->vesa.vmi[i].mode+0x200); 
    89     add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); 
    90     menu->items_count++; 
    91    } 
     89    menu->menu = add_menu(" VESA Modes ", -1); 
     90    menu->items_count = 0; 
     91    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     92    for (int i = 0; i < hardware->vesa.vmi_count; i++) { 
     93        struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi; 
     94        /* Sometimes, vesa bios reports 0x0 modes 
     95         * We don't need to display that ones */ 
     96        if ((mi->h_res == 0) || (mi->v_res == 0)) 
     97            continue; 
     98        snprintf(buffer, sizeof buffer, "%4u x %4u x %2ubits vga=%3d", 
     99                 mi->h_res, mi->v_res, mi->bpp, 
     100                 hardware->vesa.vmi[i].mode + 0x200); 
     101        snprintf(statbuffer, sizeof statbuffer, "%4ux%4ux%2ubits vga=%3d", 
     102                 mi->h_res, mi->v_res, mi->bpp, 
     103                 hardware->vesa.vmi[i].mode + 0x200); 
     104        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     105        menu->items_count++; 
     106    } 
    92107} 
    93108 
    94109/* Main VESA Menu*/ 
    95 int compute_VESA(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware) { 
    96  char buffer[15]; 
    97  compute_vesa_card(&hdt_menu->vesa_card_menu,hardware); 
    98  compute_vesa_modes(&hdt_menu->vesa_modes_menu,hardware); 
    99  hdt_menu->vesa_menu.menu = add_menu(" VESA ",-1); 
    100  hdt_menu->vesa_menu.items_count=0; 
     110int compute_VESA(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware) 
     111{ 
     112    char buffer[15]; 
     113    compute_vesa_card(&hdt_menu->vesa_card_menu, hardware); 
     114    compute_vesa_modes(&hdt_menu->vesa_modes_menu, hardware); 
     115    hdt_menu->vesa_menu.menu = add_menu(" VESA ", -1); 
     116    hdt_menu->vesa_menu.items_count = 0; 
    101117 
    102  add_item("VESA Bios","VESA Bios",OPT_SUBMENU,NULL,hdt_menu->vesa_card_menu.menu); 
    103  hdt_menu->vesa_menu.items_count++; 
    104  snprintf(buffer,sizeof buffer,"%s (%d)","Modes",hardware->vesa.vmi_count); 
    105  add_item(buffer,"VESA Modes",OPT_SUBMENU,NULL,hdt_menu->vesa_modes_menu.menu); 
    106  hdt_menu->vesa_menu.items_count++; 
    107  printf("MENU: VESA menu done (%d items)\n",hdt_menu->vesa_menu.items_count); 
    108  return 0; 
     118    add_item("VESA Bios", "VESA Bios", OPT_SUBMENU, NULL, 
     119             hdt_menu->vesa_card_menu.menu); 
     120    hdt_menu->vesa_menu.items_count++; 
     121    snprintf(buffer, sizeof buffer, "%s (%d)", "Modes", 
     122             hardware->vesa.vmi_count); 
     123    add_item(buffer, "VESA Modes", OPT_SUBMENU, NULL, 
     124             hdt_menu->vesa_modes_menu.menu); 
     125    hdt_menu->vesa_menu.items_count++; 
     126    printf("MENU: VESA menu done (%d items)\n", 
     127           hdt_menu->vesa_menu.items_count); 
     128    return 0; 
    109129} 
  • com32/hdt/hdt-menu-vpd.c

    r3058ef r990205  
    3434void compute_vpd(struct s_my_menu *menu, struct s_hardware *hardware) 
    3535{ 
    36         char buffer[SUBMENULEN + 1]; 
    37         char statbuffer[STATLEN + 1];   /* Status bar */ 
     36    char buffer[SUBMENULEN + 1]; 
     37    char statbuffer[STATLEN + 1];       /* Status bar */ 
    3838 
    39         menu->menu = add_menu(" VPD ", -1); 
    40         menu->items_count = 0; 
    41         set_menu_pos(SUBMENU_Y, SUBMENU_X); 
     39    menu->menu = add_menu(" VPD ", -1); 
     40    menu->items_count = 0; 
     41    set_menu_pos(SUBMENU_Y, SUBMENU_X); 
    4242 
    43         snprintf(buffer, sizeof buffer, "Address                  : %s", 
    44                  hardware->vpd.base_address); 
    45         snprintf(statbuffer, sizeof statbuffer, "Address: %s", 
    46                  hardware->cpu.vendor); 
     43    snprintf(buffer, sizeof buffer, "Address                  : %s", 
     44             hardware->vpd.base_address); 
     45    snprintf(statbuffer, sizeof statbuffer, "Address: %s", 
     46             hardware->cpu.vendor); 
     47    add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     48    menu->items_count++; 
     49 
     50    if (strlen(hardware->vpd.bios_build_id) > 0) { 
     51        snprintf(buffer, sizeof buffer, "Bios Build ID            : %s", 
     52                 hardware->vpd.bios_build_id); 
     53        snprintf(statbuffer, sizeof statbuffer, "Bios Build ID: %s", 
     54                 hardware->vpd.bios_build_id); 
    4755        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    4856        menu->items_count++; 
     57    } 
    4958 
    50         if (strlen(hardware->vpd.bios_build_id) > 0) { 
    51            snprintf(buffer, sizeof buffer, "Bios Build ID            : %s", 
    52                  hardware->vpd.bios_build_id); 
    53            snprintf(statbuffer, sizeof statbuffer, "Bios Build ID: %s", 
    54                  hardware->vpd.bios_build_id); 
    55            add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    56            menu->items_count++; 
    57         } 
     59    if (strlen(hardware->vpd.bios_release_date) > 0) { 
     60        snprintf(buffer, sizeof buffer, "Bios Release Date        : %s", 
     61                 hardware->vpd.bios_release_date); 
     62        snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s", 
     63                 hardware->vpd.bios_release_date); 
     64        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     65        menu->items_count++; 
     66    } 
    5867 
    59         if (strlen(hardware->vpd.bios_release_date) > 0) { 
    60            snprintf(buffer, sizeof buffer, "Bios Release Date        : %s", 
    61                  hardware->vpd.bios_release_date); 
    62            snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s", 
    63                  hardware->vpd.bios_release_date); 
    64            add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    65            menu->items_count++; 
    66         } 
     68    if (strlen(hardware->vpd.bios_version) > 0) { 
     69        snprintf(buffer, sizeof buffer, "Bios Version             : %s", 
     70                 hardware->vpd.bios_version); 
     71        snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s", 
     72                 hardware->vpd.bios_version); 
     73        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     74        menu->items_count++; 
     75    } 
    6776 
    68         if (strlen(hardware->vpd.bios_version) > 0) { 
    69            snprintf(buffer, sizeof buffer, "Bios Version             : %s", 
    70                  hardware->vpd.bios_version); 
    71            snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s", 
    72                  hardware->vpd.bios_version); 
    73            add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    74            menu->items_count++; 
    75         } 
     77    if (strlen(hardware->vpd.default_flash_filename) > 0) { 
     78        snprintf(buffer, sizeof buffer, "Default Flash Filename   : %s", 
     79                 hardware->vpd.default_flash_filename); 
     80        snprintf(statbuffer, sizeof statbuffer, "Default Flash Filename: %s", 
     81                 hardware->vpd.default_flash_filename); 
     82        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     83        menu->items_count++; 
     84    } 
    7685 
    77         if (strlen(hardware->vpd.default_flash_filename) > 0) { 
    78            snprintf(buffer, sizeof buffer, "Default Flash Filename   : %s", 
    79                  hardware->vpd.default_flash_filename); 
    80            snprintf(statbuffer, sizeof statbuffer, "Default Flash Filename: %s", 
    81                  hardware->vpd.default_flash_filename); 
    82            add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    83            menu->items_count++; 
    84         } 
     86    if (strlen(hardware->vpd.box_serial_number) > 0) { 
     87        snprintf(buffer, sizeof buffer, "Box Serial Number        : %s", 
     88                 hardware->vpd.box_serial_number); 
     89        snprintf(statbuffer, sizeof statbuffer, "Box Serial Number: %s", 
     90                 hardware->vpd.box_serial_number); 
     91        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     92        menu->items_count++; 
     93    } 
    8594 
    86         if (strlen(hardware->vpd.box_serial_number) > 0) { 
    87            snprintf(buffer, sizeof buffer, "Box Serial Number        : %s", 
    88                  hardware->vpd.box_serial_number); 
    89            snprintf(statbuffer, sizeof statbuffer, "Box Serial Number: %s", 
    90                  hardware->vpd.box_serial_number); 
    91            add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    92            menu->items_count++; 
    93         } 
     95    if (strlen(hardware->vpd.motherboard_serial_number) > 0) { 
     96        snprintf(buffer, sizeof buffer, "Motherboard Serial Number: %s", 
     97                 hardware->vpd.motherboard_serial_number); 
     98        snprintf(statbuffer, sizeof statbuffer, "Motherboard Serial Number: %s", 
     99                 hardware->vpd.motherboard_serial_number); 
     100        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     101        menu->items_count++; 
     102    } 
    94103 
    95         if (strlen(hardware->vpd.motherboard_serial_number) > 0) { 
    96            snprintf(buffer, sizeof buffer, "Motherboard Serial Number: %s", 
    97                  hardware->vpd.motherboard_serial_number); 
    98            snprintf(statbuffer, sizeof statbuffer, "Motherboard Serial Number: %s", 
    99                  hardware->vpd.motherboard_serial_number); 
    100            add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    101            menu->items_count++; 
    102         } 
     104    if (strlen(hardware->vpd.machine_type_model) > 0) { 
     105        snprintf(buffer, sizeof buffer, "Machine Type/Model       : %s", 
     106                 hardware->vpd.machine_type_model); 
     107        snprintf(statbuffer, sizeof statbuffer, "Machine Type/Model: %s", 
     108                 hardware->vpd.machine_type_model); 
     109        add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
     110        menu->items_count++; 
     111    } 
    103112 
    104         if (strlen(hardware->vpd.machine_type_model) > 0) { 
    105            snprintf(buffer, sizeof buffer, "Machine Type/Model       : %s", 
    106                  hardware->vpd.machine_type_model); 
    107            snprintf(statbuffer, sizeof statbuffer, "Machine Type/Model: %s", 
    108                  hardware->vpd.machine_type_model); 
    109            add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); 
    110            menu->items_count++; 
    111         } 
    112  
    113         printf("MENU: VPD menu done (%d items)\n", menu->items_count); 
     113    printf("MENU: VPD menu done (%d items)\n", menu->items_count); 
    114114} 
  • com32/hdt/hdt-menu.c

    rbb88c6 r990205  
    3333int start_menu_mode(struct s_hardware *hardware, char *version_string) 
    3434{ 
    35   struct s_hdt_menu hdt_menu; 
    36  
    37   memset(&hdt_menu, 0, sizeof(hdt_menu)); 
    38  
    39   /* Detect every kind of hardware */ 
    40   detect_hardware(hardware); 
    41  
    42   /* Setup the menu system */ 
    43   setup_menu(version_string); 
    44  
    45   /* Compute all submenus */ 
    46   compute_submenus(&hdt_menu, hardware); 
    47  
    48   /* Compute the main menu */ 
    49   compute_main_menu(&hdt_menu, hardware); 
     35    struct s_hdt_menu hdt_menu; 
     36 
     37    memset(&hdt_menu, 0, sizeof(hdt_menu)); 
     38 
     39    /* Detect every kind of hardware */ 
     40    detect_hardware(hardware); 
     41 
     42    /* Setup the menu system */ 
     43    setup_menu(version_string); 
     44 
     45    /* Compute all submenus */ 
     46    compute_submenus(&hdt_menu, hardware); 
     47 
     48    /* Compute the main menu */ 
     49    compute_main_menu(&hdt_menu, hardware); 
    5050 
    5151#ifdef WITH_MENU_DISPLAY 
    52   t_menuitem *curr; 
    53   char cmd[160]; 
    54  
    55   if (!quiet) 
    56       more_printf("Starting Menu (%d menus)\n", hdt_menu.total_menu_count); 
    57   curr = showmenus(hdt_menu.main_menu.menu); 
    58   /* When we exit the menu, do we have something to do? */ 
    59   if (curr) { 
    60     /* When want to execute something */ 
    61     if (curr->action == OPT_RUN) { 
    62       /* Tweak, we want to switch to the cli */ 
    63       if (!strncmp 
    64           (curr->data, HDT_SWITCH_TO_CLI, 
    65            sizeof(HDT_SWITCH_TO_CLI))) { 
    66         return HDT_RETURN_TO_CLI; 
    67       } 
    68       strcpy(cmd, curr->data); 
    69  
    70       /* Use specific syslinux call if needed */ 
    71       if (issyslinux()) 
    72         runsyslinuxcmd(cmd); 
    73       else 
    74         csprint(cmd, 0x07); 
    75       return 1; // Should not happen when run from SYSLINUX 
    76     } 
    77   } 
    78 #endif 
    79   return 0; 
     52    t_menuitem *curr; 
     53    char cmd[160]; 
     54 
     55    if (!quiet) 
     56        more_printf("Starting Menu (%d menus)\n", hdt_menu.total_menu_count); 
     57    curr = showmenus(hdt_menu.main_menu.menu); 
     58    /* When we exit the menu, do we have something to do? */ 
     59    if (curr) { 
     60        /* When want to execute something */ 
     61        if (curr->action == OPT_RUN) { 
     62            /* Tweak, we want to switch to the cli */ 
     63            if (!strncmp 
     64                (curr->data, HDT_SWITCH_TO_CLI, sizeof(HDT_SWITCH_TO_CLI))) { 
     65                return HDT_RETURN_TO_CLI; 
     66            } 
     67            strcpy(cmd, curr->data); 
     68 
     69            /* Use specific syslinux call if needed */ 
     70            if (issyslinux()) 
     71                runsyslinuxcmd(cmd); 
     72            else 
     73                csprint(cmd, 0x07); 
     74            return 1;           // Should not happen when run from SYSLINUX 
     75        } 
     76    } 
     77#endif 
     78    return 0; 
    8079} 
    8180 
     
    8382TIMEOUTCODE ontimeout() 
    8483{ 
    85   // beep(); 
    86   return CODE_WAIT; 
     84    // beep(); 
     85    return CODE_WAIT; 
    8786} 
    8887 
    8988/* Keyboard handler for the menu system */ 
    90 void keys_handler(t_menusystem * ms __attribute__ (( unused )), t_menuitem * mi, int scancode) 
    91 { 
    92   int nr, nc; 
    93  
    94   /* 0xFFFF is an invalid helpid */ 
    95   if (scancode == KEY_F1 && mi->helpid != 0xFFFF) { 
    96     runhelpsystem(mi->helpid); 
    97   } 
    98  
    99   /* 
    100    * If user hit TAB, and item is an "executable" item 
    101    * and user has privileges to edit it, edit it in place. 
    102    */ 
    103   if ((scancode == KEY_TAB) && (mi->action == OPT_RUN)) { 
     89void keys_handler(t_menusystem * ms 
     90                  __attribute__ ((unused)), t_menuitem * mi, int scancode) 
     91{ 
     92    int nr, nc; 
     93 
     94    /* 0xFFFF is an invalid helpid */ 
     95    if (scancode == KEY_F1 && mi->helpid != 0xFFFF) { 
     96        runhelpsystem(mi->helpid); 
     97    } 
     98 
     99    /* 
     100     * If user hit TAB, and item is an "executable" item 
     101     * and user has privileges to edit it, edit it in place. 
     102     */ 
     103    if ((scancode == KEY_TAB) && (mi->action == OPT_RUN)) { 
    104104//(isallowed(username,"editcmd") || isallowed(username,"root"))) { 
    105     if (getscreensize(1, &nr, &nc)) { 
    106         /* Unknown screen size? */ 
    107         nc = 80; 
    108         nr = 24; 
    109     } 
    110     /* User typed TAB and has permissions to edit command line */ 
    111     gotoxy(EDITPROMPT, 1); 
    112     csprint("Command line:", 0x07); 
    113     editstring(mi->data, ACTIONLEN); 
    114     gotoxy(EDITPROMPT, 1); 
    115     cprint(' ', 0x07, nc - 1); 
    116   } 
     105        if (getscreensize(1, &nr, &nc)) { 
     106            /* Unknown screen size? */ 
     107            nc = 80; 
     108            nr = 24; 
     109        } 
     110        /* User typed TAB and has permissions to edit command line */ 
     111        gotoxy(EDITPROMPT, 1); 
     112        csprint("Command line:", 0x07); 
     113        editstring(mi->data, ACTIONLEN); 
     114        gotoxy(EDITPROMPT, 1); 
     115        cprint(' ', 0x07, nc - 1); 
     116    } 
    117117} 
    118118 
     
    120120void setup_menu(char *version) 
    121121{ 
    122   /* Creating the menu */ 
    123   init_menusystem(version); 
    124   set_window_size(0, 0, 25, 80); 
    125  
    126   /* Do not use inactive attributes - they make little sense for HDT */ 
    127   set_normal_attr(-1, -1, 0x17, 0x1F); 
    128  
    129   /* Register the menusystem handler */ 
    130   // reg_handler(HDLR_SCREEN,&msys_handler); 
    131   reg_handler(HDLR_KEYS, &keys_handler); 
    132  
    133   /* Register the ontimeout handler, with a time out of 10 seconds */ 
    134   reg_ontimeout(ontimeout, 1000, 0); 
     122    /* Creating the menu */ 
     123    init_menusystem(version); 
     124    set_window_size(0, 0, 25, 80); 
     125 
     126    /* Do not use inactive attributes - they make little sense for HDT */ 
     127    set_normal_attr(-1, -1, 0x17, 0x1F); 
     128 
     129    /* Register the menusystem handler */ 
     130    // reg_handler(HDLR_SCREEN,&msys_handler); 
     131    reg_handler(HDLR_KEYS, &keys_handler); 
     132 
     133    /* Register the ontimeout handler, with a time out of 10 seconds */ 
     134    reg_ontimeout(ontimeout, 1000, 0); 
    135135} 
    136136 
     
    139139{ 
    140140 
    141   /* Compute this menu if a DMI table exists */ 
    142   if (hardware->is_dmi_valid) { 
    143     if (hardware->dmi.ipmi.filled == true) 
    144       compute_ipmi(&hdt_menu->ipmi_menu, &hardware->dmi); 
    145     if (hardware->dmi.base_board.filled == true) 
    146       compute_motherboard(&(hdt_menu->mobo_menu), 
    147               &(hardware->dmi)); 
    148     if (hardware->dmi.chassis.filled == true) 
    149       compute_chassis(&(hdt_menu->chassis_menu), 
    150           &(hardware->dmi)); 
    151     if (hardware->dmi.system.filled == true) 
    152       compute_system(&(hdt_menu->system_menu), 
    153                &(hardware->dmi)); 
    154     compute_memory(hdt_menu, &(hardware->dmi),hardware); 
    155     if (hardware->dmi.bios.filled == true) 
    156       compute_bios(&(hdt_menu->bios_menu), &(hardware->dmi)); 
    157     if (hardware->dmi.battery.filled == true) 
    158       compute_battery(&(hdt_menu->battery_menu), 
    159           &(hardware->dmi)); 
    160   } 
    161  
    162   compute_processor(&(hdt_menu->cpu_menu), hardware); 
    163   compute_vpd(&(hdt_menu->vpd_menu), hardware); 
    164   compute_disks(hdt_menu, hardware); 
     141    /* Compute this menu if a DMI table exists */ 
     142    if (hardware->is_dmi_valid) { 
     143        if (hardware->dmi.ipmi.filled == true) 
     144            compute_ipmi(&hdt_menu->ipmi_menu, &hardware->dmi); 
     145        if (hardware->dmi.base_board.filled == true) 
     146            compute_motherboard(&(hdt_menu->mobo_menu), &(hardware->dmi)); 
     147        if (hardware->dmi.chassis.filled == true) 
     148            compute_chassis(&(hdt_menu->chassis_menu), &(hardware->dmi)); 
     149        if (hardware->dmi.system.filled == true) 
     150            compute_system(&(hdt_menu->system_menu), &(hardware->dmi)); 
     151        compute_memory(hdt_menu, &(hardware->dmi), hardware); 
     152        if (hardware->dmi.bios.filled == true) 
     153            compute_bios(&(hdt_menu->bios_menu), &(hardware->dmi)); 
     154        if (hardware->dmi.battery.filled == true) 
     155            compute_battery(&(hdt_menu->battery_menu), &(hardware->dmi)); 
     156    } 
     157 
     158    compute_processor(&(hdt_menu->cpu_menu), hardware); 
     159    compute_vpd(&(hdt_menu->vpd_menu), hardware); 
     160    compute_disks(hdt_menu, hardware); 
    165161 
    166162#ifdef WITH_PCI 
    167   compute_PCI(hdt_menu, hardware); 
    168   compute_PXE(&(hdt_menu->pxe_menu), hardware); 
    169   compute_kernel(&(hdt_menu->kernel_menu), hardware); 
    170 #endif 
    171   compute_summarymenu(&(hdt_menu->summary_menu), hardware); 
    172   compute_syslinuxmenu(&(hdt_menu->syslinux_menu), hardware); 
    173   compute_VESA(hdt_menu,hardware); 
    174   compute_aboutmenu(&(hdt_menu->about_menu)); 
     163    compute_PCI(hdt_menu, hardware); 
     164    compute_PXE(&(hdt_menu->pxe_menu), hardware); 
     165    compute_kernel(&(hdt_menu->kernel_menu), hardware); 
     166#endif 
     167    compute_summarymenu(&(hdt_menu->summary_menu), hardware); 
     168    compute_syslinuxmenu(&(hdt_menu->syslinux_menu), hardware); 
     169    compute_VESA(hdt_menu, hardware); 
     170    compute_aboutmenu(&(hdt_menu->about_menu)); 
    175171} 
    176172 
    177173void compute_main_menu(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware) 
    178174{ 
    179   char menu_item[64]; 
    180   /* Let's count the number of menus we have */ 
    181   hdt_menu->total_menu_count = 0; 
    182   hdt_menu->main_menu.items_count = 0; 
    183  
    184   hdt_menu->main_menu.menu = add_menu(" Main Menu ", -1); 
    185   set_item_options(-1, 24); 
     175    char menu_item[64]; 
     176    /* Let's count the number of menus we have */ 
     177    hdt_menu->total_menu_count = 0; 
     178    hdt_menu->main_menu.items_count = 0; 
     179 
     180    hdt_menu->main_menu.menu = add_menu(" Main Menu ", -1); 
     181    set_item_options(-1, 24); 
    186182 
    187183#ifdef WITH_PCI 
    188   snprintf(menu_item, sizeof(menu_item), "PC<I> Devices(%2d)\n", 
    189      hardware->nb_pci_devices); 
    190   add_item(menu_item, "PCI Devices Menu", OPT_SUBMENU, NULL, 
    191      hdt_menu->pci_menu.menu); 
    192   hdt_menu->main_menu.items_count++; 
    193   hdt_menu->total_menu_count += hdt_menu->pci_menu.items_count; 
    194 #endif 
    195   if (hdt_menu->disk_menu.items_count > 0) { 
    196     snprintf(menu_item, sizeof(menu_item), "<D>isks      (%2d)\n", 
    197       hdt_menu->disk_menu.items_count); 
    198     add_item(menu_item, "Disks Menu", OPT_SUBMENU, NULL, 
    199       hdt_menu->disk_menu.menu); 
    200     hdt_menu->main_menu.items_count++; 
    201     hdt_menu->total_menu_count += hdt_menu->disk_menu.items_count; 
    202   } 
     184    snprintf(menu_item, sizeof(menu_item), "PC<I> Devices(%2d)\n", 
     185             hardware->nb_pci_devices); 
     186    add_item(menu_item, "PCI Devices Menu", OPT_SUBMENU, NULL, 
     187             hdt_menu->pci_menu.menu); 
     188    hdt_menu->main_menu.items_count++; 
     189    hdt_menu->total_menu_count += hdt_menu->pci_menu.items_count; 
     190#endif 
     191    if (hdt_menu->disk_menu.items_count > 0) { 
     192        snprintf(menu_item, sizeof(menu_item), "<D>isks      (%2d)\n", 
     193                hdt_menu->disk_menu.items_count); 
     194        add_item(menu_item, "Disks Menu", OPT_SUBMENU, NULL, 
     195                hdt_menu->disk_menu.menu); 
     196        hdt_menu->main_menu.items_count++; 
     197        hdt_menu->total_menu_count += hdt_menu->disk_menu.items_count; 
     198    } 
    203199 
    204200    snprintf(menu_item, sizeof(menu_item), "<M>emory\n"); 
    205201    add_item(menu_item, "Memory Menu", OPT_SUBMENU, NULL, 
    206        hdt_menu->memory_menu.menu); 
     202             hdt_menu->memory_menu.menu); 
    207203    hdt_menu->main_menu.items_count++; 
    208204    hdt_menu->total_menu_count += hdt_menu->memory_menu.items_count; 
    209205 
    210206    add_item("<P>rocessor", "Main Processor Menu", OPT_SUBMENU, NULL, 
    211      hdt_menu->cpu_menu.menu); 
    212   hdt_menu->main_menu.items_count++; 
    213  
    214   if (hardware->is_dmi_valid) { 
    215     if (hardware->dmi.base_board.filled == true) { 
    216       add_item("M<o>therboard", "Motherboard Menu", 
    217          OPT_SUBMENU, NULL, hdt_menu->mobo_menu.menu); 
    218       hdt_menu->main_menu.items_count++; 
    219     } 
    220  
    221     if (hardware->dmi.bios.filled == true) { 
    222       add_item("<B>ios", "Bios Menu", OPT_SUBMENU, NULL, 
    223          hdt_menu->bios_menu.menu); 
    224       hdt_menu->main_menu.items_count++; 
    225     } 
    226  
    227     if (hardware->dmi.chassis.filled == true) { 
    228       add_item("<C>hassis", "Chassis Menu", OPT_SUBMENU, NULL, 
    229          hdt_menu->chassis_menu.menu); 
    230       hdt_menu->main_menu.items_count++; 
    231     } 
    232  
    233     if (hardware->dmi.system.filled == true) { 
    234       add_item("<S>ystem", "System Menu", OPT_SUBMENU, NULL, 
    235          hdt_menu->system_menu.menu); 
    236       hdt_menu->main_menu.items_count++; 
    237     } 
    238  
    239     if (hardware->dmi.battery.filled == true) { 
    240       add_item("Ba<t>tery", "Battery Menu", OPT_SUBMENU, NULL, 
    241          hdt_menu->battery_menu.menu); 
    242       hdt_menu->main_menu.items_count++; 
    243     } 
    244     if (hardware->dmi.ipmi.filled == true) { 
    245       add_item("I<P>MI", "IPMI Menu", OPT_SUBMENU, NULL, 
    246          hdt_menu->ipmi_menu.menu); 
    247       hdt_menu->main_menu.items_count++; 
    248     } 
    249   } 
    250  
    251  if (hardware->is_vpd_valid == true) { 
    252    add_item("<V>PD","VPD Information Menu", OPT_SUBMENU, NULL, 
    253       hdt_menu->vpd_menu.menu); 
    254    hdt_menu->main_menu.items_count++; 
    255   } 
    256  
    257   if (hardware->is_pxe_valid == true) { 
    258     add_item("P<X>E", "PXE Information Menu", OPT_SUBMENU, NULL, 
    259       hdt_menu->pxe_menu.menu); 
    260     hdt_menu->main_menu.items_count++; 
    261   } 
    262  
    263  if (hardware->is_vesa_valid == true) { 
    264    add_item("<V>ESA","VESA Information Menu", OPT_SUBMENU, NULL, 
    265       hdt_menu->vesa_menu.menu); 
    266    hdt_menu->main_menu.items_count++; 
    267   } 
    268  
    269   add_item("", "", OPT_SEP, "", 0); 
     207             hdt_menu->cpu_menu.menu); 
     208    hdt_menu->main_menu.items_count++; 
     209 
     210    if (hardware->is_dmi_valid) { 
     211        if (hardware->dmi.base_board.filled == true) { 
     212            add_item("M<o>therboard", "Motherboard Menu", 
     213                     OPT_SUBMENU, NULL, hdt_menu->mobo_menu.menu); 
     214            hdt_menu->main_menu.items_count++; 
     215        } 
     216 
     217        if (hardware->dmi.bios.filled == true) { 
     218            add_item("<B>ios", "Bios Menu", OPT_SUBMENU, NULL, 
     219                     hdt_menu->bios_menu.menu); 
     220            hdt_menu->main_menu.items_count++; 
     221        } 
     222 
     223        if (hardware->dmi.chassis.filled == true) { 
     224            add_item("<C>hassis", "Chassis Menu", OPT_SUBMENU, NULL, 
     225                     hdt_menu->chassis_menu.menu); 
     226            hdt_menu->main_menu.items_count++; 
     227        } 
     228 
     229        if (hardware->dmi.system.filled == true) { 
     230            add_item("<S>ystem", "System Menu", OPT_SUBMENU, NULL, 
     231                     hdt_menu->system_menu.menu); 
     232            hdt_menu->main_menu.items_count++; 
     233        } 
     234 
     235        if (hardware->dmi.battery.filled == true) { 
     236            add_item("Ba<t>tery", "Battery Menu", OPT_SUBMENU, NULL, 
     237                     hdt_menu->battery_menu.menu); 
     238            hdt_menu->main_menu.items_count++; 
     239        } 
     240        if (hardware->dmi.ipmi.filled == true) { 
     241            add_item("I<P>MI", "IPMI Menu", OPT_SUBMENU, NULL, 
     242                     hdt_menu->ipmi_menu.menu); 
     243            hdt_menu->main_menu.items_count++; 
     244        } 
     245    } 
     246 
     247    if (hardware->is_vpd_valid == true) { 
     248        add_item("<V>PD", "VPD Information Menu", OPT_SUBMENU, NULL, 
     249                hdt_menu->vpd_menu.menu); 
     250        hdt_menu->main_menu.items_count++; 
     251    } 
     252 
     253    if (hardware->is_pxe_valid == true) { 
     254        add_item("P<X>E", "PXE Information Menu", OPT_SUBMENU, NULL, 
     255                hdt_menu->pxe_menu.menu); 
     256        hdt_menu->main_menu.items_count++; 
     257    } 
     258 
     259    if (hardware->is_vesa_valid == true) { 
     260        add_item("<V>ESA", "VESA Information Menu", OPT_SUBMENU, NULL, 
     261                hdt_menu->vesa_menu.menu); 
     262        hdt_menu->main_menu.items_count++; 
     263    } 
     264 
     265    add_item("", "", OPT_SEP, "", 0); 
    270266#ifdef WITH_PCI 
    271   if ((hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) || 
    272       (hardware->modules_alias_return_code != -ENOMODULESALIAS)) { 
    273     add_item("<K>ernel Modules", "Kernel Modules Menu", OPT_SUBMENU, 
    274       NULL, hdt_menu->kernel_menu.menu); 
    275     hdt_menu->main_menu.items_count++; 
    276   } 
    277 #endif 
    278   add_item("S<y>slinux", "Syslinux Information Menu", OPT_SUBMENU, NULL, 
    279      hdt_menu->syslinux_menu.menu); 
    280   hdt_menu->main_menu.items_count++; 
    281   add_item("S<u>mmary", "Summary Information Menu", OPT_SUBMENU, NULL, 
    282      hdt_menu->summary_menu.menu); 
    283   hdt_menu->main_menu.items_count++; 
    284  
    285   add_item("", "", OPT_SEP, "", 0); 
    286  
    287   add_item("S<w>itch to CLI", "Switch to Command Line", OPT_RUN, 
    288      HDT_SWITCH_TO_CLI, 0); 
    289   add_item("<A>bout", "About Menu", OPT_SUBMENU, NULL, 
    290      hdt_menu->about_menu.menu); 
    291   add_item("<R>eboot", "Reboot", OPT_RUN, hardware->reboot_label, 0); 
    292   add_item("E<x>it","Exit", OPT_EXITMENU,NULL,0); 
    293   hdt_menu->main_menu.items_count++; 
    294  
    295   hdt_menu->total_menu_count += hdt_menu->main_menu.items_count; 
     267    if ((hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) || 
     268        (hardware->modules_alias_return_code != -ENOMODULESALIAS)) { 
     269        add_item("<K>ernel Modules", "Kernel Modules Menu", OPT_SUBMENU, 
     270                NULL, hdt_menu->kernel_menu.menu); 
     271        hdt_menu->main_menu.items_count++; 
     272    } 
     273#endif 
     274    add_item("S<y>slinux", "Syslinux Information Menu", OPT_SUBMENU, NULL, 
     275             hdt_menu->syslinux_menu.menu); 
     276    hdt_menu->main_menu.items_count++; 
     277    add_item("S<u>mmary", "Summary Information Menu", OPT_SUBMENU, NULL, 
     278             hdt_menu->summary_menu.menu); 
     279    hdt_menu->main_menu.items_count++; 
     280 
     281    add_item("", "", OPT_SEP, "", 0); 
     282 
     283    add_item("S<w>itch to CLI", "Switch to Command Line", OPT_RUN, 
     284             HDT_SWITCH_TO_CLI, 0); 
     285    add_item("<A>bout", "About Menu", OPT_SUBMENU, NULL, 
     286             hdt_menu->about_menu.menu); 
     287    add_item("<R>eboot", "Reboot", OPT_RUN, hardware->reboot_label, 0); 
     288    add_item("E<x>it", "Exit", OPT_EXITMENU, NULL, 0); 
     289    hdt_menu->main_menu.items_count++; 
     290 
     291    hdt_menu->total_menu_count += hdt_menu->main_menu.items_count; 
    296292} 
    297293 
    298294void detect_hardware(struct s_hardware *hardware) 
    299295{ 
    300   if (!quiet) 
    301       more_printf("MEMORY: Detecting\n"); 
    302   hardware->detected_memory_size = detect_memsize(); 
    303  
    304   if (!quiet) 
    305       more_printf("DMI: Detecting Table\n"); 
    306   if (detect_dmi(hardware) == -ENODMITABLE) { 
    307     printf("DMI: ERROR ! Table not found ! \n"); 
    308     printf 
    309         ("DMI: Many hardware components will not be detected ! \n"); 
    310   } else { 
    311       if (!quiet) 
    312           more_printf("DMI: Table found ! (version %u.%u)\n", 
    313                  hardware->dmi.dmitable.major_version, 
    314                  hardware->dmi.dmitable.minor_version); 
    315   } 
    316  
    317   if (!quiet) 
    318       more_printf("CPU: Detecting\n"); 
    319   cpu_detect(hardware); 
    320  
    321   if (!quiet) 
    322       more_printf("DISKS: Detecting\n"); 
    323   detect_disks(hardware); 
    324  
    325   if (!quiet) 
    326       more_printf("VPD: Detecting\n"); 
    327   detect_vpd(hardware); 
     296    if (!quiet) 
     297        more_printf("MEMORY: Detecting\n"); 
     298    hardware->detected_memory_size = detect_memsize(); 
     299 
     300    if (!quiet) 
     301        more_printf("DMI: Detecting Table\n"); 
     302    if (detect_dmi(hardware) == -ENODMITABLE) { 
     303        printf("DMI: ERROR ! Table not found ! \n"); 
     304        printf("DMI: Many hardware components will not be detected ! \n"); 
     305    } else { 
     306        if (!quiet) 
     307            more_printf("DMI: Table found ! (version %u.%u)\n", 
     308                        hardware->dmi.dmitable.major_version, 
     309                        hardware->dmi.dmitable.minor_version); 
     310    } 
     311 
     312    if (!quiet) 
     313        more_printf("CPU: Detecting\n"); 
     314    cpu_detect(hardware); 
     315 
     316    if (!quiet) 
     317        more_printf("DISKS: Detecting\n"); 
     318    detect_disks(hardware); 
     319 
     320    if (!quiet) 
     321        more_printf("VPD: Detecting\n"); 
     322    detect_vpd(hardware); 
    328323 
    329324#ifdef WITH_PCI 
    330   detect_pci(hardware); 
    331   if (!quiet) 
    332       more_printf("PCI: %d Devices Found\n", hardware->nb_pci_devices); 
    333 #endif 
    334   if (!quiet) 
    335       more_printf("VESA: Detecting\n"); 
    336   detect_vesa(hardware); 
    337 } 
     325    detect_pci(hardware); 
     326    if (!quiet) 
     327        more_printf("PCI: %d Devices Found\n", hardware->nb_pci_devices); 
     328#endif 
     329    if (!quiet) 
     330        more_printf("VESA: Detecting\n"); 
     331    detect_vesa(hardware); 
     332} 
  • com32/hdt/hdt-menu.h

    r47ac91 r990205  
    5252 
    5353struct s_my_menu { 
    54   unsigned char menu; 
    55   int items_count; 
     54    unsigned char menu; 
     55    int items_count; 
    5656}; 
    5757 
    5858struct s_hdt_menu { 
    59   struct s_my_menu main_menu; 
    60   struct s_my_menu cpu_menu; 
    61   struct s_my_menu mobo_menu; 
    62   struct s_my_menu chassis_menu; 
    63   struct s_my_menu bios_menu; 
    64   struct s_my_menu ipmi_menu; 
    65   struct s_my_menu system_menu; 
    66   struct s_my_menu pci_menu; 
    67   struct s_my_menu pci_sub_menu[MAX_PCI_SUB_MENU]; 
    68   struct s_my_menu kernel_menu; 
    69   struct s_my_menu memory_menu; 
    70   struct s_my_menu memory_sub_menu[MAX_MEMORY_SUB_MENU]; 
    71   struct s_my_menu disk_menu; 
    72   struct s_my_menu disk_sub_menu[MAX_DISK_SUB_MENU]; 
    73   struct s_my_menu battery_menu; 
    74   struct s_my_menu syslinux_menu; 
    75   struct s_my_menu about_menu; 
    76   struct s_my_menu summary_menu; 
    77   struct s_my_menu pxe_menu; 
    78   struct s_my_menu vesa_menu; 
    79   struct s_my_menu vesa_card_menu; 
    80   struct s_my_menu vesa_modes_menu; 
    81   struct s_my_menu vpd_menu; 
    82   int total_menu_count; // Sum of all menus we have 
     59    struct s_my_menu main_menu; 
     60    struct s_my_menu cpu_menu; 
     61    struct s_my_menu mobo_menu; 
     62    struct s_my_menu chassis_menu; 
     63    struct s_my_menu bios_menu; 
     64    struct s_my_menu ipmi_menu; 
     65    struct s_my_menu system_menu; 
     66    struct s_my_menu pci_menu; 
     67    struct s_my_menu pci_sub_menu[MAX_PCI_SUB_MENU]; 
     68    struct s_my_menu kernel_menu; 
     69    struct s_my_menu memory_menu; 
     70    struct s_my_menu memory_sub_menu[MAX_MEMORY_SUB_MENU]; 
     71    struct s_my_menu disk_menu; 
     72    struct s_my_menu disk_sub_menu[MAX_DISK_SUB_MENU]; 
     73    struct s_my_menu battery_menu; 
     74    struct s_my_menu syslinux_menu; 
     75    struct s_my_menu about_menu; 
     76    struct s_my_menu summary_menu; 
     77    struct s_my_menu pxe_menu; 
     78    struct s_my_menu vesa_menu; 
     79    struct s_my_menu vesa_card_menu; 
     80    struct s_my_menu vesa_modes_menu; 
     81    struct s_my_menu vpd_menu; 
     82    int total_menu_count;       // Sum of all menus we have 
    8383}; 
    8484 
    8585TIMEOUTCODE ontimeout(); 
    86 void keys_handler(t_menusystem * ms __attribute__ (( unused )), t_menuitem * mi, int scancode); 
     86void keys_handler(t_menusystem * ms 
     87                  __attribute__ ((unused)), t_menuitem * mi, int scancode); 
    8788 
    8889// PCI Stuff 
     
    101102void compute_chassis(struct s_my_menu *menu, s_dmi * dmi); 
    102103void compute_bios(struct s_my_menu *menu, s_dmi * dmi); 
    103 void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi, struct s_hardware *hardware); 
     104void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi, 
     105                    struct s_hardware *hardware); 
    104106void compute_ipmi(struct s_my_menu *menu, s_dmi * dmi); 
    105107 
     
    128130void setup_menu(char *version); 
    129131void compute_main_menu(struct s_hdt_menu *hdt_menu, 
    130                        struct s_hardware *hardware); 
     132                       struct s_hardware *hardware); 
    131133void compute_submenus(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware); 
    132134void detect_hardware(struct s_hardware *hardware); 
  • com32/hdt/hdt-util.c

    r43de53 r990205  
    3232void sectors_to_size(int sectors, char *buffer) 
    3333{ 
    34         int b = (sectors / 2); 
    35         int mib = b >> 10; 
    36         int gib = mib >> 10; 
    37         int tib = gib >> 10; 
     34    int b = (sectors / 2); 
     35    int mib = b >> 10; 
     36    int gib = mib >> 10; 
     37    int tib = gib >> 10; 
    3838 
    39         if (tib > 0) 
    40                 sprintf(buffer, "%3d TiB", tib); 
    41         else if (gib > 0) 
    42                 sprintf(buffer, "%3d GiB", gib); 
    43         else if (mib > 0) 
    44                 sprintf(buffer, "%3d MiB", mib); 
    45         else 
    46                 sprintf(buffer, "%d b", b); 
     39    if (tib > 0) 
     40        sprintf(buffer, "%3d TiB", tib); 
     41    else if (gib > 0) 
     42        sprintf(buffer, "%3d GiB", gib); 
     43    else if (mib > 0) 
     44        sprintf(buffer, "%3d MiB", mib); 
     45    else 
     46        sprintf(buffer, "%d b", b); 
    4747} 
    4848 
    49 void sectors_to_size_dec(char *previous_unit, int *previous_size, char *unit, int *size, int sectors) 
     49void sectors_to_size_dec(char *previous_unit, int *previous_size, char *unit, 
     50                         int *size, int sectors) 
    5051{ 
    51         *size = sectors / 2; // Converting to bytes 
    52         strlcpy(unit, "KB", 2); 
    53         strlcpy(previous_unit, unit, 2); 
    54         *previous_size = *size; 
     52    *size = sectors / 2;        // Converting to bytes 
     53    strlcpy(unit, "KB", 2); 
     54    strlcpy(previous_unit, unit, 2); 
     55    *previous_size = *size; 
     56    if (*size > 1000) { 
     57        *size = *size / 1000; 
     58        strlcpy(unit, "MB", 2); 
    5559        if (*size > 1000) { 
     60            *previous_size = *size; 
     61            *size = *size / 1000; 
     62            strlcpy(previous_unit, unit, 2); 
     63            strlcpy(unit, "GB", 2); 
     64            if (*size > 1000) { 
     65                *previous_size = *size; 
    5666                *size = *size / 1000; 
    57                 strlcpy(unit, "MB", 2); 
    58                 if (*size > 1000) { 
    59                         *previous_size = *size; 
    60                         *size = *size / 1000; 
    61                         strlcpy(previous_unit, unit, 2); 
    62                         strlcpy(unit, "GB", 2); 
    63                         if (*size > 1000) { 
    64                                 *previous_size = *size; 
    65                                 *size = *size / 1000; 
    66                                 strlcpy(previous_unit, unit, 2); 
    67                                 strlcpy(unit, "TB", 2); 
    68                         } 
    69                 } 
     67                strlcpy(previous_unit, unit, 2); 
     68                strlcpy(unit, "TB", 2); 
     69            } 
    7070        } 
     71    } 
    7172} 
  • com32/hdt/hdt.c

    r0da1ff r990205  
    4343/* Defines the number of lines in the console 
    4444 * Default is 20 for a std console */ 
    45 int max_console_lines=20; 
     45int max_console_lines = 20; 
    4646 
    4747int main(const int argc, const char *argv[]) 
    4848{ 
    49   char version_string[256]; 
    50   const char *arg; 
    51   struct s_hardware hardware; 
     49    char version_string[256]; 
     50    const char *arg; 
     51    struct s_hardware hardware; 
    5252 
    53   snprintf(version_string, sizeof version_string, "%s %s (%s)", 
    54            PRODUCT_NAME,VERSION, CODENAME); 
     53    snprintf(version_string, sizeof version_string, "%s %s (%s)", 
     54             PRODUCT_NAME, VERSION, CODENAME); 
    5555 
    56   /* Cleaning structures */ 
    57   init_hardware(&hardware); 
     56    /* Cleaning structures */ 
     57    init_hardware(&hardware); 
    5858 
    59   /* Detecting Syslinux version */ 
    60   detect_syslinux(&hardware); 
     59    /* Detecting Syslinux version */ 
     60    detect_syslinux(&hardware); 
    6161 
    62   /* Detecting parameters */ 
    63   detect_parameters(argc, argv, &hardware); 
     62    /* Detecting parameters */ 
     63    detect_parameters(argc, argv, &hardware); 
    6464 
    65   /* Opening the Syslinux console */ 
    66   init_console(&hardware); 
     65    /* Opening the Syslinux console */ 
     66    init_console(&hardware); 
    6767 
    68   /* Clear the screen and reset position of the cursor */ 
    69   clear_screen(); 
    70   printf("\033[1;1H"); 
     68    /* Clear the screen and reset position of the cursor */ 
     69    clear_screen(); 
     70    printf("\033[1;1H"); 
    7171 
    72   printf("%s\n", version_string); 
     72    printf("%s\n", version_string); 
    7373 
    74   if ((arg = find_argument(argv + 1, "nomenu")) || (find_argument(argv+1,"auto"))) 
    75         start_cli_mode(&hardware); 
    76   else { 
    77         int return_code = start_menu_mode(&hardware, version_string); 
    78         if (return_code == HDT_RETURN_TO_CLI) 
    79                 start_cli_mode(&hardware); 
    80         else 
    81                 return return_code; 
    82   } 
    83   return 0; 
     74    if ((arg = find_argument(argv + 1, "nomenu")) 
     75        || (find_argument(argv + 1, "auto"))) 
     76        start_cli_mode(&hardware); 
     77    else { 
     78        int return_code = start_menu_mode(&hardware, version_string); 
     79        if (return_code == HDT_RETURN_TO_CLI) 
     80            start_cli_mode(&hardware); 
     81        else 
     82            return return_code; 
     83    } 
     84    return 0; 
    8485}