#!/bin/sh # This shell script takes the standard asy driver for Solaris x86, # which lives in /kernel/drv/asy (Solaris x86 2.1 and 2.4) or # /platform/i86pc/kernel/drv/asy (2.5), and produces a patched version # in /tmp/asy. This patched version remaps speeds 50 and 75 bits/s to # 57600 and 115200 bits/s respectively. Therefore, in order to work # at 57600, ask for speed 50. Similarly, for 115200, ask for 75. # These speeds will probably only work with a 16550A buffered UART # chip. # This shell script does not require any privileges, and is probably # best run as a normal user. # To install the patched version, take a safe copy of the original in, # say, /kernel/drv/asy.original, and copy the patched version from # /tmp/asy to /kernel/drv/asy. This will need to be done by root. # You will then need to reboot in order to load the new driver into # the kernel. # Andrew Gabriel, 14/Feb/1995 Home: Andrew@cucumber.demon.co.uk # Consultant Software Engineer Work: Andrew.Gabriel@net-tel.co.uk VERSION=0.1 # 14/Feb/1995 Solaris 2.1 and 2.4 asy drivers VERSION=0.2 # 14/May/1995 Also patched 102324-02 asy driver VERSION=1.0 # 03/Sep/1995 Released VERSION=1.1 # 10/Sep/1995 Comments improved VERSION=1.2 # 23/Mar/1996 2.4 DU9 and 2.5 added. VERSION=1.3 # 15/Jul/1996 2.5 DU3 added. VERSION=1.4 # 19/Jan/1997 Correction to detection of Solaris 2.1 and 2.4. VERSION=1.5 # 10/Jun/1997 2.5 DU9 added, and Solaris 5.5.1 support. VERSION=1.6 # 12/Dec/1997 2.5 DU11 added VERSION=1.7 # 16/Feb/1998 2.6 PATH=/usr/bin if [ "`uname -r`" = "5.1" -o "`uname -r`" = "5.4" ] then INPUT=/kernel/drv/asy else INPUT=/platform/i86pc/kernel/drv/asy fi OUTPUT=/tmp/asy # "before" and "after" patched UART clock divisor values, as output # by od -d OLDVALUES="\ 0000000 02304 01536 01047 00857 00768 00576 00384 00192\n\ 0000020 00096 00064 00048 00024 00012 00006 00003\n\ 0000036" NEWVALUES="\ 0000000 00002 00001 01047 00857 00768 00576 00384 00192\n\ 0000020 00096 00064 00048 00024 00012 00006 00003\n\ 0000036" echo " Solaris x86 asy port speed patcher version $VERSION DISCLAIMER: This publication (software patch) is provided \"as is\" without warranty of any kind, either express or implied. You use this entirely at your own risk. It has not been fully tested; it is your responsibility to test it to your satisfaction in your own environment. It will not work in all situations. Do you accept these conditions? (type \"yes\" if you do) \c" read REPLY echo if [ "$REPLY" != "yes" ] then echo "Sorry, but this patch is not suitable for your requirements" exit 1 fi if [ "`uname -m`" != "i86pc" ] then echo "FAILED: This patch is only applicable to Solaris on x86," # ...because the zs driver uses different clock values echo " and can only be run on x86 platforms." # ...because the /bin/echo command below assumes little-endian system. exit 1 fi # Offset of patch depends on release and patchlevel of Solaris. FILESIZE=`cat $INPUT | wc -c | sed -e 's/^ *//'` case "`uname -r`-$FILESIZE" in 5.1-18844) OFFSET=10682;; 5.4-19524) OFFSET=10914;; # original asy driver in 2.4 5.4-19556) OFFSET=11130;; # Patch 102342-02 asy driver (in driver update 6) 5.4-19876) OFFSET=11386;; # 2.4 driver update 9 5.5-19596|5.5.1-19596) OFFSET=11118;; # original asy driver in 2.5 5.5-20168|5.5.1-20168) OFFSET=11458;; # 2.5 driver update 3 5.5-21132|5.5.1-21132) OFFSET=12142;; # 2.5 driver update 9 5.5-21396|5.5.1-21132) OFFSET=12258;; # 2.5 driver update 11 5.6-22504) OFFSET=12682;; # 2.6 *) echo "FAILED: Size of $INPUT not as expected for SunOS `uname -r`." echo " Patch not applied." exit 1 ;; esac echo "Checking that UART clock divisor values are at expected location" dd if=$INPUT bs=1 count=30 iseek=$OFFSET 2>/dev/null | od -d > /tmp/asychk echo $OLDVALUES | cmp -s - /tmp/asychk if [ $? -ne 0 ] then echo $NEWVALUES | cmp -s - /tmp/asychk if [ $? = 0 ] then echo "NOTE: Patch seems to have been applied already!!!" exit 1 fi echo "FAILED: UART clock divisor values not at offset $OFFSET" echo " in input file $INPUT" echo echo "You must locate the table, and modify this shell" echo "script to set the correct OFFSET, and then rerun it." exit 1 fi echo echo "Values are as expected" echo echo "Creating new asy driver in $OUTPUT" # There must be an easier way to edit a binary file with standard tools? dd if=$INPUT bs=1 count=$OFFSET of=$OUTPUT 2>/dev/null && /bin/echo "\002\000\001\000\c" >> $OUTPUT && dd if=$INPUT bs=1 iseek=`expr $OFFSET + 4` >> $OUTPUT 2>/dev/null if [ $? -ne 0 ] then echo "FAILED: creating patched file \($OUTPUT\) failed." exit 1 fi echo echo "Checking new driver" if [ `cat $INPUT | wc -c` != `cat $OUTPUT | wc -c` ] then echo "FAILED: file size mismatch" exit 1 fi dd if=$OUTPUT bs=1 count=30 iseek=$OFFSET 2>/dev/null | od -d > /tmp/asyres echo $NEWVALUES | cmp -s - /tmp/asyres if [ $? -ne 0 ] then echo "FAILED: data compare mismatch" exit 1 fi echo echo "Patch complete. Patched driver in $OUTPUT" echo echo "As root, you should now make a safe copy of $INPUT" echo "and copy the new $OUTPUT to $INPUT. Finally, reboot." echo "Then, any request for 50 baud will be mapped to 57600," echo "and any request for 75 baud will be mapped to 115200." echo echo "DISCLAIMER: You use this at entirely your own risk!!!" rm /tmp/asychk /tmp/asyres exit 0