NetBSD/sys/dev/isa
dyoung 0d1ba3e899 During shutdown, detach devices in an orderly fashion.
Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks.  For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown.  Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags.  Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag.  The default for kern.detachall is 0.  SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress.  In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs.  Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
2009-04-02 00:09:32 +00:00
..
ad1848_isa.c
ad1848var.h
addcom_isa.c
adv_isa.c
aha_isa.c
aic_isa.c
aps.c
aria.c
ariareg.h
ast.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
atppc_isa.c
atppc_isadma.c
atppc_isadma.h
attimer_isa.c Convert to new 2 clause license 2008-04-29 06:53:00 +00:00
aztech.c
bha_isa.c
boca.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
cec.c
cms.c
cmsreg.h
com_isa.c During shutdown, detach devices in an orderly fashion. 2009-04-02 00:09:32 +00:00
com_multi.c
com_multi.h
commultiprint.c
cs89x0isa.c
cs89x0isavar.h
cs4231var.h
cy_isa.c
daic_isa.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
depca_isa.c
dpt_isa.c
ega.c ANSIfy functions with function-pointer arguments 2009-03-16 23:11:09 +00:00
egavar.h
elink.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
elink.h
esp_isa.c
esp_isavar.h
ess_isa.c
ess.c
essreg.h
essvar.h
fd.c g/c BUFQ_FOO() macros and use bufq_foo() directly. 2009-01-13 13:33:58 +00:00
fdc_isa.c
fdcvar.h
fdreg.h
fdvar.h
files.isa
finsio_isa.c
gus.c kill MALLOC and FREE macros. 2008-12-17 20:51:31 +00:00
gusreg.h
i82365_isa.c constify the pcmcia/cardbus method tables 2008-06-26 12:33:17 +00:00
i82365_isasubr.c ansify function definitions 2009-03-16 09:32:38 +00:00
i82365_isavar.h
ics2101.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
ics2101var.h
if_ai.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
if_aireg.h
if_ate.c
if_cs_isa.c
if_ec.c
if_ecreg.h
if_ef.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
if_efreg.h
if_eg.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
if_egreg.h
if_el.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
if_elreg.h
if_ep_isa.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
if_fmv_isa.c
if_hp.c Add some 'int' into function definitions where the K&R one didn't 2009-03-17 18:19:15 +00:00
if_ix.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
if_ixreg.h
if_iy.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
if_lc_isa.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
if_le_isa.c
if_levar.h
if_ne_isa.c
if_ntwoc_isa.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
if_ntwoc_isareg.h
if_sm_isa.c
if_tr_isa.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
if_tribm_isa.c
if_trtcm_isa.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
if_tscs_isa.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
if_we_isa.c
ioat66.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
isa.c
isabusprint.c
isadma.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
isadmareg.h
isadmavar.h
isareg.h
isavar.h
isic_isa_avm_a1.c
isic_isa_itk_ix1.c
isic_isa_tel_s08.c
isic_isa_tel_s016.c
isic_isa_tel_s0163.c
isic_isa_usr_sti.c
isic_isa.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
isv.c Use the right format specifiers to print the new struct timeval. 2009-02-27 23:13:32 +00:00
isvio.h
itesio_isa.c
itesio_isavar.h
joy_ess.c
joy_isa.c
lm_isa.c Consistent use of softc member name - fixes build breakage from previous. 2008-10-12 23:07:32 +00:00
lpt_isa.c lpt(4): register NULL pmf handler. 2008-05-31 14:07:03 +00:00
madreg.h
Makefile
mcd.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
mcdreg.h
midi_pcppi.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
moxa_isa.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
mpu_isa.c
mpu_sb.c
mpu_ym.c
nca_isa.c
nsclpcsio_isa.c Remove LKMs and switch to the module framework, pass 1. 2008-11-12 12:35:50 +00:00
opl_ess.c
opl_isa.c
opl_sb.c
opl_wss.c
opl_ym.c
pas.c
pasreg.h
pcdisplay.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
pcdisplayvar.h
pckbc_isa.c Add pmf support. 2008-05-25 16:19:12 +00:00
pcppi.c 'boot -z' bogons 2009-03-14 11:08:28 +00:00
pcppireg.h
pcppivar.h
radiotrack2.c
radiotrack.c
README.seagate
rtfps.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
satlink.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
satlinkio.h
satlinkreg.h
sb_isa.c
sb.c
sbdsp.c
sbdspvar.h
sbreg.h
sbvar.h
seagate.c ansify function definitions 2009-03-16 09:32:38 +00:00
sf16fmr2.c
slhci_isa.c
smsc.c
smscvar.h
spkr.c Ansify function definitions w/o arguments. Generated with sed. 2009-03-18 10:22:21 +00:00
spkrio.h
tcic2_isa.c ansify function definitions 2009-03-16 09:32:38 +00:00
tcom.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
toaster.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
toasterlcd.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
tsdio.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
tsdioreg.h
tsdiovar.h
ug_isa.c
uha_isa.c Change about 4500 of the K&R function definitions to ANSI ones. 2009-03-14 15:35:58 +00:00
vga_isa.c
vga_isavar.h
wdc_isa.c During shutdown, detach devices in an orderly fashion. 2009-04-02 00:09:32 +00:00
wds.c ANSIfy another 1261 function definitions. 2009-03-14 21:04:01 +00:00
wdsreg.h
weasel_isa.c
weaselreg.h
weaselvar.h
wss_isa.c
wss.c
wssreg.h
wssvar.h
wt.c Replace device_lookup() with device_lookup_private() on getting softc 2008-06-08 12:43:51 +00:00
wtreg.h
ym.c
ymvar.h

