PERFORCE change 153201 for review
Marko Zec
zec at FreeBSD.org
Wed Nov 19 00:48:14 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=153201
Change 153201 by zec at zec_tca51 on 2008/11/19 08:47:37
IFC @ 153200
(just in case as suggested by Julian, though no net* files
seem to have changed since the last update)
Affected files ...
.. //depot/projects/vimage-commit2/src/sys/arm/at91/at91_mci.c#7 integrate
.. //depot/projects/vimage-commit2/src/sys/arm/at91/uart_dev_at91usart.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/acpica/acpi.c#6 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/bce/if_bce.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/sio/sio_pci.c#2 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/sio/sio_puc.c#2 integrate
.. //depot/projects/vimage-commit2/src/sys/fs/cd9660/cd9660_bmap.c#2 integrate
.. //depot/projects/vimage-commit2/src/sys/fs/cd9660/cd9660_node.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/fs/cd9660/cd9660_node.h#2 integrate
.. //depot/projects/vimage-commit2/src/sys/fs/cd9660/cd9660_vfsops.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/fs/cd9660/cd9660_vnops.c#5 integrate
.. //depot/projects/vimage-commit2/src/sys/isa/isa_common.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/isa/isa_common.h#3 integrate
.. //depot/projects/vimage-commit2/src/sys/isa/isahint.c#2 integrate
.. //depot/projects/vimage-commit2/src/sys/isa/isavar.h#4 integrate
.. //depot/projects/vimage-commit2/src/sys/kern/bus_if.m#2 integrate
.. //depot/projects/vimage-commit2/src/sys/kern/subr_bus.c#5 integrate
Differences ...
==== //depot/projects/vimage-commit2/src/sys/arm/at91/at91_mci.c#7 (text+ko) ====
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/at91/at91_mci.c,v 1.9 2008/10/29 20:01:26 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/at91/at91_mci.c,v 1.10 2008/11/18 12:42:59 stas Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -176,7 +176,7 @@
* Allocate DMA tags and maps
*/
err = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0,
- BUS_SPACE_MAXADDR_32BIT, US_SPACE_MAXADDR, NULL, NULL, MAXPHYS, 1,
+ BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MAXPHYS, 1,
MAXPHYS, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->dmatag);
if (err != 0)
goto out;
==== //depot/projects/vimage-commit2/src/sys/arm/at91/uart_dev_at91usart.c#4 (text) ====
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/at91/uart_dev_at91usart.c,v 1.16 2008/10/07 17:23:16 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/at91/uart_dev_at91usart.c,v 1.17 2008/11/18 12:42:59 stas Exp $");
#include "opt_comconsole.h"
@@ -350,7 +350,7 @@
/*
* Allocate DMA tags and maps
*/
- err = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0,
+ err = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
USART_BUFFER_SIZE, 1, USART_BUFFER_SIZE, BUS_DMA_ALLOCNOW, NULL,
NULL, &atsc->dmatag);
==== //depot/projects/vimage-commit2/src/sys/dev/acpica/acpi.c#6 (text+ko) ====
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi.c,v 1.253 2008/11/02 17:35:15 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi.c,v 1.254 2008/11/18 21:01:54 jhb Exp $");
#include "opt_acpi.h"
#include <sys/param.h>
@@ -158,6 +158,8 @@
#if defined(__i386__) || defined(__amd64__)
static void acpi_enable_pcie(void);
#endif
+static void acpi_hint_device_unit(device_t acdev, device_t child,
+ const char *name, int *unitp);
static device_method_t acpi_methods[] = {
/* Device interface */
@@ -187,6 +189,7 @@
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
+ DEVMETHOD(bus_hint_device_unit, acpi_hint_device_unit),
/* ACPI bus */
DEVMETHOD(acpi_id_probe, acpi_device_id_probe),
@@ -949,6 +952,89 @@
return (&ad->ad_rl);
}
+static int
+acpi_match_resource_hint(device_t dev, int type, long value)
+{
+ struct acpi_device *ad = device_get_ivars(dev);
+ struct resource_list *rl = &ad->ad_rl;
+ struct resource_list_entry *rle;
+
+ STAILQ_FOREACH(rle, rl, link) {
+ if (rle->type != type)
+ continue;
+ if (rle->start <= value && rle->end >= value)
+ return (1);
+ }
+ return (0);
+}
+
+/*
+ * Wire device unit numbers based on resource matches in hints.
+ */
+static void
+acpi_hint_device_unit(device_t acdev, device_t child, const char *name,
+ int *unitp)
+{
+ const char *s;
+ long value;
+ int line, matches, unit;
+
+ /*
+ * Iterate over all the hints for the devices with the specified
+ * name to see if one's resources are a subset of this device.
+ */
+ line = 0;
+ for (;;) {
+ if (resource_find_dev(&line, name, &unit, "at", NULL) != 0)
+ break;
+
+ /* Must have an "at" for acpi or isa. */
+ resource_string_value(name, unit, "at", &s);
+ if (!(strcmp(s, "acpi0") == 0 || strcmp(s, "acpi") == 0 ||
+ strcmp(s, "isa0") == 0 || strcmp(s, "isa") == 0))
+ continue;
+
+ /*
+ * Check for matching resources. We must have at least one,
+ * and all resources specified have to match.
+ *
+ * XXX: We may want to revisit this to be more lenient and wire
+ * as long as it gets one match.
+ */
+ matches = 0;
+ if (resource_long_value(name, unit, "port", &value) == 0) {
+ if (acpi_match_resource_hint(child, SYS_RES_IOPORT, value))
+ matches++;
+ else
+ continue;
+ }
+ if (resource_long_value(name, unit, "maddr", &value) == 0) {
+ if (acpi_match_resource_hint(child, SYS_RES_MEMORY, value))
+ matches++;
+ else
+ continue;
+ }
+ if (resource_long_value(name, unit, "irq", &value) == 0) {
+ if (acpi_match_resource_hint(child, SYS_RES_IRQ, value))
+ matches++;
+ else
+ continue;
+ }
+ if (resource_long_value(name, unit, "drq", &value) == 0) {
+ if (acpi_match_resource_hint(child, SYS_RES_DRQ, value))
+ matches++;
+ else
+ continue;
+ }
+
+ if (matches > 0) {
+ /* We have a winner! */
+ *unitp = unit;
+ break;
+ }
+ }
+}
+
/*
* Pre-allocate/manage all memory and IO resources. Since rman can't handle
* duplicates, we merge any in the sysresource attach routine.
==== //depot/projects/vimage-commit2/src/sys/dev/bce/if_bce.c#4 (text) ====
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.43 2008/08/27 18:47:24 davidch Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.44 2008/11/19 03:24:35 delphij Exp $");
/*
* The following controllers are supported by this driver:
@@ -2555,7 +2555,7 @@
} else if (BCE_CHIP_BOND_ID(sc) & BCE_CHIP_BOND_ID_SERDES_BIT)
sc->bce_phy_flags |= BCE_PHY_SERDES_FLAG;
- if (sc->bce_phy_flags && BCE_PHY_SERDES_FLAG) {
+ if (sc->bce_phy_flags & BCE_PHY_SERDES_FLAG) {
sc->bce_flags |= BCE_NO_WOL_FLAG;
if (BCE_CHIP_NUM(sc) != BCE_CHIP_NUM_5706) {
sc->bce_phy_addr = 2;
==== //depot/projects/vimage-commit2/src/sys/dev/sio/sio_pci.c#2 (text+ko) ====
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/sio/sio_pci.c,v 1.23 2007/03/29 04:26:52 maxim Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/sio/sio_pci.c,v 1.24 2008/11/18 21:01:54 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -43,7 +43,6 @@
#include <dev/pci/pcivar.h>
static int sio_pci_attach(device_t dev);
-static void sio_pci_kludge_unit(device_t dev);
static int sio_pci_probe(device_t dev);
static device_method_t sio_pci_methods[] = {
@@ -101,39 +100,9 @@
id++;
if (id->desc == NULL)
return (ENXIO);
- sio_pci_kludge_unit(dev);
return (sioattach(dev, id->rid, 0UL));
}
-/*
- * Don't cut and paste this to other drivers. It is a horrible kludge
- * which will fail to work and also be unnecessary in future versions.
- */
-static void
-sio_pci_kludge_unit(dev)
- device_t dev;
-{
- devclass_t dc;
- int err;
- int start;
- int unit;
-
- unit = 0;
- start = 0;
- while (resource_int_value("sio", unit, "port", &start) == 0 &&
- start > 0)
- unit++;
- if (device_get_unit(dev) < unit) {
- dc = device_get_devclass(dev);
- while (devclass_get_device(dc, unit))
- unit++;
- device_printf(dev, "moving to sio%d\n", unit);
- err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */
- if (err)
- device_printf(dev, "error moving device %d\n", err);
- }
-}
-
static int
sio_pci_probe(dev)
device_t dev;
==== //depot/projects/vimage-commit2/src/sys/dev/sio/sio_puc.c#2 (text+ko) ====
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/sio/sio_puc.c,v 1.11 2007/11/30 21:36:12 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/sio/sio_puc.c,v 1.12 2008/11/18 21:01:54 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -62,34 +62,6 @@
0,
};
-/*
- * Don't cut and paste this to other drivers. It is a horrible kludge
- * which will fail to work and also be unnecessary in future versions.
- */
-static void
-sio_puc_kludge_unit(device_t dev)
-{
- devclass_t dc;
- int err;
- int start;
- int unit;
-
- unit = 0;
- start = 0;
- while (resource_int_value("sio", unit, "port", &start) == 0 &&
- start > 0)
- unit++;
- if (device_get_unit(dev) < unit) {
- dc = device_get_devclass(dev);
- while (devclass_get_device(dc, unit))
- unit++;
- device_printf(dev, "moving to sio%d\n", unit);
- err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */
- if (err)
- device_printf(dev, "error moving device %d\n", err);
- }
-}
-
static int
sio_puc_attach(device_t dev)
{
@@ -98,7 +70,6 @@
if (BUS_READ_IVAR(device_get_parent(dev), dev, PUC_IVAR_CLOCK,
&rclk) != 0)
rclk = DEFAULT_RCLK;
- sio_puc_kludge_unit(dev);
return (sioattach(dev, 0, rclk));
}
==== //depot/projects/vimage-commit2/src/sys/fs/cd9660/cd9660_bmap.c#2 (text+ko) ====
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/fs/cd9660/cd9660_bmap.c,v 1.16 2007/02/11 13:54:25 rodrigc Exp $");
+__FBSDID("$FreeBSD: src/sys/fs/cd9660/cd9660_bmap.c,v 1.17 2008/11/18 23:19:43 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -46,9 +46,10 @@
#include <fs/cd9660/cd9660_node.h>
/*
- * Bmap converts a the logical block number of a file to its physical block
- * number on the disk. The conversion is done by using the logical block
- * number to index into the data block (extent) for the file.
+ * Bmap converts the logical block number of a file to its physical
+ * block number on the disk. The conversion is done by using the
+ * logical block number to index into the data block (extent) for the
+ * file.
*/
int
cd9660_bmap(ap)
==== //depot/projects/vimage-commit2/src/sys/fs/cd9660/cd9660_node.c#4 (text+ko) ====
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/fs/cd9660/cd9660_node.c,v 1.58 2008/10/23 15:53:51 des Exp $");
+__FBSDID("$FreeBSD: src/sys/fs/cd9660/cd9660_node.c,v 1.59 2008/11/18 23:13:40 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -72,7 +72,6 @@
if (prtactive && vrefcnt(vp) != 0)
vprint("cd9660_inactive: pushing active", vp);
- ip->i_flag = 0;
/*
* If we are done with the inode, reclaim it
* so that it can be reused immediately.
==== //depot/projects/vimage-commit2/src/sys/fs/cd9660/cd9660_node.h#2 (text+ko) ====
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* @(#)cd9660_node.h 8.6 (Berkeley) 5/14/95
- * $FreeBSD: src/sys/fs/cd9660/cd9660_node.h,v 1.33 2007/02/11 13:54:25 rodrigc Exp $
+ * $FreeBSD: src/sys/fs/cd9660/cd9660_node.h,v 1.34 2008/11/18 23:13:40 jhb Exp $
*/
/*
@@ -58,7 +58,6 @@
struct iso_node {
struct vnode *i_vnode; /* vnode associated with this inode */
- u_long i_flag; /* see below */
ino_t i_number; /* the identity of the inode */
/* we use the actual starting block of the file */
struct iso_mnt *i_mnt; /* filesystem associated with this inode */
@@ -78,9 +77,6 @@
#define i_forw i_chain[0]
#define i_back i_chain[1]
-/* flags */
-#define IN_ACCESS 0x0020 /* inode access time to be updated */
-
#define VTOI(vp) ((struct iso_node *)(vp)->v_data)
#define ITOV(ip) ((ip)->i_vnode)
==== //depot/projects/vimage-commit2/src/sys/fs/cd9660/cd9660_vfsops.c#4 (text+ko) ====
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/fs/cd9660/cd9660_vfsops.c,v 1.157 2008/10/28 13:44:11 trasz Exp $");
+__FBSDID("$FreeBSD: src/sys/fs/cd9660/cd9660_vfsops.c,v 1.159 2008/11/18 23:19:43 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -153,14 +153,14 @@
* Not an update, or updating the name: look up the name
* and verify that it refers to a sensible block device.
*/
- NDINIT(&ndp, LOOKUP, FOLLOW, UIO_SYSSPACE, fspec, td);
+ NDINIT(&ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, fspec, td);
if ((error = namei(&ndp)))
return (error);
NDFREE(&ndp, NDF_ONLY_PNBUF);
devvp = ndp.ni_vp;
if (!vn_isdisk(devvp, &error)) {
- vrele(devvp);
+ vput(devvp);
return (error);
}
@@ -169,7 +169,6 @@
* or has superuser abilities
*/
accmode = VREAD;
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_ACCESS(devvp, accmode, td->td_ucred, td);
if (error)
error = priv_check(td, PRIV_VFS_MOUNT_PERM);
@@ -177,22 +176,20 @@
vput(devvp);
return (error);
}
- VOP_UNLOCK(devvp, 0);
if ((mp->mnt_flag & MNT_UPDATE) == 0) {
error = iso_mountfs(devvp, mp);
+ if (error)
+ vrele(devvp);
} else {
if (devvp != imp->im_devvp)
error = EINVAL; /* needs translation */
- else
- vrele(devvp);
+ vput(devvp);
}
- if (error) {
- vrele(devvp);
- return error;
- }
+ if (error)
+ return (error);
vfs_mountedfrom(mp, fspec);
- return 0;
+ return (0);
}
/*
@@ -222,7 +219,6 @@
struct bufobj *bo;
char *cs_local, *cs_disk;
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
DROP_GIANT();
g_topology_lock();
error = g_vfs_open(devvp, &cp, "cd9660", 0);
@@ -505,11 +501,6 @@
if (mntflags & MNT_FORCE)
flags |= FORCECLOSE;
-#if 0
- mntflushbuf(mp, 0);
- if (mntinvalbuf(mp))
- return EBUSY;
-#endif
if ((error = vflush(mp, 0, flags, td)))
return (error);
==== //depot/projects/vimage-commit2/src/sys/fs/cd9660/cd9660_vnops.c#5 (text+ko) ====
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/fs/cd9660/cd9660_vnops.c,v 1.117 2008/10/28 13:44:11 trasz Exp $");
+__FBSDID("$FreeBSD: src/sys/fs/cd9660/cd9660_vnops.c,v 1.120 2008/11/18 23:19:43 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -295,7 +295,6 @@
return (0);
if (uio->uio_offset < 0)
return (EINVAL);
- ip->i_flag |= IN_ACCESS;
imp = ip->i_mnt;
do {
lbn = lblkno(imp, uio->uio_offset);
@@ -397,7 +396,7 @@
cl = idp->current.d_namlen;
cname = idp->current.d_name;
-assoc = (cl > 1) && (*cname == ASSOCCHAR);
+ assoc = (cl > 1) && (*cname == ASSOCCHAR);
if (assoc) {
cl--;
cname++;
@@ -744,12 +743,6 @@
if (bp->b_blkno == bp->b_lblkno) {
bp->b_blkno = (ip->iso_start + bp->b_lblkno) <<
(ip->i_mnt->im_bshift - DEV_BSHIFT);
- if ((long)bp->b_blkno == -1) /* XXX: cut&paste junk ? */
- clrbuf(bp);
- }
- if ((long)bp->b_blkno == -1) { /* XXX: cut&paste junk ? */
- bufdone(bp);
- return (0);
}
bp->b_iooffset = dbtob(bp->b_blkno);
bo = ip->i_mnt->im_bo;
==== //depot/projects/vimage-commit2/src/sys/isa/isa_common.c#4 (text+ko) ====
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/isa/isa_common.c,v 1.48 2008/11/02 18:48:54 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/isa/isa_common.c,v 1.49 2008/11/18 21:01:54 jhb Exp $");
#include "opt_isa.h"
@@ -467,15 +467,41 @@
return (0);
}
+/*
+ * Claim any unallocated resources to keep other devices from using
+ * them.
+ */
+static void
+isa_claim_resources(device_t dev, device_t child)
+{
+ struct isa_device *idev = DEVTOISA(child);
+ struct resource_list *rl = &idev->id_resources;
+ struct resource_list_entry *rle;
+ int rid;
+
+ STAILQ_FOREACH(rle, rl, link) {
+ if (!rle->res) {
+ rid = rle->rid;
+ resource_list_alloc(rl, dev, child, rle->type, &rid,
+ 0ul, ~0ul, 1, 0);
+ }
+ }
+}
+
+/*
+ * Called after other devices have initialised to probe for isa devices.
+ */
void
isa_probe_children(device_t dev)
{
- device_t *children;
+ struct isa_device *idev;
+ device_t *children, child;
struct isa_config *cfg;
int nchildren, i;
/*
- * Create all the children by calling driver's identify methods.
+ * Create all the non-hinted children by calling drivers'
+ * identify methods.
*/
bus_generic_probe(dev);
@@ -496,8 +522,7 @@
}
for (i = 0; i < nchildren; i++) {
- device_t child = children[i];
- struct isa_device *idev = DEVTOISA(child);
+ idev = DEVTOISA(children[i]);
bzero(cfg, sizeof(*cfg));
if (idev->id_config_cb)
@@ -507,16 +532,39 @@
free(cfg, M_TEMP);
/*
- * Next probe all non-pnp devices so that they claim their
- * resources first.
+ * Next, probe all the PnP BIOS devices so they can subsume any
+ * hints.
+ */
+ for (i = 0; i < nchildren; i++) {
+ child = children[i];
+ idev = DEVTOISA(child);
+
+ if (idev->id_order > ISA_ORDER_PNPBIOS)
+ continue;
+ if (!TAILQ_EMPTY(&idev->id_configs) &&
+ !isa_assign_resources(child))
+ continue;
+
+ if (device_probe_and_attach(child) == 0)
+ isa_claim_resources(dev, child);
+ }
+ free(children, M_TEMP);
+
+ /*
+ * Next, enumerate hinted devices and probe all non-pnp devices so
+ * that they claim their resources first.
*/
+ bus_enumerate_hinted_children(dev);
+ if (device_get_children(dev, &children, &nchildren))
+ return;
if (bootverbose)
printf("isa_probe_children: probing non-PnP devices\n");
for (i = 0; i < nchildren; i++) {
- device_t child = children[i];
- struct isa_device *idev = DEVTOISA(child);
+ child = children[i];
+ idev = DEVTOISA(child);
- if (TAILQ_FIRST(&idev->id_configs))
+ if (device_is_attached(child) ||
+ !TAILQ_EMPTY(&idev->id_configs))
continue;
device_probe_and_attach(child);
@@ -528,31 +576,15 @@
if (bootverbose)
printf("isa_probe_children: probing PnP devices\n");
for (i = 0; i < nchildren; i++) {
- device_t child = children[i];
- struct isa_device* idev = DEVTOISA(child);
+ child = children[i];
+ idev = DEVTOISA(child);
- if (!TAILQ_FIRST(&idev->id_configs))
+ if (device_is_attached(child) || TAILQ_EMPTY(&idev->id_configs))
continue;
if (isa_assign_resources(child)) {
- struct resource_list *rl = &idev->id_resources;
- struct resource_list_entry *rle;
-
device_probe_and_attach(child);
-
- /*
- * Claim any unallocated resources to keep other
- * devices from using them.
- */
- STAILQ_FOREACH(rle, rl, link) {
- if (!rle->res) {
- int rid = rle->rid;
- resource_list_alloc(rl, dev, child,
- rle->type,
- &rid,
- 0, ~0, 1, 0);
- }
- }
+ isa_claim_resources(dev, child);
}
}
@@ -580,6 +612,7 @@
resource_list_init(&idev->id_resources);
TAILQ_INIT(&idev->id_configs);
+ idev->id_order = order;
device_set_ivars(child, idev);
@@ -833,23 +866,9 @@
isa_child_detached(device_t dev, device_t child)
{
struct isa_device* idev = DEVTOISA(child);
- struct resource_list *rl = &idev->id_resources;
- struct resource_list_entry *rle;
- if (TAILQ_FIRST(&idev->id_configs)) {
- /*
- * Claim any unallocated resources to keep other
- * devices from using them.
- */
- STAILQ_FOREACH(rle, rl, link) {
- if (!rle->res) {
- int rid = rle->rid;
- resource_list_alloc(rl, dev, child,
- rle->type,
- &rid, 0, ~0, 1, 0);
- }
- }
- }
+ if (TAILQ_FIRST(&idev->id_configs))
+ isa_claim_resources(dev, child);
}
static void
@@ -900,20 +919,8 @@
device_probe_and_attach(child);
- if (TAILQ_FIRST(&idev->id_configs)) {
- /*
- * Claim any unallocated resources to keep other
- * devices from using them.
- */
- STAILQ_FOREACH(rle, rl, link) {
- if (!rle->res) {
- int rid = rle->rid;
- resource_list_alloc(rl, dev, child,
- rle->type,
- &rid, 0, ~0, 1, 0);
- }
- }
- }
+ if (TAILQ_FIRST(&idev->id_configs))
+ isa_claim_resources(dev, child);
}
free(children, M_TEMP);
@@ -1077,6 +1084,8 @@
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_child_pnpinfo_str, isa_child_pnpinfo_str),
DEVMETHOD(bus_child_location_str, isa_child_location_str),
+ DEVMETHOD(bus_hinted_child, isa_hinted_child),
+ DEVMETHOD(bus_hint_device_unit, isa_hint_device_unit),
/* ISA interface */
DEVMETHOD(isa_add_config, isa_add_config),
@@ -1086,11 +1095,7 @@
{ 0, 0 }
};
-driver_t isa_driver = {
- "isa",
- isa_methods,
- 1, /* no softc */
-};
+DEFINE_CLASS_0(isa, isa_driver, isa_methods, 0);
devclass_t isa_devclass;
==== //depot/projects/vimage-commit2/src/sys/isa/isa_common.h#3 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/isa/isa_common.h,v 1.16 2008/11/02 18:48:54 imp Exp $
+ * $FreeBSD: src/sys/isa/isa_common.h,v 1.17 2008/11/18 21:01:54 jhb Exp $
*/
/*
@@ -59,6 +59,7 @@
int id_pnpbios_handle; /* pnp handle, if any */
int id_pnp_csn; /* pnp Card Number */
int id_pnp_ldn; /* pnp Logical device on card */
+ int id_order;
};
#define DEVTOISA(dev) ((struct isa_device *) device_get_ivars(dev))
==== //depot/projects/vimage-commit2/src/sys/isa/isahint.c#2 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/isa/isahint.c,v 1.18 2006/07/08 16:50:10 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/isa/isahint.c,v 1.19 2008/11/18 21:01:54 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -33,10 +33,11 @@
#include <sys/bus.h>
#include <sys/module.h>
#include <isa/isavar.h>
+#include <isa/isa_common.h>
#include <machine/resource.h>
-static void
-isahint_add_device(device_t parent, const char *name, int unit)
+void
+isa_hinted_child(device_t parent, const char *name, int unit)
{
device_t child;
int sensitive, start, count;
@@ -82,43 +83,79 @@
isa_set_configattr(child, (isa_get_configattr(child)|ISACFGATTR_HINTS));
}
-static void
-isahint_identify(driver_t *driver, device_t parent)
+static int
+isa_match_resource_hint(device_t dev, int type, long value)
{
- int i;
- static char buf[] = "isaXXX";
- const char *dname;
- int dunit;
+ struct isa_device* idev = DEVTOISA(dev);
+ struct resource_list *rl = &idev->id_resources;
+ struct resource_list_entry *rle;
- /*
- * Add all devices configured to be attached to parent.
- */
- sprintf(buf, "isa%d", device_get_unit(parent));
- i = 0;
- while (resource_find_match(&i, &dname, &dunit, "at", buf) == 0)
- isahint_add_device(parent, dname, dunit);
-
- /*
- * and isa?
- */
- i = 0;
- while (resource_find_match(&i, &dname, &dunit, "at", "isa") == 0)
- isahint_add_device(parent, dname, dunit);
+ STAILQ_FOREACH(rle, rl, link) {
+ if (rle->type != type)
+ continue;
+ if (rle->start <= value && rle->end >= value)
+ return (1);
+ }
+ return (0);
}
-static device_method_t isahint_methods[] = {
- /* Device interface */
- DEVMETHOD(device_identify, isahint_identify),
+void
+isa_hint_device_unit(device_t bus, device_t child, const char *name, int *unitp)
+{
+ const char *s;
+ long value;
+ int line, matches, unit;
- { 0, 0 }
-};
+ line = 0;
+ for (;;) {
+ if (resource_find_dev(&line, name, &unit, "at", NULL) != 0)
+ break;
-static driver_t isahint_driver = {
- "hint",
- isahint_methods,
- 1, /* no softc */
-};
+ /* Must have an "at" for isa. */
+ resource_string_value(name, unit, "at", &s);
+ if (!(strcmp(s, device_get_nameunit(bus)) == 0 ||
+ strcmp(s, device_get_name(bus)) == 0))
+ continue;
-static devclass_t hint_devclass;
+ /*
+ * Check for matching resources. We must have at least one,
+ * and all resources specified have to match.
+ *
+ * XXX: We may want to revisit this to be more lenient and wire
+ * as long as it gets one match.
+ */
+ matches = 0;
+ if (resource_long_value(name, unit, "port", &value) == 0) {
+ if (isa_match_resource_hint(child, SYS_RES_IOPORT,
+ value))
+ matches++;
+ else
+ continue;
+ }
+ if (resource_long_value(name, unit, "maddr", &value) == 0) {
+ if (isa_match_resource_hint(child, SYS_RES_MEMORY,
+ value))
+ matches++;
+ else
+ continue;
+ }
+ if (resource_long_value(name, unit, "irq", &value) == 0) {
+ if (isa_match_resource_hint(child, SYS_RES_IRQ, value))
+ matches++;
+ else
+ continue;
+ }
+ if (resource_long_value(name, unit, "drq", &value) == 0) {
+ if (isa_match_resource_hint(child, SYS_RES_DRQ, value))
+ matches++;
+ else
+ continue;
+ }
-DRIVER_MODULE(isahint, isa, isahint_driver, hint_devclass, 0, 0);
+ if (matches > 0) {
+ /* We have a winner! */
+ *unitp = unit;
+ break;
+ }
+ }
+}
==== //depot/projects/vimage-commit2/src/sys/isa/isavar.h#4 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/isa/isavar.h,v 1.31 2008/11/02 18:48:54 imp Exp $
+ * $FreeBSD: src/sys/isa/isavar.h,v 1.32 2008/11/18 21:01:54 jhb Exp $
*/
#ifndef _ISA_ISAVAR_H_
@@ -181,6 +181,9 @@
(int)(chan), (uintmax_t)(size)); \
} while (0)
+void isa_hinted_child(device_t parent, const char *name, int unit);
+void isa_hint_device_unit(device_t bus, device_t child, const char *name,
+ int *unitp);
int isab_attach(device_t dev);
#ifdef PC98
==== //depot/projects/vimage-commit2/src/sys/kern/bus_if.m#2 (text+ko) ====
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/sys/kern/bus_if.m,v 1.35 2008/03/20 21:24:32 jhb Exp $
+# $FreeBSD: src/sys/kern/bus_if.m,v 1.36 2008/11/18 21:01:54 jhb Exp $
#
#include <sys/bus.h>
@@ -544,7 +544,7 @@
*/
METHOD void hinted_child {
device_t _dev;
- const char * _dname;
+ const char *_dname;
int _dunit;
};
@@ -558,3 +558,19 @@
device_t _dev;
device_t _child;
} DEFAULT bus_generic_get_dma_tag;
+
+/**
+ * @brief Allow the bus to determine the unit number of a device.
+ *
+ * @param _dev the parent device of @p _child
+ * @param _child the device whose unit is to be wired
+ * @param _name the name of the device's new devclass
+ * @param _unitp a pointer to the device's new unit value
+ */
+METHOD void hint_device_unit {
+ device_t _dev;
+ device_t _child;
+ const char *_name;
+ int *_unitp;
+};
+
==== //depot/projects/vimage-commit2/src/sys/kern/subr_bus.c#5 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/subr_bus.c,v 1.211 2008/11/13 21:46:19 n_hibma Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/subr_bus.c,v 1.212 2008/11/18 21:01:54 jhb Exp $");
#include "opt_bus.h"
@@ -1315,12 +1315,18 @@
* @retval ENOMEM memory allocation failure
*/
static int
-devclass_alloc_unit(devclass_t dc, int *unitp)
+devclass_alloc_unit(devclass_t dc, device_t dev, int *unitp)
{
+ const char *s;
int unit = *unitp;
PDEBUG(("unit %d in devclass %s", unit, DEVCLANAME(dc)));
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list