[comp.unix.aux] A/UX device drivers

gabler@oakhill.UUCP (Christopher Gabler) (03/22/90)

I am in the process of writing a device driver for a General Purpose InterfaceBus in a Mac II.  The operating system used is A/UX 1.1. I have purchased the APDA A/UX Device Drivers kit and several supportive books on the Mac II hardware and Unix.  I have had many difficulties using the present resources in programming the driver and correctly installing it in the A/UX kernel.

The kinds of problems I am encountering are in using the example TEST driver. The example TEST routines from the kit are present in the /usr/src/device_drivers/1.1/TEST directory.  Using both of the available Makefiles (one in the text, and a slightly different one in the software)  the new autoconfiged kernel cannot physically find the "TEST" device. 

Variations in the autoconfig routine can place the TEST device as a module in the kernel.  This is seen by using the command "module_dump /unix".  Listing the contents of /dev also shows the TEST device with others like console and tty, etc.  However, if I try to open the device TEST, I get an error "device notfound".  I am also using the "launch -n" command in the sash when I startup the A/UX.

I have also noticed a strange occurrence when the autoconfig routine loads the TEST device in the list of device modules.  The Apple ethercard (already present) is excluded from the listing of startup devices.  When this happens, I lose my ethernet access.  The autoconfiguration routine is of the format "autoconfig -o /testunix -L loadfile -S /etc/startup -M /etc/master".

+++++++++++++++++++++++++++++++++++++++++
Christopher T. Gabler					+
Motorola Inc.							+
6501 Wm. Cannon Drive West  MS OE28		+
Austin, TX  78735-8598					+
+++++++++++++++++++++++++++++++++++++++++

rick@Apple.COM (Rick Auricchio) (03/23/90)

In article <3126@sol1.oakhill.UUCP> gabler@sol1.UUCP (Christopher Gabler) writes:
>I have also noticed a strange occurrence when the autoconfig routine loads
the TEST device in the list of device modules.  The Apple ethercard (already
present) is excluded from the listing of startup devices.  When this happens,
I lose my ethernet access.  The autoconfiguration routine is of the format
"autoconfig -o /testunix -L loadfile -S /etc/startup -M /etc/master".
	
	ALWAYS use the -I option, which causes "initialization" scripts to
	be run during autoconfig.  Unfortunately omitted from the document,
	and it really should be a default anyway.
-- 
-- 
Rick Auricchio, Apple Computer Inc, 20525 Mariani Av MS 58A Cupertino CA 95014
sun!apple!rick   OR   rick@apple.COM     Mooney N894AR     (408) 974-4227
		Never eat prunes when you're famished.
My opinion is my own. My employer? They use a windsock and a fire extinguisher.

liam@cs.qmw.ac.uk (William Roberts) (03/23/90)

In article <3126@sol1.oakhill.UUCP> gabler@sol1.UUCP (Christopher Gabler) writes:
>Variations in the autoconfig routine can place the TEST device as a module in the kernel.  This is seen by using the command "module_dump /unix".  Listing the contents of /dev also shows the TEST device with others like console and tty, etc.  However, if I try to open the device TEST, I get an error "device notfound".  I am also using the "launch -n" command in the sash when I startup the A/UX.
>
>I have also noticed a strange occurrence when the autoconfig routine loads the TEST device in the list of device modules.  The Apple ethercard (already present) is excluded from the listing of startup devices.  When this happens, I lose my ethernet access.  The autoconfiguration routine is of the format "autoconfig -o /testunix -L loadfile -S /etc/startup -M /etc/master".

Your problem is that the "-L loadfile" option means "ignore the
list of cards actually present, just use this information
instead". You should change the TEST file in /etc/master.d so
that instead of having an "id" line, it has something like

include .
cp0    -       qmc_  -      32       1

Alternatively, put the correct ID number for your GPIB card and
put the card into the machine: it shouldn't be able to do
anything until you enable it (it may kill your machine if the
MacOS driver was installed in the Sash partition, though,
because the MacOS driver close routine probably doesn't disable
the card properly (if at all)).

Once you've done this, try autoconfig without the -L option.

As for your "device not found" problem, I suspect that you
aren't remaking the device special files as part of the startup
script. Here are my versions of the TEST driver install and
uninstall scripts, based on the 1.0 device drivers kit, for a
software only device driver we use here at QMW.

I've also provided the revised Makefile which puts these files
in the right places and does /etc/newunix to get it going. You
should be able to recognise the Apple TEST stuff as a very near
ancestor of these files....

#         This is a shar archive.
#         Remove everything above and including the cut line.
#         Then run the rest of the file through sh.
#--------cut--------cut--------cut--------cut--------cut--------
#! /bin/sh
#  shar:  Shell Archiver
#         Run the following with /bin/sh to create:
#             qmc.install
#             qmc.uninstall
#             Makefile
# This archive created: Fri Mar 23 14:51:47 WET 1990
echo shar: extracting "qmc.install" '('1959 chars')'
if test -f qmc.install
then
    echo shar: will not overwrite existing file "qmc.install"
else
cat << \SHAR_EOF > qmc.install
: "@(#)Copyright 1988-89, Apple Computer - Version 1.16 of TEST.install on 09:35:50 3/8/89"

###############################################################################
###
###  /etc/install.d/TEST
###
###############################################################################

