Commit Graph

282 Commits

Author SHA1 Message Date
thorpej dc59bc1db3 Update for sys/buf.h/disksort_*() changes. 2000-01-21 23:39:55 +00:00
bouyer 638e1a6958 Improve the downgrade logic:
- If UDMA 2 is failing try UDMA 1 first, it helps in some cases
- downgrade if we get an error in the first 4000 xfers, or if we get
  4 errors in 4000 xfers if the first 4000 went without troubles.

While I'm there commit a local change I have since some time to get my CD
probed: issue a "blanck" IDENTIFY before the one used to detect slave ghosts,
with my drive the first IDENTIFY following a controller reset fails with an
aborted command ...
2000-01-17 00:01:00 +00:00
leo 384bdc532b Implement the DIOCKLABEL ioctl. Through this ioctl it it possible keep the
disklabel on the last close or to drop it.
1999-12-23 21:23:19 +00:00
bouyer 8f56b89950 More WDCDEBUG_PRINT. 1999-11-26 12:39:43 +00:00
leo 0c76b12125 Give lp->d_type a value other than 'unknown'. When the model is "ST506",
the d_type field becomes DTYPE_ST506, otherwise it will be set to DTYPE_ESDI.
1999-11-10 14:11:34 +00:00
enami a2369d8e97 Cancel active transfers on aic/wdc detach.
Also makes LS-120 drive works for me again.
1999-10-20 15:22:24 +00:00
enami 67e874d814 Allow to detach wdc, atapibus, wd and cd. 1999-09-23 11:04:29 +00:00
enami c08940c49b Fix indentation of close curly brace. 1999-09-22 09:51:03 +00:00
bouyer 7e874499c9 Don't call wddone() from _wdstart(), the ata_wdc system will do it now.
call wd_flushcache() with the proper flags (especially don't set
AT_WAIT | AT_POLL).
1999-08-09 09:48:04 +00:00
bouyer c0da6c9129 Don't use C_NEEDDONE, it's deprecated. 1999-08-09 09:43:11 +00:00
bouyer fae9929734 - Add some debug printf (WDCPROBE) in _wdcreset_wait(), I've needed these
2 times in the past
- Set up timeout per xfer instead of per interrupt. This helps with
  PIO transfer (we would call timeout()/untimout() several times for a
  transfer).
- If we missed an interrupt for a PIO transfer, reset and restart it
  immedialy, don't try to recover and continue. If we missed an interrupt we
  may have lost a read/write cycle on the IDE bus. If this happens 1) we
  corrupt data and 2) we enter an interrupt loop at the end of the xfer, as
  the drive has some more data to read/write, but the host thinks the xfer is
  done.
