From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simone Gotti Date: Mon, 12 Apr 2004 09:57:06 +0000 Subject: Re: Little script for ISAPNP hotplug Message-Id: <200404121157.06352.simone.gotti@email.it> MIME-Version: 1 Content-Type: multipart/mixed; boundary="Boundary-00=_yfmeAHUbXA746FO" 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=_yfmeAHUbXA746FO Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Monday 12 April 2004 04:25, Alexander E. Patrakov wrote: > Simone Gotti wrote: > >Thanks to Alexander E. Patrakov that made a similar script, I've added his > >functions for the conversion of the string form to the ID form in the > >isapnp.rc script. > > The script that you attached has no equivalent of my > simplify_isapnpmap_line() function and will thus fail if the line in > modules.isapnpmap contains multiple vendor/function pairs and the second > one (not the first one) matches > > The line in modules.isapnpmap is: > # module cardvendor carddevice driver_data vendor function [vendor2 > function2] ... \--------"the rest"-------------------/ > > The simplify_isapnpmap_line() function expects the $module, > $cardvendor and $carddevice variables to be set, driver_data > ignored, and "the rest" to be the arguments. It outputs > lines of the following form: > > # module cardvendor carddevice vendor function > # module cardvendor carddevice vendor2 function2 > > to match against. > > Or do you just ignore the "vendor" and "function" fields? This is > dangerous, since there are lines with 0xffff as both carddevice > and cardvendor. No I'm using the vendor and function values but I didn't know that there can be more the 1 value of vendor and function for every line of modules.isapnpmap. Now I've changed the script, it's attached. > Also, your script outputs: > > /proc/bus/pnp/ or /proc/bus/isapnp/ not found, Is it enabled in your > kernel? > > if the support is compiled into the kernel, but there are no isapnp devices > in the system. Now I've removed it, Like I've said I can't test it with a 2.4 kernel because I can't find the /proc/bus/pnp/ or /proc/bus/isapnp/ dirs. While with 2.6 the dir /proc/bus/pnp/ exists. Does the 2.4 kernels works in a different way with isapnp? My motherboard has 12 isapnp devices but with 2.4 none is showed... Bye and Thanks again! -- Simone Gotti --Boundary-00=_yfmeAHUbXA746FO 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 # 2004/04/11 Simone Gotti make the modules.isapnp parsing more fast # we don't need the isapnpmodules C program anymore. # 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" = "" ]; 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 therest do # comments are lines that start with "#" ... # be careful, they still get parsed by bash! case "$module" in \#*) continue ;; esac : checkmatch $module set $therest while [ $# -gt 0 ] do id_temp=$2$1 if [ $id_temp == $CHECKED_ID ]; then DRIVERS="$module $DRIVERS" : drivers $DRIVERS break fi shift shift done done } # # What to do with this ISAPNP hotplug event? # case $ACTION in add) LABEL="ISAPNP id $ISAPNP_ID" CHECKED_ID="0x`echo $ISAPNP_ID | cut -b1-4`0x`echo $ISAPNP_ID | cut -b5-8`" # 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=_yfmeAHUbXA746FO 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) # 2004/04/11 Alexander E. Patrakov (patrakov@ums.usu.ru) # Bash functions for converting ISAPNP_STRING to ID # # PATH=/sbin:/bin:/usr/sbin:/usr/bin cd /etc/hotplug . ./hotplug.functions decode_isapnp_vendor() { echo -n $1 | od -A n -t d1 | ( read A B C printf '%x\n' $(( ( ( $A & 0x3f ) << 2) | \ ( ( $B & 0x18 ) >> 3) | \ ( ( $B & 0x07 ) <<13) | \ ( ( $C & 0x1f ) << 8) )) ) } hex_swab() { echo `echo $1 | cut -b3-4``echo $1 | cut -b1-2` } isapnp_boot_events () { # make sure the isapnp agent will run ACTION=add DOCK=0/0/0 ISAPNP_SLOT=00:00 ISAPNP_ID= export ACTION DOCK ISAPNP_ID if [ -d /sys/bus ]; 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` #convert the string in the ISAPNP_ID rawcardvendor=`echo $ISAPNP_STRING | cut -b1-3` rawcarddevice=`echo $ISAPNP_STRING | cut -b4-7` cardvendor=`decode_isapnp_vendor $rawcardvendor` carddevice=`hex_swab $rawcarddevice` ISAPNP_ID=$carddevice$cardvendor /sbin/hotplug isapnp done fi else # Check for /proc/bus/pnp/ 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 # Check for /proc/bus/isapnp/ elif [ -d /proc/bus/isapnp/ ]; then cat /proc/bus/isapnp/devices | while read line do ISAPNP_ID=`echo $line | cut -d' ' -f2` /sbin/hotplug isapnp done #else #echo "/proc/bus/pnp/ or /proc/bus/isapnp/ 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=_yfmeAHUbXA746FO-- ------------------------------------------------------- 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