Commit Graph

185 Commits

Author SHA1 Message Date
Poul-Henning Kamp
1fdb6e6c69 Step down a level and issue format requests with a struct bio instead
of a struct buf.
2000-05-06 07:01:47 +00:00
Poul-Henning Kamp
9626b608de Separate the struct bio related stuff out of <sys/buf.h> into
<sys/bio.h>.

<sys/bio.h> is now a prerequisite for <sys/buf.h> but it shall
not be made a nested include according to bdes teachings on the
subject of nested includes.

Diskdrivers and similar stuff below specfs::strategy() should no
longer need to include <sys/buf.> unless they need caching of data.

Still a few bogus uses of struct buf to track down.

Repocopy by:    peter
2000-05-05 09:59:14 +00:00
Bruce Evans
3aae7b16d2 Fixed the type of some ivar access functions. Ivars have type uintptr_t,
not u_long.  On i386's with 64-bit longs, returning u_longs indirectly
in (more than) the space reserved for uintptr_t's tended to corrupt the
previous frame pointer in the stack frame, so it was not easy to debug.
The type mismatches are hidden by the bogus cast in DEVMETHOD().
2000-04-30 10:01:56 +00:00
Poul-Henning Kamp
8177437d85 Complete the bio/buf divorce for all code below devfs::strategy
Exceptions:
        Vinum untouched.  This means that it cannot be compiled.
        Greg Lehey is on the case.

        CCD not converted yet, casts to struct buf (still safe)

        atapi-cd casts to struct buf to examine B_PHYS
2000-04-15 05:54:02 +00:00
Poul-Henning Kamp
c244d2de43 Move B_ERROR flag to b_ioflags and call it BIO_ERROR.
(Much of this done by script)

Move B_ORDERED flag to b_ioflags and call it BIO_ORDERED.

Move b_pblkno and b_iodone_chain to struct bio while we transition, they
will be obsoleted once bio structs chain/stack.

Add bio_queue field for struct bio aware disksort.

Address a lot of stylistic issues brought up by bde.
2000-04-02 15:24:56 +00:00
Poul-Henning Kamp
56a2308964 Fix floppy driver after my isadma changes. 2000-03-25 21:20:23 +00:00
Poul-Henning Kamp
b99c307a21 Rename the existing BUF_STRATEGY() to DEV_STRATEGY()
substitute BUF_WRITE(foo) for VOP_BWRITE(foo->b_vp, foo)

substitute BUF_STRATEGY(foo) for VOP_STRATEGY(foo->b_vp, foo)

This patch is machine generated except for the ccd.c and buf.h parts.
2000-03-20 11:29:10 +00:00
Poul-Henning Kamp
21144e3bf1 Remove B_READ, B_WRITE and B_FREEBUF and replace them with a new
field in struct buf: b_iocmd.  The b_iocmd is enforced to have
exactly one bit set.

B_WRITE was bogusly defined as zero giving rise to obvious coding
mistakes.

Also eliminate the redundant struct buf flag B_CALL, it can just
as efficiently be done by comparing b_iodone to NULL.

Should you get a panic or drop into the debugger, complaining about
"b_iocmd", don't continue.  It is likely to write on your disk
where it should have been reading.

This change is a step in the direction towards a stackable BIO capability.

A lot of this patch were machine generated (Thanks to style(9) compliance!)

Vinum users:  Greg has not had time to test this yet, be careful.
2000-03-20 10:44:49 +00:00
Joerg Wunsch
5f830ea2cd Make the Y-E Data PCMCIA floppy of the Toshiba Libretto work under
-current.  It doesn't work yet as stable as the 3.x/PAO version of the
driver does, however, i get occasional `FDC direction bit not set' and
other weird messages, but it basically works at least.

The old (defunct) #ifdef FDC_YE stuff has been eliminated completely
now, PCMCIA-FDC specific functions have been implemented differently
where needed.

Unfortunately, due to the fact that the traditional PeeCee FDC with
its funny non-contiguous register space (one register for WD1003
harddisk controllers is interleaved into the FDC register set), and
Peter's subsequent changes involving two different bus space handles
for normal FDCs, the changes required for the Y-E stuff are more
complex than i'd love them to be.  I've done my best to keep the logic
for normal FDCs intact.

Since the Y-E FDC seems to lose interrupts after a FDC reset
sometimes, i've also replaced the timeout logic in fd_turnoff() to
generate an artificial pseudo interrupt in case of a timeout while the
drive has still outstanding transfers waiting.  This avoids the total
starvation of the driver that could be observed with highly damaged
media under 3.x/PAO.  This part of the patch has been revied by bde
previously.

I've fixed a number of occasions where previous commits have been
missing the encapuslation of ISA DMA related functions inside
FDC_NODMA checks.

I've added one call to SET_BCDR() during preparation of the format
floppy operation.  Floppy formatting has been totally broken before in
3.x/PAO (garbage ID fields have been written to the medium, causing
`wrong cylinder' errors upon media reading).  This is just black
magic, i don't have the slightes idea _why_ this needs to be but just
copied over the hack that has been used by the PAO folks in the normal
read/write case anyway.

