#/bin/bash # # given a good-video.lst or good-eth-scsi.lst, make C source to contain # the information in a C structure. # # assume input file from stdin # assume that pci.h in /usr/include/linux will work with pci.c which # the good list was genereated from # # # see if they specified a pci.h to use, otherwise try /usr/include/linux/pci.h # if [ "$1" = "" ]; then pcihin=/usr/include/linux/pci.h else pcihin=$1 fi # # filter pci.h and store in temp file # pcihfile=/tmp/pci_h$$ trap 'rm -f $pcihfile; exit' INT TERM sed -n '/\#define/p' < $pcihin > $pcihfile # # now make template for C code # ctemplate=/tmp/pci-ids.h$$ trap 'rm -f $ctemplate; exit' INT TERM cat > $ctemplate << EOF #include "$pcihfile" #define DEVICE(vid,did,name) \ {PCI_VENDOR_ID_##vid, PCI_DEVICE_ID_##did, (name)} /* This is an automatically generated file by makepciids. */ /* some PCI ids map to multiple modules (!!) */ /* we just stick in an mulitple entries for the PCI id, with different */ /* module name for each one. Code just search for ALL matches to a */ /* given PCI id to get all the modules that might(!) work */ struct pci_module_map { unsigned short vendor; /* PCI vendor id */ unsigned short device; /* PCI device id */ const char *name; /* PCI human readable name */ const char *module; /* module to load */ }; EOF # # now make the rest of the file # # # scsi, eth, and video # echo "struct pci_module_map scsi_pci_ids[] = {" >> $ctemplate cat good-scsi.lst >> $ctemplate echo "};" >> $ctemplate echo "int scsi_num_ids=sizeof(scsi_pci_ids)/sizeof(struct pci_module_map);" >> $ctemplate echo "" >> $ctemplate echo "struct pci_module_map eth_pci_ids[] = {" >> $ctemplate cat good-eth.lst >> $ctemplate echo "};" >> $ctemplate echo "int eth_num_ids=sizeof(eth_pci_ids)/sizeof(struct pci_module_map);" >> $ctemplate echo "" >> $ctemplate echo "struct pci_module_map video_pci_ids[] = {" >> $ctemplate cat good-video.lst >> $ctemplate echo "};" >> $ctemplate echo "int video_num_ids=sizeof(video_pci_ids)/sizeof(struct pci_module_map);" >> $ctemplate echo "" >> $ctemplate echo "struct pci_module_map audio_pci_ids[] = {" >> $ctemplate cat good-audio.lst >> $ctemplate echo "};" >> $ctemplate echo "int audio_num_ids=sizeof(audio_pci_ids)/sizeof(struct pci_module_map);" >> $ctemplate echo "" >> $ctemplate echo "/* END of automatically generated text */" >> $ctemplate # # now make the C code # /lib/cpp -P -C $ctemplate | uniq > pci-ids-temp.h rm -f $ctemplate rm -f $pcihfile exit