PATH=/bin:/usr/bin:/etc:/usr/etc
name=qmc

###-------------------------------------------------------------------------###
###  Install the driver object file
###-------------------------------------------------------------------------###

   cp /etc/install.d/boot.d/$name /etc/boot.d
   chmod 644 /etc/boot.d/$name

###-------------------------------------------------------------------------###
###  Install the driver master script file
###-------------------------------------------------------------------------###
###
### Note that the qmc driver is not associated with a specific
### card id of any sort, so we use "include ." instead of a card id.

### flags   nvec   prefix_   soft   devcnt   ipl

### c   - I am a character device driver
### p0  - call my init routine after initialising the kmem structures

cat > /etc/master.d/$name <<'--EOF--'
include .
cp0    -       qmc_  -      32       1
--EOF--

chmod 644 /etc/master.d/$name

###-------------------------------------------------------------------------###
###  Install the startup file
###-------------------------------------------------------------------------###

cat > /etc/startup.d/$name <<'--EOF--'
: "@(#)Copyright 1988-89, Apple Computer - Version 1.16 of TEST.install on 09:35:50 3/8/89"

#  startup script for qmc

PATH=/bin:/usr/bin:/etc:/usr/etc
scriptname=$0
name=qmc

while test -n "$1"
do
    case $1 in

        -M )
             #  For -M flag: Save the major number

             shift
             major=$1
             rm -f /dev/qmc
             mknod /dev/qmc c $major 0
             echo created /dev/qmc
             ;;

         * )
             # Ignore all other flags

             ;;
    esac
    shift
done
--EOF--

chmod 755 /etc/startup.d/$name
SHAR_EOF
if test 1959 -ne `wc -c < qmc.install`
then
    echo shar: error transmitting "qmc.install" '('should be 1959 chars')'
else
    echo qmc.install
fi
fi
echo shar: extracting "qmc.uninstall" '('1016 chars')'
if test -f qmc.uninstall
then
    echo shar: will not overwrite existing file "qmc.uninstall"
else
cat << \SHAR_EOF > qmc.uninstall
: "@(#)Copyright 1988-89, Apple Computer - Version 1.16 of TEST.uninsta on 09:35:53 3/8/89"

###############################################################################
###
###  /etc/uninstall.d/TEST
###
###############################################################################

PATH=/bin:/usr/bin:/etc:/usr/etc
name=qmc

###-------------------------------------------------------------------------###
###  Remove the driver object file
###-------------------------------------------------------------------------###

   rm -f /etc/boot.d/$name

###-------------------------------------------------------------------------###
###  Remove the driver master script file
###-------------------------------------------------------------------------###

   rm -f /etc/master.d/$name

###-------------------------------------------------------------------------###
###  Remove the startup script file
###-------------------------------------------------------------------------###

   rm -f /etc/startup.d/$name
SHAR_EOF
if test 1016 -ne `wc -c < qmc.uninstall`
then
    echo shar: error transmitting "qmc.uninstall" '('should be 1016 chars')'
else
    echo qmc.uninstall
fi
fi
echo shar: extracting "Makefile" '('1035 chars')'
if test -f Makefile
then
    echo shar: will not overwrite existing file "Makefile"
else
cat << \SHAR_EOF > Makefile
# "@(#)Copyright 1988-89, Apple Computer - Version 1.16 of Makefile on 09:35:45 3/8/89"

# Define DEST to point to your root directory
# ( this is usually / )
DEST=/

DEFINES= -DKERNEL -DNEW_PMMU -DDEBUG
FLAGS= ${DEFINES} ${INCLUDES}

CFLAGS= ${FLAGS} -O

DRIVER_OBJS= qmc_device.o

install:        demo unix.symtab
                sync
                sync

all:            ${DRIVER_OBJS}

unix.symtab:    qmc
                @echo  install the files and make the new kernel
                cp qmc $(DEST)/etc/install.d/boot.d/qmc
                chmod 644 $(DEST)/etc/install.d/boot.d/qmc
                cp qmc.install $(DEST)/etc/install.d/qmc
                chmod 755 $(DEST)/etc/install.d/qmc
                cp qmc.uninstall $(DEST)/etc/uninstall.d/qmc
                chmod 755 $(DEST)/etc/uninstall.d/qmc
                $(DEST)/etc/newunix qmc
                autoconfig -I \
                    -S $(DEST)/etc/startup -o $(DEST)/unix \
                    -M $(DEST)/etc/master
                echo nm -xe $(DEST)/unix | sort -t\| +1 >unix.symtab
                sync
                sync

qmc:          ${DRIVER_OBJS}
                ld -o qmc -x -r ${DRIVER_OBJS} /usr/lib/unshared.ld

demo: demo.c
        cc ${CFLAG} -o demo demo.c

demo ${DRIVER_OBJS}: qmc_dev.h
SHAR_EOF
if test 1035 -ne `wc -c < Makefile`
then
    echo shar: error transmitting "Makefile" '('should be 1035 chars')'
else
    echo Makefile
fi
fi
#         End of shar archive
exit 0
-- 

William Roberts                 ARPA: liam@cs.qmw.ac.uk
Queen Mary & Westfield College  UUCP: liam@qmw-cs.UUCP
Mile End Road                   AppleLink: UK0087
LONDON, E1 4NS, UK              Tel:  01-975 5250 (Fax: 01-980 6533)