Subject: port-i386/6274: port-i386 has no NCR 53C80 driver
To: None <gnats-bugs@gnats.netbsd.org>
From: John Ruschmeyer <jruschme@exit109.com>
List: netbsd-bugs
Date: 10/11/1998 18:42:40
>Number:         6274
>Category:       port-i386
>Synopsis:       port-i386 has no NCR 53C80 driver
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 11 17:50:01 1998
>Last-Modified:
>Originator:     John Ruschmeyer
>Organization:
Many small piles
>Release:        NetBSD-1.3.2
>Environment:
	
System: NetBSD tigger 1.3.2 NetBSD 1.3.2 (TIGTEST) #39: Sun Oct 11 11:23:14 PDT 1998 root@tigger:/usr/src/sys/arch/i386/compile/TIGTEST i386


>Description:
	NetBSD-1.3.2 has no NCR53C80 driver for port i386.
>How-To-Repeat:
	Buy 53C80-based card, try to configure. :-)
>Fix:
	Attached is a diff which contains code that implements an NCR 53C80/
53C400 driver for NetBSD-1.3.2. It consists of two portions:

1) Patches to the MI 53C80 driver to make it use bus_space(). (Requires additiondefine to enable. Default is to compile in "legacy" memory-mapped mode.)
2) Machine-dependent driver ('nca') which contains ISA attach and probe code.

A README and a sample config file are also included.

Share and enjoy...
<<<John>>>


