Commit Graph

306 Commits

Author SHA1 Message Date
Warner Losh
b593dd82f7 Use bus_setup_intr in preference to BUS_SETUP_INTR. 2004-09-14 17:28:51 +00:00
Warner Losh
b4046cd721 Checkpoint the fdc resource changes:
o Allow for up to 3 resource I/O ranges to be given for the floppy
  controller, rather than just two that are allowed for now.
o Make sure that we can work with either a base address of 0x3f0 or 0x3f2.
o Create new inline functions to access the YE DATA's unique BDCR register.
o Update pccard attachment to add the fd device.
o Do some minor style(9) polishing.

# I'm guessing that the fdc pccard attachment broke some time ago, since
# there are a number of issues with it still.
2004-09-14 07:06:49 +00:00
Warner Losh
389bdd096c When ISA_PNP_PROBE is called, it will return 0 when it finds a device,
ENOENT when there's no PNP ID for this device node, or ENXIO when there
is one, but it doesn't match.

In the nonPNP case (as most Alpha systems appear to be), we were
treating the error return as an error, when it should be have ignored
it.  Version 1.9 properly ignored it, but the attach re-write of 1.10
introduced this logic error.

Pointy Hat to: phk (for breaking it then asking me to fix it :-)
Sponsored by: The Voices in Bill Paul's Head, LLC
2004-08-31 20:37:10 +00:00
Nate Lawson
885128efdc Fix _FDI drive type probing. The new fd child is not an ACPI device while
the old one is.  Hence we need to evaluate the old one for _FDI since it
has a valid ACPI_HANDLE ivar.  This is a minimal fix.  Make a note that a
more complete one is to make fdc support the ACPI_HANDLE ivar for its
children.

This and the previous change are MT5 candidates.
2004-08-30 21:35:34 +00:00
Nate Lawson
f40c77a223 Fix _FDE probing by using the buffer contents instead of the buffer
object itself.  ACPI-CA returns an ACPI_OBJECT of type Buffer rather than
the buffer contents itself.
2004-08-30 21:13:03 +00:00
Poul-Henning Kamp
1d4b1bb78d Hide a printf under bootverbose. 2004-08-27 17:08:24 +00:00
Poul-Henning Kamp
ec200f23d2 Attempt to make the probe for hardware more specific. 2004-08-21 08:40:00 +00:00
Nate Lawson
7500723246 Remove a check that is too strict. With BIOSen that specify an IO/ctl port
of 0x3f2-0x3f5,0x3f7 the ports are not 7 bytes apart.  This should fix
floppy probing on such systems.  (We handle the case of adjusting for
a start of 0x3f2 -> 0x3f0 separately, although that code should still be
checked if there are still floppy problems for others.)

Tested by:	Sarunas Vancevicius <vsarunas_at_eircom.net>
MFC after:	3 days
2004-08-20 16:34:30 +00:00
Poul-Henning Kamp
03c8015457 Remove unused file. 2004-08-20 15:15:48 +00:00
Poul-Henning Kamp
1b67be7b75 Rewrite of the floppy driver to make it MPsafe & GEOM friendly:
Centralize the fdctl_wr() function by adding the offset in
	the resource to the softc structure.

	Bugfix: Read the drive-change signal from the correct place:
	same place as the ctl register.

	Remove the cdevsw{} related code and implement a GEOM class.

	Ditch the state-engine and park a thread on each controller
	to service the queue.

	Make the interrupt FAST & MPSAFE since it is just a simple
	wakeup(9) call.

	Rely on a per controller mutex to protect the bioqueues.
	Grab GEOMs topology lock when we have to and Giant when
	ISADMA needs it.  Since all access to the hardware is
	isolated in the per controller thread, the rest of the
	driver is lock & Giant free.

	Create a per-drive queue where requests are parked while
	the motor spins up.  When the motor is running the requests
	are purged to the per controller queue.  This allows
	requests to other drives to be serviced during spin-up.

	Only setup the motor-off timeout when we finish the last
	request on the queue and cancel it when a new request
	arrives.  This fixes the bug in the old code where the motor
	turned off while we were still retrying a request.

	Make the "drive-change" work reliably.  Probe the drive on
	first opens.  Probe with a recal and a seek to cyl=1 to
	reset the drive change line and check again to see if we
	have a media.

	When we see the media disappear we destroy the geom provider,
	create a new one, and flag that autodetection should happen
	next time we see a media (unless a specific format is configured).

	Add sysctl tunables for a lot of drive related parameters.
	If you spend a lot of time waiting for floppies you can
	grab the i82078 pdf from Intels web-page and try tuning
	these.

	Add sysctl debug.fdc.debugflags which will enable various
	kinds of debugging printfs.

	Add central definitions of our well known floppy formats.

	Simplify datastructures for autoselection of format and
	call the code at the right times.

	Bugfix: Remove at least one piece of code which would have
	made 2.88M floppies not work.

	Use implied seeks on enhanced controllers.

	Use multisector transfers on all controllers.  Increase
	ISADMA bounce buffers accordingly.

	Fall back to single sector when retrying.  Reset retry count
	on every successful transaction.

	Sort functions in a more sensible order and generally tidy
	up a fair bit here and there.

	Assorted related fixes and adjustments in userland utilities.

