Commit Graph

91 Commits

Author SHA1 Message Date
Peter Wemm
2fc4762c60 Move the hints gunk to a seperate file. It isn't really part of the
newbus structure (no more than subr_rman.c is anyway).
2001-07-14 08:25:18 +00:00
Peter Wemm
9516fbd6d9 Go back to having either static OR dynamic hints, with fallback
support.  Trying to fix the merged set where dynamic overrode
static was getting more and more complicated by the day.

This should fix the duplicate atkbd, psm, fd* etc in GENERIC.  (which
paniced the alpha, but not the i386)
2001-07-14 00:23:10 +00:00
Peter Wemm
2398f0cd1d Hints overhaul:
- Replace some very poorly thought out API hacks that should have been
  fixed a long while ago.
- Provide some much more flexible search functions (resource_find_*())
- Use strings for storage instead of an outgrowth of the rather
  inconvenient temporary ioconf table from config().  We already had a
  fallback to using strings before malloc/vm was running anyway.
2001-06-12 09:40:04 +00:00
Nick Hibma
11a8d6c202 Unset the devclass if the attach fails and the devclass was not set to
begin with.

Reviewed by:	dfr
2001-01-08 22:16:26 +00:00
Warner Losh
38c490a10f Make this file conform mostly to style(9):
o Use 8 space hard tabs
o Eliminate trailing white space (while I'm here, just in a couple of places)
o wrap mostly at 80 columns (printf literal strings being the notable
  exception)
o use return (foo) consistantly
o use 0 vs NULL more consistantly
o use queue(3) xxx_FOREACH macros where appropriate (some places used it
  before, others didn't).
o use BSD line continuation parameters

Pendants will likely notice minor style(9) violations, but for the
most part the file now looks much much closer to style(9) and is
mostly self-consistant.

Approved in principle by: dfr
Reviewed by: md5 (no changes to the .o)
2001-01-05 07:29:54 +00:00
David Malone
7cc0979fd6 Convert more malloc+bzero to malloc+M_ZERO.
Submitted by:	josh@zipperup.org
Submitted by:	Robert Drehmel <robd@gmx.net>
2000-12-08 21:51:06 +00:00
Poul-Henning Kamp
959b7375ed Staticize some malloc M_ instances. 2000-12-08 20:09:00 +00:00
Matthew N. Dodd
46aa504e42 Alter the return value and arguments of the GET_RESOURCE_LIST bus method.
Alter consumers of this method to conform to the new convention.
Minor cosmetic adjustments to bus.h.

This isn't of concern as this interface isn't in use yet.
2000-11-28 06:49:15 +00:00
Kirk McKusick
a077f63555 In preparation for deprecating CIRCLEQ macros in favor of TAILQ
macros which provide the same functionality and are a bit more
efficient, convert use of CIRCLEQ's in resource manager to TAILQ's.

Approved by:	Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
2000-11-14 20:46:02 +00:00
Mike Smith
edcb5775ec Implement a trivial but effective interface for obtaining the kernel's
device tree and resource manager contents.  This is the kernel side of
the upcoming libdevinfo, which will expose this information to userspace
applications in a trivial fashion.

Remove the now-obsolete DEVICE_SYSCTLS code.
2000-11-09 10:21:23 +00:00
Matthew N. Dodd
0cb53e2487 Add new bus method 'GET_RESOURCE_LIST' and appropriate generic
implementation.

Add bus_generic_rl_{get,set,delete,release,alloc}_resource() functions
which provide generic operations for devices using resource list style
resource management.

This should simplify a number of bus drivers.  Further commits to follow.
2000-10-18 05:15:40 +00:00
Matthew N. Dodd
098b8a1eb0 Initialize 'hints_loaded' to 0.
This allows static hints to work properly.
2000-09-17 23:57:52 +00:00
Peter Wemm
58da4602af When we are picking the next available unit number, specifically say
what we picked.  Otherwise it is anybody's guess as to where the
device ended up.
2000-09-05 00:30:46 +00:00
Doug Rabson
a4f9b116e3 * Remove a bogus call to kobj_init() from make_device().
* Add a non-empty implementation of root_print_child().
2000-08-28 21:08:12 +00:00
Peter Wemm
12db06a04f If the config program found a hints file and included it as a fallback,
then treat it as such.  This isn't perfect, but should do for things
like GENERIC.  When in fallback mode, they will be used if there are NO
other hints.
2000-08-25 19:48:10 +00:00
Peter Wemm
f7ce4efc8a Fix a const related warning. 2000-07-28 22:41:56 +00:00
Peter Wemm
f03c9f90d1 Patch up some bogons in the resource_find() vs resource_find_hard()
interfaces.  The original resource_find() returned a pointer to an internal
resource table entry.  resource_find_hard() dereferences the actual
passed in value (oops!) - effectively trashing random memory due to
the pointer being passed in with a random initial value.

Submitted by:  bde
2000-07-18 06:08:27 +00:00
Poul-Henning Kamp
77978ab8bc Previous commit changing SYSCTL_HANDLER_ARGS violated KNF.
Pointed out by:	bde
2000-07-04 11:25:35 +00:00
Poul-Henning Kamp
9282307a5d Add device_set_softc() which does the obvious.
Not objected to by:	dfr
2000-07-03 13:06:29 +00:00
Poul-Henning Kamp
82d9ae4e32 Style police catches up with rev 1.26 of src/sys/sys/sysctl.h:
Sanitize SYSCTL_HANDLER_ARGS so that simplistic tools can grog our
sources:

        -sysctl_vm_zone SYSCTL_HANDLER_ARGS
        +sysctl_vm_zone (SYSCTL_HANDLER_ARGS)
2000-07-03 09:35:31 +00:00
Peter Wemm
ce365ee318 Some changes and fixes from Bruce:
Use strtoul(), not strtol() in the hints decoder so that
    'flags 0xa0ffa0ff' is not truncated to 0x7fffffff.
  Use a stack buffer instead of a static 100 byte bss buffer.
  Use \0 for the NUL character.
  Remove some ``excessive'' parens.
2000-06-26 09:53:37 +00:00
Peter Wemm
7d02379e48 As a bit of a gross hack, allow earlier access to both the static and
dynamic hints.  This allows the resource_XXX_value() calls to work
before malloc() has started.  This gets the serial console working as well
as a few other things.
2000-06-15 09:57:20 +00:00
Peter Wemm
690f8fc4c3 Fix a stray debug output. change if (1 || bootverbose) to if (bootverbose) 2000-06-15 04:12:17 +00:00
Peter Wemm
f71c01cc52 Borrow phk's axe and apply the next stage of config(8)'s evolution.
Use Warner Losh's "hint" driver to decode ascii strings to fill the
resource table at boot time.

config(8) no longer generates an ioconf.c table - ie: the configuration
no longer has to be compiled into the kernel.  You can reconfigure your
isa devices with the likes of this at loader(8) time:
  set hint.ed.0.port=0x320

userconfig will be rewritten to use this style interface one day and will
move to /boot/userconfig.4th or something like that.

It is still possible to statically compile in a set of hints into a kernel
if you do not wish to use loader(8).  See the "hints" directive in GENERIC
as an example.

All device wiring has been moved out of config(8).  There is a set of
helper scripts (see i386/conf/gethints.pl, and the same for alpha and pc98)
that extract the 'at isa? port foo irq bar' from the old files and produces
a hints file.  If you install this file as /boot/device.hints (and update
/boot/defaults/loader.conf - You can do a build/install in sys/boot) then
loader will load it automatically for you.  You can also compile in the
hints directly with:  hints "device.hints"  as well.

There are a few things that I'm not too happy with yet.  Under this scheme,
things like LINT would no longer be useful as "documentation" of settings.
I have renamed this file to 'NOTES' and stored the example hints strings
in it.  However... this is not something that config(8) understands, so
there is a script that extracts the build-specific data from the
documentation file (NOTES) to produce a LINT that can be config'ed and
built.  A stack of man4 pages will need updating. :-/

Also, since there is no longer a difference between 'device' and
'pseudo-device' I collapsed the two together, and the resulting 'device'
takes a 'number of units' for devices that still have it statically
allocated.  eg:  'device fe 4' will compile the fe driver with NFE set
to 4.  You can then set hints for 4 units (0 - 3).  Also note that
'device fe0' will be interpreted as "zero units of 'fe'" which would be
bad, so there is a config warning for this.  This is only needed for
old drivers that still have static limits on numbers of units.
All the statically limited drivers that I could find were marked.

Please exercise EXTREME CAUTION when transitioning!

Moral support by: phk, msmith, dfr, asmodai, imp, and others
2000-06-13 22:28:50 +00:00
Bruce Evans
0477138dad Fixed allocation of unit numbers. Allocate the amount of space actually
required (rounded up a little) instead of twice the previous amount (or
a fixed amount for the first allocation).

The bug caused memory corruption when a new unit number for a devclass
was more than about twice the previous maximum one (or more than 3 for
the first one), so it corrupted memory (which happened to be the atkbdc
port resource list) in the reporter's configuration with sio unit
numbers { 0, 25, 1, 2, ... }.

Reviewed by:	dfr
Reported by:	Leonid Lukiyanets <stalwar78@hotmail.com>
2000-06-11 07:19:20 +00:00
Søren Schmidt
d5f65fcbd7 If devclass_alloc_unit() is called with a wired unit #, and this is
buzy, only search upwards for a free slot to use..

This broke unit numbering on ATA systems where PCI attached controllers
come before the mainboard ones...

Reviewed by: dfr
2000-05-26 13:59:05 +00:00
Jake Burkholder
e39756439c Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by:		msmith and others
2000-05-26 02:09:24 +00:00
Jake Burkholder
740a1973a6 Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by:	phk
Reviewed by:	phk
Approved by:	mdodd
2000-05-23 20:41:01 +00:00
Paul Richards
8651b9ec1b If BUS_DEBUG is defined then create a sysctl, debug.bus_debug, that
is used to control whether the debug messages are output at runtime.
It defaults to on so that if you define BUS_DEBUG in your kernel
then you get all the debugging info when you boot.

It's very useful for disabling all the debugging info when you're
developing a loadable device driver and you're doing lots of loads
and unloads but don't always want to see all the debugging info.
2000-05-03 17:45:04 +00:00
Doug Rabson
4b4a49fda5 * Move the driver_t::refs field to kobj_t to replace kobj_t::instances.
* Back out a couple of workarounds for the confusion between
  kobj_t::instances and driver_t::refs.
2000-05-01 10:45:15 +00:00
Peter Wemm
eb2d8c2e8a The newer module dependency code exposes an apparent bug in the
bus/driver/kobj system.  I am not 100% sure that this is the correct fix,
but it is harmless and does seem to solve the problem.  At worst, it could
cause a tiny memory leak at unload time - this is better than a free(NULL)
and subsequent panic.  I'm waiting for comments from Doug about this.
This may yet be backed out and fixed differently.

The change itself is to increment the reference count on drivers in one
case where it appears to have been missed.  When everything is unloaded,
kobj_class_free() was being called twice in some cases, and panicing the
second time.
2000-04-29 13:24:35 +00:00
Doug Rabson
0d484d4793 Make sure the driver's ops table has been initialised before calling
static methods.
2000-04-22 15:03:08 +00:00
Doug Rabson
8cb3dda2df Fix LINT. 2000-04-17 08:09:43 +00:00
Warner Losh
d543f330aa Issue a detached message after detaching the device.
Not Objected to by: new-bus@
2000-04-17 04:30:48 +00:00
Doug Rabson
f7b7769172 * Factor out the object system from new-bus so that it can be used by
non-device code.
* Re-implement the method dispatch to improve efficiency. The new system
  takes about 40ns for a method dispatch on a 300Mhz PII which is only
  10ns slower than a direct function call on the same hardware.

This changes the new-bus ABI slightly so make sure you re-compile any
driver modules which you use.
2000-04-08 14:17:18 +00:00
Warner Losh
ce73953a1e device_set_unit() DO NOT USE THIS. This was approved before 4.0
release for inclusion into the release, but bde talked me out of
committing the module that needs this until after the release.  It is
after the release now. :-)
2000-04-01 06:06:37 +00:00
Nick Hibma
846664235c Instead of using the next unit available, use the first unit available.
This avoids the unit number from going up indefinitely when
diconnecting and connecting 2 devices alternately.

Noticed by: nsayer (quite a while ago)

And stop calling DEVICE_NOMATCH at probe repeatedly. This stops the
message on the PCI VGA board from being printed when loading a PCI driver.
2000-03-16 09:32:59 +00:00
Doug Rabson
1d9a6ae08b If a driver probe fails, unset it from the device. This fixes a problem
with certain multiport cards.

Approved by: jkh
2000-02-29 09:36:25 +00:00
Søren Schmidt
a6e23e28c1 Hide the "devclass_alloc_unit: %s%d already exists, using next available..."
behind bootverbose

Approved by: jkh
2000-02-20 10:07:28 +00:00
Joerg Wunsch
2c6610f343 Hide the boring `not probed (disabled)'' messages behind bootverbose'.
This unspams the boot messages, concentrating on the drivers that have
actually been probed.

This basically resurrects revision 1.106 from old /sys/i386/isa/isa.c.

Reviewed by:	jkh, dfr
2000-02-15 19:23:34 +00:00
Doug Rabson
54ac5b9b76 * Set the devclass of a device before calling the probe method. This allows
device_printf() etc. to print something intelligible.
* Allow device_set_devclass(dev, 0) for clearing the devclass.
1999-12-24 16:21:15 +00:00
Matt Jacob
9efed284d5 correct incomplete last change 1999-12-03 09:10:04 +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
Nick Hibma
39e86a12aa Remove check for attached state.
sc = devclass_get_softc(devclass, unit);

doesn't return NULL during attach anymore, and produces the sc,
identical to (for devclass_get_unit(devclass, unit) != NULL that is):

   sc = device_get_softc(devclass_get_unit(devclass, unit));

Reviewed-by:   dfr
1999-12-02 16:30:21 +00:00
Matthew N. Dodd
44a451ba24 Reduce code duplication.
Hopefully this clears up some confusion about the nature of
devclass_get_softc() vs. device_get_softc() as well.

The check against DS_ATTACHED remains as this is not
a change that modifies functionality.

Reviewed by:	Peter "in principle" Wemm
1999-11-30 07:06:03 +00:00
Peter Wemm
efa726dd8f 'const'ify a bunch of pointers in the resource_*() functions for accessing
the config hint tables.  This fixes a few warnings elsewhere (eg: fd).
1999-11-18 06:05:30 +00:00
Doug Rabson
25afb89b1c * Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
  layout of ivars.

* Move set_resource, get_resource and delete_resource from
  isa_if.m to bus_if.m.

* Simplify driver code by providing wrappers to those methods:

     bus_set_resource(dev, type, rid, start, count);
     bus_get_resource(dev, type, rid, startp, countp);
     bus_get_resource_start(dev, type, rid);
     bus_get_resource_count(dev, type, rid);
     bus_delete_resource(dev, type, rid);

* Delete isa_get_rsrc and use bus_get_resource_start instead.

* Fix a stupid typo in isa_alloc_resource reported by Takahashi
  Yoshihiro <nyan@FreeBSD.org>.

* Print a diagnostic message if we can't assign resources to a PnP
  device.

* Change device_print_prettyname() so that it doesn't print
  "(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
Peter Wemm
d1f088dab5 Trim unused options (or #ifdef for undoc options).
Submitted by:	phk
1999-10-11 15:19:12 +00:00
Warner Losh
6d4d0ac958 Call DEVICE_IDENIFY in bus_generic_driver_added to allow devices to
add nodes to the tree.  Also, default to bus_generic_driver_added for
the BUS_DRIVER_ADDED method.

This allows newbus busses to be kldload'd.

Reviewed by: dfr
1999-10-09 03:48:18 +00:00
Poul-Henning Kamp
168e3d05f9 Create and use a dedicated malloc type for bus related stuff.
Reviewed by:	dfr
1999-09-10 21:11:23 +00:00