2004-11-22 16:47:29 +03:00
#!/bin/sh -e
MODLIST =
MODHDR =
[ -x /usr/bin/mar ]
[ -x /usr/bin/getpciids ]
exit_handler( )
{
local rc = $?
trap - EXIT
[ -z " $MODLIST " ] || rm -f -- " $MODLIST "
[ -z " $MODHDR " ] || rm -f -- " $MODHDR "
exit $rc
}
write_decls( )
{
cat <<E_O_F
#define PCI_REVISION_ID 0x08 /* Revision ID */
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 */
} ;
E_O_F
}
write_typed( )
{
local type =
local TYPE =
local marfile = " $1 "
shift
[ -n " $marfile " -a -f " $marfile " ]
type = ${ marfile %/* }
type = ${ type ##*/ }
[ -n " $type " ]
TYPE = ` echo $type | tr '[a-z]' '[A-Z]' `
cat <<E_O_F
#ifndef DISABLE_${TYPE}
struct pci_module_map ${ type } _pci_ids[ ] = {
E_O_F
mar -l " $marfile " | sed 's|^[[:space:]]\+\([^\.]\+\)\.ko|\1|g' > " $MODLIST "
getpciids -f " $MODLIST " | \
while read vendor device subv subd module; do
[ -n " $module " ] || module = " $subv "
echo $module $vendor $device
done | sort -u | while read module vendor device; do
[ -n " ${ module ##*hci-hcd } " ] || continue
printf '\t{ 0x%s, 0x%s, "%s", "%s" },\n' $vendor $device "" $module
done
cat <<E_O_F
} ;
int ${ type } _num_ids = sizeof( ${ type } _pci_ids) / sizeof( struct pci_module_map) ;
#endif /* DISABLE_${TYPE} */
E_O_F
}
trap exit_handler SIGHUP SIGPIPE SIGINT SIGTERM SIGQUIT EXIT
2004-11-22 21:25:25 +03:00
export TMPDIR = /tmp
2004-11-22 16:47:29 +03:00
MODLIST = ` mktemp -t modlist.XXXXXXXXXX`
MODHDR = ` mktemp -t modhdr.XXXXXXXXXX`
write_decls > " $MODHDR "
for marfile in " $@ " ; do
write_typed $marfile >> " $MODHDR "
done
cat " $MODHDR "