#	$NetBSD: README.seagate,v 1.5 2005/12/11 12:22:02 christos Exp $

The hardware:

The ST01/02, and Future Domain 950 are very simple SCSI controllers. They are
not busmastering, so the processor must do all transfers a la IDE. They support
blind transfer by adding wait states (up to a certain limit). Interrupt is
generated for reconnect and parity errors (maybe also for some other events).

The card consists of one command port that writes to scsi control lines, reads
status lines, and a data port that read/writes to the 8 data lines. The address
decoding gives both data and control ports large memory areas to a single
port. This is used by the code.

The ST01/02 differs from the FD950 in memory address location and SCSI id.

Probing for the card:

A card is recognized by comparing the BIOS signature with known signatures. A
new card may not be recognized if the BIOS signature has changed. Please send
new signatures to me.

Driver function:

A scsi command is sent to scsi_cmd function. The command is either placed in
the queue or an retryable message is returned. The routine may wait for
completion of the command depending on the supplied flags. A timer is started
for every command placed in the queue. The commands are added in the order they
are received. There is a possiblity to make all REQUEST SENSE commands be
queued before all other commands, but I dont think it is a good thing (Linux
do however use this).

The card is mostly controlled by the sea_main function. It is called by
scsi_cmd, the interrupt routine, and the timeout routine. The sea_main routine
runs as long there are something to do (transfer data, issue queued commands,
and handle reconnected commands).

The data transfers may be done in two different ways: Blind and polled
transfers. They differ in the way the driver does it handshaking with the
target. During a blind transfer, the driver code blindly transfers a block
of data without checking for changed phase. During polled transfers, the
phase is checked between every character transfered. The polled transfers
are always used for status information and command transfers.

Because the card does not use DMA in any way, there is no need to handle
physical addresses. There is no problem with the isa-bus address limit of
16MB, making bounce-buffers unnecessary.

The data structures:

Every card has a sea_softc structure keeping the queues of commands waiting to
be issued, and commands currently disconnected. The type of card (Seagate or
Future Domain), data and control port addresses, scsi id, busy flags for all
possible targets, and interrupt vector for the card.

Every scsi command to be issued are stored in a sea_scb structure. It contains
a flag describing status/error of the command, current data buffer position,
and number of bytes remaining to be transfered.


PROBLEMS

I have had problems getting the ST02 boot using the boot floppies. I think it
is some problem with BIOS calls not working. It is unfortunately impossible to
disconnect the ST02 floppy controller.

I have had problem to get the driver talk to a 40 MB Seagate disk. I dont have
access to it any more, so I can't do any more checks on that.

NOTE: The ST02 creates its own description of the disk attached. This is not
the same as the disk says. This translation problem may cause problems when
sharing a disk between both DOS and BSD. It is however not impossible.