This last change fix the (or at last some of the) 'lookup after lost interrupt'
some peoples have been experiencing.
1999-08-06 12:00:23 +00:00
bouyer 94d00cdb29 Bump timeout to 10s only for ATAPI devices, 1s is fine for IDE drives once
they are ready.
1999-04-15 09:41:09 +00:00
jonathan 380d12dfbd Complete bugfix in rev 1.3: increase read-parameter-block timeout to 10s
(as used for the hardware for which rev 1.3 was made.)
1999-04-14 22:23:15 +00:00
bouyer b43b844f6f - change the interrupt routines to take a 3rd arguments, set to 1 if we
are called from the interrupt or timeout handler, 0 otherwise.
- use this to know if we can busy-wait for wait_for_unbusy or wait_for_ready
This fixes a bug where CDs withot the DRQ_INTR capability would not busy-wait
for the CMDOUT phase.
While I'm there change 2 delay() to DELAY() for consistency, and
garbage-collect some old code from wdcintr() which has been ifdef'd out
for some time now.
1999-04-01 21:46:28 +00:00
bouyer 1ff88ee466 Avoid busy-waiting when possible if we are not polling (real IRQ or timeout
callback). Shared PCI IRQ should now work (but still untested).
1999-03-25 16:17:36 +00:00
bouyer af9df0ab31 Revert to a 10s timeout, 1s is too low for drives in sleep mode. 1999-03-17 10:13:56 +00:00
bouyer a6365676fa Add a new disk flag: DRIVE_OLD for pre-ATA disks. probe routine will now set
DRIVE_OLD, DRIVE_ATA or DRIVE_ATAPI based on register signatures.
The attach routine will issue a IDENTIFY command for ATA/ATAPI disk,
to detect flase matches by the probe routine.
probe/attach should now be fully compliant with ata-4/ata-5. As a side
effect, ATAPI drives which improperly use ATA register signatures should now
be attached as ATAPI.
1999-03-10 13:11:43 +00:00
bouyer ba74f49e60 Keep track of CRC errors in Ultra-DMA mode. If we noticed a CRC error and we
need to downgrade, downgrade to PIO, as it has been shown if we got CRC errors
in Ultra-DMA mode, we will have silent data corruption in multiword DMA mode
(isn't IDE wonderfull ? :).
Set timeout to 1s for "normal" ata I/O, to minimise the effects of missed
interrupts.
1999-03-07 14:02:53 +00:00
explorer 3ebb419571 Update to slightly altered rnd_attach_source() api 1999-02-28 17:08:05 +00:00
hubertf ed418e30a2 Only define WDCDEBUG if not already define (e.g. by kernel option) 1999-02-21 00:52:04 +00:00
hubertf 37a9e5bb67 Only define WDCDEBUG if not already defined (e.g. by some kernel option) 1999-02-21 00:15:42 +00:00
bouyer e96144a012 Add a missing ':'. pointed out by Dave Huang. 1999-02-18 14:44:34 +00:00
bouyer 1e0e78854a There's no ATA draft where it is required for the drive to set DRDY | DSC when
the disk is ready to transfer data, and in ATA-5 the DSC has been obsoleted.
So only wait for DRQ to transfer data. This can be made conditional on the
ATA version if it's proven to break with some drives (worked with all the
drives I have access to).
While I'm there correct a few typos.
1999-02-08 15:22:28 +00:00
bouyer ce870816e0 Cosmetic changes, from Soren S. Jorvan. 1999-01-29 11:36:20 +00:00
bouyer a1471db64a move wd.c:print_wderror() to ata.c:ata_perror().
In wdc_probe_caps() add code to guess the ATA revision supported (if
ATA4 if Ultra-DMA, ATA2 if PIO mode > 2). We can't rely on param.atap_ata_major
here, at last one Ultra-DMA drive claims to support only ATA-3.
Use the ATA version in ata_perror(), and to try a flush cache command
in a shutdown hook for IDE drives.
1999-01-18 20:06:24 +00:00
thorpej 1a56840ec0 Make this compile again after void * arithmetic changes. 1999-01-09 03:05:19 +00:00
augustss 332d7c138f Avoid arithmetic on `void *' since that's not ANSI C. 1999-01-08 18:10:35 +00:00
bouyer c37bf0ccb4 Keep track of DMA errors, and downgrade the transert mode (UDMA ->DMA,
DMA->PIO) in case of 2 consecutive errors. Don't downgrade if the
PIO/DMA/UDMA modes were forced by a config flag.
1998-12-16 13:02:03 +00:00
bouyer 1f0d6730cc Switch to single-sector transfert mode only for the last retry, to let
a chance to the underlying driver to downgrade the mode first.
1998-12-16 13:00:02 +00:00
bouyer c10f6edafc AT_ERROR should be different from AT_TIMEOUT. pointed out by Matthias Drochner. 1998-12-04 11:17:54 +00:00
bouyer 45675ab14b - change drive_flags from u_int8_t to u_int16_t
- keep the modes supported by the drive in struct ata_drive_datas (will be
  later used for downgrading the DMA/PIO mode on error)
- use config flags to force/disable PIO/DMA/UDMA modes
- For the CMD PCI0643/6 setup DMA mode to DMA Read multiple.
1998-12-02 10:52:24 +00:00
tsubai 75ed099b01 struct ataparam has endian dependence, so add big-endian case. 1998-12-01 13:06:37 +00:00
kenh 48f2e0ae6c Add a new flag to wdc_command: ATA_READREG. This will indicate that all
device registers should be read back into the wdc_command structure after
successfull command completion.  Use this this in wdioctl() for
ATAIOCCOMMAND.
1998-11-23 23:00:26 +00:00
drochner 3e38051bc5 in wdc_softc: access the per-channel data via a pointer array instead of
an array of fixed-sized channel_softc elements. This way IDE controllers
which more than 1 channel (pciide) can extend the channel data easily
for private needs.
To avoid the double dereference at runtime, change the argument of
wdcstart() to the channel data pointer instead of the array index.
1998-11-21 15:41:41 +00:00
thorpej d0a4fb616f Implement controller reference counting on ATA devices. 1998-11-20 01:23:52 +00:00
kenh 510830d2c3 Rename WDCIOCCOMMAND (and related structures) to ATAIOCCOMMAND 1998-11-19 23:44:20 +00:00
kenh 9bc9937238 Add support for the WDCIOCCOMMAND ioctl. This allows the sending of
arbitrary ATA commands from user-space.  Concepts mostly taken from
the implementation of the SCIOCCOMMAND ioctl.
1998-11-19 19:46:12 +00:00
kenh 7faa4da4bc Don't protect this with #ifdef _KERNEL 1998-11-18 16:32:29 +00:00
bouyer d74652866f For ATAPI IDENTiFY, poll only for DRQ, some devices don't assert DRDY at this
point.
1998-11-16 11:25:41 +00:00
bouyer 1e71e76d6c - clearify the boot messages (features supported vs features used). Thanks to
Havard Eidnes for his complains about this :)
- fix some typo in comments
- hoppefully better detection of drives reporting bogus PIO modes.
1998-11-11 19:38:27 +00:00
bouyer 7bdbb5c993 Donc reset the disk state to 0 in wd.c, set a flag which will cause it
to be reset to 0 at wdcstart(). This fixes a race condition between
normal I/O and wdioclt(). Also use interrupts for wd_get_params in wdopen().
1998-10-20 17:00:25 +00:00
bouyer a7c841cfbc Donc reset the disk state to 0 in wd.c, set a flag which will cause it
to be reset to 0 at wdcstart(). This fixes a race condition between
normal I/O and wdioclt().
1998-10-20 17:00:24 +00:00
bouyer e8322de657 Add a new drive flag, DRIVE_MODE, set when the drive properly reported its
PIO/DMA modes. Don't try a SET_FEATURE if it didn't report its mode.
1998-10-13 15:18:46 +00:00
bouyer 7545a59b8c In debug message, always print controller:channel:drive 1998-10-13 15:02:41 +00:00
bouyer ff0134b99f Properly separate DEBUF_XFERS and DEBUG_FUNCS: DEBUF_XFERS is for data
transfers (may be called often), where DEBUG_FUNCS is for setup functions
(not used for normal contitions).
1998-10-13 09:33:59 +00:00
thorpej dc7cfafe4c Default to "no debugging messages" (still patchable). 1998-10-13 05:39:01 +00:00
bouyer 46aa11acac Adjust include list. 1998-10-12 19:50:09 +00:00
bouyer 19fddaeeb5 Merge bouyer-ide 1998-10-12 16:09:10 +00:00
drochner 73ac88b3ed make the default disklabel consistent to the SCSI/ATAPI case 1998-09-07 21:28:22 +00:00
rvb 305a943ba7 Use scsi style geometry printout 1998-08-15 15:05:22 +00:00
mycroft 6dc903202f Assign my copyrights to TNF. 1998-08-15 10:10:47 +00:00
rvb 48bf26949f Report "true" disk geometry; like sd disks do 1998-08-13 18:16:53 +00:00
cgd 651b44e211 Rework the way kernel include files are installed. In the new method,
as with user-land programs, include files are installed by each directory
in the tree that has includes to install.  (This allows more flexibility
as to what gets installed, makes 'partial installs' easier, and gives us
more options as to which machines' includes get installed at any given
time.)  The old SYS_INCLUDES={symlinks,copies} behaviours are _both_
still supported, though at least one bug in the 'symlinks' case is
fixed by this change.  Include files can't be build before installation,
so directories that have includes as targets (e.g. dev/pci) have to move
those targets into a different Makefile.
1998-06-12 23:22:30 +00:00
thorpej be62e9cb1b Nuke __BROKEN_INDIRECT_CONFIG. 1998-06-09 07:35:06 +00:00
enami df385821f4 Print newline like others do when tracing wdunlock. 1998-06-04 02:25:05 +00:00
mycroft 18aa33cce5 Disable the change to check wdp_ataversion, since it's unreliable with old
devices.  (Yuck.)
1998-05-09 05:20:35 +00:00
mycroft 0b2694152f Update copyright. 1998-04-26 06:03:23 +00:00
mycroft eddaea2d53 In LBA mode, always use the `total capacity' count, rather than calculating
the capacity based on the c/h/s numbers.  In fact, don't use the c/h/s
numbers for much of anything.
For ATA-4 drives or later, always use LBA mode, since it's now required.