WORKAROUNDS:
	Do allow r/w opens of r/o media but refuse actual write
	operations.  This is necessary until the p4::phk_bufwork
	branch gets integrated (This problem relates to remounting
	not reopening devices, see sys/*/*/${fs}_vfsops.c for details).

	Keep PC98's private copy of the old floppy driver compiling
	and presumably working (see below).

TODO (planned)

	Move probing of drives until after interrupts/timeouts work
	(like for ATA/SCSI drives).

TODO (unplanned)

	This driver should be made to work on PC98 as well.

	Test on YE-DATA PCMCIA floppy drive.

	Fix 2.88M media.

This is a MT5 candidate (depends on the bioq_takefirst() addition).
2004-08-20 15:14:25 +00:00
Poul-Henning Kamp
3abefc9e56 Remove confused comment. 2004-08-14 21:40:28 +00:00
Nate Lawson
20819082dc Fix ACPI floppy enumeration for three types of divergent behavior.
* Some systems have _FDE and child floppy devices, but no _FDI.  This seems
  to be compatible with the standard.  Don't error out if there is no _FDI.
  Instead, continue on to the next device.  The normal fd probe will take
  care of this device.
* Some systems have _FDE but no child devices in AML.  For these, add a
  second pass that compares the results of _FDE to the presence of devices.
  If not present, add the missing device.
* Some BIOS authors didn't read the spec.  They use tape drive values for
  all fdc(4) devices.  Since this isn't grossly incompatible with the
  required boolean value, use them.  They also define the _FDE items as a
  package instead of buffer.  Regenerate the buffer from the package if it
  is present.

Tested by:	tjr, marcel
2004-07-28 22:35:41 +00:00
Yoshihiro Takahashi
5ceae6b826 Correct typo. 2004-07-17 10:05:56 +00:00
Yoshihiro Takahashi
55d553460e Remove duplicate include. 2004-07-17 10:05:32 +00:00
Warner Losh
59f7a82d52 Be consistant with probe 2004-07-16 23:07:38 +00:00
Nate Lawson
0bdf1a5508 Clean up resources properly if attach fails. Always reset ISA drives on
probe.
2004-07-15 16:41:07 +00:00
Nate Lawson
a6e4d8c453 Re-work for fdc_acpi. Expose fdc_add_child() and move the static
hints-based probe to fdc_hints_probe().

Also:
* Fix some resource leaks when attach fails.
* Remove the FDC_ATTACHED flag.  It was supposed to prevent multiple
  unloads but this is not necessary.
2004-07-15 16:39:40 +00:00
Nate Lawson
a54c9cb131 Add an ACPI floppy drive attachment that probes via the _FDE and _FDI
methods.  It also now handles ordinary floppy drive probing for drives
attached to ACPI.

