From 5209894429f09bba73a6545d1d495fc9279a7147 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Mon, 16 Feb 2009 11:17:28 +0100 Subject: [PATCH] hdt: Returning ENOPCIIDS and ENOMODULESPCIMAP when pci.ids and modules.pcidmap files are missing --- com32/include/sys/pci.h | 5 +++++ com32/lib/pci/scan.c | 6 +++--- sample/hdt.c | 28 +++++++++++++++++++++------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/com32/include/sys/pci.h b/com32/include/sys/pci.h index 8d71a35..ff45047 100644 --- a/com32/include/sys/pci.h +++ b/com32/include/sys/pci.h @@ -10,6 +10,11 @@ typedef uint32_t pciaddr_t; +enum { + ENOPCIIDS = 100, + ENOMODULESPCIMAP +}; + /* a structure for extended pci information */ /* XXX: use pointers for these? */ struct pci_dev_info { diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c index c2c7214..c1345b8 100644 --- a/com32/lib/pci/scan.c +++ b/com32/lib/pci/scan.c @@ -100,7 +100,7 @@ int get_module_name_from_pci_ids(struct pci_domain *domain) /* Opening the modules.pcimap (of a linux kernel) from the boot device */ f=fopen("modules.pcimap", "r"); if (!f) - return -1; + return -ENOMODULESPCIMAP; strcpy(vendor_id,"0000"); strcpy(product_id,"0000"); @@ -182,7 +182,7 @@ int get_class_name_from_pci_ids(struct pci_domain *domain) /* Opening the pci.ids from the boot device */ f = fopen("pci.ids","r"); if (!f) - return -1; + return -ENOPCIIDS; /* for each line we found in the pci.ids */ while ( fgets(line, sizeof line, f) ) { @@ -276,7 +276,7 @@ int get_name_from_pci_ids(struct pci_domain *domain) /* Opening the pci.ids from the boot device */ f = fopen("pci.ids","r"); if (!f) - return -1; + return -ENOPCIIDS; strlcpy(vendor_id,"0000",4); strlcpy(product_id,"0000",4); diff --git a/sample/hdt.c b/sample/hdt.c index a9503f2..8f4389a 100644 --- a/sample/hdt.c +++ b/sample/hdt.c @@ -50,7 +50,7 @@ #define EDITPROMPT 21 -#define SUBMENULEN 50 +#define SUBMENULEN 46 #define WITH_PCI 1 #define WITH_MENU_DISPLAY 1 @@ -60,6 +60,8 @@ int nb_sub_disk_menu=0; int nb_pci_devices=0; bool is_dmi_valid=false; int menu_count=0; +int pci_ids=0; +int modules_pcimap=0; #define ATTR_PACKED __attribute__((packed)) @@ -472,8 +474,13 @@ int compute_PCI(unsigned char *menu, struct pci_domain **pci_domain) { } *menu = add_menu(" PCI Devices ",-1); - menu_count++; - + menu_count++; + if (pci_ids == -ENOPCIIDS) { + add_item("The pci.ids file is missing","Missing pci.ids file",OPT_INACTIVE,NULL,0); + add_item("PCI Device names can't be computed.","Missing pci.ids file",OPT_INACTIVE,NULL,0); + add_item("Please put one in same dir as hdt","Missing pci.ids file",OPT_INACTIVE,NULL,0); + add_item("","",OPT_SEP,"",0); + } for (int j=0;jdev_info->linux_kernel_module)!=0) { snprintf(buffer,sizeof buffer,"%s (%s)",pci_device->dev_info->linux_kernel_module, pci_device->dev_info->class_name); @@ -503,6 +516,7 @@ void compute_KERNEL(unsigned char *menu,struct pci_domain **pci_domain) { add_item(buffer,infobar,OPT_INACTIVE,NULL,0); } + } } } @@ -1054,12 +1068,12 @@ void detect_hardware(s_dmi *dmi, s_cpu *cpu, struct pci_domain **pci_domain, str printf("PCI: Resolving class names\n"); /* Assigning class name for each device*/ - get_class_name_from_pci_ids(*pci_domain); + pci_ids=get_class_name_from_pci_ids(*pci_domain); printf("PCI: Resolving module names\n"); /* Detecting which kernel module should match each device */ - get_module_name_from_pci_ids(*pci_domain); + modules_pcimap=get_module_name_from_pci_ids(*pci_domain); #endif } -- 2.7.4