Collectively, this allows >8GB disks (like the 12GB Bigfoot) to work.
1998-04-26 05:28:23 +00:00
bouyer 68096acabd From Robert V. Baron:
Compute the disk block addr at command queing time rather than exec time.
This fix a bug which could lead to data corruption on disk: when a command
was reexecuted after an error condition (from wdcunwedge), the partition
offset was re-added to the block addr, leading to a transfert at the wrong
disk block.
This should fix the problem reported by some laptop's users, where the
first disk read after a suspend/resume returned garbage.
1998-04-23 13:30:39 +00:00
leo 0e4dce88d4 Conditionalize badblock handling on 'HAS_BAD144_HANDLING'. Some ports
(like atari) do not support it.
1998-03-25 09:58:24 +00:00
thorpej 8354e68508 Remove "class" declarations, and add "devclass" declarations where
appropriate.  Fix several inconsistencies between device class and
attributes.  Mostly from Chris Demetriou.
1998-02-16 22:12:45 +00:00
cgd 8540a31ee3 kill a couple of unnecessary #ifs 1998-01-15 01:26:13 +00:00
cgd aaede4d8d8 Various cleanups and bug fixes to the wdc/wd code:
* Fix bug in wdc that would overflow ATAPI transfer length.
* Improve wdc probe code so that 'wdc' is probed in if present
  even if there are no drives attached, and so that it works
  properly even if the only device is an ATAPI slave.
