Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lkm/arch/mac68k/iwm IWM floppy disk driver module writte...



details:   https://anonhg.NetBSD.org/src/rev/f1e4fe98276b
branches:  trunk
changeset: 467641:f1e4fe98276b
user:      scottr <scottr%NetBSD.org@localhost>
date:      Fri Mar 26 22:25:40 1999 +0000

description:
IWM floppy disk driver module written by Hauke Fath

diffstat:

 sys/lkm/arch/mac68k/iwm/Makefile        |   31 +++
 sys/lkm/arch/mac68k/iwm/README.iwm      |   85 +++++++++
 sys/lkm/arch/mac68k/iwm/README.technote |  293 ++++++++++++++++++++++++++++++++
 sys/lkm/arch/mac68k/iwm/TODO            |   71 +++++++
 sys/lkm/arch/mac68k/iwm/iwm_mod.c       |  237 +++++++++++++++++++++++++
 sys/lkm/arch/mac68k/iwm/iwm_mod.h       |   56 ++++++
 6 files changed, 773 insertions(+), 0 deletions(-)

diffs (truncated from 797 to 300 lines):

diff -r 20ad06850411 -r f1e4fe98276b sys/lkm/arch/mac68k/iwm/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/lkm/arch/mac68k/iwm/Makefile  Fri Mar 26 22:25:40 1999 +0000
@@ -0,0 +1,31 @@
+#      $Id: Makefile,v 1.1 1999/03/26 22:25:40 scottr Exp $
+#
+# Makefile for loadable iwm device driver kernel module
+#
+
+.include "../Makefile.inc"
+
+.PATH:         $S/arch/mac68k/obio
+
+CFILES=                iwm_mod.c iwm_fd.c
+SFILES=                iwm.s
+
+SRCS=          ${CFILES} ${SFILES}
+
+KMOD=          iwmfd
+
+MAN=
+
+CLEANFILES+=   *~ ${KMOD}
+
+#WARNS=                1
+#CPPFLAGS=     -DDIAGNOSTIC -DDDB -DDEBUG -nostdinc -Dmc68020 -Dmac68k
+CPPFLAGS=      -DDIAGNOSTIC -DDDB -nostdinc -Dmc68020 -Dmac68k
+CFLAGS=        -g -O -m68020-40
+
+AFLAGS=                -x assembler-with-cpp -traditional-cpp
+
+
+.include <bsd.kmod.mk> 
+
+
diff -r 20ad06850411 -r f1e4fe98276b sys/lkm/arch/mac68k/iwm/README.iwm
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/lkm/arch/mac68k/iwm/README.iwm        Fri Mar 26 22:25:40 1999 +0000
@@ -0,0 +1,85 @@
+#      $Id: README.iwm,v 1.1 1999/03/26 22:25:40 scottr Exp $
+
+From: Hauke Fath <hauke%Espresso.Rhein-Neckar.DE@localhost>
+Subject: NetBSD/mac68k IWM floppy driver
+
+
+## Contents
+
+This is a short overview over the package's contents.  
+
+The sources in this archive implement a floppy disk driver for 
+NetBSD/mac68k.  The driver can be built as a LKM (Loadable Kernel 
+Module) as well as an integral part of the kernel. As the name "iwmfd" 
+tries to point out, it currently supports 800K DD disks formatted in 
+Apple's proprietary GCR. 
+
+Sorry, no MFM, no HD disks.
+
+
+## Where does it go?
+
+cd to /usr/src and untar the archive.
+
+Most of the contents go to "./sys/arch/mac68k/lkm/iwm", some files go 
+to "./sys/arch/mac68k/dev" and "./sys/arch/mac68k/conf". 
+The file "1-3-2-iwm.diff", located in "./sys/arch", contains diffs to 
+files in the mac68k subtree and should be applied as "patch <1-3-2-iwm.diff" 
+from the "./sys/arch" direectory.
+
+To run the driver lkm, you need to have a custom kernel with patches 
+(at least) in mac68k/machdep.c and configured with the option LKM.
+For debugging, you'd also want DDB, DEBUG, DIAGNOSTIC and INSECURE, 
+and maybe UCONSOLE (see the example kernel config file).
+
+INSECURE runs the kernel in secure level #0 when in multi-user and allows 
+root to attach an LKM to it.
+
+
+## How do I run it?
+
+I assume you have built a custom kernel that defines the IWM I/O address 
+and was configured with LKM.
+
+Go to "./sys/arch/mac68k/lkm/iwm", do a make depend && make.
+After building the LKM (make links && make depend && make), you can type 
+'make load' as root to attach the LKM to the kernel for testing, if it 
+was configured with INSECURE (see above).
+  
+Then put the iwmfd.o file into /usr/lkm, create an entry in /etc/lkm.conf
+for it (basically "iwmfd.o - - - - -", see man lkm.conf), make sure loading 
+LKMs during startup is enabled in /etc/rc.conf, and reboot.
+
+It helps if you have something sensible on your 800K floppy. Suntar 2.xx 
+(available on any info-mac mirror, try archie) is capable of writing a tar 
+archive to a raw 800k disk (it will complain, but you can ignore that); 
+you may want to put some text files onto the disk.
+
+
+## Getting technical
+
+A Loadable Kernel Module is an object file that can be attached to a 
+running kernel (see lkm(4), lkm.conf(5), modload(8), modunload(8)).  
+The LKM code sees all the kernel's global symbols (functions, global 
+variables); it can patch tables and variables and thus substitute kernel 
+facilities (e.g.  system calls, file systems, device drivers) with its 
+own functionality.
+
+In fact, I found it harder to understand what a device driver is and how it 
+fits into the kernel that to turn an existing ( and - hopefully - well
+understood) device driver into a loadable module.  
+
+The biggest change concerns the autoconfig framework: Noone calls the 
+xxx{match,attach,print} functions so they can as well be scrapped.  The 
+device initialization part of their functionality, though, has to be kept 
+and should be called when the module is loaded (see fdProbe(), iwmProbe() 
+in fd.c, called from iwmModule.c) and unloaded.  
+
+Terry Lambert's LKM framework contains templates for file systems and 
+system calls as well as for block and for character device drivers.  
+Unfortunately, it lacks examples for the latter, and as we are talking 
+about a disk driver which has to supply (patch) a character device switch 
+as well as a block device switch, we have to roll our own. It's not that 
+difficult, though... see {load,unload}Module() in iwmModule.c for the patch 
+code.
+
diff -r 20ad06850411 -r f1e4fe98276b sys/lkm/arch/mac68k/iwm/README.technote
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/lkm/arch/mac68k/iwm/README.technote   Fri Mar 26 22:25:40 1999 +0000
@@ -0,0 +1,293 @@
+#      $Id: README.technote,v 1.1 1999/03/26 22:25:40 scottr Exp $
+
+
+The IWM chip (the Mac floppy controller) is a descendant of the Apple
+][ disk controller and quite different from the everyday FDC. Instead
+of configuring your FDC, sending a command and sleep()ing until it
+completes, you have to do everything by hand.
+
+That means: Sit on the floppy's head, look for a header ID and read &
+decode the header. If it indicates the sector you want, read the
+sector data and decode it while you're reading (a fairly complex
+scheme, and one of apple's best kept secrets, too). Continue at will;
+similarly for writing.
+
+Now, did you miss the word "interrupt"? -- There is none. The IWM runs
+entirely in polled mode, all interrupts disabled. The MacOS .Sony
+driver polls one serial port during disk I/O to maintain LocalTalk
+connectivity; other than that, the machine is locked.
+
+
+
+
+IWM Registers:
+==============
+
+
+1. IWM register selection
+
+Q6    Q7    Register
+-----------------------------------------------------------------------------
+off   off   Read from data register
+off   on    Read from handshake register
+on    off   Read from status register
+on    on    Write to mode register -- drive is off
+            Write to data register -- drive is on
+            
+
+2. IWM mode register
+
+Bit   Function
+-----------------------------------------------------------------------------
+7     reserved
+6     reserved
+5     reserved
+4     clock speed:         0 = 7 MHz (Apple II)
+                           1 = 8 MHz (Mac)
+3     bit cell time:       0 = 2 usec/bit (3.5")      (*)
+                           1 = 4 usec/bit (5.25")
+2     motor-off timer:     0 = motor off delayed by 1 sec (5.25")
+                           1 = no delay (3.5")
+1     handshake protocol:  0 = synchronous/software timing (5.25")
+                           1 = asynchronous/IWM timing (3.5")
+0     latch mode:          0 = read data valid for 7 usec (5.25")
+                           1 = read data valid for full byte time (3.5")
+
+
+3. IWM status register
+                                 
+Bit   Function
+-----------------------------------------------------------------------------
+7     sense input:         5.25" write protect line
+                           3.5"  general status line
+6     reserved             HD media format?
+5     drive enabled        1 = drive is on
+4     clock speed:         0 = 7 MHz (Apple II)
+                           1 = 8 MHz (Mac)
+3     bit cell time:       0 = 2 usec/bit (3.5")      (*)
+                           1 = 4 usec/bit (5.25")
+2     motor-off timer:     0 = motor off delayed by 1 sec (5.25")
+                           1 = no delay (3.5")
+1     handshake protocol:  0 = synchronous/software timing (5.25")
+                           1 = asynchronous/IWM timing (3.5")
+0     latch mode:          0 = read data valid for 7 usec (5.25")
+                           1 = read data valid for full byte time (3.5")
+
+
+4. IWM handshake register
+
+Bit   Function
+-----------------------------------------------------------------------------
+7     IWM state:           0 = busy
+                           1 = ready for data
+6     underrun:            0 = write underrun (data not delivered in time)
+                           1 = no error
+5     reserved
+4     reserved
+3     reserved
+2     reserved
+1     reserved
+0     reserved                                                 
+
+
+---
+(*)   inverse to "iwmstuff"!! Is this really the bit cell time?
+      Valid reads from a Macintosh Sony drive have a '1' here.
+
+
+
+
+
+
+SWIM registers:
+===============
+
+(coming soon...)
+
+
+
+
+Floppy drive registers:
+=======================
+
+
+1. Status bits:
+
+The result of the query for 'Param' is returned in Bit 7 of q7L, which is 
+usually checked by a bmi/bpl branch.
+
+
+CA1   CA0   SEL   CA2   Param    Register    Function (q7L, Bit 7)
+-----------------------------------------------------------------------------
+off   off   off   off   0x00     DIRTN       direction of head step:
+                                             0 = inward (greater track no)
+                                             1 = outward (smaller track no)
+off   off   off   on    0x01     RDDATA0     Reading sets up drive to read 
+                                             data from lower head
+off   off   on    off   0x02     CSTIN       Disk inserted:
+                                             0 = disk in drive
+                                             1 = drive empty
+off   off   on    on    0x03     RDDATA1     Reading sets up drive to read 
+                                             data from upper head
+off   on    off   off   0x04     STEP        Disk head is stepping (1)
+                                             0 = yes, still stepping 
+                                             1 = no, drive ready
+off   on    off   on    0x05     -----       Not used
+off   on    on    off   0x06     WRTPRT      Disk is locked:
+                                             0 = write-protected
+                                             1 = write-enabled
+off   on    on    on    0x07     -----       Not used
+on    off   off   off   0x08     MOTORON     Drive motor state:
+                                             0 = on
+                                             1 = off
+on    off   off   on    0x09     SIDES       Number of sides:
+                                             0 = single-sided drive
+                                             1 = double-sided drive
+on    off   on    off   0x0A     TK0         Track 00 switch:
+                                             0 = head is at track 00
+                                             1 = head is elsewhere
+on    off   on    on    0x0B     ?????       Head loaded/drive ready:
+                                             0 = ready
+                                             1 = not ready
+on    on    off   off   0x0C     ?????       (Disk switched?)
+on    on    off   on    0x0D     ------      Not used
+on    on    on    off   0x0E     TACH        Tachometer (60 pulses/rev)
+on    on    on    on    0x0F     DRVIN       Drive installed: (2)
+                                             0 = drive is connected
+                                             1 = no drive
+
+(1)   After step is done, wait ca. 30 µs before issuing next step command; 
+otherwise steps tend to get lost.
+
+(2)   The SWIM & SuperDrive apparently use DRVIN (0x0F) to distinguish between 
+DD and HD disk media and check for an installed drive with 0x0D.
+                                             
+
+2. Control bits:
+
+
+CA1   CA0   SEL   CA2   Param    Register    Function
+-----------------------------------------------------------------------------
+off   off   off   off   0x00     DIRTN       Set direction of head step
+                                             to inward (greater track no)



Home | Main Index | Thread Index | Old Index