diff -N -r -u sys.old/arch/i386/conf/GENERIC_NCA sys/arch/i386/conf/GENERIC_NCA
--- sys.old/arch/i386/conf/GENERIC_NCA	Wed Dec 31 16:00:00 1969
+++ sys/arch/i386/conf/GENERIC_NCA	Sun Oct 11 16:54:27 1998
@@ -0,0 +1,441 @@
+#	$NetBSD: GENERIC,v 1.114.2.10 1998/05/05 08:10:38 mycroft Exp $
+#
+#	GENERIC_NCA -- everything that's currently supported
+#			plus the NCR 53C80/53C400
+#
+
+include "arch/i386/conf/std.i386"
+
+maxusers	32		# estimated number of users
+
+# CPU support.  At least one is REQUIRED.
+options 	I386_CPU
+options 	I486_CPU
+options 	I586_CPU
+options 	I686_CPU	
+
+# CPU-related options.
+options 	MATH_EMULATE	# floating point emulation
+#options 	VM86		# virtual 8086 emulation
+options 	USER_LDT	# user-settable LDT; used by WINE
+# eliminate delay no-ops in I/O; recommended on all but very old machines
+#options 	DUMMY_NOPS
+
+# Misc. i386-specific options
+options 	XSERVER		# X server support in console drivers
+
+# This option allows you to force a serial console at the specified
+# I/O address.   see console(4) for details.
+#options 	"CONSDEVNAME=\"com\""
+
+# The following options override the memory sizes passed in from the boot
+# block.  Use them *only* if the boot block is unable to determine the correct
+# values.  Note that the BIOS may *correctly* report less than 640k of base
+# memory if the extended BIOS data area is located at the top of base memory
+# (as is the case on most recent systems).
+#options 	REALBASEMEM=...	# size of base memory
+#options 	REALEXTMEM=...	# size of extended memory
+
+# Standard system options
+
+options 	UCONSOLE	# users can use TIOCCONS (for xconsole)
+options 	INSECURE	# disable kernel security levels
+
+options 	RTC_OFFSET=0	# hardware clock is this many mins. west of GMT
+#options 	NTP		# NTP phase/frequency locked loop
+
+options 	KTRACE		# system call tracing via ktrace(1)
+
+options 	SYSVMSG		# System V-like message queues
+options 	SYSVSEM		# System V-like semaphores
+options 	SYSVSHM		# System V-like memory sharing
+#options 	SHMMAXPGS=1024	# 1024 pages is the default
+
+options 	LKM		# loadable kernel modules
+
+# Diagnostic/debugging support options
+options 	DIAGNOSTIC	# cheap kernel consistency checks
+#options 	DEBUG		# expensive debugging checks/support
+options 	KMEMSTATS	# kernel memory statistics (vmstat -m)
+options 	DDB		# in-kernel debugger
+#options 	KGDB		# remote debugger
+#options 	"KGDB_DEVNAME=\"com\"",KGDBADDR=0x3f8,KGDBRATE=9600
+#makeoptions	DEBUG="-g"	# compile full symbol table
+
+# Compatibility options
+options 	COMPAT_NOMID	# compatibility with 386BSD, BSDI, NetBSD 0.8,
+options 	COMPAT_09	# NetBSD 0.9,
+options 	COMPAT_10	# NetBSD 1.0,
+options 	COMPAT_11	# NetBSD 1.1,
+options 	COMPAT_12	# NetBSD 1.2,
+options 	COMPAT_43	# and 4.3BSD
+
+options 	COMPAT_SVR4	# binary compatibility with SVR4
+options 	COMPAT_IBCS2	# binary compatibility with SCO and ISC
+options 	COMPAT_LINUX	# binary compatibility with Linux
+options 	COMPAT_FREEBSD	# binary compatibility with FreeBSD
+
+# Executable format options
+options 	EXEC_ELF32	# 32-bit ELF executables (SVR4, Linux)
+
+# File systems
+file-system 	FFS		# UFS
+file-system 	EXT2FS		# second extended file system (linux)
+file-system 	LFS		# log-structured file system
+file-system 	MFS		# memory file system
+file-system 	NFS		# Network File System client
+file-system 	CD9660		# ISO 9660 + Rock Ridge file system
+file-system 	MSDOSFS		# MS-DOS file system
+file-system 	FDESC		# /dev/fd
+file-system 	KERNFS		# /kern
+file-system 	NULLFS		# loopback file system
+file-system 	PORTAL		# portal filesystem (still experimental)
+file-system 	PROCFS		# /proc
+file-system 	UMAPFS		# NULLFS + uid and gid remapping
+file-system 	UNION		# union file system
+
+# File system options
+options 	QUOTA		# UFS quotas
+options 	NFSSERVER	# Network File System server
+options 	FIFO		# FIFOs; RECOMMENDED
+#options 	EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and
+				# immutable) behave as system flags.
+
+# Networking options
+#options 	GATEWAY		# packet forwarding
+options 	INET		# IP + ICMP + TCP + UDP
+#options 	MROUTING	# IP multicast routing
+options 	NS		# XNS
+#options 	NSIP		# XNS tunneling over IP
+options 	ISO,TPIP	# OSI
+options 	EON		# OSI tunneling over IP
+options 	CCITT,LLC,HDLC	# X.25
+options 	NETATALK	# AppleTalk networking protocols
+#options 	PPP_BSDCOMP	# BSD-Compress compression support for PPP
+#options 	PPP_DEFLATE	# Deflate compression support for PPP
+#options 	PPP_FILTER	# Active filter support for PPP (requires bpf)
+#options 	PFIL_HOOKS	# pfil(9) packet filter hooks
+#options 	IPFILTER_LOG	# ipmon(8) log support
+
+# Compatibility with 4.2BSD implementation of TCP/IP.  Not recommended.
+#options 	TCP_COMPAT_42
+
+# These options enable verbose messages for several subsystems.
+# Warning, these may compile large string tables into the kernel!
+options 	EISAVERBOSE	# verbose EISA device autoconfig messages
+options 	PCIVERBOSE	# verbose PCI device autoconfig messages
+#options 	PCMCIAVERBOSE	# verbose PCMCIA configuration messages
+options 	SCSIVERBOSE	# human readable SCSI error messages
+
+# Kernel root file system and dump configuration.
+config		netbsd	root on ? type ?
+#config		netbsd	root on sd0a type ffs
+#config		netbsd	root on ? type nfs
+
+#
+# Device configuration
+#
+
+mainbus0 at root
+
+#apm0	at mainbus0			# Advanced power management
+
+
+# Basic Bus Support
+
+# PCI bus support
+pci*	at mainbus? bus ?
+pci*	at pchb? bus ?
+pci*	at ppb? bus ?
+
+# PCI bridges
+pchb*	at pci? dev ? function ?	# PCI-Host bridges
+pcib*	at pci? dev ? function ?	# PCI-ISA bridges
+ppb*	at pci? dev ? function ?	# PCI-PCI bridges
+
+# EISA bus support
+eisa*	at mainbus?
+
+# ISA bus support
+isa*	at mainbus?
+isa*	at pcib?
+
+# PCMCIA bus support
+pcmcia*	at pcic? controller ? socket ?
+
+# ISA PCMCIA controllers
+pcic0	at isa? port 0x3e0 iomem 0xd0000 iosiz 0x4000
+pcic1	at isa? port 0x3e2 iomem 0xd4000 iosiz 0x4000
+
+# ISA Plug-and-Play bus support
+isapnp0	at isa?
+
+
+# Coprocessor Support
+
+# Math Coprocessor support
+npx0	at isa? port 0xf0 irq 13	# x86 math coprocessor
+
+
+# Console Devices
+
+# ISA console.  You can only configure one of these!
+pc0	at isa? port 0x60 irq 1		# pccons generic PC console driver
+#vt0	at isa? port 0x60 irq 1		# PCVT console driver
+
+
+# Serial Devices
+
+# PCI serial interfaces
+cy*	at pci? dev ? function ?	# Cyclades Cyclom-Y serial boards
+
+# ISA Plug-and-Play serial interfaces
+com*	at isapnp?			# Modems and serial boards
+
+# PCMCIA serial interfaces
+com*	at pcmcia? function ?		# Modems and serial cards
+
+# ISA serial interfaces
+#options 	COM_HAYESP		# adds Hayes ESP serial board support
+com0	at isa? port 0x3f8 irq 4	# Standard PC serial ports
+com1	at isa? port 0x2f8 irq 3
+com2	at isa? port 0x3e8 irq 5
+#com3	at isa? port 0x2e8 irq 9
+#ast0	at isa? port 0x1a0 irq 5	# AST 4-port serial cards
+#com*	at ast? slave ?
+#boca0	at isa? port 0x100 irq 5	# BOCA 8-port serial cards
+#com*	at boca? slave ?
+#rtfps0	at isa? port 0x1230 irq 10	# RT 4-port serial cards
+#com*	at rtfps? slave ?
+#cy0	at isa? iomem 0xd4000 irq 12	# Cyclades serial cards
+
+
+# Parallel Printer Interfaces
+
+# ISA parallel printer interfaces
+lpt0	at isa? port 0x378 irq 7	# standard PC parallel ports
+lpt1	at isa? port 0x278
+lpt2	at isa? port 0x3bc
+
+
+# SCSI Controllers and Devices
+
+# PCI SCSI controllers
+ahc*	at pci? dev ? function ?	# Adaptec [23]94x, aic78x0 SCSI
+bha*	at pci? dev ? function ?	# BusLogic 9xx SCSI
+isp*	at pci? dev ? function ?	# Qlogic ISP [12]0x0 SCSI/FibreChannel
+ncr*	at pci? dev ? function ?	# NCR 53c8xx SCSI
+
+# EISA SCSI controllers
+ahb*	at eisa? slot ?			# Adaptec 174[02] SCSI
+ahc*	at eisa? slot ?			# Adaptec 274x, aic7770 SCSI
+bha*	at eisa? slot ?			# BusLogic 7xx SCSI
+uha*	at eisa? slot ?			# UltraStor 24f SCSI
+
+# PCMCIA SCSI controllers
+aic*	at pcmcia? function ?		# Adaptec APA-1460 SCSI
+
+# ISA SCSI controllers
+aha0	at isa? port 0x330 irq ? drq ?	# Adaptec 154[02] SCSI
+aha1	at isa? port 0x334 irq ? drq ?
+ahc0	at isa? port ? irq ?		# Adaptec 284x SCSI
+aic0	at isa? port 0x340 irq 11	# Adaptec 152[02] SCSI
+bha0	at isa? port 0x330 irq ? drq ?	# BusLogic [457]4X SCSI
+bha1	at isa? port 0x334 irq ? drq ?
+sea0	at isa? iomem 0xc8000 irq 5	# Seagate/Future Domain SCSI
+uha0	at isa? port 0x330 irq ? drq ?	# UltraStor [13]4f SCSI
+uha1	at isa? port 0x340 irq ? drq ?
+wds0	at isa? port 0x350 irq 15 drq 6	# WD7000 and TMC-7000 controllers
+wds1	at isa? port 0x358 irq 11 drq 5
+
+# This option is required by the nca driver
+options	NCR5380_USE_BUS_SPACE
+# NCR 53C80/53C400 controllers can be port or memory mapped
+nca0	at isa? port 0x360 irq 15	# Port-mapped NCR 53C80 contoller
+nca1	at isa? iomem 0xd8000 irq 5	# Memory-mapped controller (T128, etc.)
+
+# SCSI bus support
+scsibus* at aha?
+scsibus* at ahb?
+scsibus* at ahc?
+scsibus* at aic?
+scsibus* at bha?
+scsibus* at isp?
+scsibus* at ncr?
+scsibus* at sea?
+scsibus* at uha?
+scsibus* at wds?
+scsibus* at nca?
+
+# SCSI devices
+sd*	at scsibus? target ? lun ?	# SCSI disk drives
+st*	at scsibus? target ? lun ?	# SCSI tape drives
+cd*	at scsibus? target ? lun ?	# SCSI CD-ROM drives
+ch*	at scsibus? target ? lun ?	# SCSI autochangers
+ss*	at scsibus? target ? lun ?	# SCSI scanners
+uk*	at scsibus? target ? lun ?	# SCSI unknown
+
+
+# IDE and Related Devices
+
+# ISA IDE controllers
+wdc0	at isa? port 0x1f0 irq 14	# ST506, ESDI, and IDE controllers
+wdc1	at isa? port 0x170 irq 15
+
+# IDE drives
+wd*	at wdc? drive ?			# the drives themselves
+
+# ATAPI bus support
+atapibus* at wdc?
+
+# ATAPI devices
+cd*	at atapibus? drive ?		# ATAPI CD-ROM drives
+
+
+# Miscellaneous mass storage devices
+
+# ISA floppy
+fdc0	at isa? port 0x3f0 irq 6 drq 2	# standard PC floppy controllers
+#fdc1	at isa? port 0x370 irq ? drq ?
+fd*	at fdc? drive ?			# the drives themselves
+# some machines need you to do this instead of fd*
+#fd0	at fdc0 drive 0
+
+# ISA CD-ROM devices
+#mcd0	at isa? port 0x300 irq 10	# Mitsumi CD-ROM drives
+
+# ISA tape devices
+# note: the wt driver conflicts unpleasantly with ed devices at the
+# same I/O address. The probe reprograms their EEPROMs. Don't
+# uncomment it unless you are actually using it.
+#wt0	at isa? port 0x308 irq 5 drq 1	# Archive and Wangtek QIC tape drives
+
+
+# Network Interfaces
+
+# PCI network interfaces
+de*	at pci? dev ? function ?	# DEC 21x4x-based Ethernet
+en*	at pci? dev ? function ?	# ENI/Adaptec ATM
+ep*	at pci? dev ? function ?	# 3Com 3c59x/3c90x Ethernet
+fpa*	at pci? dev ? function ?	# DEC DEFPA FDDI
+fxp*	at pci? dev ? function ?	# Intel EtherExpress PRO 10+/100B
+le*	at pci? dev ? function ?	# PCnet-PCI Ethernet
+ne*	at pci? dev ? function ?	# NE2000-compatible Ethernet
+tl*	at pci? dev ? function ?	# ThunderLAN-based Ethernet
+
+# EISA network interfaces
+ep*	at eisa? slot ?			# 3Com 3c579 Ethernet
+fea*	at eisa? slot ?			# DEC DEFEA FDDI
+
+# ISA Plug-and-Play network interfaces
+ep*	at isapnp?			# 3Com 3c509 Ethernet
+ne*	at isapnp?			# NE2000-compatible Ethernet
+
+# PCMCIA network interfaces
+ep*	at pcmcia? function ?		# 3Com 3c589 and 3c562 Ethernet
+ne*	at pcmcia? function ?		# NE2000-compatible Ethernet
+sm*	at pcmcia? function ?		# Megahertz Ethernet
+
+# ISA network interfaces
+ec0	at isa? port 0x250 iomem 0xd8000 irq 9	# 3Com 3c503 Ethernet
+eg0	at isa? port 0x280 irq 9		# 3C505 ethernet cards
+el0	at isa? port 0x300 irq 9		# 3C501 ethernet cards
+ep0	at isa? port ? irq ?			# 3C509 ethernet cards
+fe0	at isa? port 0x2a0 irq ?		# AT1700
+ie0	at isa? port 0x360 iomem 0xd0000 irq 7	# StarLAN and 3C507
+ie1	at isa? port 0x300 irq 10		# EtherExpress
+iy0	at isa? port 0x360 irq ?		# EtherExpress PRO 10 ISA
+lc0	at isa? port 0x320 iomem ? irq ?	# DEC EtherWORKS III (LEMAC)
+#le0	at isa? port 0x320 irq 10 drq 7		# IsoLan, NE2100, and DEPCA
+ne0	at isa? port 0x280 irq 9		# NE[12]000 ethernet cards
+ne1	at isa? port 0x300 irq 10
+sm0	at isa? port 0x300 irq 10		# SMC91C9x Ethernet
+we0	at isa? port 0x280 iomem 0xd0000 irq 9	# WD/SMC Ethernet
+we1	at isa? port 0x300 iomem 0xcc000 irq 10
+
+# MII bus support
+mii*	at tl?
+
+# MII PHY network interfaces
+tlphy*	at mii? dev ?			# ThunderLAN PHYs
+nsphy*	at mii? dev ?			# NS and compatible PHYs
+
+
+# Audio Devices
+
+# ISA Plug-and-Play audio devices
+guspnp*	at isapnp?			# Gravis Ultra Sound PnP audio
+sb*	at isapnp?			# SoundBlaster-compatible audio
+
+# ISA audio devices
+gus0	at isa? port 0x220 irq 7 drq 1 drq2 6	# Gravis Ultra Sound
+pas0	at isa? port 0x220 irq 7 drq 1		# ProAudio Spectrum
+pss0	at isa? port 0x220 irq 7 drq 6  	# Personal Sound System
+sp0	at pss0 port 0x530 irq 10 drq 0		# 	sound port driver
+sb0	at isa? port 0x220 irq 7 drq 1 drq2 5	# SoundBlaster
+wss0	at isa? port 0x530 irq 10 drq 0	drq2 1	# Windows Sound System
+
+# Audio support
+audio*	at gus?
+audio*	at guspnp?
+audio*	at pas?
+audio*	at sb?
+audio*	at sp?
+audio*	at wss?
+
+# The spkr driver provides a simple tone interface to the built in speaker.
+#spkr0	at pckbd? port 0x61		# PC speaker
+
+
+# Mice
+
+# ISA busmice
+lms0	at isa? port 0x23c irq 5	# Logitech bus mouse
+lms1	at isa? port 0x238 irq 5
+mms0	at isa? port 0x23c irq 5	# Microsoft InPort mouse
+mms1	at isa? port 0x238 irq 5
+#pms0	at pckbd? irq 12		# PS/2 auxiliary port mouse
+
+
+# Joysticks
+
+# ISA Plug-and-Play joysticks
+joy*	at isapnp?			# Game ports (usually on audio cards)
+
+# ISA joysticks. Probe is a little strange; add only if you have one.
+#joy0	at isa? port 0x201
+
+
+# Miscellaneous Devices
+
+# Planetconnect Satellite receiver driver.
+#satlink0 at isa? port 0x300 drq 1
+
+
+# Pull in optional local configuration
+include	"arch/i386/conf/GENERIC.local"
+
+
+# Pseudo-Devices
+
+# disk/mass storage pseudo-devices
+pseudo-device	ccd		4	# concatenated/striped disk devices
+pseudo-device	md		1	# memory disk device (ramdisk)
+pseudo-device	vnd		4	# disk-like interface to files
+
+# network pseudo-devices
+pseudo-device	bpfilter	8	# Berkeley packet filter
+pseudo-device	ipfilter		# IP filter (firewall) and NAT
+pseudo-device	loop			# network loopback
+pseudo-device	ppp		2	# Point-to-Point Protocol
+pseudo-device	sl		2	# Serial Line IP
+pseudo-device	strip		2	# Starmode Radio IP (Metricom)
+pseudo-device	tun		2	# network tunneling over tty
+
+# miscellaneous pseudo-devices
+pseudo-device	pty		64	# pseudo-terminals
+pseudo-device	tb		1	# tablet line discipline
+
+# rnd is EXPERIMENTAL at this point.
+#pseudo-device	rnd			# /dev/random and in-kernel generator
+#options 	RND_COM			# use "com" randomness as well (BROKEN)
diff -N -r -u sys.old/dev/ic/ncr5380sbc.c sys/dev/ic/ncr5380sbc.c
--- sys.old/dev/ic/ncr5380sbc.c	Sun Oct 11 16:43:05 1998
+++ sys/dev/ic/ncr5380sbc.c	Sun Oct 11 16:42:10 1998
@@ -64,6 +64,10 @@
  *   Michael L. Hitch (amiga drivers: sci.c)
  *   Leo Weppelman (atari driver: ncr5380.c)
  * There are others too.  Thanks, everyone.