* bus_space-ify.
* split the ISA attachment from the wdc driver, and remove
  ISA dependencies from non-ISA files.
* claim that wd and wdc are now machine-independent (probably not
  completely true, but mostly so; they at least work on arm32 and
  i386).
* Various other minor fixups and cleanups, some of which were pointed
  out by Kazuki Sakamoto.
1998-01-14 23:41:59 +00:00
cgd ad141a69a7 Shuffle wd/wdc driver files around (via repository copies). wdc
now lives in dev/ic, wd now lives in dev/ata.  there's now a 'ata'
interface attribute defined in conf/files, but wdc can't go there
yet because some ports still use private versions based on the old
ISA version.
1998-01-14 23:36:30 +00:00
thorpej 06ce220790 Update for config changes. 1998-01-12 09:39:57 +00:00
explorer 80513cb5ae o Make usage of /dev/random dependant on
pseudo-device   rnd                     # /dev/random and in-kernel generator
  in config files.

o Add declaration to all architectures.

o Clean up copyright message in rnd.c, rnd.h, and rndpool.c to include
  that this code is derived in part from Ted Tyso's linux code.
1997-10-13 00:46:08 +00:00
explorer b5feb41072 Add hooks to insert timing info into the random system 1997-10-10 01:09:03 +00:00
thorpej 939e074dcc Implement DIOCGDEFLABEL. 1997-10-08 23:05:22 +00:00
bouyer 702b60b0c1 Add a map to wdc_softc to track the already known devices to prevent them to
be probed several times. This fixes the "ATAPI CD probed as wd drive" problem.
Thanks to Geoff Wing <mason@primenet.com.au> for testing this on his hardware.
1997-09-03 07:57:51 +00:00
bouyer 6f3bab1f59 Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
1997-08-27 11:22:52 +00:00
fvdl 3dd82f1394 Work around possible race condition with 2 drives on one controller
in wd_get_parms. PR 3773, from Onno van der Linden (onno@simplex.nl)
1997-07-18 00:26:22 +00:00
jtk 26414c7820 use locator defines in "locators.h" to index cf_loc[]
still to be done and/or decided not to be done: replace all *UNK uses in
isa code with the native names from locators.h
1997-07-17 00:58:48 +00:00
thorpej efde490942 foosize()'s return value is in DEV_BSIZE units; adjust the size obtained
from the disklabel accordingly.
1997-06-24 00:20:44 +00:00
pk 5d4e140e53 Remove spurious line left over in previous commit. 1997-06-18 22:17:14 +00:00
pk f5bf0d3701 wdsize(): only call wdopen()/wdclose() if not already open, per the
current `openmask'.
1997-06-18 20:39:55 +00:00
thorpej 11e78a6b0d Pull thorpej-bus-dma branch into mainline. 1997-06-06 23:43:45 +00:00
perry 8852c180ef Fixes to wd driver from cgd -- corrects several nasty bugs typically
associated with coming out of suspends/sleeps on laptops.
Approved by fvdl.
1997-01-17 20:45:29 +00:00
thorpej 3b4e2a1ac9 In wdattach(), when printing out info about the drive, make the output
look a little more like a SCSI disk's.  This has the pleasant side-effect
of preventing the output from annoyingly extending past 80 columns.
1996-11-27 10:50:39 +00:00
mikel af29f79ed4 Fix WDDEBUG code; PR kern/1480. 1996-11-07 05:23:07 +00:00
christos 86373f8cf9 backout kprintf changes 1996-10-13 01:37:04 +00:00
christos 58953408cb printf -> kprintf, sprintf -> ksprintf 1996-10-10 22:04:48 +00:00
cgd 2a73ef60b7 change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
1996-08-27 21:53:46 +00:00
mycroft cec36bf8d5 Use intr.h. 1996-05-12 23:51:23 +00:00
christos 27292adc4c - gcc -Wall fixes 1996-04-29 19:50:47 +00:00
cgd 51e85d07b9 update for addition of a machine-dependent cookie as the first argument
to isa_intr_{,dis}establish().
1996-04-11 22:27:59 +00:00
thorpej de7c200585 New device attachment scheme:
- split softc size and match/attach out from cfdriver into
	  a new struct cfattach.

	- new "attach" directive for files.*.  May specify the name of
	  the cfattach structure, so that devices may be easily attached
	  to parents with different autoconfiguration semantics.
1996-03-17 00:53:54 +00:00
mycroft 546ad9e88b Add support to the ISA DMA framework for auto-initialize mode.
Add experimental SB16 code, disabled for now.
1996-03-01 04:08:13 +00:00
mycroft 3441f118d5 Make sure we disk_busy() for every transfer we start. 1996-01-08 21:21:56 +00:00
thorpej 5b39541e48 New generic disk framework. Highlights:
- New metrics handling.  Metrics are now kept in the new
	  `struct disk'.  Busy time is now stored as a timeval, and
	  transfer count in bytes.

	- Storage for disklabels is now dynamically allocated, so that
	  the size of the disk structure is not machine-dependent.

	- Several new functions for attaching and detaching disks, and
	  handling metrics calculation.