The entired device_busy() stuff seems to be pointless to me.  In any
case, i had to add device_unbusy() calls symmetrical to the
device_busy() calls, otherwise the PCMCIA floppy driver could never be
deactivated.  (As it used to be, it caused a `mark the device busier
and busier' situation.)  IMHO, all block device drivers should be
marked busy based on active buffers still waiting for the driver, so
the device_unbusy() calls should probably go to biodone().  Only one
other driver (whose name escapes me at the moment) uses device_busy()
calls at all, so i question the value of all this...

I think this entire `device busy' logic simply doesn't fit for PCMCIA
&al.  It cannot be the decision of some piece of kernel software to
declare a device `busy by now, you can't remove it', when the actual
physical power of removing it is the user pulling the card.  The
kernel simply has to cope with the removal, however busy the device
might have been by the time of the removal, period.  Perhaps a force
flag needs to be added?

Upon inserting the card a second time, i get:

WARNING: "fd" is usurping "fd"'s cdevsw[]
WARNING: "fd" is usurping "fd"'s bmaj

I suspect this is related to the XXX comment at the call to
cdevsw_add().  Does anybody know what the correct way is to cleanup
this?
2000-03-18 18:27:01 +00:00
Peter Wemm
b6e5f28e51 Futher cleanup.. "device_print_prettyname(); printf()" -> device_printf()
It seems that the IDE system uses 0x3f6 for itself, which conflicts with
fdc's default 0x3f0-3f7 allocation range. Sigh.  Work around this.
Use bus_set_resource() rather than allocating specific areas, it makes
the code a little cleaner.

Based on work by:	dfr
2000-01-08 09:33:09 +00:00
Warner Losh
3b1782065f Merge most of FDC_YE into the mainline driver.
o Rename FDC_PCMCIA to FDC_NODMA to allow systems that don't have dma
  for floppies.
o Remove all but two FDC_YE ifdefs.  They aren't needed.
o Move defines for YE_DATAPORT to fdreg.h.

Not fixed:
o The pccard probe/attach.  However, motivated individuals can more
  easily add this now.

This is a merge of changes I've had in my tree for a long time.  These
fixes were tested on my VAIO with its normal floppy.  Please let me
know if I broke anything.

Prodded by: Peter Wemm <peter@freebsd.org>
2000-01-06 07:13:54 +00:00
Peter Wemm
b9da888fcb Make the evil broken pnpbios compensation slightly less evil.
This is the hack that compensates for when bios vendors "forget" to
include the fdc control (0x3f7) port in their io port mappings.  Instead
of accessing ports outside of a range allocated to a handle, simply
allocate the port directly.  It even shows up in the probe..
2000-01-05 17:42:43 +00:00
Peter Wemm
37286586ff Patch up some of the evilness left over from the early newbus porting.
In particular:
 - Don't leave resources allocated in the probe routine.  Allocate them
   during probe and release them.  Probe's job is to identify devices only.
 - Don't abuse the ivars pointer.. (!).  Create real ivars and use the
   proper access system.  (the bus_read_ivar method)
 - Don't add the children until attach() has successfully grabbed the
   hardware, otherwise there are potential leaks if attach fails.
2000-01-05 16:31:27 +00:00
KATO Takenori
6fb89845b4 Added following modes:
5in     HD 2 heads, 77 cylinders, 8 sectors/track, 1024 bytes/sector
 5/3.5in DD 2 heads, 80 cylinders, 8 sectors/track, 512 bytes/sector

Meanings of the rogrammer-readeble fd name were explained by Brian
Fundakowski Feldman and Peter Wemm in hackers list and NOKUBI
Hirotaka.

Reviewed by:	nyan
1999-12-28 07:38:38 +00:00
Joerg Wunsch
e34c71ea40 Add a flag to disable FIFO probing. The code seems to have a chance of
misdetecting FIFO capabilities, at least on my girlfriend's Thinkpad 755,
the driver doesn't work using the FIFO.

While i was at it, i (partially) fixed option FCC_YE since it would no
longer have compiled at all under -current.  I've also made an attempt
to document the device driver flags value (ab-)used internally by this
option.

RELENG_3 candidate, but with a slightly different patch there (will go
to jkh in email).
1999-12-21 08:33:03 +00:00
Peter Wemm
a2639a184d Add a truely evil workaround (hack!) for some unfortunate BIOS
programming practices.  It seems that newer fdc chips have an
alternative way of setting the transfer speed (including high speed
modes for floppy tape) that doesn't use the control register (which
we don't support - we use the old way only).  So, they (the BIOS
programmers) sometimes leave out the 0x3f6 control register from
the PnP ports descriptor(!!).  "Hey, it works with windows, so
what's the problem?" :-(  Anyway, this hack tries to compensate
for that.  This was discussed with dfr (who did the pnp attachment).
1999-12-06 06:59:09 +00:00
Matthew N. Dodd
fe0d408987 Remove the 'ivars' arguement to device_add_child() and
device_add_child_ordered().  'ivars' may now be set using the
device_set_ivars() function.

This makes it easier for us to change how arbitrary data structures are
associated with a device_t.  Eventually we won't be modifying device_t
to add additional pointers for ivars, softc data etc.

Despite my best efforts I've probably forgotten something so let me know
if this breaks anything.  I've been running with this change for months
and its been quite involved actually isolating all the changes from
the rest of the local changes in my tree.

Reviewed by:	peter, dfr
1999-12-03 08:41:24 +00:00
Peter Wemm
8de0675c61 Tidy up a few loose ends in the fifo setup code.
Don't use NFDC as an arbitary limit, it is not required and goes against
using PnP fdc devices (eg: when PNPBIOS is turned on, the motherboard
devices (sio, fdc, etc etc) are detected via PnP, not config(8).)
1999-11-18 05:15:09 +00:00
Doug Rabson
427ccf0071 Add code to support ISA PnP. 1999-11-11 08:48:40 +00:00
Peter Wemm
475ad603bb Use cdevsw_add() (temporarily) to avoid DEV_DRIVER_MODULE(), since the
make_dev()'s that are there are not enough.
1999-11-08 07:32:06 +00:00
Poul-Henning Kamp
d6a0e38a1b Remove five now unused fields from struct cdevsw. They should never
have been there in the first place.  A GENERIC kernel shrinks almost 1k.

Add a slightly different safetybelt under nostop for tty drivers.

Add some missing FreeBSD tags
1999-09-25 18:24:47 +00:00
Poul-Henning Kamp
11a0be87e3 Two more devstat_end_transaction() -> devstat_end_transaction_buf(). 1999-09-19 12:43:34 +00:00
Poul-Henning Kamp
2186cd9e8d Use devstat_end_transaction_buf() rather than Use devstat_end_transaction() 1999-09-18 21:30:27 +00:00
Bruce Evans
887ba12fc5 Removed diskerr()'s unused d_name arg and updated callers. This fixes
warnings caused by the arg having the wrong type (not const enough).
The arg was also wrong (a full name instead of a short one) for calls
from from subr_diskmbr.c and pc98/diskslice_machdep.c.
1999-09-13 12:59:41 +00:00
Julian Elischer
85a219d201 Changes to centralise the default blocksize behaviour.
More likely to follow.

Submitted by: phk@freebsd.org
1999-09-09 19:08:44 +00:00
Doug Rabson
062acdb7e7 Change isa_get/set_flags() to device_get/set_flags(). 1999-09-07 08:42:49 +00:00
Peter Wemm
16e68fc605 Cosmetic tweak. Collect the fdc methods together and apart from the fd
methods so it's a little easier to seperate the two when reading the code.
1999-09-03 11:32:21 +00:00
Julian Elischer
7012bab988 Revert a bunch of contraversial changes by PHK. After
a quick think and discussion among various people some form of some of
these changes will probably be recommitted.

The reversion requested was requested by dg while discussions proceed.
PHK has indicated that he can live with this, and it has been agreed
that some form of some of these changes may return shortly after further
discussion.
1999-09-03 05:16:59 +00:00
Poul-Henning Kamp
02e1576966 Make bdev userland access work like cdev userland access unless
the highly non-recommended option ALLOW_BDEV_ACCESS is used.

(bdev access is evil because you don't get write errors reported.)

Kill si_bsize_best before it kills Matt :-)

Use the specfs routines rather having cloned copies in devfs.
1999-08-30 07:56:23 +00:00
Poul-Henning Kamp
9465bf4495 Initialize dev->si_bsize*, the floppy driver doesn't use dsopen(). 1999-08-28 08:10:13 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Julian Elischer
ada9bd8cb8 Add PHK's make_dev() into more places where DEVFS used to be
hooked in directly.

Alpha change checked by: Matthew Jacob <mjacob@feral.com>
i4b ISDN changes checked by: Udo Schweigert <ust@cert.siemens.de>
    and Hellmuth Michaelis <hm@hcs.de>
PC98 changes checked by: Takahashi Yoshihiro <nyan@FreeBSD.org>
1999-08-27 07:26:26 +00:00
Poul-Henning Kamp
9dcbe2404a Convert DEVFS hooks in (most) drivers to make_dev().
Diskslice/label code not yet handled.

Vinum, i4b, alpha, pc98 not dealt with (left to respective Maintainers)

Add the correct hook for devfs to kern_conf.c

The net result of this excercise is that a lot less files depends on DEVFS,
and devtoname() gets more sensible output in many cases.

A few drivers had minor additional cleanups performed relating to cdevsw
registration.

A few drivers don't register a cdevsw{} anymore, but only use make_dev().
1999-08-23 20:59:21 +00:00
Poul-Henning Kamp
49ff4debd3 Spring cleaning around strategy and disklabels/slices:
Introduce BUF_STRATEGY(struct buf *, int flag) macro, and use it throughout.
please see comment in sys/conf.h about the flag argument.

Remove strategy argument from all the diskslice/label/bad144
implementations, it should be found from the dev_t.

Remove bogus and unused strategy1 routines.

Remove open/close arguments from dssize().  Pick them up from dev_t.

Remove unused and unfinished setgeom support from diskslice/label/bad144 code.
1999-08-14 11:40:51 +00:00
Joerg Wunsch
25d01e9527 Revert rev 1.149. Bruce convinced me that the problem already disappeared
by the fix in rev 1.120, which i wasn't immediately aware of.
1999-07-29 11:27:33 +00:00
Matthew N. Dodd
15317dd875 Alter the behavior of sys/kern/subr_bus.c:device_print_child()
- device_print_child() either lets the BUS_PRINT_CHILD
	  method produce the entire device announcement message or
	  it prints "foo0: not found\n"

Alter sys/kern/subr_bus.c:bus_generic_print_child() to take on
the previous behavior of device_print_child() (printing the
"foo0: <FooDevice 1.1>" bit of the announce message.)

Provide bus_print_child_header() and bus_print_child_footer()
to actually print the output for bus_generic_print_child().
These functions should be used whenever possible (unless you can
just use bus_generic_print_child())

The BUS_PRINT_CHILD method now returns int instead of void.

Modify everything else that defines or uses a BUS_PRINT_CHILD
method to comply with the above changes.

	- Devices are 'on' a bus, not 'at' it.
	- If a custom BUS_PRINT_CHILD method does the same thing
	  as bus_generic_print_child(), use bus_generic_print_child()
	- Use device_get_nameunit() instead of both
	  device_get_name() and device_get_unit()
	- All BUS_PRINT_CHILD methods return the number of
	  characters output.

Reviewed by: dfr, peter
1999-07-29 01:03:04 +00:00
Joerg Wunsch
409aadb1c9 Hack to work around a NULL pointer dereferencation that can be triggered
by removing a floppy that as being operated on.

The spagghetti is hardly understandable at all anymore, so i can't
100 % ascertain this is really the Right Thing to do, maybe our new
floppy driver maintainer, Jesus Monroy Jr can do this. :-))
1999-07-21 12:19:44 +00:00
Poul-Henning Kamp
03016f421b Remove cmaj and bmaj args from DEV_DRIVER_MODULE. 1999-07-04 14:58:56 +00:00
Kirk McKusick
67812eacd7 Convert buffer locking from using the B_BUSY and B_WANTED flags to using
lockmgr locks. This commit should be functionally equivalent to the old
semantics. That is, all buffer locking is done with LK_EXCLUSIVE
requests. Changes to take advantage of LK_SHARED and LK_RECURSIVE will
be done in future commits.
1999-06-26 02:47:16 +00:00
Doug Rabson
a97c75b7ea * Change include file locations.
* Fix some misunderstandings about the return value of resource_int_value().
* Make it build on alpha (doesn't work yet...)
1999-05-31 18:39:17 +00:00
Poul-Henning Kamp
4e2f199e0c This commit should be a extensive NO-OP:
Reformat and initialize correctly all "struct cdevsw".

        Initialize the d_maj and d_bmaj fields.

        The d_reset field was not removed, although it is never used.

I used a program to do most of this, so all the files now use the
same consistent format.  Please keep it that way.

Vinum and i4b not modified, patches emailed to respective authors.
1999-05-30 16:53:49 +00:00
Doug Rabson
f7f2df54bb No support for pnp yet. 1999-05-30 11:12:30 +00:00
Bruce Evans
f86e40770a Fixed reset handling for motor off resets. I first fixed this together
with other reset handling in rev.1.83 but broke it in rev.1.120.  The
breakage didn't seem to cause any problems even on the system which had
problems ("extra" interrupts and botched handling thereof) before rev.1.83.
It only affects multi-floppy systems anyway.
1999-05-11 04:58:30 +00:00
Doug Rabson
566643e39e Move the declaration of the interrupt type from the driver structure
to the BUS_SETUP_INTR call.
1999-05-08 21:59:43 +00:00
Peter Wemm
4fdff1649a GC unused #define id_physid id_scsiid 1999-05-08 18:13:15 +00:00
Poul-Henning Kamp
46eede0058 Continue where Julian left off in July 1998:
Virtualize bdevsw[] from cdevsw.  bdevsw() is now an (inline)
        function.

        Join CDEV_MODULE and BDEV_MODULE to DEV_MODULE (please pay attention
        to the order of the cmaj/bmaj arguments!)

        Join CDEV_DRIVER_MODULE and BDEV_DRIVER_MODULE to DEV_DRIVER_MODULE
        (ditto!)

(Next step will be to convert all bdev dev_t's to cdev dev_t's
before they get to do any damage^H^H^H^H^H^Hwork in the kernel.)
1999-05-07 10:11:40 +00:00
Poul-Henning Kamp
c48d17750f Introduce two functions: physread() and physwrite() and use these directly
in *devsw[] rather than the 46 local copies of the same functions.

(grog will do the same for vinum when he has time)
1999-05-07 07:03:47 +00:00
Poul-Henning Kamp
b0eeea2042 remove b_proc from struct buf, it's (now) unused.
Reviewed by:	dillon, bde
1999-05-06 20:00:34 +00:00
Peter Wemm
edfdec1910 Disable FDC_YE - it's broken at present (breaking LINT) and awaiting some
pccard fixups.
Make DEVFS compile, it breaks LINT.
1999-05-02 20:38:08 +00:00
Poul-Henning Kamp
f711d546d2 Suser() simplification:
1:
  s/suser/suser_xxx/

2:
  Add new function: suser(struct proc *), prototyped in <sys/proc.h>.

3:
  s/suser_xxx(\([a-zA-Z0-9_]*\)->p_ucred, \&\1->p_acflag)/suser(\1)/

The remaining suser_xxx() calls will be scrutinized and dealt with
later.

There may be some unneeded #include <sys/cred.h>, but they are left
as an exercise for Bruce.

More changes to the suser() API will come along with the "jail" code.
1999-04-27 11:18:52 +00:00