Subject: Conexant Olitec driver module loading at startup
From: Paul Hanni <hannip@aol.net>
Date: Sun, 04 Feb 2001 20:37:34 -0500

Well, after I managed to get my Conexant/Rockwell HSF modem to work with
Linux using the Olitec driver I wanted a way to have the object modules
loaded at boot time.  Receiving a number of clues from previous posts to
this discussion group and the Linmodem-HOWTO web page I ventured out to
find a solution.  Thankfully, I found a solution that works!

The following are my notes on the solution.  Whether this is the optimal
solution or not I don't know.  If someone has a better solution, or some
modifications to this one please speak up.

First a disclaimer.  This has only been tested on Linux Mandrake 7.2
using the Olitec driver that has objects compiled against the 2.2.17
kernel (PCI_56K_V2_K2.2.17.tar.gz) on my computer only.
Follow these notes at your own risk.

These are the steps I took.

1) Make the modules loadable by modprobe. Copy the *.o mod files
to /lib/modules/2.2.17-21mdk/misc and execute "depmod -a" to build
the module dependencies file. Use "modprobe myserial" to load the modem
modules.  Note that modprobe can't force loading if there is a version
mismatch like insmod can.  See (2) for workaround.  Once you verify
that "modprobe myserial" is functioning without error then add
"myserial",
quotes not included, to /etc/modules so that it will be loaded at boot
up.

2) There is a way to get around the version mismatch errors that cause
modprobe to fail to load the myserial module and its dependant modules.
The GNU objcopy command can rename the kernel symbols in the object
files.  There is a fixscript that has been floating around that uses
objcopy to change an objects unresolved symbols to the correct versioned
symbol for the running kernel.  I stole this code and made some minor
modifications to skip symbols that could not be found in the running
kernel.  This was needed since the conexant objects depend on each
others exported symbols.  The fixscript is listed below with a new
fixall script to run fixscript against all the object files found in
the current directory.  It creates a subdirectory using the running
kernel name to store the modified object files.
STEPS:
a) Copy these scripts and the conexant object files into the same
directory.  As root execute "./fixall | tee fixall.out".

b) Verify that all the modified objects were created in the new
subdirectory.

c) Check the fixall.out file for symbols that were not found for
the running kernel.  Execute the following command to get the list.

grep Warning fixall.out | cut -d' ' -f7 | sort -u

The output should match the following list.  If there are additional
symbols listed then this is a problem.
ComCtrlGetInterface
ConfigMgrGetInterface
DebugMgrGetInterface
DevMgrGetInterface
GetBasic2Funcs
GetFallBackInterface
GetFsksInterface
GetTonesInterface
GetV34Interface
GetV90Interface
LinuxScrSetEntryPointCallback
LinuxScrSleep
LinuxScrWakeup
MemMgrGetInterface
NVMMgrGetInterface
RTMgrGetInterface
StatMgrGetInterface

d) copy the modified object files to the appropriate directory under
/lib/modules.  See (1) above for additional instructions.

------- Start of fixall script ---------------
#! /bin/bash
# To make this file executable:  chmod +x fixall
# This script processes all object files found in the current directory
# and calls fixscript against each one.  The modified object files
# will be stored in a subdirectory with the name of your kernel version.
#

OUTDIR=`uname -r`
if [ ! -d $OUTDIR ]; then
   mkdir $OUTDIR
fi

ls *.o | xargs -i ./fixscript {} ./$OUTDIR/{}

echo
echo "Modified output files have been stored in ./$OUTDIR"
------ End of fixall script -----------------

------ Start of fixscript script -------------------
#! /bin/bash
# To make this file executable:  chmod +x fixscript
# This is a very slight edit of the ltfixscript contributed to
# the Linmodems Newslist
# Additional mods were made to skip symbols that have no match.
#  From - Sun Jul 23 04:27:38 2000
#  From: "Mark Spieth" <mark at  digivation.com.au>
#  To: <discuss@linmodems.org>
#  Subject: ltmodem symbols and version fixed
#  Date: Sun, 23 Jul 2000 12:39:44 +1000
#  Organization: Digivation Pty Ltd

echo "Fixscript V1.8"

if [ -z "$1" -o -z "$2" ]; then
cat <<END
This script changes version number tags of binary
kernel modules to match the version of the currently
running kernel. It also renames any symbol that the
current kernel can't resolve into their equivalent
resolvable symbols.

For inserting binary modules into kernels, the 'fixed'
module can be inserted with:
        insmod module
which is used in automated kernel module management,
rather than forcing module loading with:
        insmod -f module
which is necessary when kernel and module versions
are not matched.

WARNING! This change is purely cosmetic, and the use
of version matched binaries whenever possible is
strongly advised. It may crash your kernel due to
inconsistencies in data structures between the kernel
as it stands and the headers used to originally compile
the module being fixed. No guarantees are given or implied
under any circumstances.

GNU objcopy version 2.9.5 or later is required;
this is provided as part of the 'binary utilities'
packages such as the Debian binutils.deb

USAGE: fixscript input-file output-file
END
exit 1
fi

MI=/tmp/modinfo

[ -z "$DEPMOD" ] && DEPMOD=depmod

#new kernel version modinfo section
echo -ne "kernel_version="`uname -r`"\0" > $MI

#build the objcopy command
CMD="objcopy"
for i in `$DEPMOD -e $1 2>&1 | grep "depmod\:" | sed 's/depmod://g' |\
grep -v "Unresolved symbols"` ; do
 i1=`echo $i | awk '{
  gsub(/_R[0-9a-fA-F]+/,"");
  printf("%s", $1);
 }'`
 new=`awk '/ '$i1'_R/ {
  printf("%s", $2);
 }' < /proc/ksyms`
 if [ -z $new ]; then
    echo "Warning: no kernel symbol found for $i, skipping"
 else
    echo "doing $1 trunc=$i1 new=$new"
    CMD="$CMD --redefine-sym=$i=$new"
 fi
done
 
#replace the modinfo section with the new one
CMD="$CMD --remove-section=.modinfo --add-section=.modinfo=$MI"
CMD="$CMD $*"
 
#run the command
echo $CMD
$CMD
 
#remove the section file
rm -f $MI
------- End of fixscript script --------------
-- 
___________________________________________________________________________
Paul Hanni                                                 
hannip@aol.net