History log of /openbsd-current/sys/dev/ic/wdcvar.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.59 18-Jun-2024 jsg

remove prototypes with no matching function


# 1.58 29-May-2024 jsg

remove prototypes with no matching function


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.57 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.56 12-Jul-2017 mikeb

Introduce two quirks to prevent attaching ATA and ATAPI devices

Hyper-V and Xen have varying support for detaching emulated IDE
devices ranging from none on Hyper-V to only IDE disks but not
CDROM (Xen). The quirk mechanism provides a way of enforcing the
desired behavior.

With suggestions and OK kettenis, tedu, mlarkin


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.55 17-Aug-2015 krw

The 80's called and want their interface back. Remove last fragments of
ST-506 support. Remove redundant 'precomp' variables/fields and rename
remaining few to 'features' to be consistant with the rest of the code.

Consensus that no ST-506 disks (requiring ISA cards, <120MB, usually
rife with bad sectors that can't be worked around) are still running
OpenBSD.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.54 22-Jan-2014 dlg

dont piggyback on C_PRIVATEXFER because it must not touch splx.
because im using it while the system is up and running i need the
xfer free path to take the right locks, which PRIVATEXFER doesnt.
invent a new C_SCSIXFER flag that provides the safety needed.

this fixes issues people have had installing from atapiscsi(4) cdrom
devices.

bug spelunking and tailq corruption identified by jsing@
ok jsing@


# 1.53 18-Jan-2014 dlg

move atapiscsi to iopools by making the entire ata layer use them too.

this would have been difficult before because the ata completion
paths try to be helfpul by freeing xfers on the adapters behalf,
whch doesn't work in the new world scsi model where the layer that
allocated the thing is responsible for freeing it, and expects to
get it back and maybe use it again. however, deraadt@ added magic
flags for hibernate that im now using to keep ata xfers for the
scsi layers.

committing this now so itll be tested. i cant think of a better time
to handle fallout from diffs like this than hackathons.

discussed with deraadt@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.52 15-Jul-2011 deraadt

Cope with the start-dma-before-init errata and some other register setup
errata for the Serverworks SATA chipset found on the macppc xserve G5.
ok jmc


# 1.51 09-May-2011 matthew

Refactor queue allocation and initialization into a wdc_alloc_queue()
function, and let attachment code calls this rather than malloc(9).
This prevents re-initialization of the queue in shared queue chipsets.
Also, add wdc_free_queue() as a complementary function.

Earlier version (without wdc_free_queue()) tested by sthen@ and Amit
Kulkarni on various pciide(4) chips.

ok dlg@


# 1.50 08-May-2011 matthew

Eliminate a few unused wdc capability flags (WDC_CAPABILITY_HWLOCK,
WDC_CAPABILITY_ATA_NOSTREAM, and WDC_CAPABILITY_ATAPI_NOSTREAM).

ok dlg@, jsg@, krw@


# 1.49 18-Apr-2011 deraadt

keep an eye out for wdc registers returning 0xff. if they return 0xff,
this probably means the controller is dead -- as in, a hot plug eject
event. in that case, mark the driver dead and try harder to return -1
in the interrupt handler.
tested by many
ok dlg, miod did not object


# 1.48 15-Apr-2011 miod

Change wdc_reset_channel() to take a `no wait' argument. Pass in turn this
argument to wdcreset(), to have it skip waiting until active channels see
their BUSY bit clear in the status register.

Use this feature in the resume path, during the first reset operation. The
first reset is supposed to only wake up the controller, and the disks don't
come back until the second reset is issued, therefore waiting for them to
report themselves as ready after the first reset, but before the second, is
moot - and as a matter of fact some controllers, such as the AMD 754 and
clones/offspring (e.g. Geode) keep the BUSY bit asserted after the first
reset.

Last, but not least, make sure wd@ata invokes wd_get_params() again before
returning from the resume code, as we will still be using polled transfers
for a short while.

This causes the Lemote Yeelong to resume within less than one second, instead
of the lousy 30 seconds wait between the two resets; and the wd_get_params()
voodoo prevents it from getting spurious ide interrupts afterwards.

wd_get_params() magic from dlg; rest of the work by yours truly after enough
prodding by dlg@ and pirofti@, among others. ok deraadt@ dlg@


# 1.47 05-Apr-2011 deraadt

wd_hibernate_io() is a standalone disk io writer which tries to not
damage kernel memory very much while doing the job. It is not very
pretty yet, but improving it will need some MI work.
ok mlarkin jsg dlg


Revision tags: OPENBSD_4_9_BASE
# 1.46 29-Aug-2010 deraadt

pcmcia/wdc_pcmcia.c


Revision tags: OPENBSD_4_8_BASE
# 1.45 09-May-2010 jasper

hander -> handler

ok miod@


Revision tags: OPENBSD_4_7_BASE
# 1.44 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


# 1.43 05-Oct-2009 jsg

Add some minimalistic detach/unmap bits for pciide,
done using a chipset unmap callback.

Still needs to work to distinguish between compat
register mappings and compat interrupts so we
don't get caught out.

Tested with a diskless sii3112 CardBus eSATA controller
by me, and testing and feedback by deraadt@ with
a phison based expresscard SSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.42 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.41 08-May-2007 deraadt

wdcrestart() is never used


# 1.40 08-May-2007 deraadt

atapi_print() is never used


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.39 03-May-2006 jsg

Provide a function pointer that allows for the wdc reset
method to be changed as required.
This will be required for dealing with several chips in pciide.


Revision tags: OPENBSD_3_9_BASE
# 1.38 10-Feb-2006 kettenis

Fix LBA48 access for ServerWorks SATA.
ok grange@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.37 17-Oct-2004 grange

Add a callback drv_probe() to allow underlying ata controller driver
to probe for drives in its own way. It's a no-op for now but will be
needed for native sata support.


# 1.36 17-Oct-2004 grange

Move declaration of default _vtbl members (wdc_default_*) to
wdcvar.h.


# 1.35 17-Oct-2004 grange

Define number of general and ``shadow'' (overlapping) ATA registers;
from NetBSD.


# 1.34 24-Sep-2004 grange

Multiple inclusion protection.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 02-Jun-2004 grange

Add quirks field to the wdc softc and implement the first one:
WDC_QUIRK_NOSHORTDMA which disables DMA for the one-sector
transfers. Use this quirk for the Geode SC1100 IDE to fix
hanging during fdisk reported in PR 3729.
Thanks to Alexandre Belloni <abelloni@nerim.net> for testing.

ok costa@


Revision tags: OPENBSD_3_5_BASE
# 1.32 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


# 1.31 17-Oct-2003 grange

Merge an old fix from NetBSD:
- do not stop/unload current DMA operation if an IRQ was not detected
by DMA engine unless the force flag was given, fixes DMA problems
in shared IRQ setups;
- ack interrupt before entering DMA codepath

Tested by many.
Work by niklas@ but he doesn't want to commit it for some reason.


# 1.30 16-Oct-2003 grange

New flag to mark SATA controllers


# 1.29 16-Oct-2003 grange

spaces/tabs cleanup


# 1.28 28-Sep-2003 grange

kill trailing spaces, no functional changes


Revision tags: OPENBSD_3_4_BASE
# 1.27 23-Jul-2003 grange

Old Promise ATA controllers need some additional operations
during DMA transfers to work correctly with LBA48 drives.
Based on diff from Takeshi Nakayama <tn@catvmics.ne.jp> for NetBSD
with some corrections from FreeBSD ATA driver.


# 1.26 05-Jul-2003 grange

better indent


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 03-May-2002 gluk

LBA48 support.
Adopted from NetBSD by Alexander Yurchenko <grange@openbsd.ru>.

costa@ ok.


Revision tags: OPENBSD_3_1_BASE
# 1.24 16-Mar-2002 csapuntz

The new code logs the control signals on the IDE bus. You can extract the log
using atactl <device> dump. The log will help us support more devices.
Send logs to csapuntz@


# 1.23 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.22 14-Mar-2002 millert

First round of __P removal in sys


# 1.21 07-Jan-2002 mickey

pass the proc* down the ioctl chain to controller; mjacob@ csapuntz@ ok


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 31-Jul-2001 csapuntz

branches: 1.20.4;


On DMA timeouts, stop busmaster PCIIDE and reset channel. Avoid reading
device registers as this may cause lock-ups on some chipsets

Clean-up in atapiscsi. Get rid of claim_irq. Instead, atapiscsi always
returns -1 (maybe) from the interrupt handler.


# 1.19 25-Jun-2001 csapuntz

Fix excessive resets and device probes by storing IDENTIFY results in the
drvp structure


# 1.18 30-Apr-2001 csapuntz

Move ATA IOCTL commands to low-level WDC driver


Revision tags: OPENBSD_2_9_BASE
# 1.17 04-Apr-2001 csapuntz

Lay the groundwork for disabling ATAPI DMA on controllers
where we have trouble. Note, in theory, ATAPI DMA is no different
than ATA DMA.

"Promise" not to tell anybody


# 1.16 25-Mar-2001 csapuntz

Minor mods to DMA interface - get rid of unnecessary args. Allow DMA functions to return status flags.

Note: Changing code to have DMA interface indicate when I/O is done (a la NetBSD) was considered. It was rejected due to questionable backward compatability
with ISA DMA and MAC obio DMA

Added irqack from NetBSD (though this feature should really be in the
PCI interrupt handlers)

Use pool


# 1.15 15-Mar-2001 csapuntz

Fix races between timeouts and interrupts.

Cleanup atapiscsi driver a bit by moving fields out of xfer.


# 1.14 05-Mar-2001 ho

Convert to new timeout API. costa@ ok.


# 1.13 29-Jan-2001 csapuntz

Add wdc_print_current_modes to print current transfer modes set on the
devices. Print after attach in wdc_isa, wdc_isapnp, wdc_pcmcia.
pciide_print_modes rewritten to use wdc_print_current_modes.

Disable wdc_print_caps since it's not as useful.

Inspired by NetBSD. Thanks to Dale and Theo for pointing out this improvement.


Revision tags: OPENBSD_2_8_BASE
# 1.12 27-Oct-2000 csapuntz

Patch to get rid of ST506 phantoms. Thanks to Grigoriy Orlov for the design
and testing.


# 1.11 20-Jul-2000 csapuntz

chp->wdc can be NULL on probe.

Propagate verbose flag from cf_data to channel


# 1.10 20-Jul-2000 csapuntz

Fix to ATA detect. Some devices seem to be comatose after reset
(return 0x00 status persistently). Send them identify to wake them up.

Flag value 0x10000 will enable probe messages for a channel/controller.
When UKC supports setting flags, this will be useful debugging
failing IDE detects without kernel recompiles.


# 1.9 30-Jun-2000 art

Convert some parts to new timeouts.


Revision tags: OPENBSD_2_7_BASE
# 1.8 10-Apr-2000 csapuntz

Added support for wd detach (merge from NetBSD). Support for
SCSI/ATAPI detach is not here yet.

Minor cleanup of wdc. Downgrade to UDMA mode 1 before going further.
Want to stay in UDMA modes because they're more error-resilient due to
a CRC.

Got rid of some of the ridiculous amount of softc sharing going on.
Hopefully, this will make the life of whoever goes in and fixes the
ref-counting to be correct easier.


Revision tags: SMP_BASE
# 1.7 14-Dec-1999 csapuntz

branches: 1.7.2;


Thanks aaron.

Changed time->ticks


# 1.6 11-Dec-1999 csapuntz

ATAPI Tape drive support. Should be considered experimental.

Major restructuring of the code path that sends ATAPI packet commands.
One set of functions works in polling, process, and interrupt contexts.


Revision tags: kame_19991208
# 1.5 17-Nov-1999 csapuntz

New interface to ATA registers that goes through the lower-level device
driver (pciide, wdc, etc.)

Remove #define WDCDEBUG from top of files

More fixes to ATAPISCSI logic:

Not all devices transition correctly between phases. Devices are supposed
to keep BSY high until they've set the registers to the next sensible
state. Some devices drop BSY and leave the registers in an old or
nonsense state. Our polling code is extremely sensitive to this
(though an early itnerrupt could also observe this). So, if the device is
in an unexpected state, the new polling code waits for a while in the hope
that it enters a better state.

This seems to fix many of the problems reported.

Also, there was a horrible bug which would cause sense to fail on a ATAPI
command that sent data to the drive


Revision tags: OPENBSD_2_6_BASE
# 1.4 29-Oct-1999 deraadt

reliability fixes from csapuntz; commit message replaced later with details


# 1.3 09-Oct-1999 csapuntz

wdc layer work:
Separate wdc_probe_caps into wdc_probe_caps and wdc_print_caps for more
flexibility in printing capability information.

Get rid of wdc_final_attach.

Include name of device (e.g. cd0), if possible, on errors.

atapiscsi layer work:
Put a pointer to the SCSI device into ata_drive_datas' drv_softc field

Simplify, simplify, simplify. Got rid of a bunch of fields in atapiscsi_softc

Delay printing capabilities until we know the real device name (e.g. st0)


# 1.2 22-Jul-1999 csapuntz

Create wdc_enable_intr, wdc_disable_intr, wdc_select_drive.

wdc_select_drive implements the drive selection protocol
as documented in the ATA-5 preliminary specs.


# 1.1 18-Jul-1999 csapuntz

Import of NetBSD ATA/IDE stuff.

Introduction of home-grown

To enable this stuff in your configuration, look at the NEWATA conf file
and go through

dev/isa/files.isa
dev/pci/files.pci
conf/files
arch/i386/conf/files.i386

and follow the instructions on commenting/uncommenting stuff


# 1.58 29-May-2024 jsg

remove prototypes with no matching function


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.57 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.56 12-Jul-2017 mikeb

Introduce two quirks to prevent attaching ATA and ATAPI devices

Hyper-V and Xen have varying support for detaching emulated IDE
devices ranging from none on Hyper-V to only IDE disks but not
CDROM (Xen). The quirk mechanism provides a way of enforcing the
desired behavior.

With suggestions and OK kettenis, tedu, mlarkin


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.55 17-Aug-2015 krw

The 80's called and want their interface back. Remove last fragments of
ST-506 support. Remove redundant 'precomp' variables/fields and rename
remaining few to 'features' to be consistant with the rest of the code.

Consensus that no ST-506 disks (requiring ISA cards, <120MB, usually
rife with bad sectors that can't be worked around) are still running
OpenBSD.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.54 22-Jan-2014 dlg

dont piggyback on C_PRIVATEXFER because it must not touch splx.
because im using it while the system is up and running i need the
xfer free path to take the right locks, which PRIVATEXFER doesnt.
invent a new C_SCSIXFER flag that provides the safety needed.

this fixes issues people have had installing from atapiscsi(4) cdrom
devices.

bug spelunking and tailq corruption identified by jsing@
ok jsing@


# 1.53 18-Jan-2014 dlg

move atapiscsi to iopools by making the entire ata layer use them too.

this would have been difficult before because the ata completion
paths try to be helfpul by freeing xfers on the adapters behalf,
whch doesn't work in the new world scsi model where the layer that
allocated the thing is responsible for freeing it, and expects to
get it back and maybe use it again. however, deraadt@ added magic
flags for hibernate that im now using to keep ata xfers for the
scsi layers.

committing this now so itll be tested. i cant think of a better time
to handle fallout from diffs like this than hackathons.

discussed with deraadt@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.52 15-Jul-2011 deraadt

Cope with the start-dma-before-init errata and some other register setup
errata for the Serverworks SATA chipset found on the macppc xserve G5.
ok jmc


# 1.51 09-May-2011 matthew

Refactor queue allocation and initialization into a wdc_alloc_queue()
function, and let attachment code calls this rather than malloc(9).
This prevents re-initialization of the queue in shared queue chipsets.
Also, add wdc_free_queue() as a complementary function.

Earlier version (without wdc_free_queue()) tested by sthen@ and Amit
Kulkarni on various pciide(4) chips.

ok dlg@


# 1.50 08-May-2011 matthew

Eliminate a few unused wdc capability flags (WDC_CAPABILITY_HWLOCK,
WDC_CAPABILITY_ATA_NOSTREAM, and WDC_CAPABILITY_ATAPI_NOSTREAM).

ok dlg@, jsg@, krw@


# 1.49 18-Apr-2011 deraadt

keep an eye out for wdc registers returning 0xff. if they return 0xff,
this probably means the controller is dead -- as in, a hot plug eject
event. in that case, mark the driver dead and try harder to return -1
in the interrupt handler.
tested by many
ok dlg, miod did not object


# 1.48 15-Apr-2011 miod

Change wdc_reset_channel() to take a `no wait' argument. Pass in turn this
argument to wdcreset(), to have it skip waiting until active channels see
their BUSY bit clear in the status register.

Use this feature in the resume path, during the first reset operation. The
first reset is supposed to only wake up the controller, and the disks don't
come back until the second reset is issued, therefore waiting for them to
report themselves as ready after the first reset, but before the second, is
moot - and as a matter of fact some controllers, such as the AMD 754 and
clones/offspring (e.g. Geode) keep the BUSY bit asserted after the first
reset.

Last, but not least, make sure wd@ata invokes wd_get_params() again before
returning from the resume code, as we will still be using polled transfers
for a short while.

This causes the Lemote Yeelong to resume within less than one second, instead
of the lousy 30 seconds wait between the two resets; and the wd_get_params()
voodoo prevents it from getting spurious ide interrupts afterwards.

wd_get_params() magic from dlg; rest of the work by yours truly after enough
prodding by dlg@ and pirofti@, among others. ok deraadt@ dlg@


# 1.47 05-Apr-2011 deraadt

wd_hibernate_io() is a standalone disk io writer which tries to not
damage kernel memory very much while doing the job. It is not very
pretty yet, but improving it will need some MI work.
ok mlarkin jsg dlg


Revision tags: OPENBSD_4_9_BASE
# 1.46 29-Aug-2010 deraadt

pcmcia/wdc_pcmcia.c


Revision tags: OPENBSD_4_8_BASE
# 1.45 09-May-2010 jasper

hander -> handler

ok miod@


Revision tags: OPENBSD_4_7_BASE
# 1.44 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


# 1.43 05-Oct-2009 jsg

Add some minimalistic detach/unmap bits for pciide,
done using a chipset unmap callback.

Still needs to work to distinguish between compat
register mappings and compat interrupts so we
don't get caught out.

Tested with a diskless sii3112 CardBus eSATA controller
by me, and testing and feedback by deraadt@ with
a phison based expresscard SSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.42 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.41 08-May-2007 deraadt

wdcrestart() is never used


# 1.40 08-May-2007 deraadt

atapi_print() is never used


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.39 03-May-2006 jsg

Provide a function pointer that allows for the wdc reset
method to be changed as required.
This will be required for dealing with several chips in pciide.


Revision tags: OPENBSD_3_9_BASE
# 1.38 10-Feb-2006 kettenis

Fix LBA48 access for ServerWorks SATA.
ok grange@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.37 17-Oct-2004 grange

Add a callback drv_probe() to allow underlying ata controller driver
to probe for drives in its own way. It's a no-op for now but will be
needed for native sata support.


# 1.36 17-Oct-2004 grange

Move declaration of default _vtbl members (wdc_default_*) to
wdcvar.h.


# 1.35 17-Oct-2004 grange

Define number of general and ``shadow'' (overlapping) ATA registers;
from NetBSD.


# 1.34 24-Sep-2004 grange

Multiple inclusion protection.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 02-Jun-2004 grange

Add quirks field to the wdc softc and implement the first one:
WDC_QUIRK_NOSHORTDMA which disables DMA for the one-sector
transfers. Use this quirk for the Geode SC1100 IDE to fix
hanging during fdisk reported in PR 3729.
Thanks to Alexandre Belloni <abelloni@nerim.net> for testing.

ok costa@


Revision tags: OPENBSD_3_5_BASE
# 1.32 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


# 1.31 17-Oct-2003 grange

Merge an old fix from NetBSD:
- do not stop/unload current DMA operation if an IRQ was not detected
by DMA engine unless the force flag was given, fixes DMA problems
in shared IRQ setups;
- ack interrupt before entering DMA codepath

Tested by many.
Work by niklas@ but he doesn't want to commit it for some reason.


# 1.30 16-Oct-2003 grange

New flag to mark SATA controllers


# 1.29 16-Oct-2003 grange

spaces/tabs cleanup


# 1.28 28-Sep-2003 grange

kill trailing spaces, no functional changes


Revision tags: OPENBSD_3_4_BASE
# 1.27 23-Jul-2003 grange

Old Promise ATA controllers need some additional operations
during DMA transfers to work correctly with LBA48 drives.
Based on diff from Takeshi Nakayama <tn@catvmics.ne.jp> for NetBSD
with some corrections from FreeBSD ATA driver.


# 1.26 05-Jul-2003 grange

better indent


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 03-May-2002 gluk

LBA48 support.
Adopted from NetBSD by Alexander Yurchenko <grange@openbsd.ru>.

costa@ ok.


Revision tags: OPENBSD_3_1_BASE
# 1.24 16-Mar-2002 csapuntz

The new code logs the control signals on the IDE bus. You can extract the log
using atactl <device> dump. The log will help us support more devices.
Send logs to csapuntz@


# 1.23 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.22 14-Mar-2002 millert

First round of __P removal in sys


# 1.21 07-Jan-2002 mickey

pass the proc* down the ioctl chain to controller; mjacob@ csapuntz@ ok


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 31-Jul-2001 csapuntz

branches: 1.20.4;


On DMA timeouts, stop busmaster PCIIDE and reset channel. Avoid reading
device registers as this may cause lock-ups on some chipsets

Clean-up in atapiscsi. Get rid of claim_irq. Instead, atapiscsi always
returns -1 (maybe) from the interrupt handler.


# 1.19 25-Jun-2001 csapuntz

Fix excessive resets and device probes by storing IDENTIFY results in the
drvp structure


# 1.18 30-Apr-2001 csapuntz

Move ATA IOCTL commands to low-level WDC driver


Revision tags: OPENBSD_2_9_BASE
# 1.17 04-Apr-2001 csapuntz

Lay the groundwork for disabling ATAPI DMA on controllers
where we have trouble. Note, in theory, ATAPI DMA is no different
than ATA DMA.

"Promise" not to tell anybody


# 1.16 25-Mar-2001 csapuntz

Minor mods to DMA interface - get rid of unnecessary args. Allow DMA functions to return status flags.

Note: Changing code to have DMA interface indicate when I/O is done (a la NetBSD) was considered. It was rejected due to questionable backward compatability
with ISA DMA and MAC obio DMA

Added irqack from NetBSD (though this feature should really be in the
PCI interrupt handlers)

Use pool


# 1.15 15-Mar-2001 csapuntz

Fix races between timeouts and interrupts.

Cleanup atapiscsi driver a bit by moving fields out of xfer.


# 1.14 05-Mar-2001 ho

Convert to new timeout API. costa@ ok.


# 1.13 29-Jan-2001 csapuntz

Add wdc_print_current_modes to print current transfer modes set on the
devices. Print after attach in wdc_isa, wdc_isapnp, wdc_pcmcia.
pciide_print_modes rewritten to use wdc_print_current_modes.

Disable wdc_print_caps since it's not as useful.

Inspired by NetBSD. Thanks to Dale and Theo for pointing out this improvement.


Revision tags: OPENBSD_2_8_BASE
# 1.12 27-Oct-2000 csapuntz

Patch to get rid of ST506 phantoms. Thanks to Grigoriy Orlov for the design
and testing.


# 1.11 20-Jul-2000 csapuntz

chp->wdc can be NULL on probe.

Propagate verbose flag from cf_data to channel


# 1.10 20-Jul-2000 csapuntz

Fix to ATA detect. Some devices seem to be comatose after reset
(return 0x00 status persistently). Send them identify to wake them up.

Flag value 0x10000 will enable probe messages for a channel/controller.
When UKC supports setting flags, this will be useful debugging
failing IDE detects without kernel recompiles.


# 1.9 30-Jun-2000 art

Convert some parts to new timeouts.


Revision tags: OPENBSD_2_7_BASE
# 1.8 10-Apr-2000 csapuntz

Added support for wd detach (merge from NetBSD). Support for
SCSI/ATAPI detach is not here yet.

Minor cleanup of wdc. Downgrade to UDMA mode 1 before going further.
Want to stay in UDMA modes because they're more error-resilient due to
a CRC.

Got rid of some of the ridiculous amount of softc sharing going on.
Hopefully, this will make the life of whoever goes in and fixes the
ref-counting to be correct easier.


Revision tags: SMP_BASE
# 1.7 14-Dec-1999 csapuntz

branches: 1.7.2;


Thanks aaron.

Changed time->ticks


# 1.6 11-Dec-1999 csapuntz

ATAPI Tape drive support. Should be considered experimental.

Major restructuring of the code path that sends ATAPI packet commands.
One set of functions works in polling, process, and interrupt contexts.


Revision tags: kame_19991208
# 1.5 17-Nov-1999 csapuntz

New interface to ATA registers that goes through the lower-level device
driver (pciide, wdc, etc.)

Remove #define WDCDEBUG from top of files

More fixes to ATAPISCSI logic:

Not all devices transition correctly between phases. Devices are supposed
to keep BSY high until they've set the registers to the next sensible
state. Some devices drop BSY and leave the registers in an old or
nonsense state. Our polling code is extremely sensitive to this
(though an early itnerrupt could also observe this). So, if the device is
in an unexpected state, the new polling code waits for a while in the hope
that it enters a better state.

This seems to fix many of the problems reported.

Also, there was a horrible bug which would cause sense to fail on a ATAPI
command that sent data to the drive


Revision tags: OPENBSD_2_6_BASE
# 1.4 29-Oct-1999 deraadt

reliability fixes from csapuntz; commit message replaced later with details


# 1.3 09-Oct-1999 csapuntz

wdc layer work:
Separate wdc_probe_caps into wdc_probe_caps and wdc_print_caps for more
flexibility in printing capability information.

Get rid of wdc_final_attach.

Include name of device (e.g. cd0), if possible, on errors.

atapiscsi layer work:
Put a pointer to the SCSI device into ata_drive_datas' drv_softc field

Simplify, simplify, simplify. Got rid of a bunch of fields in atapiscsi_softc

Delay printing capabilities until we know the real device name (e.g. st0)


# 1.2 22-Jul-1999 csapuntz

Create wdc_enable_intr, wdc_disable_intr, wdc_select_drive.

wdc_select_drive implements the drive selection protocol
as documented in the ATA-5 preliminary specs.


# 1.1 18-Jul-1999 csapuntz

Import of NetBSD ATA/IDE stuff.

Introduction of home-grown

To enable this stuff in your configuration, look at the NEWATA conf file
and go through

dev/isa/files.isa
dev/pci/files.pci
conf/files
arch/i386/conf/files.i386

and follow the instructions on commenting/uncommenting stuff


# 1.57 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.56 12-Jul-2017 mikeb

Introduce two quirks to prevent attaching ATA and ATAPI devices

Hyper-V and Xen have varying support for detaching emulated IDE
devices ranging from none on Hyper-V to only IDE disks but not
CDROM (Xen). The quirk mechanism provides a way of enforcing the
desired behavior.

With suggestions and OK kettenis, tedu, mlarkin


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.55 17-Aug-2015 krw

The 80's called and want their interface back. Remove last fragments of
ST-506 support. Remove redundant 'precomp' variables/fields and rename
remaining few to 'features' to be consistant with the rest of the code.

Consensus that no ST-506 disks (requiring ISA cards, <120MB, usually
rife with bad sectors that can't be worked around) are still running
OpenBSD.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.54 22-Jan-2014 dlg

dont piggyback on C_PRIVATEXFER because it must not touch splx.
because im using it while the system is up and running i need the
xfer free path to take the right locks, which PRIVATEXFER doesnt.
invent a new C_SCSIXFER flag that provides the safety needed.

this fixes issues people have had installing from atapiscsi(4) cdrom
devices.

bug spelunking and tailq corruption identified by jsing@
ok jsing@


# 1.53 18-Jan-2014 dlg

move atapiscsi to iopools by making the entire ata layer use them too.

this would have been difficult before because the ata completion
paths try to be helfpul by freeing xfers on the adapters behalf,
whch doesn't work in the new world scsi model where the layer that
allocated the thing is responsible for freeing it, and expects to
get it back and maybe use it again. however, deraadt@ added magic
flags for hibernate that im now using to keep ata xfers for the
scsi layers.

committing this now so itll be tested. i cant think of a better time
to handle fallout from diffs like this than hackathons.

discussed with deraadt@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.52 15-Jul-2011 deraadt

Cope with the start-dma-before-init errata and some other register setup
errata for the Serverworks SATA chipset found on the macppc xserve G5.
ok jmc


# 1.51 09-May-2011 matthew

Refactor queue allocation and initialization into a wdc_alloc_queue()
function, and let attachment code calls this rather than malloc(9).
This prevents re-initialization of the queue in shared queue chipsets.
Also, add wdc_free_queue() as a complementary function.

Earlier version (without wdc_free_queue()) tested by sthen@ and Amit
Kulkarni on various pciide(4) chips.

ok dlg@


# 1.50 08-May-2011 matthew

Eliminate a few unused wdc capability flags (WDC_CAPABILITY_HWLOCK,
WDC_CAPABILITY_ATA_NOSTREAM, and WDC_CAPABILITY_ATAPI_NOSTREAM).

ok dlg@, jsg@, krw@


# 1.49 18-Apr-2011 deraadt

keep an eye out for wdc registers returning 0xff. if they return 0xff,
this probably means the controller is dead -- as in, a hot plug eject
event. in that case, mark the driver dead and try harder to return -1
in the interrupt handler.
tested by many
ok dlg, miod did not object


# 1.48 15-Apr-2011 miod

Change wdc_reset_channel() to take a `no wait' argument. Pass in turn this
argument to wdcreset(), to have it skip waiting until active channels see
their BUSY bit clear in the status register.

Use this feature in the resume path, during the first reset operation. The
first reset is supposed to only wake up the controller, and the disks don't
come back until the second reset is issued, therefore waiting for them to
report themselves as ready after the first reset, but before the second, is
moot - and as a matter of fact some controllers, such as the AMD 754 and
clones/offspring (e.g. Geode) keep the BUSY bit asserted after the first
reset.

Last, but not least, make sure wd@ata invokes wd_get_params() again before
returning from the resume code, as we will still be using polled transfers
for a short while.

This causes the Lemote Yeelong to resume within less than one second, instead
of the lousy 30 seconds wait between the two resets; and the wd_get_params()
voodoo prevents it from getting spurious ide interrupts afterwards.

wd_get_params() magic from dlg; rest of the work by yours truly after enough
prodding by dlg@ and pirofti@, among others. ok deraadt@ dlg@


# 1.47 05-Apr-2011 deraadt

wd_hibernate_io() is a standalone disk io writer which tries to not
damage kernel memory very much while doing the job. It is not very
pretty yet, but improving it will need some MI work.
ok mlarkin jsg dlg


Revision tags: OPENBSD_4_9_BASE
# 1.46 29-Aug-2010 deraadt

pcmcia/wdc_pcmcia.c


Revision tags: OPENBSD_4_8_BASE
# 1.45 09-May-2010 jasper

hander -> handler

ok miod@


Revision tags: OPENBSD_4_7_BASE
# 1.44 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


# 1.43 05-Oct-2009 jsg

Add some minimalistic detach/unmap bits for pciide,
done using a chipset unmap callback.

Still needs to work to distinguish between compat
register mappings and compat interrupts so we
don't get caught out.

Tested with a diskless sii3112 CardBus eSATA controller
by me, and testing and feedback by deraadt@ with
a phison based expresscard SSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.42 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.41 08-May-2007 deraadt

wdcrestart() is never used


# 1.40 08-May-2007 deraadt

atapi_print() is never used


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.39 03-May-2006 jsg

Provide a function pointer that allows for the wdc reset
method to be changed as required.
This will be required for dealing with several chips in pciide.


Revision tags: OPENBSD_3_9_BASE
# 1.38 10-Feb-2006 kettenis

Fix LBA48 access for ServerWorks SATA.
ok grange@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.37 17-Oct-2004 grange

Add a callback drv_probe() to allow underlying ata controller driver
to probe for drives in its own way. It's a no-op for now but will be
needed for native sata support.


# 1.36 17-Oct-2004 grange

Move declaration of default _vtbl members (wdc_default_*) to
wdcvar.h.


# 1.35 17-Oct-2004 grange

Define number of general and ``shadow'' (overlapping) ATA registers;
from NetBSD.


# 1.34 24-Sep-2004 grange

Multiple inclusion protection.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 02-Jun-2004 grange

Add quirks field to the wdc softc and implement the first one:
WDC_QUIRK_NOSHORTDMA which disables DMA for the one-sector
transfers. Use this quirk for the Geode SC1100 IDE to fix
hanging during fdisk reported in PR 3729.
Thanks to Alexandre Belloni <abelloni@nerim.net> for testing.

ok costa@


Revision tags: OPENBSD_3_5_BASE
# 1.32 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


# 1.31 17-Oct-2003 grange

Merge an old fix from NetBSD:
- do not stop/unload current DMA operation if an IRQ was not detected
by DMA engine unless the force flag was given, fixes DMA problems
in shared IRQ setups;
- ack interrupt before entering DMA codepath

Tested by many.
Work by niklas@ but he doesn't want to commit it for some reason.


# 1.30 16-Oct-2003 grange

New flag to mark SATA controllers


# 1.29 16-Oct-2003 grange

spaces/tabs cleanup


# 1.28 28-Sep-2003 grange

kill trailing spaces, no functional changes


Revision tags: OPENBSD_3_4_BASE
# 1.27 23-Jul-2003 grange

Old Promise ATA controllers need some additional operations
during DMA transfers to work correctly with LBA48 drives.
Based on diff from Takeshi Nakayama <tn@catvmics.ne.jp> for NetBSD
with some corrections from FreeBSD ATA driver.


# 1.26 05-Jul-2003 grange

better indent


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 03-May-2002 gluk

LBA48 support.
Adopted from NetBSD by Alexander Yurchenko <grange@openbsd.ru>.

costa@ ok.


Revision tags: OPENBSD_3_1_BASE
# 1.24 16-Mar-2002 csapuntz

The new code logs the control signals on the IDE bus. You can extract the log
using atactl <device> dump. The log will help us support more devices.
Send logs to csapuntz@


# 1.23 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.22 14-Mar-2002 millert

First round of __P removal in sys


# 1.21 07-Jan-2002 mickey

pass the proc* down the ioctl chain to controller; mjacob@ csapuntz@ ok


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 31-Jul-2001 csapuntz

branches: 1.20.4;


On DMA timeouts, stop busmaster PCIIDE and reset channel. Avoid reading
device registers as this may cause lock-ups on some chipsets

Clean-up in atapiscsi. Get rid of claim_irq. Instead, atapiscsi always
returns -1 (maybe) from the interrupt handler.


# 1.19 25-Jun-2001 csapuntz

Fix excessive resets and device probes by storing IDENTIFY results in the
drvp structure


# 1.18 30-Apr-2001 csapuntz

Move ATA IOCTL commands to low-level WDC driver


Revision tags: OPENBSD_2_9_BASE
# 1.17 04-Apr-2001 csapuntz

Lay the groundwork for disabling ATAPI DMA on controllers
where we have trouble. Note, in theory, ATAPI DMA is no different
than ATA DMA.

"Promise" not to tell anybody


# 1.16 25-Mar-2001 csapuntz

Minor mods to DMA interface - get rid of unnecessary args. Allow DMA functions to return status flags.

Note: Changing code to have DMA interface indicate when I/O is done (a la NetBSD) was considered. It was rejected due to questionable backward compatability
with ISA DMA and MAC obio DMA

Added irqack from NetBSD (though this feature should really be in the
PCI interrupt handlers)

Use pool


# 1.15 15-Mar-2001 csapuntz

Fix races between timeouts and interrupts.

Cleanup atapiscsi driver a bit by moving fields out of xfer.


# 1.14 05-Mar-2001 ho

Convert to new timeout API. costa@ ok.


# 1.13 29-Jan-2001 csapuntz

Add wdc_print_current_modes to print current transfer modes set on the
devices. Print after attach in wdc_isa, wdc_isapnp, wdc_pcmcia.
pciide_print_modes rewritten to use wdc_print_current_modes.

Disable wdc_print_caps since it's not as useful.

Inspired by NetBSD. Thanks to Dale and Theo for pointing out this improvement.


Revision tags: OPENBSD_2_8_BASE
# 1.12 27-Oct-2000 csapuntz

Patch to get rid of ST506 phantoms. Thanks to Grigoriy Orlov for the design
and testing.


# 1.11 20-Jul-2000 csapuntz

chp->wdc can be NULL on probe.

Propagate verbose flag from cf_data to channel


# 1.10 20-Jul-2000 csapuntz

Fix to ATA detect. Some devices seem to be comatose after reset
(return 0x00 status persistently). Send them identify to wake them up.

Flag value 0x10000 will enable probe messages for a channel/controller.
When UKC supports setting flags, this will be useful debugging
failing IDE detects without kernel recompiles.


# 1.9 30-Jun-2000 art

Convert some parts to new timeouts.


Revision tags: OPENBSD_2_7_BASE
# 1.8 10-Apr-2000 csapuntz

Added support for wd detach (merge from NetBSD). Support for
SCSI/ATAPI detach is not here yet.

Minor cleanup of wdc. Downgrade to UDMA mode 1 before going further.
Want to stay in UDMA modes because they're more error-resilient due to
a CRC.

Got rid of some of the ridiculous amount of softc sharing going on.
Hopefully, this will make the life of whoever goes in and fixes the
ref-counting to be correct easier.


Revision tags: SMP_BASE
# 1.7 14-Dec-1999 csapuntz

branches: 1.7.2;


Thanks aaron.

Changed time->ticks


# 1.6 11-Dec-1999 csapuntz

ATAPI Tape drive support. Should be considered experimental.

Major restructuring of the code path that sends ATAPI packet commands.
One set of functions works in polling, process, and interrupt contexts.


Revision tags: kame_19991208
# 1.5 17-Nov-1999 csapuntz

New interface to ATA registers that goes through the lower-level device
driver (pciide, wdc, etc.)

Remove #define WDCDEBUG from top of files

More fixes to ATAPISCSI logic:

Not all devices transition correctly between phases. Devices are supposed
to keep BSY high until they've set the registers to the next sensible
state. Some devices drop BSY and leave the registers in an old or
nonsense state. Our polling code is extremely sensitive to this
(though an early itnerrupt could also observe this). So, if the device is
in an unexpected state, the new polling code waits for a while in the hope
that it enters a better state.

This seems to fix many of the problems reported.

Also, there was a horrible bug which would cause sense to fail on a ATAPI
command that sent data to the drive


Revision tags: OPENBSD_2_6_BASE
# 1.4 29-Oct-1999 deraadt

reliability fixes from csapuntz; commit message replaced later with details


# 1.3 09-Oct-1999 csapuntz

wdc layer work:
Separate wdc_probe_caps into wdc_probe_caps and wdc_print_caps for more
flexibility in printing capability information.

Get rid of wdc_final_attach.

Include name of device (e.g. cd0), if possible, on errors.

atapiscsi layer work:
Put a pointer to the SCSI device into ata_drive_datas' drv_softc field

Simplify, simplify, simplify. Got rid of a bunch of fields in atapiscsi_softc

Delay printing capabilities until we know the real device name (e.g. st0)


# 1.2 22-Jul-1999 csapuntz

Create wdc_enable_intr, wdc_disable_intr, wdc_select_drive.

wdc_select_drive implements the drive selection protocol
as documented in the ATA-5 preliminary specs.


# 1.1 18-Jul-1999 csapuntz

Import of NetBSD ATA/IDE stuff.

Introduction of home-grown

To enable this stuff in your configuration, look at the NEWATA conf file
and go through

dev/isa/files.isa
dev/pci/files.pci
conf/files
arch/i386/conf/files.i386

and follow the instructions on commenting/uncommenting stuff


Revision tags: OPENBSD_6_2_BASE
# 1.56 12-Jul-2017 mikeb

Introduce two quirks to prevent attaching ATA and ATAPI devices

Hyper-V and Xen have varying support for detaching emulated IDE
devices ranging from none on Hyper-V to only IDE disks but not
CDROM (Xen). The quirk mechanism provides a way of enforcing the
desired behavior.

With suggestions and OK kettenis, tedu, mlarkin


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.55 17-Aug-2015 krw

The 80's called and want their interface back. Remove last fragments of
ST-506 support. Remove redundant 'precomp' variables/fields and rename
remaining few to 'features' to be consistant with the rest of the code.

Consensus that no ST-506 disks (requiring ISA cards, <120MB, usually
rife with bad sectors that can't be worked around) are still running
OpenBSD.


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.54 22-Jan-2014 dlg

dont piggyback on C_PRIVATEXFER because it must not touch splx.
because im using it while the system is up and running i need the
xfer free path to take the right locks, which PRIVATEXFER doesnt.
invent a new C_SCSIXFER flag that provides the safety needed.

this fixes issues people have had installing from atapiscsi(4) cdrom
devices.

bug spelunking and tailq corruption identified by jsing@
ok jsing@


# 1.53 18-Jan-2014 dlg

move atapiscsi to iopools by making the entire ata layer use them too.

this would have been difficult before because the ata completion
paths try to be helfpul by freeing xfers on the adapters behalf,
whch doesn't work in the new world scsi model where the layer that
allocated the thing is responsible for freeing it, and expects to
get it back and maybe use it again. however, deraadt@ added magic
flags for hibernate that im now using to keep ata xfers for the
scsi layers.

committing this now so itll be tested. i cant think of a better time
to handle fallout from diffs like this than hackathons.

discussed with deraadt@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.52 15-Jul-2011 deraadt

Cope with the start-dma-before-init errata and some other register setup
errata for the Serverworks SATA chipset found on the macppc xserve G5.
ok jmc


# 1.51 09-May-2011 matthew

Refactor queue allocation and initialization into a wdc_alloc_queue()
function, and let attachment code calls this rather than malloc(9).
This prevents re-initialization of the queue in shared queue chipsets.
Also, add wdc_free_queue() as a complementary function.

Earlier version (without wdc_free_queue()) tested by sthen@ and Amit
Kulkarni on various pciide(4) chips.

ok dlg@


# 1.50 08-May-2011 matthew

Eliminate a few unused wdc capability flags (WDC_CAPABILITY_HWLOCK,
WDC_CAPABILITY_ATA_NOSTREAM, and WDC_CAPABILITY_ATAPI_NOSTREAM).

ok dlg@, jsg@, krw@


# 1.49 18-Apr-2011 deraadt

keep an eye out for wdc registers returning 0xff. if they return 0xff,
this probably means the controller is dead -- as in, a hot plug eject
event. in that case, mark the driver dead and try harder to return -1
in the interrupt handler.
tested by many
ok dlg, miod did not object


# 1.48 15-Apr-2011 miod

Change wdc_reset_channel() to take a `no wait' argument. Pass in turn this
argument to wdcreset(), to have it skip waiting until active channels see
their BUSY bit clear in the status register.

Use this feature in the resume path, during the first reset operation. The
first reset is supposed to only wake up the controller, and the disks don't
come back until the second reset is issued, therefore waiting for them to
report themselves as ready after the first reset, but before the second, is
moot - and as a matter of fact some controllers, such as the AMD 754 and
clones/offspring (e.g. Geode) keep the BUSY bit asserted after the first
reset.

Last, but not least, make sure wd@ata invokes wd_get_params() again before
returning from the resume code, as we will still be using polled transfers
for a short while.

This causes the Lemote Yeelong to resume within less than one second, instead
of the lousy 30 seconds wait between the two resets; and the wd_get_params()
voodoo prevents it from getting spurious ide interrupts afterwards.

wd_get_params() magic from dlg; rest of the work by yours truly after enough
prodding by dlg@ and pirofti@, among others. ok deraadt@ dlg@


# 1.47 05-Apr-2011 deraadt

wd_hibernate_io() is a standalone disk io writer which tries to not
damage kernel memory very much while doing the job. It is not very
pretty yet, but improving it will need some MI work.
ok mlarkin jsg dlg


Revision tags: OPENBSD_4_9_BASE
# 1.46 29-Aug-2010 deraadt

pcmcia/wdc_pcmcia.c


Revision tags: OPENBSD_4_8_BASE
# 1.45 09-May-2010 jasper

hander -> handler

ok miod@


Revision tags: OPENBSD_4_7_BASE
# 1.44 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


# 1.43 05-Oct-2009 jsg

Add some minimalistic detach/unmap bits for pciide,
done using a chipset unmap callback.

Still needs to work to distinguish between compat
register mappings and compat interrupts so we
don't get caught out.

Tested with a diskless sii3112 CardBus eSATA controller
by me, and testing and feedback by deraadt@ with
a phison based expresscard SSD.


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.42 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.41 08-May-2007 deraadt

wdcrestart() is never used


# 1.40 08-May-2007 deraadt

atapi_print() is never used


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.39 03-May-2006 jsg

Provide a function pointer that allows for the wdc reset
method to be changed as required.
This will be required for dealing with several chips in pciide.


Revision tags: OPENBSD_3_9_BASE
# 1.38 10-Feb-2006 kettenis

Fix LBA48 access for ServerWorks SATA.
ok grange@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.37 17-Oct-2004 grange

Add a callback drv_probe() to allow underlying ata controller driver
to probe for drives in its own way. It's a no-op for now but will be
needed for native sata support.


# 1.36 17-Oct-2004 grange

Move declaration of default _vtbl members (wdc_default_*) to
wdcvar.h.


# 1.35 17-Oct-2004 grange

Define number of general and ``shadow'' (overlapping) ATA registers;
from NetBSD.


# 1.34 24-Sep-2004 grange

Multiple inclusion protection.


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 02-Jun-2004 grange

Add quirks field to the wdc softc and implement the first one:
WDC_QUIRK_NOSHORTDMA which disables DMA for the one-sector
transfers. Use this quirk for the Geode SC1100 IDE to fix
hanging during fdisk reported in PR 3729.
Thanks to Alexandre Belloni <abelloni@nerim.net> for testing.

ok costa@


Revision tags: OPENBSD_3_5_BASE
# 1.32 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


# 1.31 17-Oct-2003 grange

Merge an old fix from NetBSD:
- do not stop/unload current DMA operation if an IRQ was not detected
by DMA engine unless the force flag was given, fixes DMA problems
in shared IRQ setups;
- ack interrupt before entering DMA codepath

Tested by many.
Work by niklas@ but he doesn't want to commit it for some reason.


# 1.30 16-Oct-2003 grange

New flag to mark SATA controllers


# 1.29 16-Oct-2003 grange

spaces/tabs cleanup


# 1.28 28-Sep-2003 grange

kill trailing spaces, no functional changes


Revision tags: OPENBSD_3_4_BASE
# 1.27 23-Jul-2003 grange

Old Promise ATA controllers need some additional operations
during DMA transfers to work correctly with LBA48 drives.
Based on diff from Takeshi Nakayama <tn@catvmics.ne.jp> for NetBSD
with some corrections from FreeBSD ATA driver.


# 1.26 05-Jul-2003 grange

better indent


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.25 03-May-2002 gluk

LBA48 support.
Adopted from NetBSD by Alexander Yurchenko <grange@openbsd.ru>.

costa@ ok.


Revision tags: OPENBSD_3_1_BASE
# 1.24 16-Mar-2002 csapuntz

The new code logs the control signals on the IDE bus. You can extract the log
using atactl <device> dump. The log will help us support more devices.
Send logs to csapuntz@


# 1.23 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.22 14-Mar-2002 millert

First round of __P removal in sys


# 1.21 07-Jan-2002 mickey

pass the proc* down the ioctl chain to controller; mjacob@ csapuntz@ ok


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 31-Jul-2001 csapuntz

branches: 1.20.4;


On DMA timeouts, stop busmaster PCIIDE and reset channel. Avoid reading
device registers as this may cause lock-ups on some chipsets

Clean-up in atapiscsi. Get rid of claim_irq. Instead, atapiscsi always
returns -1 (maybe) from the interrupt handler.


# 1.19 25-Jun-2001 csapuntz

Fix excessive resets and device probes by storing IDENTIFY results in the
drvp structure


# 1.18 30-Apr-2001 csapuntz

Move ATA IOCTL commands to low-level WDC driver


Revision tags: OPENBSD_2_9_BASE
# 1.17 04-Apr-2001 csapuntz

Lay the groundwork for disabling ATAPI DMA on controllers
where we have trouble. Note, in theory, ATAPI DMA is no different
than ATA DMA.

"Promise" not to tell anybody


# 1.16 25-Mar-2001 csapuntz

Minor mods to DMA interface - get rid of unnecessary args. Allow DMA functions to return status flags.

Note: Changing code to have DMA interface indicate when I/O is done (a la NetBSD) was considered. It was rejected due to questionable backward compatability
with ISA DMA and MAC obio DMA

Added irqack from NetBSD (though this feature should really be in the
PCI interrupt handlers)

Use pool


# 1.15 15-Mar-2001 csapuntz

Fix races between timeouts and interrupts.

Cleanup atapiscsi driver a bit by moving fields out of xfer.


# 1.14 05-Mar-2001 ho

Convert to new timeout API. costa@ ok.


# 1.13 29-Jan-2001 csapuntz

Add wdc_print_current_modes to print current transfer modes set on the
devices. Print after attach in wdc_isa, wdc_isapnp, wdc_pcmcia.
pciide_print_modes rewritten to use wdc_print_current_modes.

Disable wdc_print_caps since it's not as useful.

Inspired by NetBSD. Thanks to Dale and Theo for pointing out this improvement.


Revision tags: OPENBSD_2_8_BASE
# 1.12 27-Oct-2000 csapuntz

Patch to get rid of ST506 phantoms. Thanks to Grigoriy Orlov for the design
and testing.


# 1.11 20-Jul-2000 csapuntz

chp->wdc can be NULL on probe.

Propagate verbose flag from cf_data to channel


# 1.10 20-Jul-2000 csapuntz

Fix to ATA detect. Some devices seem to be comatose after reset
(return 0x00 status persistently). Send them identify to wake them up.

Flag value 0x10000 will enable probe messages for a channel/controller.
When UKC supports setting flags, this will be useful debugging
failing IDE detects without kernel recompiles.


# 1.9 30-Jun-2000 art

Convert some parts to new timeouts.


Revision tags: OPENBSD_2_7_BASE
# 1.8 10-Apr-2000 csapuntz

Added support for wd detach (merge from NetBSD). Support for
SCSI/ATAPI detach is not here yet.

Minor cleanup of wdc. Downgrade to UDMA mode 1 before going further.
Want to stay in UDMA modes because they're more error-resilient due to
a CRC.

Got rid of some of the ridiculous amount of softc sharing going on.
Hopefully, this will make the life of whoever goes in and fixes the
ref-counting to be correct easier.


Revision tags: SMP_BASE
# 1.7 14-Dec-1999 csapuntz

branches: 1.7.2;


Thanks aaron.

Changed time->ticks


# 1.6 11-Dec-1999 csapuntz

ATAPI Tape drive support. Should be considered experimental.

Major restructuring of the code path that sends ATAPI packet commands.
One set of functions works in polling, process, and interrupt contexts.


Revision tags: kame_19991208
# 1.5 17-Nov-1999 csapuntz

New interface to ATA registers that goes through the lower-level device
driver (pciide, wdc, etc.)

Remove #define WDCDEBUG from top of files

More fixes to ATAPISCSI logic:

Not all devices transition correctly between phases. Devices are supposed
to keep BSY high until they've set the registers to the next sensible
state. Some devices drop BSY and leave the registers in an old or
nonsense state. Our polling code is extremely sensitive to this
(though an early itnerrupt could also observe this). So, if the device is
in an unexpected state, the new polling code waits for a while in the hope
that it enters a better state.

This seems to fix many of the problems reported.

Also, there was a horrible bug which would cause sense to fail on a ATAPI
command that sent data to the drive


Revision tags: OPENBSD_2_6_BASE
# 1.4 29-Oct-1999 deraadt

reliability fixes from csapuntz; commit message replaced later with details


# 1.3 09-Oct-1999 csapuntz

wdc layer work:
Separate wdc_probe_caps into wdc_probe_caps and wdc_print_caps for more
flexibility in printing capability information.

Get rid of wdc_final_attach.

Include name of device (e.g. cd0), if possible, on errors.

atapiscsi layer work:
Put a pointer to the SCSI device into ata_drive_datas' drv_softc field

Simplify, simplify, simplify. Got rid of a bunch of fields in atapiscsi_softc

Delay printing capabilities until we know the real device name (e.g. st0)


# 1.2 22-Jul-1999 csapuntz

Create wdc_enable_intr, wdc_disable_intr, wdc_select_drive.

wdc_select_drive implements the drive selection protocol
as documented in the ATA-5 preliminary specs.


# 1.1 18-Jul-1999 csapuntz

Import of NetBSD ATA/IDE stuff.

Introduction of home-grown

To enable this stuff in your configuration, look at the NEWATA conf file
and go through

dev/isa/files.isa
dev/pci/files.pci
conf/files
arch/i386/conf/files.i386

and follow the instructions on commenting/uncommenting stuff