Old-style instrumentation is still supported in drivers that did it before.
However, old-style instrumentation is being deprecated, and will go away
once the userland utilities are updated for the new framework.

For usage and architectural details, see the forthcoming disk(9) manual
page.
1996-01-07 22:01:38 +00:00
mycroft 3da4b2a160 The IST_* and IPL_* constants are not bus-specific; don't treat them as such.
Change splimp -> splnet in Ethernet, ARCnet, and FDDI drivers.
1995-12-24 02:29:35 +00:00
mycroft 82b6eec41c Use an intermediate variable to shorten label initialization code.
Make wddump() work on more machines.
1995-08-05 23:50:23 +00:00
mycroft 7263209ce6 Make each disk and tape driver define its own read and write functions.
Deprecate rawread() and rawwrite() completely.  Remove d_strategy from cdevsw to
force the abstraction barrier.
1995-07-04 07:15:28 +00:00
cgd 2a8d6461a8 implement new-style block device dump routine if __BDEVSW_DUMP_OLD_TYPE
not defined, otherwise use an "not implemented" stub.
1995-06-26 05:16:55 +00:00
cgd 8a640328ed clean up several ISA device interfaces: autoconfiguration, header
inclusion, and interrupt configuration.  more work still needs to be done,
but it's getting better...
1995-04-17 12:06:30 +00:00
mycroft 04e937dcbd Don't boundary check I/O to the `raw' partition. 1995-04-15 05:01:26 +00:00
mycroft 68c8c80929 kernel_pmap --> pmap_kernel() 1995-04-10 16:48:27 +00:00
mycroft 7e2dabf972 Add a missing unlock. 1995-04-01 10:29:41 +00:00
mycroft e17c63cee6 Revamp the locking mechanism slightly. Update some outdated comments, and add
a few new ones.
1995-03-29 23:36:27 +00:00
mycroft b51403f60d Remove the write protect check altogether, and rely on the drive to do it. 1995-03-25 19:45:18 +00:00
mycroft 06d0a67a07 Check for read-only media in open(), not write(). 1995-03-23 12:11:07 +00:00