aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-02-22 08:19:15 +0100
committerH. Peter Anvin <hpa@zytor.com>2009-02-25 20:58:43 -0800
commit6738d1b2f38294c0b4dac690f3a5306007bbb531 (patch)
tree15a1675c2e877280221a64fc6537f368f433f39e
parent6e50d71a40cf5b93fb698916cb1e4ad1ea7abf1c (diff)
downloadsyslinux-elf-6738d1b2f38294c0b4dac690f3a5306007bbb531.tar.gz
syslinux-elf-6738d1b2f38294c0b4dac690f3a5306007bbb531.tar.xz
syslinux-elf-6738d1b2f38294c0b4dac690f3a5306007bbb531.zip
hdt: CLI: Improving show pci output
-rw-r--r--com32/hdt/hdt-cli-pci.c75
-rw-r--r--com32/hdt/hdt.c1
2 files changed, 67 insertions, 9 deletions
diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c
index a521a387..ae29d737 100644
--- a/com32/hdt/hdt-cli-pci.c
+++ b/com32/hdt/hdt-cli-pci.c
@@ -31,20 +31,49 @@
#include <stdlib.h>
#include <string.h>
+void cli_detect_pci(struct s_hardware *hardware) {
+ bool error=false;
+ if (hardware->pci_detection==false) {
+ detect_pci(hardware);
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ more_printf("The pci.ids file is missing, device names can't be computed.\n");
+ more_printf("Please put one in same dir as hdt\n");
+ error=true;
+ }
+ if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
+ more_printf("The modules.pcimap file is missing, device names can't be computed.\n");
+ more_printf("Please put one in same dir as hdt\n");
+ error=true;
+ }
+ if (error == true) {
+ char tempbuf[10];\
+ printf("Press enter to continue\n");\
+ fgets(tempbuf, sizeof(tempbuf), stdin);\
+ }
+ }
+}
+
void main_show_pci(struct s_hardware *hardware) {
int i=1;
struct pci_device *pci_device;
char kernel_modules [LINUX_KERNEL_MODULE_SIZE*MAX_KERNEL_MODULES_PER_PCI_DEVICE];
-
- if (hardware->pci_detection==false) {
- detect_pci(hardware);
- }
- printf("%d PCI devices detected\n",hardware->nb_pci_devices);
+ bool nopciids=false;
+ bool nomodulespcimap=false;
+ char first_line[81];
+ char second_line[81];
+ char third_line[81];
+ cli_detect_pci(hardware);
+ clear_screen();
+ more_printf("%d PCI devices detected\n",hardware->nb_pci_devices);
if (hardware->pci_ids_return_code == -ENOPCIIDS) {
- printf("The pci.ids file is missing, device names can't be computed. Please put one in same dir as hdt\n");
+ nopciids=true;
}
+ if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
+ nomodulespcimap=true;
+ }
+
/* For every detected pci device, compute its submenu */
for_each_pci_func(pci_device, hardware->pci_domain) {
memset(kernel_modules,0,sizeof kernel_modules);
@@ -56,14 +85,44 @@ void main_show_pci(struct s_hardware *hardware) {
}
if (pci_device->dev_info->linux_kernel_module_count==0) strlcpy(kernel_modules,"unknown",7);
- printf("%02d: %02x:%02x.%01x %s %s \n",
+ if ((nopciids == false) && (nomodulespcimap == false)) {
+ snprintf(first_line,sizeof(first_line),"%02d: %02x:%02x.%01x %s %s \n",
i,__pci_bus, __pci_slot, __pci_func,pci_device->dev_info->vendor_name,
pci_device->dev_info->product_name);
- printf(" # %s # ID:%04x:%04x[%04x:%04x] # Kmod:%s\n",
+ snprintf(second_line,sizeof(second_line)," # %-25s # ID:%04x:%04x[%04x:%04x]\n",
pci_device->dev_info->class_name,
pci_device->vendor, pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
+ snprintf(third_line,sizeof(third_line), " # Linux Kernel Module(s): %s \n",kernel_modules);
+ more_printf(first_line);
+ more_printf(second_line);
+ more_printf(third_line);
+ more_printf("\n");
+ } else if ((nopciids == true) && (nomodulespcimap == true)) {
+ more_printf("%02d: %02x:%02x.%01x %04x:%04x [%04x:%04x] \n",
+ i,__pci_bus, __pci_slot, __pci_func,
+ pci_device->vendor, pci_device->product,
pci_device->sub_vendor, pci_device->sub_product,kernel_modules);
+ } else if ((nopciids == true) && (nomodulespcimap == false)) {
+ more_printf("%02d: %02x:%02x.%01x %04x:%04x [%04x:%04x] Kmod:%s\n",
+ i,__pci_bus, __pci_slot, __pci_func,
+ pci_device->vendor, pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product,kernel_modules,
+ pci_device->sub_product,kernel_modules);
+ } else if ((nopciids == false) && (nomodulespcimap == true)) {
+ snprintf(first_line,sizeof(first_line),"%02d: %02x:%02x.%01x %s %s \n",
+ i,__pci_bus, __pci_slot, __pci_func,pci_device->dev_info->vendor_name,
+ pci_device->dev_info->product_name);
+ snprintf(second_line,sizeof(second_line)," # %-25s # ID:%04x:%04x[%04x:%04x]\n",
+ pci_device->dev_info->class_name,
+ pci_device->vendor, pci_device->product,
+ pci_device->sub_vendor, pci_device->sub_product);
+ more_printf(first_line);
+ more_printf(second_line);
+ more_printf("\n");
+ }
+
i++;
}
diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c
index f482da97..7ee39048 100644
--- a/com32/hdt/hdt.c
+++ b/com32/hdt/hdt.c
@@ -54,7 +54,6 @@ int main(int argc, char *argv[])
clear_screen();
printf("%s\n",version_string);
-
if ((arg = find_argument(argv+1, "nomenu"))) {
start_cli_mode(argc, argv);
} else{