1995-05-01 21:56:32 +00:00
|
|
|
/*
|
|
|
|
* The new sysinstall program.
|
|
|
|
*
|
|
|
|
* This is probably the last program in the `sysinstall' line - the next
|
|
|
|
* generation being essentially a complete rewrite.
|
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
1995-05-01 21:56:32 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 1995
|
|
|
|
* Jordan Hubbard. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
1995-05-30 08:29:07 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
* verbatim and that no modifications are made prior to this
|
1995-05-01 21:56:32 +00:00
|
|
|
* point in the file.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysinstall.h"
|
1995-05-11 06:47:46 +00:00
|
|
|
#include <sys/fcntl.h>
|
1995-05-16 02:53:31 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/ioctl.h>
|
1995-12-11 16:32:33 +00:00
|
|
|
#include <sys/errno.h>
|
1996-12-14 23:09:10 +00:00
|
|
|
#include <sys/time.h>
|
1995-05-16 02:53:31 +00:00
|
|
|
#include <net/if.h>
|
1997-01-06 11:32:44 +00:00
|
|
|
#include <net/if_var.h>
|
1995-05-16 02:53:31 +00:00
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <ctype.h>
|
2004-08-02 23:18:48 +00:00
|
|
|
#include <libdisk.h>
|
1995-05-04 03:51:22 +00:00
|
|
|
|
1998-03-15 16:15:47 +00:00
|
|
|
/* how much to bias minor number for a given /dev/<ct#><un#>s<s#> slice */
|
|
|
|
#define SLICE_DELTA (0x10000)
|
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
static Device *Devices[DEV_MAX];
|
|
|
|
static int numDevs;
|
|
|
|
|
1998-02-10 18:31:27 +00:00
|
|
|
static struct _devname {
|
1995-05-16 02:53:31 +00:00
|
|
|
DeviceType type;
|
|
|
|
char *name;
|
|
|
|
char *description;
|
1998-02-10 18:31:27 +00:00
|
|
|
int major, minor, delta, max;
|
1995-05-16 02:53:31 +00:00
|
|
|
} device_names[] = {
|
2002-11-27 17:56:27 +00:00
|
|
|
{ DEVICE_TYPE_CDROM, "cd%d", "SCSI CDROM drive", 15, 2, 8, 4 },
|
|
|
|
{ DEVICE_TYPE_CDROM, "mcd%d", "Mitsumi (old model) CDROM drive", 29, 0, 8, 4 },
|
|
|
|
{ DEVICE_TYPE_CDROM, "scd%d", "Sony CDROM drive - CDU31/33A type", 45, 0, 8, 4 },
|
1999-07-20 08:47:35 +00:00
|
|
|
#ifdef notdef
|
2002-11-27 17:56:27 +00:00
|
|
|
{ DEVICE_TYPE_CDROM, "matcd%d", "Matsushita CDROM ('sound blaster' type)", 46, 0, 8, 4 },
|
1999-07-20 08:47:35 +00:00
|
|
|
#endif
|
2002-11-27 17:56:27 +00:00
|
|
|
{ DEVICE_TYPE_CDROM, "acd%d", "ATAPI/IDE CDROM", 117, 0, 8, 4 },
|
2004-08-16 03:13:12 +00:00
|
|
|
{ DEVICE_TYPE_TAPE, "sa%d", "SCSI tape drive", 14, 0, 16, 4 },
|
2000-08-22 03:14:39 +00:00
|
|
|
{ DEVICE_TYPE_TAPE, "rwt%d", "Wangtek tape drive", 10, 0, 1, 4 },
|
|
|
|
{ DEVICE_TYPE_DISK, "da%d", "SCSI disk device", 13, 65538, 8, 16 },
|
|
|
|
{ DEVICE_TYPE_DISK, "ad%d", "ATA/IDE disk device", 116, 65538, 8, 16 },
|
2000-10-29 13:04:04 +00:00
|
|
|
{ DEVICE_TYPE_DISK, "ar%d", "ATA/IDE RAID device", 157, 65538, 8, 16 },
|
2000-08-22 03:14:39 +00:00
|
|
|
{ DEVICE_TYPE_DISK, "afd%d", "ATAPI/IDE floppy device", 118, 65538, 8, 4 },
|
|
|
|
{ DEVICE_TYPE_DISK, "mlxd%d", "Mylex RAID disk", 131, 65538, 8, 4 },
|
|
|
|
{ DEVICE_TYPE_DISK, "amrd%d", "AMI MegaRAID drive", 133, 65538, 8, 4 },
|
|
|
|
{ DEVICE_TYPE_DISK, "idad%d", "Compaq RAID array", 109, 65538, 8, 4 },
|
|
|
|
{ DEVICE_TYPE_DISK, "twed%d", "3ware ATA RAID array", 147, 65538, 8, 4 },
|
2000-09-13 06:15:53 +00:00
|
|
|
{ DEVICE_TYPE_DISK, "aacd%d", "Adaptec FSA RAID array", 151, 65538, 8, 4 },
|
2003-05-11 07:18:26 +00:00
|
|
|
{ DEVICE_TYPE_DISK, "ipsd%d", "IBM ServeRAID RAID array", 176, 65538, 8, 4 },
|
2000-08-22 03:14:39 +00:00
|
|
|
{ DEVICE_TYPE_FLOPPY, "fd%d", "floppy drive unit A", 9, 0, 64, 4 },
|
2002-03-17 08:04:02 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "an", "Aironet 4500/4800 802.11 wireless adapter" },
|
This commit adds device driver support for the ADMtek AN986 Pegasus
USB ethernet chip. Adapters that use this chip include the LinkSys
USB100TX. There are a few others, but I'm not certain of their
availability in the U.S. I used an ADMtek eval board for development.
Note that while the ADMtek chip is a 100Mbps device, you can't really
get 100Mbps speeds over USB. Regardless, this driver uses miibus to
allow speed and duplex mode selection as well as autonegotiation.
Building and kldloading the driver as a module is also supported.
Note that in order to make this driver work, I had to make what some
may consider an ugly hack to sys/dev/usb/usbdi.c. The usbd_transfer()
function will use tsleep() for synchronous transfers that don't complete
right away. This is a problem since there are times when we need to
do sync transfers from an interrupt context (i.e. when reading registers
from the MAC via the control endpoint), where tsleep() us a no-no.
My hack allows the driver to have the code poll for transfer completion
subject to the xfer->timeout timeout rather that calling tsleep().
This hack is controlled by a quirk entry and is only enabled for the
ADMtek device.
Now, I'm sure there are a few of you out there ready to jump on me
and suggest some other approach that doesn't involve a busy wait. The
only solution that might work is to handle the interrupts in a kernel
thread, where you may have something resembling a process context that
makes it okay to tsleep(). This is lovely, except we don't have any
mechanism like that now, and I'm not about to implement such a thing
myself since it's beyond the scope of driver development. (Translation:
I'll be damned if I know how to do it.) If FreeBSD ever aquires such
a mechanism, I'll be glad to revisit the driver to take advantage of
it. In the meantime, I settled for what I perceived to be the solution
that involved the least amount of code changes. In general, the hit
is pretty light.
Also note that my only USB test box has a UHCI controller: I haven't
I don't have a machine with an OHCI controller available.
Highlights:
- Updated usb_quirks.* to add UQ_NO_TSLEEP quirk for ADMtek part.
- Updated usbdevs and regenerated generated files
- Updated HARDWARE.TXT and RELNOTES.TXT files
- Updated sysinstall/device.c and userconfig.c
- Updated kernel configs -- device aue0 is commented out by default
- Updated /sys/conf/files
- Added new kld module directory
1999-12-28 02:01:18 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "aue", "ADMtek USB ethernet adapter" },
|
2003-04-20 19:05:33 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "axe", "ASIX Electronics USB ethernet adapter" },
|
2003-09-09 18:17:23 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "bfe", "Broadcom BCM440x PCI ethernet card" },
|
2001-09-27 23:55:28 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "bge", "Broadcom BCM570x PCI gigabit ethernet card" },
|
2000-01-14 03:14:49 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "cue", "CATC USB ethernet adapter" },
|
1998-07-18 09:42:02 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "fpa", "DEC DEFPA PCI FDDI card" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "sr", "SDL T1/E1 sync serial PCI card" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "cc3i", "SDL HSSI sync serial PCI card" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "en", "Efficient Networks ATM PCI card" },
|
1999-12-04 17:41:31 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "dc", "DEC/Intel 21143 (and clones) PCI fast ethernet card" },
|
1998-02-10 18:31:27 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "de", "DEC DE435 PCI NIC or other DC21040-AA based card" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card" },
|
1999-06-17 19:04:56 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "ed", "Novell NE1000/2000; 3C503; NE2000-compatible PCMCIA" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 ethernet card/3C589 PCMCIA" },
|
1998-02-10 18:31:27 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "el", "3Com 3C501 ethernet card" },
|
2003-01-27 04:51:46 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "em", "Intel(R) PRO/1000 ethernet card" },
|
1998-02-10 18:31:27 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "ex", "Intel EtherExpress Pro/10 ethernet card" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A ethernet card" },
|
2005-07-21 03:33:19 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "gem", "Apple/Sun GMAC ethernet adapter" },
|
1998-02-10 18:31:27 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress ethernet card" },
|
2000-08-22 03:14:39 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "kue", "Kawasaki LSI USB ethernet adapter" },
|
1998-02-10 18:31:27 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 or 3 ethernet card" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet" },
|
2002-07-02 19:56:26 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "lge", "Level 1 LXT1001 gigabit ethernet card" },
|
2001-05-11 19:56:39 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "nge", "NatSemi PCI gigabit ethernet card" },
|
2000-09-20 17:30:22 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "pcn", "AMD Am79c79x PCI ethernet card" },
|
2002-03-17 08:04:02 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "ray", "Raytheon Raylink 802.11 wireless adaptor" },
|
Take the support for the 8139C+/8169/8169S/8110S chips out of the
rl(4) driver and put it in a new re(4) driver. The re(4) driver shares
the if_rlreg.h file with rl(4) but is a separate module. (Ultimately
I may change this. For now, it's convenient.)
rl(4) has been modified so that it will never attach to an 8139C+
chip, leaving it to re(4) instead. Only re(4) has the PCI IDs to
match the 8169/8169S/8110S gigE chips. if_re.c contains the same
basic code that was originally bolted onto if_rl.c, with the
following updates:
- Added support for jumbo frames. Currently, there seems to be
a limit of approximately 6200 bytes for jumbo frames on transmit.
(This was determined via experimentation.) The 8169S/8110S chips
apparently are limited to 7.5K frames on transmit. This may require
some more work, though the framework to handle jumbo frames on RX
is in place: the re_rxeof() routine will gather up frames than span
multiple 2K clusters into a single mbuf list.
- Fixed bug in re_txeof(): if we reap some of the TX buffers,
but there are still some pending, re-arm the timer before exiting
re_txeof() so that another timeout interrupt will be generated, just
in case re_start() doesn't do it for us.
- Handle the 'link state changed' interrupt
- Fix a detach bug. If re(4) is loaded as a module, and you do
tcpdump -i re0, then you do 'kldunload if_re,' the system will
panic after a few seconds. This happens because ether_ifdetach()
ends up calling the BPF detach code, which notices the interface
is in promiscuous mode and tries to switch promisc mode off while
detaching the BPF listner. This ultimately results in a call
to re_ioctl() (due to SIOCSIFFLAGS), which in turn calls re_init()
to handle the IFF_PROMISC flag change. Unfortunately, calling re_init()
here turns the chip back on and restarts the 1-second timeout loop
that drives re_tick(). By the time the timeout fires, if_re.ko
has been unloaded, which results in a call to invalid code and
blows up the system.
To fix this, I cleared the IFF_UP flag before calling ether_ifdetach(),
which stops the ioctl routine from trying to reset the chip.
- Modified comments in re_rxeof() relating to the difference in
RX descriptor status bit layout between the 8139C+ and the gigE
chips. The layout is different because the frame length field
was expanded from 12 bits to 13, and they got rid of one of the
status bits to make room.
- Add diagnostic code (re_diag()) to test for the case where a user
has installed a broken 32-bit 8169 PCI NIC in a 64-bit slot. Some
NICs have the REQ64# and ACK64# lines connected even though the
board is 32-bit only (in this case, they should be pulled high).
This fools the chip into doing 64-bit DMA transfers even though
there is no 64-bit data path. To detect this, re_diag() puts the
chip into digital loopback mode and sets the receiver to promiscuous
mode, then initiates a single 64-byte packet transmission. The
frame is echoed back to the host, and if the frame contents are
intact, we know DMA is working correctly, otherwise we complain
loudly on the console and abort the device attach. (At the moment,
I don't know of any way to work around the problem other than
physically modifying the board, so until/unless I can think of a
software workaround, this will have do to.)
- Created re(4) man page
- Modified rlphy.c to allow re(4) to attach as well as rl(4).
Note that this code works for the sample 8169/Marvell 88E1000 NIC
that I have, but probably won't work for the 8169S/8110S chips.
RealTek has sent me some sample NICs, but they haven't arrived yet.
I will probably need to add an rlgphy driver to handle the on-board
PHY in the 8169S/8110S (it needs special DSP initialization).
2003-09-08 02:11:25 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "re", "RealTek 8139C+/8169/8169S/8110S PCI ethernet card" },
|
2000-08-22 03:14:39 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "rl", "RealTek 8129/8139 PCI ethernet card" },
|
Take the support for the 8139C+/8169/8169S/8110S chips out of the
rl(4) driver and put it in a new re(4) driver. The re(4) driver shares
the if_rlreg.h file with rl(4) but is a separate module. (Ultimately
I may change this. For now, it's convenient.)
rl(4) has been modified so that it will never attach to an 8139C+
chip, leaving it to re(4) instead. Only re(4) has the PCI IDs to
match the 8169/8169S/8110S gigE chips. if_re.c contains the same
basic code that was originally bolted onto if_rl.c, with the
following updates:
- Added support for jumbo frames. Currently, there seems to be
a limit of approximately 6200 bytes for jumbo frames on transmit.
(This was determined via experimentation.) The 8169S/8110S chips
apparently are limited to 7.5K frames on transmit. This may require
some more work, though the framework to handle jumbo frames on RX
is in place: the re_rxeof() routine will gather up frames than span
multiple 2K clusters into a single mbuf list.
- Fixed bug in re_txeof(): if we reap some of the TX buffers,
but there are still some pending, re-arm the timer before exiting
re_txeof() so that another timeout interrupt will be generated, just
in case re_start() doesn't do it for us.
- Handle the 'link state changed' interrupt
- Fix a detach bug. If re(4) is loaded as a module, and you do
tcpdump -i re0, then you do 'kldunload if_re,' the system will
panic after a few seconds. This happens because ether_ifdetach()
ends up calling the BPF detach code, which notices the interface
is in promiscuous mode and tries to switch promisc mode off while
detaching the BPF listner. This ultimately results in a call
to re_ioctl() (due to SIOCSIFFLAGS), which in turn calls re_init()
to handle the IFF_PROMISC flag change. Unfortunately, calling re_init()
here turns the chip back on and restarts the 1-second timeout loop
that drives re_tick(). By the time the timeout fires, if_re.ko
has been unloaded, which results in a call to invalid code and
blows up the system.
To fix this, I cleared the IFF_UP flag before calling ether_ifdetach(),
which stops the ioctl routine from trying to reset the chip.
- Modified comments in re_rxeof() relating to the difference in
RX descriptor status bit layout between the 8139C+ and the gigE
chips. The layout is different because the frame length field
was expanded from 12 bits to 13, and they got rid of one of the
status bits to make room.
- Add diagnostic code (re_diag()) to test for the case where a user
has installed a broken 32-bit 8169 PCI NIC in a 64-bit slot. Some
NICs have the REQ64# and ACK64# lines connected even though the
board is 32-bit only (in this case, they should be pulled high).
This fools the chip into doing 64-bit DMA transfers even though
there is no 64-bit data path. To detect this, re_diag() puts the
chip into digital loopback mode and sets the receiver to promiscuous
mode, then initiates a single 64-byte packet transmission. The
frame is echoed back to the host, and if the frame contents are
intact, we know DMA is working correctly, otherwise we complain
loudly on the console and abort the device attach. (At the moment,
I don't know of any way to work around the problem other than
physically modifying the board, so until/unless I can think of a
software workaround, this will have do to.)
- Created re(4) man page
- Modified rlphy.c to allow re(4) to attach as well as rl(4).
Note that this code works for the sample 8169/Marvell 88E1000 NIC
that I have, but probably won't work for the 8169S/8110S chips.
RealTek has sent me some sample NICs, but they haven't arrived yet.
I will probably need to add an rlgphy driver to handle the on-board
PHY in the 8169S/8110S (it needs special DSP initialization).
2003-09-08 02:11:25 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "rue", "RealTek USB ethernet card" },
|
2000-08-22 03:14:39 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "sf", "Adaptec AIC-6915 PCI ethernet card" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "sis", "SiS 900/SiS 7016 PCI ethernet card" },
|
2000-12-09 04:51:13 +00:00
|
|
|
#ifdef PC98
|
|
|
|
{ DEVICE_TYPE_NETWORK, "snc", "SONIC ethernet card" },
|
|
|
|
#endif
|
2000-08-22 03:14:39 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "sn", "SMC/Megahertz ethernet card" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "ste", "Sundance ST201 PCI ethernet card" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "sk", "SysKonnect PCI gigabit ethernet card" },
|
1998-02-10 18:31:27 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "tx", "SMC 9432TX ethernet card" },
|
2001-07-23 20:44:54 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "txp", "3Com 3cR990 ethernet card" },
|
2000-08-22 03:14:39 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "ti", "Alteon Networks PCI gigabit ethernet card" },
|
1998-09-13 16:45:10 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "tl", "Texas Instruments ThunderLAN PCI ethernet card" },
|
2004-09-10 20:57:46 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "vge", "VIA VT612x PCI gigabit ethernet card" },
|
2000-08-22 03:14:39 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "vr", "VIA VT3043/VT86C100A Rhine PCI ethernet card" },
|
2003-01-17 18:51:21 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "vlan", "IEEE 802.1Q VLAN network interface" },
|
1998-09-13 16:45:10 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "vx", "3COM 3c590 / 3c595 ethernet card" },
|
An early Christmas present: add driver support for a whole bunch of
PCI fast ethernet adapters, plus man pages.
if_pn.c: Netgear FA310TX model D1, LinkSys LNE100TX, Matrox FastNIC 10/100,
various other PNIC devices
if_mx.c: NDC Communications SOHOware SFA100 (Macronix 98713A), various
other boards based on the Macronix 98713, 98713A, 98715, 98715A
and 98725 chips
if_vr.c: D-Link DFE530-TX, other boards based on the VIA Rhine and
Rhine II chips (note: the D-Link and certain other cards
that actually use a Rhine II chip still return the PCI
device ID of the Rhine I. I don't know why, and it doesn't
really matter since the driver treats both chips the same
anyway.)
if_wb.c: Trendware TE100-PCIE and various other cards based on the
Winbond W89C840F chip (the Trendware card is identical to
the sample boards Winbond sent me, so who knows how many
clones there are running around)
All drivers include support for ifmedia, BPF and hardware multicast
filtering.
Also updated GENERIC, LINT, RELNOTES.TXT, userconfig and
sysinstall device list.
I also have a driver for the ASIX AX88140A in the works.
1998-12-04 18:01:24 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "wb", "Winbond W89C840F PCI ethernet card" },
|
2002-03-17 08:04:02 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "wi", "Lucent WaveLAN/IEEE 802.11 wireless adapter" },
|
2000-11-07 09:16:14 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "wx", "Intel Gigabit Ethernet (82452) card" },
|
2000-09-22 23:48:27 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "xe", "Xircom/Intel EtherExpress Pro100/16 ethernet card" },
|
1998-09-13 16:45:10 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "xl", "3COM 3c90x / 3c90xB PCI ethernet card" },
|
2004-11-19 03:53:36 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "cuad%d", "%s on device %s (COM%d)", 28, 128, 1, 16 },
|
2004-01-04 21:04:02 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "fwe", "FireWire Ethernet emulation" },
|
1998-03-15 16:15:47 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "lp", "Parallel Port IP (PLIP) peer connection" },
|
|
|
|
{ DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
|
2003-03-05 18:50:18 +00:00
|
|
|
{ DEVICE_TYPE_NETWORK, "disc", "Software discard network interface" },
|
1998-02-10 18:31:27 +00:00
|
|
|
{ 0 },
|
1995-05-08 21:39:40 +00:00
|
|
|
};
|
|
|
|
|
1995-05-20 10:33:14 +00:00
|
|
|
Device *
|
1995-05-16 02:53:31 +00:00
|
|
|
new_device(char *name)
|
1995-05-01 21:56:32 +00:00
|
|
|
{
|
1995-05-16 02:53:31 +00:00
|
|
|
Device *dev;
|
|
|
|
|
|
|
|
dev = safe_malloc(sizeof(Device));
|
1995-06-11 19:33:05 +00:00
|
|
|
bzero(dev, sizeof(Device));
|
1995-05-16 02:53:31 +00:00
|
|
|
if (name)
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(dev->name, name);
|
1995-05-16 02:53:31 +00:00
|
|
|
return dev;
|
1995-05-01 21:56:32 +00:00
|
|
|
}
|
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
/* Stubs for unimplemented strategy routines */
|
|
|
|
Boolean
|
|
|
|
dummyInit(Device *dev)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-12-11 09:35:06 +00:00
|
|
|
FILE *
|
1996-03-02 07:31:58 +00:00
|
|
|
dummyGet(Device *dev, char *dist, Boolean probe)
|
1995-06-11 19:33:05 +00:00
|
|
|
{
|
1996-12-11 09:35:06 +00:00
|
|
|
return NULL;
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dummyShutdown(Device *dev)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
static int
|
1998-02-10 18:31:27 +00:00
|
|
|
deviceTry(struct _devname dev, char *try, int i)
|
1995-05-01 21:56:32 +00:00
|
|
|
{
|
1995-05-16 11:37:27 +00:00
|
|
|
int fd;
|
1998-02-10 18:31:27 +00:00
|
|
|
char unit[80];
|
|
|
|
mode_t m;
|
|
|
|
dev_t d;
|
|
|
|
int fail;
|
|
|
|
|
|
|
|
snprintf(unit, sizeof unit, dev.name, i);
|
|
|
|
snprintf(try, FILENAME_MAX, "/dev/%s", unit);
|
2000-02-25 20:55:15 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("deviceTry: attempting to open %s\n", try);
|
1998-03-16 14:33:18 +00:00
|
|
|
fd = open(try, O_RDONLY);
|
2000-02-25 20:55:15 +00:00
|
|
|
if (fd >= 0) {
|
|
|
|
if (isDebug())
|
|
|
|
msgDebug("deviceTry: open of %s succeeded on first try.\n", try);
|
1998-03-16 14:33:18 +00:00
|
|
|
return fd;
|
2000-02-25 20:55:15 +00:00
|
|
|
}
|
2000-08-22 03:14:39 +00:00
|
|
|
m = 0640 | S_IFCHR;
|
1998-02-10 18:31:27 +00:00
|
|
|
d = makedev(dev.major, dev.minor + (i * dev.delta));
|
2000-02-25 20:55:15 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("deviceTry: Making %s device for %s [%d, %d]\n", m & S_IFCHR ? "raw" : "block", try, dev.major, dev.minor + (i * dev.delta));
|
1998-02-10 18:31:27 +00:00
|
|
|
fail = mknod(try, m, d);
|
1996-11-27 01:01:52 +00:00
|
|
|
fd = open(try, O_RDONLY);
|
2000-02-25 20:55:15 +00:00
|
|
|
if (fd >= 0) {
|
|
|
|
if (isDebug())
|
|
|
|
msgDebug("deviceTry: open of %s succeeded on second try.\n", try);
|
1995-05-16 02:53:31 +00:00
|
|
|
return fd;
|
2000-02-25 20:55:15 +00:00
|
|
|
}
|
1998-02-10 18:31:27 +00:00
|
|
|
else if (!fail)
|
|
|
|
(void)unlink(try);
|
|
|
|
/* Don't try a "make-under" here since we're using a fixit floppy in this case */
|
|
|
|
snprintf(try, FILENAME_MAX, "/mnt/dev/%s", unit);
|
1996-11-27 01:01:52 +00:00
|
|
|
fd = open(try, O_RDONLY);
|
2000-02-25 20:55:15 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("deviceTry: final attempt for %s returns %d\n", try, fd);
|
1995-05-16 02:53:31 +00:00
|
|
|
return fd;
|
1995-05-04 03:51:22 +00:00
|
|
|
}
|
|
|
|
|
1995-05-20 10:33:14 +00:00
|
|
|
/* Register a new device in the devices array */
|
|
|
|
Device *
|
|
|
|
deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
|
1996-12-11 09:35:06 +00:00
|
|
|
Boolean (*init)(Device *), FILE * (*get)(Device *, char *, Boolean),
|
|
|
|
void (*shutdown)(Device *), void *private)
|
1995-05-20 10:33:14 +00:00
|
|
|
{
|
1996-06-13 17:07:41 +00:00
|
|
|
Device *newdev = NULL;
|
1995-05-20 10:33:14 +00:00
|
|
|
|
|
|
|
if (numDevs == DEV_MAX)
|
|
|
|
msgFatal("Too many devices found!");
|
1996-06-12 17:09:34 +00:00
|
|
|
else {
|
|
|
|
newdev = new_device(name);
|
|
|
|
newdev->description = desc;
|
|
|
|
newdev->devname = devname;
|
|
|
|
newdev->type = type;
|
|
|
|
newdev->enabled = enabled;
|
|
|
|
newdev->init = init ? init : dummyInit;
|
|
|
|
newdev->get = get ? get : dummyGet;
|
|
|
|
newdev->shutdown = shutdown ? shutdown : dummyShutdown;
|
|
|
|
newdev->private = private;
|
|
|
|
Devices[numDevs] = newdev;
|
|
|
|
Devices[++numDevs] = NULL;
|
|
|
|
}
|
1995-05-20 10:33:14 +00:00
|
|
|
return newdev;
|
|
|
|
}
|
1995-05-24 09:00:58 +00:00
|
|
|
|
1999-04-06 08:25:53 +00:00
|
|
|
/* Reset the registered device chain */
|
|
|
|
void
|
|
|
|
deviceReset(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < numDevs; i++) {
|
2001-07-02 00:18:04 +00:00
|
|
|
DEVICE_SHUTDOWN(Devices[i]);
|
1999-04-06 08:25:53 +00:00
|
|
|
|
|
|
|
/* XXX this potentially leaks Devices[i]->private if it's being
|
|
|
|
* used to point to something dynamic, but you're not supposed
|
|
|
|
* to call this routine at such times that some open instance
|
|
|
|
* has its private ptr pointing somewhere anyway. XXX
|
|
|
|
*/
|
|
|
|
free(Devices[i]);
|
|
|
|
}
|
|
|
|
Devices[numDevs = 0] = NULL;
|
|
|
|
}
|
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
/* Get all device information for devices we have attached */
|
|
|
|
void
|
1995-05-16 11:37:27 +00:00
|
|
|
deviceGetAll(void)
|
1995-05-01 21:56:32 +00:00
|
|
|
{
|
1998-02-10 18:31:27 +00:00
|
|
|
int i, j, fd, s;
|
1995-05-16 02:53:31 +00:00
|
|
|
struct ifconf ifc;
|
|
|
|
struct ifreq *ifptr, *end;
|
1995-05-16 11:37:27 +00:00
|
|
|
int ifflags;
|
|
|
|
char buffer[INTERFACE_MAX * sizeof(struct ifreq)];
|
|
|
|
char **names;
|
1995-05-04 03:51:22 +00:00
|
|
|
|
1998-09-30 01:46:27 +00:00
|
|
|
msgNotify("Probing devices, please wait (this can take a while)...");
|
1998-02-10 18:31:27 +00:00
|
|
|
/* First go for the network interfaces. Stolen shamelessly from ifconfig! */
|
1996-10-05 11:56:50 +00:00
|
|
|
ifc.ifc_len = sizeof(buffer);
|
|
|
|
ifc.ifc_buf = buffer;
|
|
|
|
|
|
|
|
s = socket(AF_INET, SOCK_DGRAM, 0);
|
1999-05-27 10:32:50 +00:00
|
|
|
if (s < 0)
|
1996-12-08 12:27:58 +00:00
|
|
|
goto skipif; /* Jump over network iface probing */
|
1999-05-27 10:32:50 +00:00
|
|
|
|
|
|
|
if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0)
|
1996-12-08 12:27:58 +00:00
|
|
|
goto skipif; /* Jump over network iface probing */
|
1999-05-27 10:32:50 +00:00
|
|
|
|
2001-09-30 00:43:32 +00:00
|
|
|
close(s);
|
1996-10-05 11:56:50 +00:00
|
|
|
ifflags = ifc.ifc_req->ifr_flags;
|
|
|
|
end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
|
|
|
|
for (ifptr = ifc.ifc_req; ifptr < end; ifptr++) {
|
|
|
|
char *descr;
|
|
|
|
|
|
|
|
/* If it's not a link entry, forget it */
|
|
|
|
if (ifptr->ifr_ifru.ifru_addr.sa_family != AF_LINK)
|
1999-06-17 19:04:56 +00:00
|
|
|
goto loopend;
|
1996-12-08 12:27:58 +00:00
|
|
|
|
1996-10-05 11:56:50 +00:00
|
|
|
/* Eliminate network devices that don't make sense */
|
1998-02-10 18:31:27 +00:00
|
|
|
if (!strncmp(ifptr->ifr_name, "lo", 2))
|
1999-06-17 19:04:56 +00:00
|
|
|
goto loopend;
|
1996-12-08 12:27:58 +00:00
|
|
|
|
1997-01-15 13:39:50 +00:00
|
|
|
/* If we have a slip device, don't register it */
|
1997-01-04 13:29:10 +00:00
|
|
|
if (!strncmp(ifptr->ifr_name, "sl", 2)) {
|
1999-06-17 19:04:56 +00:00
|
|
|
goto loopend;
|
1997-01-04 13:29:10 +00:00
|
|
|
}
|
|
|
|
/* And the same for ppp */
|
|
|
|
if (!strncmp(ifptr->ifr_name, "tun", 3) || !strncmp(ifptr->ifr_name, "ppp", 3)) {
|
1999-06-17 19:04:56 +00:00
|
|
|
goto loopend;
|
1997-01-04 13:29:10 +00:00
|
|
|
}
|
1996-12-08 12:27:58 +00:00
|
|
|
/* Try and find its description */
|
|
|
|
for (i = 0, descr = NULL; device_names[i].name; i++) {
|
1996-10-05 11:56:50 +00:00
|
|
|
int len = strlen(device_names[i].name);
|
|
|
|
|
1998-02-10 18:31:27 +00:00
|
|
|
if (!ifptr->ifr_name || !ifptr->ifr_name[0])
|
|
|
|
continue;
|
|
|
|
else if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) {
|
1996-10-05 11:56:50 +00:00
|
|
|
descr = device_names[i].description;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!descr)
|
|
|
|
descr = "<unknown network interface type>";
|
1996-12-08 12:27:58 +00:00
|
|
|
|
1996-10-05 11:56:50 +00:00
|
|
|
deviceRegister(ifptr->ifr_name, descr, strdup(ifptr->ifr_name), DEVICE_TYPE_NETWORK, TRUE,
|
1996-12-11 09:35:06 +00:00
|
|
|
mediaInitNetwork, NULL, mediaShutdownNetwork, NULL);
|
2000-02-25 20:55:15 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("Found a network device named %s\n", ifptr->ifr_name);
|
1996-10-05 11:56:50 +00:00
|
|
|
close(s);
|
1999-05-27 10:32:50 +00:00
|
|
|
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
1996-10-05 11:56:50 +00:00
|
|
|
continue;
|
1999-05-27 10:32:50 +00:00
|
|
|
|
1999-06-17 19:04:56 +00:00
|
|
|
loopend:
|
1996-10-05 11:56:50 +00:00
|
|
|
if (ifptr->ifr_addr.sa_len) /* I'm not sure why this is here - it's inherited */
|
|
|
|
ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len - sizeof(struct sockaddr));
|
2001-09-30 00:43:32 +00:00
|
|
|
close(s);
|
1996-10-05 11:56:50 +00:00
|
|
|
}
|
|
|
|
|
1996-12-08 12:27:58 +00:00
|
|
|
skipif:
|
1998-02-10 18:31:27 +00:00
|
|
|
/* Next, try to find all the types of devices one might need
|
1996-10-05 11:56:50 +00:00
|
|
|
* during the second stage of the installation.
|
1995-05-16 02:53:31 +00:00
|
|
|
*/
|
|
|
|
for (i = 0; device_names[i].name; i++) {
|
1998-02-10 18:31:27 +00:00
|
|
|
for (j = 0; j < device_names[i].max; j++) {
|
|
|
|
char try[FILENAME_MAX];
|
|
|
|
|
|
|
|
switch(device_names[i].type) {
|
|
|
|
case DEVICE_TYPE_CDROM:
|
|
|
|
fd = deviceTry(device_names[i], try, j);
|
|
|
|
if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
|
1998-02-10 18:43:11 +00:00
|
|
|
char n[BUFSIZ];
|
|
|
|
|
1998-02-10 18:31:27 +00:00
|
|
|
if (fd >= 0) close(fd);
|
1998-02-10 18:43:11 +00:00
|
|
|
snprintf(n, sizeof n, device_names[i].name, j);
|
|
|
|
deviceRegister(strdup(n), device_names[i].description, strdup(try),
|
1998-02-10 18:31:27 +00:00
|
|
|
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
|
|
|
|
mediaShutdownCDROM, NULL);
|
2000-02-25 20:55:15 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("Found a CDROM device for %s\n", try);
|
1998-02-10 18:31:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEVICE_TYPE_TAPE:
|
|
|
|
fd = deviceTry(device_names[i], try, j);
|
|
|
|
if (fd >= 0) {
|
1998-02-10 18:43:11 +00:00
|
|
|
char n[BUFSIZ];
|
|
|
|
|
1998-02-10 18:31:27 +00:00
|
|
|
close(fd);
|
1998-02-10 18:43:11 +00:00
|
|
|
snprintf(n, sizeof n, device_names[i].name, j);
|
|
|
|
deviceRegister(strdup(n), device_names[i].description, strdup(try),
|
1998-02-10 18:31:27 +00:00
|
|
|
DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL);
|
2000-02-25 20:55:15 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("Found a TAPE device for %s\n", try);
|
1998-02-10 18:31:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEVICE_TYPE_DISK:
|
|
|
|
fd = deviceTry(device_names[i], try, j);
|
1998-03-16 14:33:18 +00:00
|
|
|
if (fd >= 0 && RunningAsInit) {
|
1998-03-15 16:15:47 +00:00
|
|
|
dev_t d;
|
1998-03-20 23:39:57 +00:00
|
|
|
mode_t m;
|
1998-03-15 16:15:47 +00:00
|
|
|
int s, fail;
|
1998-03-20 18:07:02 +00:00
|
|
|
char unit[80], slice[80];
|
1998-03-15 16:15:47 +00:00
|
|
|
|
1998-02-10 18:31:27 +00:00
|
|
|
close(fd);
|
1998-03-15 16:15:47 +00:00
|
|
|
/* Make associated slice entries */
|
1998-06-29 09:28:01 +00:00
|
|
|
for (s = 1; s < 8; s++) {
|
1998-03-20 18:26:04 +00:00
|
|
|
snprintf(unit, sizeof unit, device_names[i].name, j);
|
1998-03-20 18:07:02 +00:00
|
|
|
snprintf(slice, sizeof slice, "/dev/%ss%d", unit, s);
|
1998-03-15 16:15:47 +00:00
|
|
|
d = makedev(device_names[i].major, device_names[i].minor +
|
|
|
|
(j * device_names[i].delta) + (s * SLICE_DELTA));
|
2000-08-22 03:14:39 +00:00
|
|
|
m = 0640 | S_IFCHR;
|
1998-03-20 23:39:57 +00:00
|
|
|
fail = mknod(slice, m, d);
|
1998-03-15 16:15:47 +00:00
|
|
|
fd = open(slice, O_RDONLY);
|
|
|
|
if (fd >= 0)
|
|
|
|
close(fd);
|
|
|
|
else if (!fail)
|
|
|
|
(void)unlink(slice);
|
|
|
|
}
|
|
|
|
}
|
1998-02-10 18:31:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DEVICE_TYPE_FLOPPY:
|
|
|
|
fd = deviceTry(device_names[i], try, j);
|
|
|
|
if (fd >= 0) {
|
1998-02-10 18:43:11 +00:00
|
|
|
char n[BUFSIZ];
|
|
|
|
|
1998-02-10 18:31:27 +00:00
|
|
|
close(fd);
|
1998-02-10 18:43:11 +00:00
|
|
|
snprintf(n, sizeof n, device_names[i].name, j);
|
|
|
|
deviceRegister(strdup(n), device_names[i].description, strdup(try),
|
1998-02-10 18:31:27 +00:00
|
|
|
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
|
|
|
|
mediaShutdownFloppy, NULL);
|
2000-02-25 20:55:15 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("Found a floppy device for %s\n", try);
|
1998-02-10 18:31:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEVICE_TYPE_NETWORK:
|
|
|
|
fd = deviceTry(device_names[i], try, j);
|
|
|
|
/* The only network devices that you can open this way are serial ones */
|
|
|
|
if (fd >= 0) {
|
|
|
|
char *newdesc, *cp;
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
cp = device_names[i].description;
|
|
|
|
/* Serial devices get a slip and ppp device each, if supported */
|
|
|
|
newdesc = safe_malloc(strlen(cp) + 40);
|
|
|
|
sprintf(newdesc, cp, "SLIP interface", try, j + 1);
|
|
|
|
deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
|
|
|
|
NULL, mediaShutdownNetwork, NULL);
|
|
|
|
msgDebug("Add mapping for %s to sl0\n", try);
|
|
|
|
newdesc = safe_malloc(strlen(cp) + 50);
|
|
|
|
sprintf(newdesc, cp, "PPP interface", try, j + 1);
|
|
|
|
deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
|
|
|
|
NULL, mediaShutdownNetwork, NULL);
|
2000-02-25 20:55:15 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("Add mapping for %s to ppp0\n", try);
|
1998-02-10 18:31:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1995-05-19 02:31:13 +00:00
|
|
|
}
|
1998-02-10 18:31:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finally, go get the disks and look for DOS partitions to register */
|
|
|
|
if ((names = Disk_Names()) != NULL) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; names[i]; i++) {
|
|
|
|
Chunk *c1;
|
|
|
|
Disk *d;
|
1995-05-19 02:31:13 +00:00
|
|
|
|
2000-07-05 07:15:57 +00:00
|
|
|
/* Ignore memory disks */
|
2003-03-05 18:48:47 +00:00
|
|
|
if (!strncmp(names[i], "md", 2))
|
2000-07-04 13:46:43 +00:00
|
|
|
continue;
|
2000-07-05 07:15:57 +00:00
|
|
|
|
2004-12-22 08:26:48 +00:00
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* Due to unknown reasons, Disk_Names() returns SCSI CDROM as a
|
|
|
|
* valid disk. This is main reason why sysinstall presents SCSI
|
|
|
|
* CDROM to available disks in Fdisk/Label menu. In addition,
|
|
|
|
* adding a blank SCSI CDROM to the menu generates floating point
|
|
|
|
* exception in sparc64. Disk_Names() just extracts sysctl
|
|
|
|
* "kern.disks". Why GEOM treats SCSI CDROM as a disk is beyond
|
|
|
|
* me and that should be investigated.
|
|
|
|
* For temporary workaround, ignore SCSI CDROM device.
|
|
|
|
*/
|
|
|
|
if (!strncmp(names[i], "cd", 2))
|
|
|
|
continue;
|
|
|
|
|
1998-02-10 18:31:27 +00:00
|
|
|
d = Open_Disk(names[i]);
|
2000-07-04 13:46:43 +00:00
|
|
|
if (!d) {
|
2002-11-01 02:05:05 +00:00
|
|
|
msgDebug("Unable to open disk %s\n", names[i]);
|
2000-07-04 13:46:43 +00:00
|
|
|
continue;
|
|
|
|
}
|
1998-02-10 18:31:27 +00:00
|
|
|
|
|
|
|
deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
|
|
|
|
dummyInit, dummyGet, dummyShutdown, d);
|
2000-02-25 20:55:15 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("Found a disk device named %s\n", names[i]);
|
1998-02-10 18:31:27 +00:00
|
|
|
|
|
|
|
/* Look for existing DOS partitions to register as "DOS media devices" */
|
|
|
|
for (c1 = d->chunks->part; c1; c1 = c1->next) {
|
2002-11-13 05:39:59 +00:00
|
|
|
if (c1->type == fat || c1->type == efi || c1->type == extended) {
|
1998-02-10 18:31:27 +00:00
|
|
|
Device *dev;
|
|
|
|
char devname[80];
|
|
|
|
|
|
|
|
/* Got one! */
|
|
|
|
snprintf(devname, sizeof devname, "/dev/%s", c1->name);
|
|
|
|
dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
|
|
|
|
mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
|
|
|
|
dev->private = c1;
|
2000-02-25 20:55:15 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
|
1998-02-10 18:31:27 +00:00
|
|
|
}
|
|
|
|
}
|
1995-05-08 01:27:07 +00:00
|
|
|
}
|
1998-02-10 18:31:27 +00:00
|
|
|
free(names);
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
1999-12-17 02:46:04 +00:00
|
|
|
dialog_clear_norefresh();
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
|
|
|
|
1999-04-06 08:25:53 +00:00
|
|
|
/* Rescan all devices, after closing previous set - convenience function */
|
|
|
|
void
|
|
|
|
deviceRescan(void)
|
|
|
|
{
|
|
|
|
deviceReset();
|
|
|
|
deviceGetAll();
|
|
|
|
}
|
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
/*
|
|
|
|
* Find all devices that match the criteria, allowing "wildcarding" as well
|
1995-05-20 10:33:14 +00:00
|
|
|
* by allowing NULL or ANY values to match all. The array returned is static
|
|
|
|
* and may be used until the next invocation of deviceFind().
|
1995-05-16 02:53:31 +00:00
|
|
|
*/
|
|
|
|
Device **
|
|
|
|
deviceFind(char *name, DeviceType class)
|
|
|
|
{
|
|
|
|
static Device *found[DEV_MAX];
|
|
|
|
int i, j;
|
|
|
|
|
1997-01-04 13:29:10 +00:00
|
|
|
j = 0;
|
|
|
|
for (i = 0; i < numDevs; i++) {
|
1995-05-17 14:40:00 +00:00
|
|
|
if ((!name || !strcmp(Devices[i]->name, name))
|
|
|
|
&& (class == DEVICE_TYPE_ANY || class == Devices[i]->type))
|
1995-05-16 02:53:31 +00:00
|
|
|
found[j++] = Devices[i];
|
1995-05-04 23:36:23 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
found[j] = NULL;
|
|
|
|
return j ? found : NULL;
|
1995-05-04 03:51:22 +00:00
|
|
|
}
|
|
|
|
|
1997-01-15 16:21:10 +00:00
|
|
|
Device **
|
|
|
|
deviceFindDescr(char *name, char *desc, DeviceType class)
|
|
|
|
{
|
|
|
|
static Device *found[DEV_MAX];
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
j = 0;
|
|
|
|
for (i = 0; i < numDevs; i++) {
|
|
|
|
if ((!name || !strcmp(Devices[i]->name, name)) &&
|
|
|
|
(!desc || !strcmp(Devices[i]->description, desc)) &&
|
|
|
|
(class == DEVICE_TYPE_ANY || class == Devices[i]->type))
|
|
|
|
found[j++] = Devices[i];
|
|
|
|
}
|
|
|
|
found[j] = NULL;
|
|
|
|
return j ? found : NULL;
|
|
|
|
}
|
|
|
|
|
1995-05-20 00:13:14 +00:00
|
|
|
int
|
|
|
|
deviceCount(Device **devs)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!devs)
|
|
|
|
return 0;
|
|
|
|
for (i = 0; devs[i]; i++);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
1995-05-04 03:51:22 +00:00
|
|
|
/*
|
1995-05-16 02:53:31 +00:00
|
|
|
* Create a menu listing all the devices of a certain type in the system.
|
|
|
|
* The passed-in menu is expected to be a "prototype" from which the new
|
|
|
|
* menu is cloned.
|
1995-05-04 03:51:22 +00:00
|
|
|
*/
|
|
|
|
DMenu *
|
1996-04-13 13:32:15 +00:00
|
|
|
deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), int (*check)(dialogMenuItem *d))
|
1995-05-04 03:51:22 +00:00
|
|
|
{
|
1995-05-16 02:53:31 +00:00
|
|
|
Device **devs;
|
1995-05-16 11:37:27 +00:00
|
|
|
int numdevs;
|
|
|
|
DMenu *tmp = NULL;
|
|
|
|
int i, j;
|
1995-05-04 03:51:22 +00:00
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
devs = deviceFind(NULL, type);
|
1996-06-13 17:07:41 +00:00
|
|
|
numdevs = deviceCount(devs);
|
|
|
|
if (!numdevs)
|
1995-05-16 11:37:27 +00:00
|
|
|
return NULL;
|
1996-04-07 03:52:36 +00:00
|
|
|
tmp = (DMenu *)safe_malloc(sizeof(DMenu) + (sizeof(dialogMenuItem) * (numdevs + 1)));
|
1995-05-16 11:37:27 +00:00
|
|
|
bcopy(menu, tmp, sizeof(DMenu));
|
|
|
|
for (i = 0; devs[i]; i++) {
|
1996-04-07 03:52:36 +00:00
|
|
|
tmp->items[i].prompt = devs[i]->name;
|
1996-06-13 17:07:41 +00:00
|
|
|
for (j = 0; j < numDevs; j++) {
|
|
|
|
if (devs[i] == Devices[j]) {
|
|
|
|
tmp->items[i].title = Devices[j]->description;
|
1995-05-16 11:37:27 +00:00
|
|
|
break;
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
1995-05-04 03:51:22 +00:00
|
|
|
}
|
1996-06-13 17:07:41 +00:00
|
|
|
if (j == numDevs)
|
1996-04-07 03:52:36 +00:00
|
|
|
tmp->items[i].title = "<unknown device type>";
|
|
|
|
tmp->items[i].fire = hook;
|
1996-04-13 13:32:15 +00:00
|
|
|
tmp->items[i].checked = check;
|
1995-05-01 21:56:32 +00:00
|
|
|
}
|
1995-05-16 11:37:27 +00:00
|
|
|
tmp->items[i].title = NULL;
|
|
|
|
return tmp;
|
1995-05-01 21:56:32 +00:00
|
|
|
}
|