Subject: How to write device drivers
To: port-amiga <port-amiga@NetBSD.ORG>
From: Markus Illenseer <markus@tiger.teuto.de>
List: port-amiga
Date: 10/18/1996 15:59:32
 After getting two mails from volunteers to write this or the other piece
of code, I thought I just pin up some hints how to continue.  This is just
a rough draft.  NetBSD - and other freely available Unices do share one
basic rule: Use the source, Luke!

 First of all:  Get the complete NetBSD 1.2 distributions, source code
included.  Install NetBSD 1.2, install the new compiler, install the
include files (cd /usr/src/include; make install)

 Second: cd /usr/src/sys/arch/amiga/conf
 Try to understand how the config files work.  Figure out where the soruce
code goes, and where the objects.  Decide whether your device driver might
be usuable for other platforms of NetBSD as well.  Look if you can share
code with other platforms.  Find out whether your driver can use code from
other implementations for other BUS-architectures such as PCI.  Add your
driver to the config file, don't forget files.amiga.

 Grab any code similar to your will-be-a-driver, rename it, remove all code
but the basic IOCTLS, intit-code, reset-code, I/O-cide and other stuff
related to your device. You now have a skeleton.

 Use "printf()" to stdout to be able to print debug messages.

 Before start:  Get informations about the device you are writing a device
for.  You need the Vendor and Product ID (AmigaDOS ShowConfig).  You need
the port-address which then enables you to access the registers.  You may
need informations about the IRQ-schematic of your device.  Figure out if
there are different versions of the device available.  Try to support them
all!  Check out how to distinguish between them.  Get manuals for the
chipsets beeing used.  Try to read and understand the code written there as
examples.  Be sure you access the chipset using the right Endian!
Introduce yourself with swap() otherwise.

 Some basic rules:  

 Don't use assembler.  Don't use hard-wired adresses.  Alloc() and free()
mem.  Use unique variables. Be noisy - use comments. 

 Commit your sources.  Mail into this list where to find your sources, ask
for Beta-testers.

 Good luck.

-- 
Markus Illenseer