Commit Graph

2199 Commits

Author SHA1 Message Date
cegger f2bccc0a8e struct device * -> device_t, use device_private() 2009-05-05 12:07:15 +00:00
dyoung 64670508f7 Detach pcppi0 at isa0 during shutdown. 2009-04-17 20:46:37 +00:00
mlelstv 485e52e2b3 attach and detach do not mix.
Create a new detach function that calls the parent function after
dealing with the private instance counter.
2009-04-10 10:18:50 +00:00
dyoung 99084a32b0 Decrease midi_pcppi_attached when midi at pcppi detaches. 2009-04-08 00:12:27 +00:00
dyoung 1de2a73134 Make pcppi(4) detach the "speaker" from attimer(4), so that the
corresponding attimer(4) resource is not perpetually busy: now it
is possible to detach and to reattach pcppi(4).  Make attimer(4)'s
device-detachment hook return EBUSY if pcppi(4) is still attached, so
that pcppi(4) cannot end up with a dangling pointer to attimer(4).
2009-04-07 22:30:09 +00:00
dyoung 00644496f7 Fix spelling: indrect -> indirect. 2009-04-07 21:48:46 +00:00
dyoung 18789e2def Detach midi at pcppi during shutdown. Sprinkle static. 2009-04-07 18:31:12 +00:00
dyoung 0d1ba3e899 During shutdown, detach devices in an orderly fashion.
Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks.  For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown.  Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags.  Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag.  The default for kern.detachall is 0.  SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress.  In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs.  Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
2009-04-02 00:09:32 +00:00
cegger df7f595ecd Ansify function definitions w/o arguments. Generated with sed. 2009-03-18 10:22:21 +00:00
dsl 98ae204731 Add some 'int' into function definitions where the K&R one didn't
specify a type.
2009-03-17 18:19:15 +00:00
dsl 7cc9af7d64 ANSIfy functions with function-pointer arguments 2009-03-16 23:11:09 +00:00
cegger 05d33dc7bf ansify function definitions 2009-03-16 09:32:38 +00:00
dsl 82357f6d42 ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
2009-03-14 21:04:01 +00:00
dsl 454af1c0e8 Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
2009-03-14 15:35:58 +00:00
ad 0fa70e9b6f 'boot -z' bogons 2009-03-14 11:08:28 +00:00
dyoung 6e3de811e0 Use the right format specifiers to print the new struct timeval. 2009-02-27 23:13:32 +00:00
bouyer 73920b4161 More printf format fixes. 2009-02-13 23:31:23 +00:00
bouyer e83cf7c074 Fix bus_addr_t/bus_size_t confusion 2009-02-13 22:39:37 +00:00
bouyer 1b21577543 Fix printf format after bus_size_t change 2009-02-13 22:39:10 +00:00
yamt 70de973662 g/c BUFQ_FOO() macros and use bufq_foo() directly. 2009-01-13 13:33:58 +00:00
cegger f8e41c4991 make this compile 2009-01-11 10:40:27 +00:00
mlelstv 0f2eef0070 fdcintr1 requires the mutex to be held. 2008-12-29 12:16:52 +00:00
tsutsui 3cf9bfd3aa Set all default geometry parameters (not only secpercyl and secsize)
before readdisklabel(9) on DIOCGDINFO so that we can get correct
media size via the ioctl. (usually floppy doesn't have a real disklabel)

Tested on i386 with 1.44M floppy.
2008-12-24 16:56:28 +00:00
cegger 9b87d582bd kill MALLOC and FREE macros. 2008-12-17 20:51:31 +00:00
cegger ad15153381 make this compile with IYDEBUG 2008-12-17 15:41:24 +00:00
christos 9a5d3f2817 replace bitmask_snprintf(9) with snprintb(3) 2008-12-16 22:35:21 +00:00
ad 0efea177e3 Remove LKMs and switch to the module framework, pass 1.
Proposed on tech-kern@.
2008-11-12 12:35:50 +00:00
dyoung de87fe677d *** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02🇩🇪ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address.  (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior.  Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability.  KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR.  In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr.  That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR.  In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR.  For example, pull ..._init() out of any switch
statement that looks like this:

        switch (...->sa_family) {
        case ...:
                ..._init();
                ...
                break;
        ...
        default:
                ..._init();
                ...
                break;
        }

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

        switch (x & (IFF_UP|IFF_RUNNING)) {
        case 0:
                ...
                break;
        case IFF_RUNNING:
                ...
                break;
        case IFF_UP:
                ...
                break;
        case IFF_UP|IFF_RUNNING:
                ...
                break;
        }

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure.  Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls.  In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source.  In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively.  Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset.  Delete unnecessary casts to void *.  Use
sockaddr_in_init() and sockaddr_in6_init().  Compare pointers with
NULL instead of "testing truth".  Replace some instances of (type
*)0 with NULL.  Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 00:20:01 +00:00
pgoyette 72ef407c2a Consistent use of softc member name - fixes build breakage from previous. 2008-10-12 23:07:32 +00:00
pgoyette eacec974a3 Add an i2c attachment for the LM78 family of temp sensor/fan control
Tested by Martin Husemann
2008-10-12 13:17:28 +00:00
martin dab198261c Apply patch from Dave Huang in PR kern/39642: catch up on com(4)'s
device_t/softc split.
2008-09-28 15:39:40 +00:00
christos 91ca465c78 device_t changes, pmf, minor knf. 2008-08-27 05:33:47 +00:00
drochner cc29fcf8b9 constify the pcmcia/cardbus method tables 2008-06-26 12:33:17 +00:00
tsutsui 1f459d82b5 Replace device_lookup() with device_lookup_private() on getting softc
for future device_t/softc spilt.
2008-06-08 12:43:51 +00:00
jmcneill ce25e3c5e1 lpt(4): register NULL pmf handler. 2008-05-31 14:07:03 +00:00
martin 5faa185ff6 Pass the com softc to comintr, not the device_t.
Fixes PR kern/38776.
2008-05-30 10:59:42 +00:00
jmcneill 21629183b8 Add pmf support. 2008-05-25 16:19:12 +00:00
plunky fcf1772a80 after the "struct disk" is finished with, it should be
destroyed with disk_destroy(9) to stave off LOCKDEBUG
panics.
2008-05-03 08:23:41 +00:00
ad 39f45b13ce - If x86, trust the nvram and elminate long probe delays.
- Update for amd64.
2008-04-30 23:02:43 +00:00
martin 3028e483e4 Convert to new 2 clause license 2008-04-29 06:53:00 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
garbled fcdfd014d7 Minor fixes to some of these files:
Add recognition for the CS4232C revision chip. (0xa2)
Make ic/ad1848.c compile with AUDIO_DEBUG
Add a needed machine/bus.h include to ic/cs4231.c
Add a few additional register defines to ic/cs4231reg.h
2008-04-28 18:49:27 +00:00
xtraeme 9f6e54935c Also attach in the IT8726F Super I/O. 2008-04-26 19:01:53 +00:00
xtraeme 27a6b8b36a Fixup the negative VINs, they were inverted and conversion was wrong. 2008-04-26 12:59:24 +00:00
xtraeme fc4443a49b Set the ENVSYS_FCHANGERFACT flag in voltage sensors, so that we
can use the 'rfact' property in /etc/envsys.conf to change the
resistor factor (in case the converted data is not correct).
2008-04-22 13:33:38 +00:00
cegger 376411d2dd device_t / softc split. From Hans Rosenfeld. 2008-04-16 09:39:01 +00:00
cegger b849cd90e5 device_t / softc split. From Hans Rosenfeld 2008-04-15 15:02:28 +00:00
tsutsui 78a1d236b6 Split device_t/softc for MI ncr53c9x and some related devices,
with various cleanup.
2008-04-13 04:55:52 +00:00
tsutsui 7c06c0a3e8 Split device_t/softc for MI mb86960, with misc cosmetics. 2008-04-12 06:27:01 +00:00
tsutsui bdd6dadf75 Fix a botch (inverted test) in rev 1.4. 2008-04-12 04:33:48 +00:00