From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simone Gotti Date: Sat, 10 Apr 2004 17:16:29 +0000 Subject: Re: Little script for ISAPNP hotplug Message-Id: <200404101916.29563.simone.gotti@email.it> MIME-Version: 1 Content-Type: multipart/mixed; boundary="Boundary-00=_tvCeAQiz8L5RgLU" List-Id: References: <200404092044.54429.simone.gotti@email.it> In-Reply-To: <200404092044.54429.simone.gotti@email.it> To: linux-hotplug@vger.kernel.org --Boundary-00=_tvCeAQiz8L5RgLU Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Friday 09 April 2004 20:44, Simone Gotti wrote: By the way, today I've did the C modules.isapnp parser program. The program is called "strange but true" isapnpmodules. it's very simple, as I've used like base the code of usbmodules. The scripts are 2 and a patch for hotplug.functions: isapnp.rc isapnp.agent hotplug.functions.patch (the patch is against hotplug-20040401, the latest avaible on my gentoo system) I've noticed that for the 2.6 kernel is prefered the bash parsing and not the use of usbmodules and pcimodules. The problem with isapnp is that in a standard PC there are more then 10 isa devices so in this way modules.isapnp is parsed a lot of times and all is slow (at least 16 seconds). Using the isapnpmodules it take not more than 2 seconds. So I've prefered it to bash parsing in the 2.6 kernel too. I don't know it I've do something wrong due to my low level of documentation on how isapnp works. isapnp.rc: It checks if isapnp exists, then it look for the presence of sysfs. If both exists then sysfs data is used. This because sysfs reports the id of the isapnpdevice in a "string" form, like PNP0501. And I'm not able to convert it in the Vendor and Function hex form with a bash script. if they don't exists then "procfs" is used. The vendor and function hex value are retrieved from "/proc/bus/pnp/devices" and sent to the isapnp.agent isapnp.agent: This agent act like the pci agent. I hope it'll be useful. Bye! -- Simone Gotti --Boundary-00=_tvCeAQiz8L5RgLU Content-Type: text/x-diff; charset="iso-8859-1"; name="hotplug.functions.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="hotplug.functions.patch" --- hotplug.functions 2004-04-10 18:53:02.000000000 +0200 +++ hotplug.functions.isapnp 2004-04-10 18:50:16.150626368 +0200 @@ -77,14 +77,20 @@ FILENAME=$2 DESCRIPTION=$3 + case $TYPE in + isapnp) + LISTER=`which ${TYPE}modules 2> /dev/null` + ;; + *) # should we use usbmodules, pcimodules? not on 2.5+, because sysfs # ought to expose the data we need to find all candidate drivers. # (on 2.5.48 it does for usb; but maybe not yet for pci.) case "$KERNEL" in - 2.2*|2.3*|2.4*) LISTER=`which ${TYPE}modules` ;; + 2.2*|2.3*|2.4*) LISTER=`which ${TYPE}modules 2> /dev/null` ;; *) LISTER="" ;; esac - + esac + if [ "$LISTER" != "" ]; then # lister programs MIGHT be preferable to parsing from shell scripts: # - usbmodules used for (a) multi-interface devices, (b) coldplug @@ -105,12 +111,30 @@ debug_mesg "pcimodules is scanning more than $PCI_SLOT ..." DRIVERS=`$LISTER` ;; + isapnp) + if [ "$ISAPNP_ID" != "" ]; then + debug_mesg "isapnpmodules is scanning for the ISAPNP Id $ISAPNP_ID ..." + DRIVERS=`$LISTER --id $ISAPNP_ID` + elif [ "$ISAPNP_STRING" != "" ]; then + debug_mesg "isapnpmodules is scanning for the ISAPNP String $ISAPNP_STRING ..." + DRIVERS=`$LISTER --string $ISAPNP_STRING` + fi + ;; esac fi # try parsing by shell scripts if no luck yet if [ "$DRIVERS" = "" ]; then + case $TYPE in + isapnp) + if [ "$LISTER" = "" ]; then + ${TYPE}_map_modules < $FILENAME + fi + ;; + *) ${TYPE}_map_modules < $FILENAME + ;; + esac fi # FIXME remove dups and blacklisted modules from $DRIVERS here --Boundary-00=_tvCeAQiz8L5RgLU Content-Type: application/x-shellscript; name="isapnp.agent" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="isapnp.agent" #!/bin/sh # # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # ISAPNP-specific hotplug policy agent. # # This should handle 2.4.* and 2.6.* ISAPNP (for now only coldplugging), # # Kernel ISAPNP params are: # # ACTION=%s [add or remove] # ISAPNP_ID=%08X # # Copyright (C) 2004 Simone Gotti, All Rights Reserved. # # HISTORY: # # 2004/04/08 Simone Gotti first version # cd /etc/hotplug . ./hotplug.functions # generated by modutils, for current 2.4.x kernels MAP_CURRENT=$MODULE_DIR/modules.isapnpmap # accumulates list of modules we may care about DRIVERS= if [ "$ISAPNP_ID" = "" -a "$ISAPNP_STRING" = "" ]; then mesg Bad ISAPNP agent invocation exit 1 fi # # stdin is "modules.isapnpmap" syntax # on return, ONE matching module was added to $DRIVERS # isapnp_map_modules () { local module ignored # comment line lists (current) isapnp_device_id field names read ignored while read module cardvendor carddevice driver_data vendor device_function do # comments are lines that start with "#" ... # be careful, they still get parsed by bash! case "$module" in \#*) continue ;; esac # remove the 0x in front of the hex values vendor=$(echo $vendor | sed -e 's/0x//') device_function=$(echo $device_function | sed -e 's/0x//') : checkmatch $module id_temp=$device_function$vendor if [ $id_temp == $ISAPNP_ID ]; then DRIVERS="$module $DRIVERS" : drivers $DRIVERS break fi done } # # What to do with this ISAPNP hotplug event? # case $ACTION in add) if [ "$ISAPNP_ID" != "" ]; then LABEL="ISAPNP id $ISAPNP_ID" elif [ "$ISAPNP_STRING" != "" ]; then LABEL="ISAPNP string $ISAPNP_STRING" fi # on 2.4 systems, modutils maintains MAP_CURRENT if [ -r $MAP_CURRENT ]; then load_drivers isapnp $MAP_CURRENT "$LABEL" fi if [ "$DRIVERS" = "" ]; then debug_mesg "... no modules for $LABEL" exit 2 fi ;; *) debug_mesg ISAPNP $ACTION event not supported exit 1 ;; esac --Boundary-00=_tvCeAQiz8L5RgLU Content-Type: application/x-shellscript; name="isapnp.rc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="isapnp.rc" #!/bin/sh # vim: syntax=sh # # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # isapnp.rc mostly to recover lost boot-time isapnp hotplug events # # Copyright (C) 2004 Simone Gotti, All Rights Reserved. # # 2004/04/08 Simone Gotti (simone.gotti@email.it) # PATH=/sbin:/bin:/usr/sbin:/usr/bin cd /etc/hotplug . ./hotplug.functions isapnp_boot_events () { # make sure the isapnp agent will run ACTION=add DOCK=0/0/0 ISAPNP_SLOT=00:00 ISAPNP_ID= ISAPNP_STRING= export ACTION DOCK ISAPNP_ID ISAPNP_STRING # Check for the existance of "isapnpmodules" # if it exists we can use "sysfs" for finding devices # This because I'm not able to convert the ISAPNP string like PNP0000 to the hex values # using a bash script... If someone can help me doing this... # If isapnpmodules doesn't exists I'll use the /proc/bus/pnp infos... LISTER=`which isapnpmodules 2> /dev/null` if [ -d /sys/bus -a "$LISTER" != "" ]; then # 2.6 kernels if [ -d /sys/bus/pnp/devices/ ]; then cd /sys/bus/pnp/devices/ for ISAPNP_DEVICE in *; do # read the String id value ISAPNP_STRING=`cat $ISAPNP_DEVICE/id` /sbin/hotplug isapnp done fi else if [ -d /proc/bus/pnp/ ]; then cat /proc/bus/pnp/devices | while read line do ISAPNP_ID=`echo $line | cut -d' ' -f2` /sbin/hotplug isapnp done else echo "/proc/bus/pnp/ not found, Is it enabled in your kernel?" fi fi return 0 } # See how we were called. case "$1" in start) isapnp_boot_events ;; stop) # echo $"isapnp stop -- ignored" ;; status) # echo $"isapnp status -- ignored" ;; restart) # always invoke by absolute path, else PATH=$PATH: $0 stop && $0 start ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac --Boundary-00=_tvCeAQiz8L5RgLU Content-Type: application/x-tbz; name="isapnpmodules-0.1.tar.bz2" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="isapnpmodules-0.1.tar.bz2" QlpoOTFBWSZTWU8Led8AC5t/kP74G4D7////f+ff7v////8EAAAIYA3/eARQUNd3O2NrXTbs7bDs ygCjoUAUKAAASKCKPKZNTepGR6nqeoMm1I/1TJoepo0yZT9RtUxoE2p6nqekYmmI00GiCo/amqb1 T2qAAAAB6gNNGgAaAAAaAAA4GgaAaBoaADQyGmgBpoBoAAyGIADQSaU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jG+xYSY2xMvj6ecwWunKJLKxkBk S7oGGSJEChtxhCTWWGRTZySZcxyyd4kGgF/nCxmB6EasVM0MhKQxBPAJ4imQj7TmPRzn4Yaz5YhL tLy8keW+AfeM2kwDv1lma/wOVSXzHaeo9q3n3hIguv8y6yHgxuGARPv8Jzw1v7THripK8vCt4kpC Si6paSvkcCjJpYAviYd0TBr3MjbE6wb0oITqlmHAqDzGCocZqh0KBwETggEwcFGLmAoUUwKDuZ6M OAZnaDOIbV8OV34fY5cvNfUB+JLRJbA6BgEkvfO4lwNwEERRHxMzJheU4SFJgXIRIaEUXXEz62uA Si7pJiguvzpXsv+MlgzHtIo0mM2OcoMfToJLPq/fneaxMMiHsiRcfAcGjjJYkygmZi+KOcv5EZTR s53XDDEhNbERMPnN+wlhhUPWS77VqfgsKyhqcotdmpWpmKp5SOHV8u02nrsXXNzIDygcDdIkynMX E5hBUYY4uaCViWN8OKx8s1YqthRTBotRQlBkMxgYEnMlqMgKhACZaCiCRzBCL4qFpk4TIIYwUGJM uE9FiYFQ9YMYSSaGmxoYBQEq5SrCMwgR7wqVMfhqjxCxMMhG0SsD9waGReeRArGx+lLn6PQiwKwb TofSFXM05kG+ofxXu83uXqLxhzF3y9EHHpX7PfOUkFDiu1SOg3nAqMiKDOdnkyLJIl43dhzCkEiI Opi3Mfvhbwx/SjUHnpJJhcZQrLv7TnISZEGs0Oc8G2FRCMQoSNhvCaS1aIhwl/h5xT3pUaGG2A5x SuowEf/i7kinChIJ4W874A== --Boundary-00=_tvCeAQiz8L5RgLU-- ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel