From 56bd7c3ec4446d237f82ede9928ccff075d47041 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Fri, 13 Mar 2009 23:38:39 +0100 Subject: [PATCH] hdt: Adding legacy IRQ stuff In the cli mode, the pci context feature the following : pci> show irq Under cli, "pci> show device " display the IRQ when device features one. The menu mode behave the same way. --- com32/hdt/hdt-cli-pci.c | 48 +++++++++++++++++++++++++++++++++++++++--------- com32/hdt/hdt-cli.h | 1 + com32/hdt/hdt-common.c | 3 +++ com32/hdt/hdt-menu-pci.c | 8 ++++++++ com32/include/sys/pci.h | 3 ++- com32/lib/pci/scan.c | 29 ++++++++++++++++++++++++++++- 6 files changed, 81 insertions(+), 11 deletions(-) diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c index 554c2ce..0c649e9 100644 --- a/com32/hdt/hdt-cli-pci.c +++ b/com32/hdt/hdt-cli-pci.c @@ -101,6 +101,8 @@ void show_pci_device(struct s_hardware *hardware, const char *item) { more_printf("SubProduct ID : %04x\n",pci_device->sub_product); more_printf("Class ID : %02x.%02x.%02x\n",pci_device->class[2], pci_device->class[1],pci_device->class[0]); more_printf("Revision : %02x\n",pci_device->revision); + if ((pci_device->irq>0) && (pci_device->irq<255)) + more_printf("IRQ : %0d\n",pci_device->irq); more_printf("PCI Bus : %02d\n",bus); more_printf("PCI Slot : %02d\n",slot); more_printf("PCI Func : %02d\n",func); @@ -162,7 +164,7 @@ void show_pci_devices(struct s_hardware *hardware) { if (nomodulespcimap == true) { more_printf("%02d: %04x:%04x [%04x:%04x] \n", i, pci_device->vendor, pci_device->product, - pci_device->sub_vendor, pci_device->sub_product,kernel_modules); + pci_device->sub_vendor, pci_device->sub_product); } else { more_printf("%02d: %04x:%04x [%04x:%04x] Kmod:%s\n", @@ -176,10 +178,42 @@ void show_pci_devices(struct s_hardware *hardware) { } } + +void show_pci_irq(struct s_hardware *hardware) { + struct pci_device *pci_device; + bool nopciids=false; + + clear_screen(); + more_printf("%d PCI devices detected\n",hardware->nb_pci_devices); + more_printf("IRQ : product\n"); + more_printf("-------------\n"); + if (hardware->pci_ids_return_code == -ENOPCIIDS) { + nopciids=true; + } + + /* For every detected pci device, compute its submenu */ + for_each_pci_func(pci_device, hardware->pci_domain) { + /* Only display valid IRQs*/ + if ((pci_device->irq>0) && (pci_device->irq<255)) { + if (nopciids == false) { + more_printf("%02d : %s %s \n", + pci_device->irq,pci_device->dev_info->vendor_name, + pci_device->dev_info->product_name); + + } else { + more_printf("%02d : %04x:%04x [%04x:%04x] \n", + pci_device->irq, pci_device->vendor, pci_device->product, + pci_device->sub_vendor, pci_device->sub_product); + } + } + } +} + void show_pci_help() { more_printf("Show supports the following commands : \n"); more_printf(" %s\n",CLI_SHOW_LIST); more_printf(" %s \n",CLI_PCI_DEVICE); + more_printf(" %s\n",CLI_IRQ); } void pci_show(char *item, struct s_hardware *hardware) { @@ -187,6 +221,10 @@ void pci_show(char *item, struct s_hardware *hardware) { show_pci_devices(hardware); return; } + if ( !strncmp(item, CLI_IRQ, sizeof(CLI_IRQ) - 1) ) { + show_pci_irq(hardware); + return; + } if ( !strncmp(item, CLI_PCI_DEVICE, sizeof(CLI_PCI_DEVICE) - 1) ) { show_pci_device(hardware,item+ sizeof(CLI_PCI_DEVICE)-1); return; @@ -225,14 +263,6 @@ void cli_detect_pci(struct s_hardware *hardware) { } void main_show_pci(struct s_hardware *hardware) { - int i=1; - char kernel_modules [LINUX_KERNEL_MODULE_SIZE*MAX_KERNEL_MODULES_PER_PCI_DEVICE]; - struct pci_device *pci_device; - bool nopciids=false; - bool nomodulespcimap=false; - char first_line[81]; - char second_line[81]; - char third_line[81]; cli_detect_pci(hardware); more_printf("PCI\n"); diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h index 92791c4..b8768e9 100644 --- a/com32/hdt/hdt-cli.h +++ b/com32/hdt/hdt-cli.h @@ -45,6 +45,7 @@ #define CLI_DMI "dmi" #define CLI_CPU "cpu" #define CLI_SHOW_LIST "list" +#define CLI_IRQ "irq" typedef enum { EXIT_MODE, diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c index 0ff7e86..43e6d36 100644 --- a/com32/hdt/hdt-common.c +++ b/com32/hdt/hdt-common.c @@ -199,6 +199,9 @@ void detect_pci(struct s_hardware *hardware) { /* Scanning to detect pci buses and devices */ hardware->pci_domain = pci_scan(); + /* Gathering addtional information*/ + gather_additional_pci_config(hardware->pci_domain); + hardware->nb_pci_devices=0; struct pci_device *pci_device; for_each_pci_func(pci_device, hardware->pci_domain) { diff --git a/com32/hdt/hdt-menu-pci.c b/com32/hdt/hdt-menu-pci.c index 477ba4a..77ea266 100644 --- a/com32/hdt/hdt-menu-pci.c +++ b/com32/hdt/hdt-menu-pci.c @@ -63,6 +63,14 @@ void compute_pci_device(struct s_my_menu *menu,struct pci_device *pci_device,int snprintf(statbuffer,sizeof statbuffer,"vendor:product[sub_vendor:sub_product] : %04x:%04x[%04x:%04x]",pci_device->vendor, pci_device->product,pci_device->sub_vendor, pci_device->sub_product); add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); menu->items_count++; + + if ((pci_device->irq>0) && (pci_device->irq<255)) { + snprintf(buffer,sizeof buffer,"IRQ : %02d",pci_device->irq); + snprintf(statbuffer,sizeof statbuffer,"IRQ : %02d",pci_device->irq); + add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); + menu->items_count++; + } + if (pci_device->dev_info->linux_kernel_module_count>1) { for (int i=0; idev_info->linux_kernel_module_count;i++) { if (i>0) { diff --git a/com32/include/sys/pci.h b/com32/include/sys/pci.h index fad7250..d736304 100644 --- a/com32/include/sys/pci.h +++ b/com32/include/sys/pci.h @@ -47,6 +47,7 @@ struct pci_device { uint32_t vid_did; uint32_t svid_sdid; uint32_t rid_class; + uint8_t irq; }; }; struct pci_dev_info *dev_info; @@ -134,5 +135,5 @@ struct match * find_pci_device(const struct pci_domain *pci_domain, int get_name_from_pci_ids(struct pci_domain *pci_domain, char *pciids_path); int get_module_name_from_pci_ids(struct pci_domain *pci_domain, char *modules_pcimap_path); int get_class_name_from_pci_ids(struct pci_domain *pci_domain, char *pciids_path); - +void gather_additional_pci_config(struct pci_domain *domain); #endif /* _SYS_PCI_H */ diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c index cfd9e65..0c52100 100644 --- a/com32/lib/pci/scan.c +++ b/com32/lib/pci/scan.c @@ -83,7 +83,7 @@ int get_module_name_from_pci_ids(struct pci_domain *domain, char *modules_pcimap char sub_vendor_id[16]; char sub_product_id[16]; FILE *f; - struct pci_device *dev; + struct pci_device *dev=NULL; /* Intializing the linux_kernel_module for each pci device to "unknown" */ /* adding a dev_info member if needed */ @@ -512,6 +512,33 @@ struct pci_domain *pci_scan(void) return NULL; } +/* gathering additional configuration*/ +void gather_additional_pci_config(struct pci_domain *domain) +{ + struct pci_bus *bus = NULL; + struct pci_slot *slot = NULL; + unsigned int nbus, ndev, nfunc, maxfunc; + pciaddr_t a; + int cfgtype; + cfgtype = pci_set_config_type(PCI_CFG_AUTO); + (void)cfgtype; + + for (nbus = 0; nbus < MAX_PCI_BUSES; nbus++) { + bus = NULL; + + for (ndev = 0; ndev < MAX_PCI_DEVICES; ndev++) { + maxfunc = 1; /* Assume a single-function device */ + slot = NULL; + + for (nfunc = 0; nfunc < maxfunc; nfunc++) { + a = pci_mkaddr(nbus, ndev, nfunc, 0); + domain->bus[nbus]->slot[ndev]->func[nfunc]->irq = pci_readb(a + 0x3c); + } + } + } +} + + void free_pci_domain(struct pci_domain *domain) { struct pci_bus *bus; -- 2.7.4