Reviewed by:	imp
2004-07-15 16:38:07 +00:00
Nate Lawson
6f41379967 Add a comment separator. 2004-07-14 22:09:32 +00:00
Warner Losh
16629bd982 Remove fdc_alloc_resources, which should have happened in last commit. 2004-07-14 07:04:17 +00:00
Warner Losh
aad6416500 Fix the pccard attachment to have a chance of working.
Move the resource allocation into the bus front ends.
2004-07-14 06:59:58 +00:00
Warner Losh
b0c2b92548 Set fdc_dev in attach 2004-07-13 02:44:40 +00:00
Warner Losh
c3ae4c40ef Don't depend on implicit include of machine/bus.h in sys/rman.h, but instead
explicitly include it.
2004-07-13 02:42:23 +00:00
Nate Lawson
bd0416f2d2 Remove unnecessary softc bzero calls. 2004-07-12 21:15:36 +00:00
Nate Lawson
752d473505 Update in preparation for adding the ACPI attachment.
* Add an fdtype ivar.  This will be the equivalent of fd->type.
* Move enabling the FIFO to the end of attach.
* Unify reset code into fdc_initial_reset().
* Add fdc_write_ivar().
* Update isa and pccard attachments accordingly.
* Set the flags unconditionally in probe since they may be overridden by
  other probe routines.  Both before and now, we're depending on probe
  being called a final time on the winning driver so the flags we get are
  the ones we intended.
* Use the bus accessor macros instead of defining our own.
* Remove duplicate assigns of fd->type.
2004-07-12 20:49:26 +00:00
Warner Losh
fa5afa1df0 Until I'm ready to commit the better pccard probe/attach routines, effectively
comment them out.
2004-07-11 16:01:25 +00:00
Warner Losh
6d6fa4fdc9 Break out the isa and pccard front ends from fdc. This is the first
step in making this driver more attachment neutral.  Others plan on
adding acpi front ends.

Still need to cleanup the MI part of the driver because it isn't as
bus independent as it could be.
2004-07-07 22:35:27 +00:00
Poul-Henning Kamp
de0b7a6307 Allocate the DMA channel shareable and only aquire it while the
device is open.  This allows certain old and rather special dual
floppy controllers to work on both channels, as long as you only
have one open at a time.
2004-07-05 20:56:06 +00:00
Poul-Henning Kamp
6fba12f206 Mark our interrupt shareable and don't insist on DMA. This gets us closer
to working with a secondary floppy controller on a PC.
2004-07-04 23:16:04 +00:00
Poul-Henning Kamp
89c9c53da0 Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.
2004-06-16 09:47:26 +00:00
Warner Losh
bc8d2181b3 Use rman_get_start in preference to reaching into the rman structure. 2004-05-27 22:43:10 +00:00
Warner Losh
734e3cc5fd Update to reflect new location in the tree. This has been repo copied
from sys/isa/fd.c in preparation for specialization of attachments for
different busses.
2004-05-17 05:42:04 +00:00
Bruce Evans
a3a10d1c3c Fixed breakage of the formatting operation in rev.1.266. The wrong
clause of an if-else statement was removed.

Reviewed by:	no response from maintainer in 12 days
2004-04-25 04:33:56 +00:00
Warner Losh
f36cfd49ad Remove advertising clause from University of California Regent's
license, per letter dated July 22, 1999 and email from Peter Wemm,
Alan Cox and Robert Watson.

Approved by: core, peter, alc, rwatson
2004-04-07 20:46:16 +00:00
Nate Lawson
5f96beb9e0 Convert callers to the new bus_alloc_resource_any(9) API.
Submitted by:	Mark Santcroos <marks@ripe.net>
Reviewed by:	imp, dfr, bde
2004-03-17 17:50:55 +00:00
Poul-Henning Kamp
db42ff97da Remove unused FDNUMTOUNIT() macro 2004-02-29 10:21:40 +00:00
Poul-Henning Kamp
503799ea5c Make mode setting with fdcontrol(8) stick.
Recognize when configured for "auto".
2004-02-25 13:44:58 +00:00
Poul-Henning Kamp
dc08ffec87 Device megapatch 4/6:
Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.
2004-02-21 21:10:55 +00:00
Poul-Henning Kamp
c9c7976f7f Device megapatch 1/6:
Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.
2004-02-21 19:42:58 +00:00
Nate Lawson
64746d0689 Workaround some ACPI BIOSen which break the IO port into multiple
resources.  (Note that the correct range is 0x3f7,0x3f0-0x3f5.)  Such
devices will be detected as follows:

  fdc0: <Enhanced floppy controller (i82077, NE72065 or clone)> port
  0x3f7,0x3f4-0x3f5,0x3f2-0x3f3,0x3f0-0x3f1 irq 6 drq 2 on acpi0

To do this, we find the minimum and maximum start addresses for the
resources and use them as the base for the IO and control ports.

Help from:	jhb
2004-02-15 20:30:22 +00:00
Peter Wemm
042093540c Look at the equipment list for amd64 as well as i386 for autodetecting
floppy drives in the absence of hints.
2003-10-23 05:52:52 +00:00
Poul-Henning Kamp
b52b7f465d Eliminate use bio_blkno. 2003-10-18 17:51:26 +00:00
Poul-Henning Kamp
a2f19df9cc Pick up softc from dev_t rathern than through newbus gymnastics. 2003-09-17 07:40:00 +00:00
Poul-Henning Kamp
f967c4f96e Since it is static these days, there is no reason to uppercase the
first letter of fdopen() to avoid nameclashing with other stuff.
2003-09-17 07:21:20 +00:00
Poul-Henning Kamp
0c7721e8f9 Disable the use of cloning use in floppy and CD drivers.
This commit puts the relevant code snippets under #ifdef GONE_IN_5
(rather than #ifndef BURN_BRIDGES) thereby disabling the code now.

The code wil be entirely removed before 5.2 unless we find reasons
why this would be a bad idea.

Approach suggested by:	imp
2003-09-11 19:27:24 +00:00
Poul-Henning Kamp
7837155fa2 Put the device cloning functions for disk-drivers under #ifndef BURN_BRIDGES.
For the floppy driver, use fdcontrol to manipulate density selection.

For the CD drivers, the 'a' and 'c' suffix is without actual effect and
any applications insisting on it can be satisfied with a symlink:
	ln -s /dev/cd0 /dev/cd0a

Ongoing discussion may result in these pieces of code being removed before
the 5-stable branch as opposed to after.
2003-09-05 10:40:16 +00:00
John Baldwin
8a9bc9c03b - Use the new resource_disabled() helper function to see if devices are
disabled.
- Change the apm driver to match the acpi driver's behavior by checking to
  see if the device is disabled in the identify routine instead of in the
  probe routine.  This way if the device is disabled it is never created.

Note that a few places (ips(4), Alpha SMP) used "disable" instead of
"disabled" for their hint names, and these hints must be changed to
"disabled".  If this is a big problem, resource_disabled() can always be
changed to honor both names.
2003-07-02 16:09:02 +00:00
Yaroslav Tykhiy
62cc1e0584 Force media autodetection if the device has lost its parameter table.
Previously, any normal I/O on an fdc(4) device would fail with ENXIO
if the device had been opened in non-blocking mode and then closed
prior to the conventional access; that would last until the floppy
disk was ejected and re-inserted to raise the unit attention condition.

Add a clarifying comment.
2003-06-16 08:42:20 +00:00
Yaroslav Tykhiy
f79981aca8 If in non-blocking mode, return EAGAIN instead of ENXIO
on an I/O attempt.  This is needed for consistency with
the concept of the half-opened state of fdc(4).

PR:		kern/52338
2003-06-16 07:50:17 +00:00
Yaroslav Tykhiy
83efe35a66 Always set bio_resid properly in fdstrategy(),
as should every block device strategy routine.
There was at least one evil consequence of not doing so:
Some errors returned by fdstrategy() could be lost (EAGAIN,
in particular.)

PR:		kern/52338 (in the audit-trail)
Discussed with:	bde
2003-06-15 18:13:17 +00:00