+ *
+ * Transliteration to bus_space() performed 9/17/98 by
+ * John Ruschmeyer (jruschme@exit109.com) for i386 'nca' driver.
+ * Thank you all.
  */
 
 #include <sys/types.h>
@@ -76,6 +80,8 @@
 #include <sys/proc.h>
 #include <sys/user.h>
 
+#include <machine/bus.h>
+
 #include <dev/scsipi/scsi_all.h>
 #include <dev/scsipi/scsipi_all.h>
 #include <dev/scsipi/scsipi_debug.h>
@@ -89,6 +95,7 @@
 #include <dev/ic/ncr5380reg.h>
 #include <dev/ic/ncr5380var.h>
 
+
 static void	ncr5380_sched __P((struct ncr5380_softc *));
 static void	ncr5380_done __P((struct ncr5380_softc *));
 
@@ -184,7 +191,7 @@
 {
 	register int timo = ncr5380_wait_req_timo;
 	for (;;) {
-		if (*sc->sci_bus_csr & SCI_BUS_REQ) {
+		if (NCR5380_READ(sci_bus_csr) & SCI_BUS_REQ) {
 			timo = 0;	/* return 0 */
 			break;
 		}
@@ -201,7 +208,7 @@
 {
 	register int timo = ncr5380_wait_nrq_timo;
 	for (;;) {
-		if ((*sc->sci_bus_csr & SCI_BUS_REQ) == 0) {
+		if ((NCR5380_READ(sci_bus_csr) & SCI_BUS_REQ) == 0) {
 			timo = 0;	/* return 0 */
 			break;
 		}
@@ -221,8 +228,9 @@
 	/* First time, raise ATN line. */
 	if (sc->sc_msgpriq == 0) {
 		register u_char icmd;
-		icmd = *sc->sci_icmd & SCI_ICMD_RMASK;
-		*sc->sci_icmd = icmd | SCI_ICMD_ATN;
+		icmd = NCR5380_READ(sci_icmd)
+			& SCI_ICMD_RMASK;
+		NCR5380_WRITE(sci_icmd,icmd|SCI_ICMD_ATN);
 		delay(2);
 	}
 	sc->sc_msgpriq |= msg_code;
@@ -239,10 +247,10 @@
 	register int		resid;
 	register int		error;
 
-	icmd = *(sc->sci_icmd) & SCI_ICMD_RMASK;
+	icmd = NCR5380_READ(sci_icmd) & SCI_ICMD_RMASK;
 
 	icmd |= SCI_ICMD_DATA;
-	*sc->sci_icmd = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 
 	resid = count;
 	while (resid > 0) {
@@ -254,25 +262,25 @@
 			NCR_TRACE("pio_out: no REQ, resid=%d\n", resid);
 			break;
 		}
-		if (SCI_BUS_PHASE(*sc->sci_bus_csr) != phase)
+		if (SCI_BUS_PHASE(NCR5380_READ(sci_bus_csr)) != phase)
 			break;
 
 		/* Put the data on the bus. */
 		if (data)
-			*sc->sci_odata = *data++;
+			NCR5380_WRITE(sci_odata,*data++);
 		else
-			*sc->sci_odata = 0;
+			NCR5380_WRITE(sci_odata,0);
 
 		/* Tell the target it's there. */
 		icmd |= SCI_ICMD_ACK;
-		*sc->sci_icmd = icmd;
+		NCR5380_WRITE(sci_icmd,icmd);
 
 		/* Wait for target to get it. */
 		error = ncr5380_wait_not_req(sc);
 
 		/* OK, it's got it (or we gave up waiting). */
 		icmd &= ~SCI_ICMD_ACK;
-		*sc->sci_icmd = icmd;
+		NCR5380_WRITE(sci_icmd,icmd);
 
 		if (error) {
 			NCR_TRACE("pio_out: stuck REQ, resid=%d\n", resid);
@@ -284,7 +292,7 @@
 
 	/* Stop driving the data bus. */
 	icmd &= ~SCI_ICMD_DATA;
-	*sc->sci_icmd = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 
 	return (count - resid);
 }
@@ -300,7 +308,7 @@
 	register int		resid;
 	register int		error;
 
-	icmd = *(sc->sci_icmd) & SCI_ICMD_RMASK;
+	icmd = NCR5380_READ(sci_icmd) & SCI_ICMD_RMASK;
 
 	resid = count;
 	while (resid > 0) {
@@ -313,25 +321,25 @@
 			break;
 		}
 		/* A phase change is not valid until AFTER REQ rises! */
-		if (SCI_BUS_PHASE(*sc->sci_bus_csr) != phase)
+		if (SCI_BUS_PHASE(NCR5380_READ(sci_bus_csr)) != phase)
 			break;
 
 		/* Read the data bus. */
 		if (data)
-			*data++ = *sc->sci_data;
+			*data++ = NCR5380_READ(sci_data);
 		else
-			(void) *sc->sci_data;
+			(void) NCR5380_READ(sci_data);
 
 		/* Tell target we got it. */
 		icmd |= SCI_ICMD_ACK;
-		*sc->sci_icmd = icmd;
+		NCR5380_WRITE(sci_icmd,icmd);
 
 		/* Wait for target to drop REQ... */
 		error = ncr5380_wait_not_req(sc);
 
 		/* OK, we can drop ACK. */
 		icmd &= ~SCI_ICMD_ACK;
-		*sc->sci_icmd = icmd;
+		NCR5380_WRITE(sci_icmd,icmd);
 
 		if (error) {
 			NCR_TRACE("pio_in: stuck REQ, resid=%d\n", resid);
@@ -367,14 +375,14 @@
 	sc->sc_prevphase = PHASE_INVALID;
 	sc->sc_state = NCR_IDLE;
 
-	*sc->sci_tcmd = PHASE_INVALID;
-	*sc->sci_icmd = 0;
-	*sc->sci_mode = 0;
-	*sc->sci_sel_enb = 0;
+	NCR5380_WRITE(sci_tcmd,PHASE_INVALID);
+	NCR5380_WRITE(sci_icmd,0);
+	NCR5380_WRITE(sci_mode,0);
+	NCR5380_WRITE(sci_sel_enb,0);
 	SCI_CLR_INTR(sc);
 
 	/* XXX: Enable reselect interrupts... */
-	*sc->sci_sel_enb = 0x80;
+	NCR5380_WRITE(sci_sel_enb,0x80);
 
 	/* Another hack (Er.. hook!) for the sun3 si: */
 	if (sc->sc_intr_on) {
@@ -392,12 +400,12 @@
 	NCR_TRACE("reset_scsibus, cur=0x%x\n",
 			  (long) sc->sc_current);
 
-	*sc->sci_icmd = SCI_ICMD_RST;
+	NCR5380_WRITE(sci_icmd,SCI_ICMD_RST);
 	delay(500);
-	*sc->sci_icmd = 0;
+	NCR5380_WRITE(sci_icmd,0);
 
-	*sc->sci_mode = 0;
-	*sc->sci_tcmd = PHASE_INVALID;
+	NCR5380_WRITE(sci_mode,0);
+	NCR5380_WRITE(sci_tcmd,PHASE_INVALID);
 
 	SCI_CLR_INTR(sc);
 	/* XXX - Need long delay here! */
@@ -1082,7 +1090,7 @@
 	 * First, check the select line.
 	 * (That has to be set first.)
 	 */
-	bus = *(sc->sci_bus_csr);
+	bus = NCR5380_READ(sci_bus_csr);
 	if ((bus & SCI_BUS_SEL) == 0) {
 		/* Not a selection or reselection. */
 		return;
@@ -1109,7 +1117,7 @@
 			return;
 		}
 		delay(2);
-		bus = *(sc->sci_bus_csr);
+		bus = NCR5380_READ(sci_bus_csr);
 		/* If SEL went away, forget it. */
 		if ((bus & SCI_BUS_SEL) == 0)
 			return;
@@ -1123,7 +1131,7 @@
 	 * "bus settle delay" before we sample the data bus
 	 */
 	delay(2);
-	data = *(sc->sci_data) & 0xFF;
+	data = NCR5380_READ(sci_data) & 0xFF;
 	/* Parity check is implicit in data validation below. */
 
 	/*
@@ -1157,12 +1165,12 @@
 	NCR_TRACE("reselect: target=0x%x\n", target);
 
 	/* Raise BSY to acknowledge target reselection. */
-	*(sc->sci_icmd) = SCI_ICMD_BSY;
+	NCR5380_WRITE(sci_icmd,SCI_ICMD_BSY);
 
 	/* Wait for target to drop SEL. */
 	timo = ncr5380_wait_nrq_timo;
 	for (;;) {
-		bus = *(sc->sci_bus_csr);
+		bus = NCR5380_READ(sci_bus_csr);
 		if ((bus & SCI_BUS_SEL) == 0)
 			break;	/* success */
 		if (--timo <= 0) {
@@ -1176,8 +1184,8 @@
 	}
 
 	/* Now we drop BSY, and we are connected. */
-	*(sc->sci_icmd) = 0;
-	*sc->sci_sel_enb = 0;
+	NCR5380_WRITE(sci_icmd,0);
+	NCR5380_WRITE(sci_sel_enb,0);
 	SCI_CLR_INTR(sc);
 
 	/*
@@ -1193,7 +1201,7 @@
 		/* Try to send an ABORT message. */
 		goto abort;
 	}
-	phase = SCI_BUS_PHASE(*sc->sci_bus_csr);
+	phase = SCI_BUS_PHASE(NCR5380_READ(sci_bus_csr));
 	if (phase != PHASE_MSG_IN) {
 		printf("%s: reselect, phase=%d\n",
 		    sc->sc_dev.dv_xname, phase);
@@ -1201,10 +1209,10 @@
 	}
 
 	/* Ack. the change to PHASE_MSG_IN */
-	*(sc->sci_tcmd) = PHASE_MSG_IN;
+	NCR5380_WRITE(sci_tcmd,PHASE_MSG_IN);
 
 	/* Peek at the message byte without consuming it! */
-	msg = *(sc->sci_data);
+	msg = NCR5380_READ(sci_data);
 	if ((msg & 0x80) == 0) {
 		printf("%s: reselect, not identify, msg=%d\n",
 		    sc->sc_dev.dv_xname, msg);
@@ -1232,9 +1240,9 @@
 		/* XXX: Restore the normal mode register. */
 		/* If this target's bit is set, do NOT check parity. */
 		if (sc->sc_parity_disable & target_mask)
-			*sc->sci_mode = (SCI_MODE_MONBSY);
+			NCR5380_WRITE(sci_mode,SCI_MODE_MONBSY);
 		else
-			*sc->sci_mode = (SCI_MODE_MONBSY | SCI_MODE_PAR_CHK);
+			NCR5380_WRITE(sci_mode,(SCI_MODE_MONBSY | SCI_MODE_PAR_CHK));
 
 		/*
 		 * Another hack for the Sun3 "si", which needs
@@ -1263,7 +1271,7 @@
 
 	/* Raise ATN, delay, raise ACK... */
 	icmd = SCI_ICMD_ATN;
-	*sc->sci_icmd = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 	delay(2);
 
 	/* Now consume the IDENTIFY message. */
@@ -1274,10 +1282,10 @@
 	sc->sc_msgpriq = SEND_ABORT;
 	ncr5380_msg_out(sc);
 
-	*(sc->sci_tcmd) = PHASE_INVALID;
-	*sc->sci_sel_enb = 0;
+	NCR5380_WRITE(sci_tcmd,PHASE_INVALID);
+	NCR5380_WRITE(sci_sel_enb,0);
 	SCI_CLR_INTR(sc);
-	*sc->sci_sel_enb = 0x80;
+	NCR5380_WRITE(sci_sel_enb,0x80);
 
 	sc->sc_state &= ~NCR_ABORTING;
 }
@@ -1313,9 +1321,10 @@
 	 * Set phase bits to 0, otherwise the 5380 won't drive the bus during
 	 * selection.
 	 */
-	*sc->sci_tcmd = PHASE_DATA_OUT;
-	*sc->sci_icmd = icmd = 0;
-	*sc->sci_mode = 0;
+	NCR5380_WRITE(sci_tcmd,PHASE_DATA_OUT);
+	NCR5380_WRITE(sci_icmd,0);
+	icmd = 0;
+	NCR5380_WRITE(sci_mode,0);
 
 	/*
 	 * Arbitrate for the bus.  The 5380 takes care of the
@@ -1336,14 +1345,14 @@
 	 */
 	s = splimp();	/* XXX: Begin time-critical section */
 
-	*(sc->sci_odata) = 0x80;	/* OUR_ID */
-	*(sc->sci_mode) = SCI_MODE_ARB;
+	NCR5380_WRITE(sci_odata,0x80);	/* OUR_ID */
+	NCR5380_WRITE(sci_mode,SCI_MODE_ARB);
 
 #define	WAIT_AIP_USEC	20	/* pleanty of time */
 	/* Wait for the AIP bit to turn on. */
 	timo = WAIT_AIP_USEC;
 	for (;;) {
-		if (*(sc->sci_icmd) & SCI_ICMD_AIP)
+		if (NCR5380_READ(sci_icmd) & SCI_ICMD_AIP)
 			break;
 		if (timo <= 0) {
 			/*
@@ -1364,7 +1373,7 @@
 	delay(3);
 
 	/* Check for ICMD_LST */
-	if (*(sc->sci_icmd) & SCI_ICMD_LST) {
+	if (NCR5380_READ(sci_icmd) & SCI_ICMD_LST) {
 		/* Some other target asserted SEL. */
 		NCR_TRACE("select: lost one, rc=%d\n", XS_BUSY);
 		goto lost_arb;
@@ -1381,7 +1390,7 @@
 	 * BSY directly so we can turn off ARB mode.
 	 */
 	icmd = (SCI_ICMD_BSY | SCI_ICMD_SEL);
-	*sc->sci_icmd = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 
 	/*
 	 * "The SCSI device that wins arbitration shall wait
@@ -1397,13 +1406,13 @@
 	 * there can be a higher selection ID than ours.
 	 * Keep this code for reference anyway...
 	 */
-	if (*(sc->sci_icmd) & SCI_ICMD_LST) {
+	if (NCR5380_READ(sci_icmd) & SCI_ICMD_LST) {
 		/* Some other target asserted SEL. */
 		NCR_TRACE("select: lost two, rc=%d\n", XS_BUSY);
 
 	lost_arb:
-		*sc->sci_icmd = 0;
-		*sc->sci_mode = 0;
+		NCR5380_WRITE(sci_icmd,0);
+		NCR5380_WRITE(sci_mode,0);
 
 		splx(s);	/* XXX: End of time-critical section. */
 
@@ -1416,8 +1425,8 @@
 	}
 
 	/* Leave ARB mode Now that we drive BSY+SEL */
-	*sc->sci_mode = 0;
-	*sc->sci_sel_enb = 0;
+	NCR5380_WRITE(sci_mode,0);
+	NCR5380_WRITE(sci_sel_enb,0);
 
 	splx(s);	/* XXX: End of time-critical section. */
 
@@ -1429,14 +1438,14 @@
 	 */
 	target_mask = (1 << sr->sr_target);
 	data = 0x80 | target_mask;
-	*(sc->sci_odata) = data;
+	NCR5380_WRITE(sci_odata,data);
 	icmd |= (SCI_ICMD_DATA | SCI_ICMD_ATN);
-	*(sc->sci_icmd) = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 	delay(2);	/* two deskew delays. */
 
 	/* De-assert BSY (targets sample the data now). */
 	icmd &= ~SCI_ICMD_BSY;
-	*(sc->sci_icmd) = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 	delay(3);	/* Bus settle delay. */
 
 	/*
@@ -1444,7 +1453,7 @@
 	 * SCSI spec. says wait for 250 mS.
 	 */
 	for (timo = 25000;;) {
-		if (*sc->sci_bus_csr & SCI_BUS_BSY)
+		if (NCR5380_READ(sci_bus_csr) & SCI_BUS_BSY)
 			goto success;
 		if (--timo <= 0)
 			break;
@@ -1460,16 +1469,16 @@
 	 * otherwise we release the bus.
 	 */
 	icmd &= ~SCI_ICMD_DATA;
-	*(sc->sci_icmd) = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 	delay(201);
-	if ((*sc->sci_bus_csr & SCI_BUS_BSY) == 0) {
+	if ((NCR5380_READ(sci_bus_csr) & SCI_BUS_BSY) == 0) {
 		/* Really no device on bus */
-		*sc->sci_tcmd = PHASE_INVALID;
-		*sc->sci_icmd = 0;
-		*sc->sci_mode = 0;
-		*sc->sci_sel_enb = 0;
+		NCR5380_WRITE(sci_tcmd,PHASE_INVALID);
+		NCR5380_WRITE(sci_icmd,0);
+		NCR5380_WRITE(sci_mode,0);
+		NCR5380_WRITE(sci_sel_enb,0);
 		SCI_CLR_INTR(sc);
-		*sc->sci_sel_enb = 0x80;
+		NCR5380_WRITE(sci_sel_enb,0x80);
 		NCR_TRACE("select: device down, rc=%d\n", XS_SELTIMEOUT);
 		return XS_SELTIMEOUT;
 	}
@@ -1481,13 +1490,13 @@
 	 * Configure the ncr5380 to monitor BSY, parity.
 	 */
 	icmd &= ~(SCI_ICMD_DATA | SCI_ICMD_SEL);
-	*sc->sci_icmd = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 
 	/* If this target's bit is set, do NOT check parity. */
 	if (sc->sc_parity_disable & target_mask)
-		*sc->sci_mode = (SCI_MODE_MONBSY);
+		NCR5380_WRITE(sci_mode,SCI_MODE_MONBSY);
 	else
-		*sc->sci_mode = (SCI_MODE_MONBSY | SCI_MODE_PAR_CHK);
+		NCR5380_WRITE(sci_mode,(SCI_MODE_MONBSY | SCI_MODE_PAR_CHK));
 
 	return XS_NOERROR;
 }
@@ -1547,10 +1556,10 @@
 	register u_char icmd;
 
 	/* acknowledge phase change */
-	*sc->sci_tcmd = PHASE_MSG_IN;
+	NCR5380_WRITE(sci_tcmd,PHASE_MSG_IN);
 
 	act_flags = ACT_CONTINUE;
-	icmd = *sc->sci_icmd & SCI_ICMD_RMASK;
+	icmd = NCR5380_READ(sci_icmd) & SCI_ICMD_RMASK;
 
 	if (sc->sc_prevphase == PHASE_MSG_IN) {
 		/* This is a continuation of the previous message. */
@@ -1588,7 +1597,7 @@
 			/* Just let ncr5380_machine() handle it... */
 			return (act_flags);
 		}
-		phase = SCI_BUS_PHASE(*sc->sci_bus_csr);
+		phase = SCI_BUS_PHASE(NCR5380_READ(sci_bus_csr));
 		if (phase != PHASE_MSG_IN) {
 			/*
 			 * Target left MESSAGE IN, probably because it
@@ -1598,7 +1607,7 @@
 			return (act_flags);
 		}
 		/* Still in MESSAGE IN phase, and REQ is asserted. */
-		if (*sc->sci_csr & SCI_CSR_PERR) {
+		if (NCR5380_READ(sci_csr) & SCI_CSR_PERR) {
 			ncr_sched_msgout(sc, SEND_PARITY_ERROR);
 			sc->sc_state |= NCR_DROP_MSGIN;
 		}
@@ -1609,7 +1618,7 @@
 				ncr_sched_msgout(sc, SEND_REJECT);
 				sc->sc_state |= NCR_DROP_MSGIN;
 			} else {
-				*sc->sc_imp++ = *sc->sci_data;
+				*sc->sc_imp++ = NCR5380_READ(sci_data);
 				n++;
 				/*
 				 * This testing is suboptimal, but most
@@ -1635,7 +1644,7 @@
 
 		/* Ack the last byte read. */
 		icmd |= SCI_ICMD_ACK;
-		*sc->sci_icmd = icmd;
+		NCR5380_WRITE(sci_icmd,icmd);
 
 		if (ncr5380_wait_not_req(sc)) {
 			NCR_TRACE("msg_in: drop, stuck REQ, n=%d\n", n);
@@ -1643,7 +1652,7 @@
 		}
 
 		icmd &= ~SCI_ICMD_ACK;
-		*sc->sci_icmd = icmd;
+		NCR5380_WRITE(sci_icmd,icmd);
 
 		if (act_flags != ACT_CONTINUE)
 			return (act_flags);
@@ -1736,7 +1745,7 @@
 
 	/* Ack the last byte read. */
 	icmd |= SCI_ICMD_ACK;
-	*sc->sci_icmd = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 
 	if (ncr5380_wait_not_req(sc)) {
 		NCR_TRACE("msg_in: last, stuck REQ, n=%d\n", n);
@@ -1744,7 +1753,7 @@
 	}
 
 	icmd &= ~SCI_ICMD_ACK;
-	*sc->sci_icmd = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 
 	/* Go get the next message, if any. */
 	if (act_flags == ACT_CONTINUE)
@@ -1782,7 +1791,7 @@
 	register u_char icmd, msg;
 
 	/* acknowledge phase change */
-	*sc->sci_tcmd = PHASE_MSG_OUT;
+	NCR5380_WRITE(sci_tcmd,PHASE_MSG_OUT);
 
 	progress = 0;	/* did we send any messages? */
 	act_flags = ACT_CONTINUE;
@@ -1791,9 +1800,9 @@
 	 * Set ATN.  If we're just sending a trivial 1-byte message,
 	 * we'll clear ATN later on anyway.  Also drive the data bus.
 	 */
-	icmd = *sc->sci_icmd & SCI_ICMD_RMASK;
+	icmd = NCR5380_READ(sci_icmd) & SCI_ICMD_RMASK;
 	icmd |= (SCI_ICMD_ATN | SCI_ICMD_DATA);
-	*sc->sci_icmd = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 
 	if (sc->sc_prevphase == PHASE_MSG_OUT) {
 		if (sc->sc_omp == sc->sc_omess) {
@@ -1920,7 +1929,7 @@
 			NCR_TRACE("msg_out: no REQ, n=%d\n", n);
 			goto out;
 		}
-		phase = SCI_BUS_PHASE(*sc->sci_bus_csr);
+		phase = SCI_BUS_PHASE(NCR5380_READ(sci_bus_csr));
 		if (phase != PHASE_MSG_OUT) {
 			/*
 			 * Target left MESSAGE OUT, possibly to reject
@@ -1936,17 +1945,17 @@
 		/* Clear ATN before last byte if this is the last message. */
 		if (n == 0 && sc->sc_msgpriq == 0) {
 			icmd &= ~SCI_ICMD_ATN;
-			*sc->sci_icmd = icmd;
+			NCR5380_WRITE(sci_icmd,icmd);
 			/* 2 deskew delays */
 			delay(2);	/* XXX */
 		}
 
 		/* Put data on the bus. */
-		*sc->sci_odata = *--sc->sc_omp;
+		NCR5380_WRITE(sci_odata,*--sc->sc_omp);
 
 		/* Raise ACK to tell target data is on the bus. */
 		icmd |= SCI_ICMD_ACK;
-		*sc->sci_icmd = icmd;
+		NCR5380_WRITE(sci_icmd,icmd);
 
 		/* Wait for REQ to be negated. */
 		if (ncr5380_wait_not_req(sc)) {
@@ -1956,7 +1965,7 @@
 
 		/* Finally, drop ACK. */
 		icmd &= ~SCI_ICMD_ACK;
-		*sc->sci_icmd = icmd;
+		NCR5380_WRITE(sci_icmd,icmd);
 
 		/* Stuck bus or something... */
 		if (act_flags & ACT_RESET_BUS)
@@ -1982,7 +1991,7 @@
 out:
 	/* Stop driving the data bus. */
 	icmd &= ~SCI_ICMD_DATA;
-	*sc->sci_icmd = icmd;
+	NCR5380_WRITE(sci_icmd,icmd);
 
 	if (!progress)
 		act_flags |= ACT_RESET_BUS;
@@ -2004,7 +2013,7 @@
 	int len;
 
 	/* acknowledge phase change */
-	*sc->sci_tcmd = PHASE_COMMAND;
+	NCR5380_WRITE(sci_tcmd,PHASE_COMMAND);
 
 	if (sr->sr_flags & SR_SENSE) {
 		rqs.opcode = REQUEST_SENSE;
@@ -2061,7 +2070,7 @@
 			goto abort;
 		}
 		/* acknowledge phase change */
-		*sc->sci_tcmd = PHASE_DATA_IN;
+		NCR5380_WRITE(sci_tcmd,PHASE_DATA_IN);
 		len = ncr5380_pio_in(sc, phase, sizeof(xs->sense.scsi_sense),
 				(u_char *)&xs->sense.scsi_sense);
 		return ACT_CONTINUE;
@@ -2092,7 +2101,7 @@
 		else
 			ncr5380_pio_out(sc, phase, 4096, NULL);
 		/* Make sure that caused a phase change. */
-		if (SCI_BUS_PHASE(*sc->sci_bus_csr) == phase) {
+		if (SCI_BUS_PHASE(NCR5380_READ(sci_bus_csr)) == phase) {
 			/* More than 4k is just too much! */
 			printf("%s: too much data padding\n",
 				sc->sc_dev.dv_xname);
@@ -2125,7 +2134,7 @@
 	 */
 	NCR_TRACE("data_xfer: doing PIO, len=%d\n", sc->sc_datalen);
 	/* acknowledge phase change */
-	*sc->sci_tcmd = phase;	/* XXX: OK for PDMA? */
+	NCR5380_WRITE(sci_tcmd,phase);	/* XXX: OK for PDMA? */
 	if (phase == PHASE_DATA_OUT) {
 		len = (*sc->sc_pio_out)(sc, phase, sc->sc_datalen, sc->sc_dataptr);
 	} else {
@@ -2153,7 +2162,7 @@
 	struct sci_req *sr = sc->sc_current;
 
 	/* acknowledge phase change */
-	*sc->sci_tcmd = PHASE_STATUS;
+	NCR5380_WRITE(sci_tcmd,PHASE_STATUS);
 
 	len = ncr5380_pio_in(sc, PHASE_STATUS, 1, &status);
 	if (len) {
@@ -2221,7 +2230,7 @@
 	 */
 	timo = ncr5380_wait_phase_timo;
 	for (;;) {
-		if (*sc->sci_bus_csr & SCI_BUS_REQ)
+		if (NCR5380_READ(sci_bus_csr) & SCI_BUS_REQ)
 			break;
 		if (--timo <= 0) {
 			if (sc->sc_state & NCR_ABORTING) {
@@ -2239,7 +2248,7 @@
 		delay(100);
 	}
 
-	phase = SCI_BUS_PHASE(*sc->sci_bus_csr);
+	phase = SCI_BUS_PHASE(NCR5380_READ(sci_bus_csr));
 	NCR_TRACE("machine: phase=%s\n",
 			  (long) phase_names[phase & 7]);
 
@@ -2254,7 +2263,7 @@
 	 * XXX: ... each phase routine does that itself.
 	 * In particular, DMA needs it done LATER.
 	 */
-	*sc->sci_tcmd = phase;	/* acknowledge phase change */
+	NCR5380_WRITE(sci_tcmd,phase);	/* acknowledge phase change */
 #endif
 
 	switch (phase) {
@@ -2325,7 +2334,7 @@
 	 * Check for parity error.
 	 * XXX - better place to check?
 	 */
-	if (*(sc->sci_csr) & SCI_CSR_PERR) {
+	if (NCR5380_READ(sci_csr) & SCI_CSR_PERR) {
 		printf("%s: parity error!\n", sc->sc_dev.dv_xname);
 		/* XXX: sc->sc_state |= NCR_ABORTING; */
 		ncr_sched_msgout(sc, SEND_PARITY_ERROR);
@@ -2387,12 +2396,12 @@
 		NCR_TRACE("machine: discon, waited %d\n",
 			ncr5380_wait_nrq_timo - timo);
 
-		*sc->sci_icmd = 0;
-		*sc->sci_mode = 0;
-		*sc->sci_tcmd = PHASE_INVALID;
-		*sc->sci_sel_enb = 0;
+		NCR5380_WRITE(sci_icmd,0);
+		NCR5380_WRITE(sci_mode,0);
+		NCR5380_WRITE(sci_tcmd,PHASE_INVALID);
+		NCR5380_WRITE(sci_sel_enb,0);
 		SCI_CLR_INTR(sc);
-		*sc->sci_sel_enb = 0x80;
+		NCR5380_WRITE(sci_sel_enb,0x80);
 
 		if ((act_flags & ACT_CMD_DONE) == 0) {
 			__asm("_ncr5380_disconnected:");
@@ -2489,6 +2498,9 @@
 	tr->val = val;
 
 	splx(s);
+#ifdef DEBUG
+	printf (msg,val);
+#endif
 }
 
 #ifdef	DDB
diff -N -r -u sys.old/dev/ic/ncr5380var.h sys/dev/ic/ncr5380var.h
--- sys.old/dev/ic/ncr5380var.h	Sun Oct 11 16:43:04 1998
+++ sys/dev/ic/ncr5380var.h	Sun Oct 11 16:42:10 1998
@@ -37,8 +37,24 @@
  * module and the machine-indepenedent ncr5380sbc.c module.
  */
 
-#define SCI_CLR_INTR(sc)	(*(sc)->sci_iack)
-#define	SCI_BUSY(sc)		(*sc->sci_bus_csr & SCI_BUS_BSY)
+
+/*
+ * Handy read/write macros
+ */
+#if NCR5380_USE_BUS_SPACE
+#include <machine/bus.h>
+
+/* bus_space() variety */
+#define NCR5380_READ(reg)	bus_space_read_1(sc->iot,sc->ioh,sc->reg)
+#define NCR5380_WRITE(reg,val)	bus_space_write_1(sc->iot,sc->ioh,sc->reg,val)
+#else
+/* legacy memory-mapped variety */
+#define NCR5380_READ(reg)	*sc->reg
+#define NCR5380_WRITE(reg,val)	*(sc->reg) = val
+#endif
+
+#define SCI_CLR_INTR(sc)	NCR5380_READ(sci_iack)
+#define	SCI_BUSY(sc)		(NCR5380_READ(sci_bus_csr) & SCI_BUS_BSY)
 
 /* These are NOT artibtrary, but map to bits in sci_tcmd */
 #define PHASE_DATA_OUT	0x0
@@ -76,9 +92,24 @@
 
 
 struct ncr5380_softc {
-	struct device	sc_dev;
-	struct		scsipi_link sc_link;
+	struct device		sc_dev;
+	struct scsipi_link	sc_link;
 
+#ifdef NCR5380_USE_BUS_SPACE
+	/* Pointers to bus_space */
+	bus_space_tag_t 	iot;
+	bus_space_handle_t 	ioh;
+
+	/* Pointers to 5380 registers.  */
+	bus_size_t	sci_r0;
+	bus_size_t	sci_r1;
+	bus_size_t	sci_r2;
+	bus_size_t	sci_r3;
+	bus_size_t	sci_r4;
+	bus_size_t	sci_r5;
+	bus_size_t	sci_r6;
+	bus_size_t	sci_r7;
+#else
 	/* Pointers to 5380 registers.  See ncr5380reg.h */
 	volatile u_char *sci_r0;
 	volatile u_char *sci_r1;
@@ -88,6 +119,7 @@
 	volatile u_char *sci_r5;
 	volatile u_char *sci_r6;
 	volatile u_char *sci_r7;
+#endif
 
 	/* Functions set from MD code */
 	int		(*sc_pio_out) __P((struct ncr5380_softc *,
diff -N -r -u sys.old/dev/isa/README.nca sys/dev/isa/README.nca
--- sys.old/dev/isa/README.nca	Wed Dec 31 16:00:00 1969
+++ sys/dev/isa/README.nca	Sun Oct 11 18:32:49 1998
@@ -0,0 +1,186 @@
+NCR 53C80/53C400 driver
+
+BACKGROUND
+----------
+The NCR 53C80 SCSI Bus Controller (SBC) is an early single-chip solution
+which formed the basis of many early SCSI host adapters for both the
+i386 and m68k platforms. The NCR 53C400 is a slightly more advanced
+chip which retains backward compatability with the 53C80.
+
+On the PC, the NCR 53C80 was most commonly used to implement simple, cheap
+SCSI host adapters that were bundled with tape and CD-ROM drives. Since
+these controllers were not bus-mastering (and in some cases were not even
+interrupt-driven), they (like IDE adapters) required the CPU to perform
+much of the actual processing. These days, these controllers are cheap
+and plentiful since many are not supported by Windows 95.
+
+Similarly, NetBSD, although it has had an MI 53C80 driver (used by the
+Sun3 and Mac68k ports) for some time, has not had a i386 driver.
+
+Until now, that is...
+
+OVERVIEW
+--------
+The NCR 53C80/53C400 driver (the 'nca' device) consists of two pieces:
+
+	1) Patches for the 53C80 MI driver to make it use bus_space()
+	   functions. (This requires an optional define. By default,
+	   the driver will compile in "legacy" memory-mapped mode.
+
+	2) A machine-dependent driver (nca) containing probe and
+	   attachment routines.
+
+This driver has bene tested with the following adapters:
+
+	NCS-250 (Chinon)	53C80, port-mapped, polled-mode
+				(This is used in my primary development
+				box to drive an external Zip drive.)
+	Sumo SCSI-AT		53C80, port-mapped, interrupt driven
+				(Note: This is an odd card in that its
+				own firmware seems to have trouble detecting
+				attached drives. Under NetBSD, however,
+				it operates with no problems.)
+	Trantor T-160		53C400, port-mapped, interrupt driven
+				This card was often bundled with NEC
+				CD-ROM drives. (My standalone test box
+				is using this as its primary adapter.)
+	DTC 3150V		53C400, memory-mapped, interrupt driven
+				This a simple card designed to drive
+				a CD-ROM.
+
+CONFIGURATION
+-------------
+To setup the nca driver, the configuration file must contain the following:
+
+	options	NCR5380_USE_BUS_SPACE
+
+This line is required to add bus_space() compatability to the MI driver.
+
+Next you need to add one or more configuration lines for the nca devices:
+
+	nca0	at isa? port 0x360 irq 15
+	nca1	at isa? iomem 0xd8000 irq 5
+
+The first is for a port-mapped controller at 0x360, IRQ 15. The second line
+is for a memory-mapped controller (Trantor T128 or equivalent) at
+0xd800-0xdff, IRQ 5.
+
+You can also set up the driver in "polled" mode (i.e., no interrupts) by
+leaving off the "irq" portion of the line:
+
+	nca0	at isa? port 0x360
+	nca1	at isa? iomem 0xd8000
+
+Lastly, you need to add a scsibus attachment line for the nca device:
+
+	scsibus* at nca?
+
+The following is the probe output from my test system:
+
+	Copyright (c) 1996, 1997, 1998
+	    The NetBSD Foundation, Inc.  All rights reserved.
+	Copyright (c) 1982, 1986, 1989, 1991, 1993
+	    The Regents of the University of California.  All rights reserved.
+	
+	NetBSD 1.3.2 (GENERIC) #2: Sun Oct  4 17:11:43 EDT 1998
+	    root@hefalump:/usr/src/sys/arch/i386/compile/GENERIC
+	cpu0: Intel 486DX (486-class)
+	real mem  = 7995392
+	avail mem = 5349376
+	using 123 buffers containing 503808 bytes of memory
+	mainbus0 (root)
+	isa0 at mainbus0
+	com1 at isa0 port 0x2f8-0x2ff irq 3: ns8250 or ns16450, no fifo
+	com2 at isa0 port 0x3e8-0x3ef irq 5: ns8250 or ns16450, no fifo
+	lpt0 at isa0 port 0x378-0x37b irq 7
+	nca0 at isa0 port 0x360-0x36f irq 15
+	nca0: NCR 53C400 detected
+	scsibus0 at nca0: 8 targets
+	sd0 at scsibus0 targ 0 lun 0: <HP, C2235, 0B11> SCSI2 0/direct fixed
+	sd0: 402MB, 1574 cyl, 9 head, 58 sec, 512 bytes/sect x 825012 sectors
+	cd0 at scsibus0 targ 6 lun 0: <CHINON, CD-ROM CDS-535, Q20> SCSI2 5/cdrom removable
+	nca1 at isa0 iomem 0xdb878-0xdb887 irq 5
+	nca1: NCR 53C400 detected
+	scsibus1 at nca1: 8 targets
+	sd1 at scsibus1 targ 5 lun 0: <IOMEGA, ZIP 100, J.02> SCSI2 0/direct removable
+	sd1: 96MB, 96 cyl, 64 head, 32 sec, 512 bytes/sect x 196608 sectors
+	npx0 at isa0 port 0xf0-0xff: using exception 16
+	pc0 at isa0 port 0x60-0x6f irq 1: color
+	pc0: console
+	fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2
+	fd0 at fdc0 drive 0: 1.44MB, 80 cyl, 2 head, 18 sec
+	biomask 8060 netmask 8460 ttymask 84e2
+	boot device: sd0
+	root on sd0a dumps on sd0b
+	root file system type: ffs
+
+In this output, nca0 is a Trantor T-160 and nca1 is a DTC 3150V. Both happen
+to be 53C400-based controllers.
+
+LIMITATIONS
+-----------
+As of this writing, the nca driver has two known limitations:
+
+1) No DMA or pseudo-DMA support
+
+This is unfortunate, but may be remedied in a later release. I would welcome
+any help by someone more familiar with DMA, particularly in relation to 
+bus_space().
+
+As it is, however, performance of the nca driver is acceptable, though some
+of that may depend on one's definition of "acceptable". Remember that these
+were not high speed controller under the best conditions, so much of it is
+really the nature of the beast. It should be adequate for tapes, CD-ROMS, 
+and low-usage disk devices (e.g., Zip drives). If you want to drive a CD-R
+drive, then invest in an Adaptec 154X or a PCI controller.
+
+2) No support for the SCSI port of the Pro AudioStudio 16.
+
+This is also unfortunate and may not be able to be remedied withing the
+current framework of the bus_space() functions and the nca driver.
+
+The problem is this: In most adapters, the eight 53C80 registers are mapped
+to eight sequential locations, either ports or memory addresses. On the
+PAS-16, however, the registers are mapped to two sets of ports- four
+sequential ports at the base address and four sequential ports located
+0x2000 higher. As I currently understand it, this is not supportable by
+the current bus_space() implementation nor is it possible for the driver
+to allocate a second bus_space_tag and _handle itself to accomodate the
+second set of ports. Without either, it is very difficult to imagine how
+a portable linkage to the MI driver could be made.
+
+Again, I welcome suggestions.
+
+HISTORY
+-------
+An nca driver first appeared in FreeBSD.
+
+This particular one borrows a little code from it and some from the i386
+'esp' and sun3 'si' drivers. It, like many things in the free unix world,
+was written because it solved a problem- mine! In my case, it was a need
+of a SCSI card and a lack of IRQs. The good news was that I had one
+(NCS-250); the bad news was that it was not supported under NetBSD. The
+rest is history.
+
+DISCLAIMER
+----------
+Like most things, you should take this code with a grain of salt. I have
+tried to test it sufficiently, but it is always possible that it is not
+compatible with some aspect of your system. If you end up suffering
+massive data loss and destruction, you have my sympathies, but I do not
+and will not allow myself to be held responsible.
+
+CREDITS
+-------
+My thanks to Jason Thorpe and the rest of the NetBSD team for making it
+so easy to write this driver. My thanks also to the authors of the
+FreeBSD nca driver for inspiration and 53C400 support.
+
+In the end, I hope that someone else can find this driver as useful as I
+have. If so, please drop me a line at jruschme@exit109.com and let me 
+know about it.
+
+Share and enjoy
+
+John Ruschmeyer (jruschme@exit109.com)
+11 October 1998
diff -N -r -u sys.old/dev/isa/files.isa sys/dev/isa/files.isa
--- sys.old/dev/isa/files.isa	Sun Oct 11 16:41:26 1998
+++ sys/dev/isa/files.isa	Sun Oct 11 16:41:03 1998
@@ -102,6 +102,11 @@
 attach	wds at isa
 file	dev/isa/wds.c			wds
 
+# NCR 5380-based boards
+device	nca: scsi, ncr5380sbc
+attach	nca at isa
+file	dev/isa/nca.c			nca
+
 #
 # Other ISA disk controllers
 #
diff -N -r -u sys.old/dev/isa/nca.c sys/dev/isa/nca.c
--- sys.old/dev/isa/nca.c	Wed Dec 31 16:00:00 1969
+++ sys/dev/isa/nca.c	Sun Oct 11 16:41:03 1998
@@ -0,0 +1,495 @@
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1994 Peter Galbavy
+ * Copyright (c) 1995 Paul Kranenburg
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Peter Galbavy
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1998 John M. Ruschmeyer (jruschme@exit109.com)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by John M. Ruschmeyer
+ * 4. The name of John M. Ruschmeyer may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This software incorporates code originally written by:
+ * 	Poul-Henning Kamp  (phk@login.dkuug.dk)
+ *  and Serge Vakulenko (vak@cronyx.ru)
+ *
+ * as used in the NCR53C80/53C400 driver for FreeBSD. As such, the above
+ * license terms extend to those individuals.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/buf.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/scsipi/scsi_all.h>
+#include <dev/scsipi/scsipi_all.h>
+#include <dev/scsipi/scsiconf.h>
+
+#include <dev/isa/isavar.h>
+#include <dev/isa/isadmavar.h>
+
+#include <dev/ic/ncr5380reg.h>
+#include <dev/ic/ncr5380var.h>
+
+#include <dev/isa/ncareg.h>
+#include <dev/isa/ncavar.h>
+
+int	nca_find __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, struct nca_probe_data*));
+int	nca_match __P((struct device *, void *, void *)); 
+void	nca_attach __P((struct device *, struct device *, void *));  
+int	nca_test __P((bus_space_tag_t, bus_space_handle_t, bus_size_t));
+
+struct cfattach nca_ca = {
+	sizeof(struct nca_softc), nca_match, nca_attach
+};
+
+struct cfdriver nca_cd = {
+	NULL, "nca", DV_DULL
+};
+
+struct scsipi_adapter nca_switch = {
+	ncr5380_scsi_cmd,
+	minphys,		/* no special minphys */
+	NULL,
+	NULL,
+};
+
+struct scsipi_device nca_dev = {
+	NULL,			/* Use default error handler */
+	NULL,			/* have a queue, served by this */
+	NULL,			/* have no async handler */
+	NULL,			/* Use default 'done' routine */
+};
+
+
+/* Supported controller types */
+#define MAX_NCA_CONTROLLER	3
+#define CTLR_NCR_5380	1
+#define	CTLR_NCR_53C400	2
+#define CTLR_PAS16	3
+
+#define NCA_ISA_IOSIZE 16
+#define MIN_DMA_LEN 128
+
+/* Options for disconnect/reselect, DMA, and interrupts. */
+#define NCA_NO_DISCONNECT    0xff
+#define NCA_NO_PARITY_CHK  0xff00
+#define NCA_FORCE_POLLING 0x10000
+#define NCA_DISABLE_DMA   0x20000
+
+
+/*
+ * Initialization and test function used by nca_find()
+ */
+int
+nca_test (iot, ioh, reg_offset)
+	bus_space_tag_t	iot;
+	bus_space_handle_t	ioh;
+	bus_size_t	reg_offset;
+{
+	/* Reset the SCSI bus. */
+	bus_space_write_1 (iot, ioh, reg_offset+C80_ICR, SCI_ICMD_RST);
+	bus_space_write_1 (iot, ioh, reg_offset+C80_ODR, 0);
+	/* Hold reset for at least 25 microseconds. */
+	delay (500);
+	/* Check that status cleared. */
+	if (bus_space_read_1 (iot, ioh, reg_offset+C80_CSBR) != SCI_BUS_RST) {
+#ifdef DEBUG
+		printf ("nca_find: reset status not cleared [0x%x]\n",
+			bus_space_read_1 (iot, ioh, reg_offset+C80_CSBR));
+#endif
+		bus_space_write_1 (iot, ioh, reg_offset+C80_ICR, 0);
+		return (0);
+	}
+	/* Clear reset. */
+	bus_space_write_1 (iot, ioh, reg_offset+C80_ICR, 0);
+	/* Wait a Bus Clear Delay (800 ns + bus free delay 800 ns). */
+	delay (16000);
+
+	/* Read RPI port, resetting parity/interrupt state. */
+	bus_space_read_1 (iot, ioh, reg_offset+C80_RPIR);
+
+	/* Test BSR: parity error, interrupt request and busy loss state
+	 * should be cleared. */
+	if (bus_space_read_1 (iot, ioh, reg_offset+C80_BSR) & (SCI_CSR_PERR |
+	    SCI_CSR_INT | SCI_CSR_DISC)) {
+#ifdef DEBUG
+		printf ("nca_find: Parity/Interrupt/Busy not cleared [0x%x]\n",
+			bus_space_read_1 (iot, ioh, reg_offset+C80_BSR));
+#endif
+		return (0);
+	}
+
+	/* We must have found one */
+	return (1);
+}
+
+
+/*
+ * Look for the board
+ */
+int
+nca_find(iot, ioh, max_offset, epd)
+	bus_space_tag_t iot;
+	bus_space_handle_t ioh;
+	bus_size_t max_offset;
+	struct nca_probe_data *epd;
+{
+	/*
+	 * We check for the existence of a board by trying to initialize it,
+	 * Then sending the commands to reset the SCSI bus.
+	 * (Unfortunately, this duplicates code which is already in the MI
+	 * driver. Unavoidable as that code is not suited to this task.)
+	 * This is largely stolen from FreeBSD.
+	 */
+
+	int 		cont_type;
+	bus_size_t	base_offset, reg_offset = 0;
+
+	/*
+	 * Some notes:
+	 * In the case of a port-mapped board, we should be pointing
+	 * right at the chip registers (if they are there at all).
+	 * For a memory-mapped card, we loop through the 16K paragraph,
+	 * 8 bytes at a time, until we either find it or run out
+	 * of region. This means we will probably be doing things like
+	 * trying to write to ROMS, etc. Hopefully, this is not a problem.
+	 */
+
+	for (base_offset = 0; base_offset < max_offset; base_offset += 0x08) {
+#ifdef DEBUG
+		printf ("nca_find: testing offset 0x%x\n", (int)base_offset);
+#endif
+
+		/* See if anything is there */
+		if (bus_space_read_1 (iot, ioh, base_offset) == 0xff)
+			continue;
+
+		/* Loop around for each board type */
+		for (cont_type = 1; cont_type <= MAX_NCA_CONTROLLER; cont_type++) {
+			/* Per-controller initialization */
+			switch (cont_type) {
+			case CTLR_NCR_5380:
+				/* No special inits */
+				reg_offset = 0;
+				break;
+			case CTLR_NCR_53C400:
+				/* Reset into 5380-compat. mode */
+				bus_space_write_1 (iot, ioh, base_offset+C400_CSR, CSR_5380_ENABLE);
+				reg_offset = C400_5380_REG_OFFSET;
+				break;
+			case CTLR_PAS16:
+				/* Not currently supported */
+				reg_offset = 0;
+				continue;
+			}
+
+			/* Initialize controller and bus */
+			if (nca_test (iot, ioh, base_offset+reg_offset)) {
+				epd->sc_reg_offset = base_offset;
+				epd->sc_host_type = cont_type;
+				return cont_type;	/* This must be it */
+			}
+		}
+	}
+
+	/* If we got here, we didn't find one */
+	return 0;
+}
+
+
+/*
+ * See if there is anything at the config'd address.
+ * If so, call the real probe to see what it is.
+ */
+int
+nca_match(parent, match, aux)
+	struct device *parent;
+	void *match, *aux;
+{
+	struct isa_attach_args *ia = aux;
+	bus_space_tag_t iot = ia->ia_iot;
+	bus_space_tag_t memt = ia->ia_memt;
+	bus_space_handle_t ioh;
+	struct nca_probe_data epd;
+	int rv = 0;
+
+	/* See if we are looking for a port- or memory-mapped adapter */
+	if (ia->ia_iobase != -1) {
+		/* Port-mapped card */
+		if (bus_space_map(iot, ia->ia_iobase, NCA_ISA_IOSIZE, 0, &ioh))
+			return 0;
+
+		/* See if a 53C80/53C400 is there */
+		rv = nca_find(iot, ioh, 0x07, &epd);
+
+		bus_space_unmap(iot, ioh, NCA_ISA_IOSIZE);
+	} else {
+		/* Memory-mapped card */
+		if (bus_space_map(memt, ia->ia_maddr, 0x4000, 0, &ioh))
+			return 0;
+
+		/* See if a 53C80/53C400 is somewhere in this para. */
+		rv = nca_find(memt, ioh, 0x03ff0, &epd);
+
+		bus_space_unmap(memt, ioh, 0x04000);
+	}
+
+	/* Adjust the attachment args if we found one */
+	if (rv) {
+		if (ia->ia_iobase != -1) {
+			/* Port-mapped */
+			ia->ia_iosize = NCA_ISA_IOSIZE;
+		} else {
+			/* Memory-mapped */
+			ia->ia_maddr += epd.sc_reg_offset;
+			ia->ia_msize = NCA_ISA_IOSIZE;
+			ia->ia_iosize = 0;
+		}
+	}
+
+	return (rv);
+}
+
+/*
+ * Attach this instance, and then all the sub-devices
+ */
+void
+nca_attach(parent, self, aux)
+	struct device *parent, *self;
+	void *aux;
+{
+	struct isa_attach_args *ia = aux;
+	struct nca_softc *esc = (void *)self;
+	struct ncr5380_softc *sc = &esc->sc_ncr5380;
+	bus_space_tag_t iot = ia->ia_iot;
+	bus_space_handle_t ioh;
+	struct nca_probe_data epd;
+	isa_chipset_tag_t ic = ia->ia_ic;
+
+	printf("\n");
+
+	if (ia->ia_iobase != -1) {
+		iot = ia->ia_iot;
+		if (bus_space_map(iot, ia->ia_iobase, NCA_ISA_IOSIZE, 0, &ioh)) {
+			printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
+			return;
+		}
+	} else {
+		iot = ia->ia_memt;
+		if (bus_space_map(iot, ia->ia_maddr, NCA_ISA_IOSIZE, 0, &ioh)) {
+			printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
+			return;
+		}
+	}
+
+	switch (nca_find(iot, ioh, NCA_ISA_IOSIZE, &epd)) {
+	case 0:
+		/* Not found- must have gone away */
+		printf("%s: nca_find failed\n", sc->sc_dev.dv_xname);
+		return;
+	case CTLR_NCR_5380:
+		printf("%s: NCR 53C80 detected\n", sc->sc_dev.dv_xname);
+		sc->sci_r0 = 0;
+		sc->sci_r1 = 1;
+		sc->sci_r2 = 2;
+		sc->sci_r3 = 3;
+		sc->sci_r4 = 4;
+		sc->sci_r5 = 5;
+		sc->sci_r6 = 6;
+		sc->sci_r7 = 7;
+		break;
+	case CTLR_NCR_53C400:
+		printf("%s: NCR 53C400 detected\n", sc->sc_dev.dv_xname);
+		sc->sci_r0 = C400_5380_REG_OFFSET + 0;
+		sc->sci_r1 = C400_5380_REG_OFFSET + 1;
+		sc->sci_r2 = C400_5380_REG_OFFSET + 2;
+		sc->sci_r3 = C400_5380_REG_OFFSET + 3;
+		sc->sci_r4 = C400_5380_REG_OFFSET + 4;
+		sc->sci_r5 = C400_5380_REG_OFFSET + 5;
+		sc->sci_r6 = C400_5380_REG_OFFSET + 6;
+		sc->sci_r7 = C400_5380_REG_OFFSET + 7;
+		break;
+	case CTLR_PAS16:
+		printf("%s: ProAudio Spectrum 16 detected\n", sc->sc_dev.dv_xname);
+		break;
+	}
+
+
+	/*
+	 * MD function pointers used by the MI code.
+	 */
+	sc->sc_pio_out = ncr5380_pio_out;
+	sc->sc_pio_in =  ncr5380_pio_in;
+	sc->sc_dma_alloc = NULL;
+	sc->sc_dma_free  = NULL;
+	sc->sc_dma_setup = NULL;
+	sc->sc_dma_start = NULL;
+	sc->sc_dma_poll  = NULL;
+	sc->sc_dma_eop   = NULL;
+	sc->sc_dma_stop  = NULL;
+	sc->sc_intr_on   = NULL;
+	sc->sc_intr_off  = NULL;
+
+	if (ia->ia_irq != IRQUNK) {
+		esc->sc_ih = isa_intr_establish(ic, ia->ia_irq, IST_EDGE,
+				IPL_BIO, (int (*)(void *))ncr5380_intr, esc);
+		if (esc->sc_ih == NULL) {
+			printf("nca: couldn't establish interrupt\n");
+			return;
+		}
+	} else 
+		sc->sc_flags |= NCR5380_FORCE_POLLING;
+
+
+	/*
+	 * Support the "options" (config file flags).
+	 * Disconnect/reselect is a per-target mask.
+	 * Interrupts and DMA are per-controller.
+	 */
+#if 0
+	esc->sc_options = 0x00000;	/* no options */
+#else
+	esc->sc_options = 0x2ffff;	/* all options except force poll */
+#endif
+
+	sc->sc_no_disconnect =
+		(esc->sc_options & NCA_NO_DISCONNECT);
+	sc->sc_parity_disable = 
+		(esc->sc_options & NCA_NO_PARITY_CHK) >> 8;
+	if (esc->sc_options & NCA_FORCE_POLLING)
+		sc->sc_flags |= NCR5380_FORCE_POLLING;
+
+#if 1	/* XXX - Temporary */
+	/* XXX - In case we think DMA is completely broken... */
+	if (esc->sc_options & NCA_DISABLE_DMA) {
+		/* Override this function pointer. */
+		sc->sc_dma_alloc = NULL;
+	}
+#endif
+	sc->sc_min_dma_len = MIN_DMA_LEN;
+
+	/*
+	 * Fill in the prototype scsi_link.
+	 */
+	sc->sc_link.scsipi_scsi.channel = SCSI_CHANNEL_ONLY_ONE;
+	sc->sc_link.scsipi_scsi.adapter_target = 7;
+	sc->sc_link.scsipi_scsi.max_target = 7;
+	sc->sc_link.type = BUS_SCSI;
+	sc->sc_link.adapter_softc = sc;
+	sc->sc_link.adapter = &nca_switch;
+	sc->sc_link.device = &nca_dev;
+	sc->sc_link.openings = 1;
+
+	/*
+	 * Initialize fields used by the MI code
+	 */
+	sc->iot = iot;
+	sc->ioh = ioh;
+
+	/*
+	 * Allocate DMA handles.
+	 */
+
+	/*
+	 *  Initialize nca board itself.
+	 */
+	ncr5380_init(sc);
+	ncr5380_reset_scsibus(sc);
+	config_found(&(sc->sc_dev), &(sc->sc_link), scsiprint);
+}
+
diff -N -r -u sys.old/dev/isa/ncareg.h sys/dev/isa/ncareg.h
--- sys.old/dev/isa/ncareg.h	Wed Dec 31 16:00:00 1969
+++ sys/dev/isa/ncareg.h	Sun Oct 11 16:41:03 1998
@@ -0,0 +1,74 @@
+
+/*
+ * Copyright (c) 1998 John M. Ruschmeyer (jruschme@exit109.com)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Eric S. Hvozda.
+ * 4. The name of Eric S. Hvozda may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This software incorporates code originally written by:
+ * 	Poul-Henning Kamp  (phk@login.dkuug.dk)
+ *  and Serge Vakulenko (vak@cronyx.ru)
+ *
+ * as used in the NCR53C80/53C400 driver for FreeBSD. As such, the above
+ * license terms extend to those individuals.
+ */
+
+/*
+ * NCR5380 registers
+ */
+#define C80_CSDR                0       /* ro - Current SCSI Data Reg. */
+#define C80_ODR                 0       /* wo - Output Data Reg. */
+#define C80_ICR                 1       /* rw - Initiator Command Reg. */
+#define C80_MR                  2       /* rw - Mode Reg. */
+#define C80_TCR                 3       /* rw - Target Command Reg. */
+#define C80_CSBR                4       /* ro - Current SCSI Bus Status Reg. */
+#define C80_SER                 4       /* wo - Select Enable Reg. */
+#define C80_BSR                 5       /* ro - Bus and Status Reg. */
+#define C80_SDSR                5       /* wo - Start DMA Send Reg. */
+#define C80_IDR                 6       /* ro - Input Data Reg. */
+#define C80_SDTR                6       /* wo - Start DMA Target Receive Reg. */
+#define C80_RPIR                7       /* ro - Reset Parity/Interrupt Reg. */
+#define C80_SDIR                7       /* wo - Start DMA Initiator Receive Reg. */
+
+
+#define C400_CSR                0       /* rw - Control and Status Reg. */
+#define CSR_5380_ENABLE                 0x80
+#define CSR_TRANSFER_DIRECTION          0x40
+#define CSR_TRANSFER_READY_INTR         0x20
+#define CSR_5380_INTR                   0x10
+#define CSR_SHARED_INTR                 0x08
+#define CSR_HOST_BUF_NOT_READY          0x04 /* read only */
+#define CSR_SCSI_BUF_READY              0x02 /* read only */
+#define CSR_5380_GATED_IRQ              0x01 /* read only */
+#define CSR_BITS "\20\1irq\2sbrdy\3hbrdy\4shintr\5intr\6tintr\7tdir\10enable"
+
+#define C400_CCR                1       /* rw - Clock Counter Reg. */
+#define C400_HBR                4       /* rw - Host Buffer Reg. */
+
+#define C400_5380_REG_OFFSET    8       /* Offset of 5380 registers. */
+
diff -N -r -u sys.old/dev/isa/ncavar.h sys/dev/isa/ncavar.h
--- sys.old/dev/isa/ncavar.h	Wed Dec 31 16:00:00 1969
+++ sys/dev/isa/ncavar.h	Sun Oct 11 16:41:03 1998
@@ -0,0 +1,80 @@
+
+/*
+ * Copyright (c) 1998 John M. Ruschmeyer (jruschme@exit109.com)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Eric S. Hvozda.
+ * 4. The name of Eric S. Hvozda may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This software incorporates code originally written by:
+ * 	Poul-Henning Kamp  (phk@login.dkuug.dk)
+ *  and Serge Vakulenko (vak@cronyx.ru)
+ *
+ * as used in the NCR53C80/53C400 driver for FreeBSD. As such, the above
+ * license terms extend to those individuals.
+ */
+
+#include <machine/bus.h>
+
+struct nca_softc {
+	struct ncr5380_softc	sc_ncr5380;	/* glue to MI code */
+
+        int             sc_active;              /* Pseudo-DMA state vars */
+        int             sc_tc;
+        int             sc_datain;
+        size_t          sc_dmasize;
+        size_t          sc_dmatrans; 
+        char            **sc_dmaaddr; 
+        size_t          *sc_pdmalen;
+
+        bus_space_tag_t sc_iot;
+        bus_space_handle_t sc_ioh;
+        void *sc_ih;
+        struct isadev sc_id;
+        int sc_irq;
+        int sc_drq;
+	int sc_options;
+
+#ifdef NCA_DEBUG
+        int sc_debug;
+#endif
+};
+
+struct nca_probe_data {
+	struct device sc_dev;
+	int sc_reg_offset;
+	int sc_host_type;
+	int sc_irq;
+	int sc_isncr;
+	int sc_rev;
+	int sc_isfast;
+	int sc_msize;
+	int sc_parity;
+	int sc_sync;
+	int sc_id;
+};
+
>Audit-Trail:
>Unformatted: