예제 #1
0
static int
ata_avila_probe(device_t dev)
{
	struct ixp425_softc *sa = device_get_softc(device_get_parent(dev));

	/* XXX any way to check? */
	if (EXP_BUS_READ_4(sa, EXP_TIMING_CS2_OFFSET) != 0)
		device_set_desc_copy(dev, "Gateworks Avila IDE/CF Controller");
	else
		device_set_desc_copy(dev,
		    "ADI Pronghorn Metro IDE/CF Controller");
	return 0;
}
예제 #2
0
파일: virtio_pci.c 프로젝트: 2asoft/freebsd
static int
vtpci_probe(device_t dev)
{
	char desc[36];
	const char *name;

	if (pci_get_vendor(dev) != VIRTIO_PCI_VENDORID)
		return (ENXIO);

	if (pci_get_device(dev) < VIRTIO_PCI_DEVICEID_MIN ||
	    pci_get_device(dev) > VIRTIO_PCI_DEVICEID_MAX)
		return (ENXIO);

	if (pci_get_revid(dev) != VIRTIO_PCI_ABI_VERSION)
		return (ENXIO);

	name = virtio_device_name(pci_get_subdevice(dev));
	if (name == NULL)
		name = "Unknown";

	snprintf(desc, sizeof(desc), "VirtIO PCI %s adapter", name);
	device_set_desc_copy(dev, desc);

	return (BUS_PROBE_DEFAULT);
}
예제 #3
0
static int
ahci_em_probe(device_t dev)
{

	device_set_desc_copy(dev, "AHCI enclosure management bridge");
	return (0);
}
예제 #4
0
/*
 * JMicron chipset support functions
 */
static int
ata_jmicron_probe(device_t dev)
{
    struct ata_pci_controller *ctlr = device_get_softc(dev);
    const struct ata_chip_id *idx;
    static const struct ata_chip_id ids[] =
    {{ ATA_JMB360, 0, 1, 0, ATA_SA300, "JMB360" },
     { ATA_JMB361, 0, 1, 1, ATA_UDMA6, "JMB361" },
     { ATA_JMB362, 0, 2, 0, ATA_SA300, "JMB362" },
     { ATA_JMB363, 0, 2, 1, ATA_UDMA6, "JMB363" },
     { ATA_JMB365, 0, 1, 2, ATA_UDMA6, "JMB365" },
     { ATA_JMB366, 0, 2, 2, ATA_UDMA6, "JMB366" },
     { ATA_JMB368, 0, 0, 1, ATA_UDMA6, "JMB368" },
     { ATA_JMB368_2, 0, 0, 1, ATA_UDMA6, "JMB368" },
     { 0, 0, 0, 0, 0, 0}};
    char buffer[64];

    if (pci_get_vendor(dev) != ATA_JMICRON_ID)
	return ENXIO;

    if (!(idx = ata_match_chip(dev, ids)))
        return ENXIO;

    sprintf(buffer, "JMicron %s %s controller",
	idx->text, ata_mode2str(idx->max_dma));
    device_set_desc_copy(dev, buffer);
    ctlr->chip = idx;
    ctlr->chipinit = ata_jmicron_chipinit;
    return (BUS_PROBE_LOW_PRIORITY);
}
예제 #5
0
static int
mvs_probe(device_t dev)
{
	char buf[64];
	int i;
	uint32_t devid, revid;

	if (!ofw_bus_status_okay(dev))
		return (ENXIO);

	if (!ofw_bus_is_compatible(dev, "mrvl,sata"))
		return (ENXIO);

	soc_id(&devid, &revid);
	for (i = 0; mvs_ids[i].id != 0; i++) {
		if (mvs_ids[i].id == devid &&
		    mvs_ids[i].rev <= revid) {
			snprintf(buf, sizeof(buf), "%s SATA controller",
			    mvs_ids[i].name);
			device_set_desc_copy(dev, buf);
			return (BUS_PROBE_VENDOR);
		}
	}
	return (ENXIO);
}
예제 #6
0
static int
ofw_pcib_probe(device_t dev)
{
	char desc[sizeof("OFW PCIe-PCIe bridge")];
	const char *dtype, *pbdtype;

#define	ISDTYPE(dtype, type)						\
	(((dtype) != NULL) && strcmp((dtype), (type)) == 0)

	if ((pci_get_class(dev) == PCIC_BRIDGE) &&
	    (pci_get_subclass(dev) == PCIS_BRIDGE_PCI) &&
	    ofw_bus_get_node(dev) != 0) {
		dtype = ofw_bus_get_type(dev);
		pbdtype = ofw_bus_get_type(device_get_parent(
		    device_get_parent(dev)));
		snprintf(desc, sizeof(desc), "OFW PCI%s-PCI%s bridge",
		    ISDTYPE(pbdtype, OFW_TYPE_PCIE) ? "e" : "",
		    ISDTYPE(dtype, OFW_TYPE_PCIE) ? "e" : "");
		device_set_desc_copy(dev, desc);
		return (0);
	}

#undef ISDTYPE

	return (ENXIO);
}
예제 #7
0
파일: ichwd.c 프로젝트: JabirTech/Source
/*
 * Look for an ICH LPC interface bridge.  If one is found, register an
 * ichwd device.  There can be only one.
 */
static void
ichwd_identify(driver_t *driver, device_t parent)
{
    struct ichwd_device *id_p;
    device_t ich = NULL;
    device_t dev;
    uint32_t rcba;
    int rc;

    ich = ichwd_find_ich_lpc_bridge(&id_p);
    if (ich == NULL)
        return;

    /* good, add child to bus */
    if ((dev = device_find_child(parent, driver->name, 0)) == NULL)
        dev = BUS_ADD_CHILD(parent, 0, driver->name, 0);

    if (dev == NULL)
        return;

    device_set_desc_copy(dev, id_p->desc);

    if (id_p->version >= 6) {
        /* get RCBA (root complex base address) */
        rcba = pci_read_config(ich, ICH_RCBA, 4);
        rc = bus_set_resource(ich, SYS_RES_MEMORY, 0,
                              (rcba & 0xffffc000) + ICH_GCS_OFFSET, ICH_GCS_SIZE);
        if (rc)
            ichwd_verbose_printf(dev,
                                 "Can not set memory resource for RCBA\n");
    }
}
예제 #8
0
/********************************************************************************
 * Given a detected drive, attach it to the bio interface.
 *
 * This is called from twe_add_unit.
 */
int
twe_attach_drive(struct twe_softc *sc, struct twe_drive *dr)
{
    char	buf[80];
    int		error;

    dr->td_disk =  device_add_child(sc->twe_dev, NULL, -1);
    if (dr->td_disk == NULL) {
	twe_printf(sc, "Cannot add unit\n");
	return (EIO);
    }
    device_set_ivars(dr->td_disk, dr);

    /* 
     * XXX It would make sense to test the online/initialising bits, but they seem to be
     * always set...
     */
    sprintf(buf, "Unit %d, %s, %s",
	    dr->td_twe_unit,
	    twe_describe_code(twe_table_unittype, dr->td_type),
	    twe_describe_code(twe_table_unitstate, dr->td_state & TWE_PARAM_UNITSTATUS_MASK));
    device_set_desc_copy(dr->td_disk, buf);

    if ((error = bus_generic_attach(sc->twe_dev)) != 0) {
	twe_printf(sc, "Cannot attach unit to controller. error = %d\n", error);
	return (EIO);
    }
    return (0);
}
예제 #9
0
static int
at91_cfata_probe(device_t dev)
{

	device_set_desc_copy(dev, "AT91RM9200 CompactFlash controller");
	return (0);
}
예제 #10
0
static int
ata_cbuschannel_probe(device_t dev)
{
    char buffer[32];

    sprintf(buffer, "ATA channel %d", (int)(intptr_t)device_get_ivars(dev));
    device_set_desc_copy(dev, buffer);

    return ata_probe(dev);
}
예제 #11
0
파일: ata-pci.c 프로젝트: coyizumi/cs111
void
ata_set_desc(device_t dev)
{
    struct ata_pci_controller *ctlr = device_get_softc(dev);
    char buffer[128];

    sprintf(buffer, "%s %s %s controller",
            ata_pcivendor2str(dev), ctlr->chip->text, 
            ata_mode2str(ctlr->chip->max_dma));
    device_set_desc_copy(dev, buffer);
}
예제 #12
0
static int
at91_channel_probe(device_t dev)
{
	struct ata_channel *ch = device_get_softc(dev);

	ch->unit = 0;
	ch->flags |= ATA_USE_16BIT | ATA_NO_SLAVE;
	device_set_desc_copy(dev, "ATA channel 0");

	return (ata_probe(dev));
}
예제 #13
0
static int
lebuffer_probe(device_t dev)
{
	const char *name;

	name = ofw_bus_get_name(dev);
	if (strcmp(name, "lebuffer") == 0) {
		device_set_desc_copy(dev, name);
		return (0);
	}
	return (ENXIO);
}
예제 #14
0
static int
tegra_ahci_probe(device_t dev)
{

	if (!ofw_bus_status_okay(dev))
		return (ENXIO);

	if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
		return (ENXIO);

	device_set_desc_copy(dev, "AHCI SATA controller");
	return (BUS_PROBE_DEFAULT);
}
예제 #15
0
static int
dma_probe(device_t dev)
{
	const char *name;

	name = ofw_bus_get_name(dev);
	if (strcmp(name, "espdma") == 0 || strcmp(name, "dma") == 0 ||
	    strcmp(name, "ledma") == 0) {
		device_set_desc_copy(dev, name);
		return (0);
	}
	return (ENXIO);
}
예제 #16
0
/********************************************************************************
 * Match a 3ware Escalade ATA RAID controller.
 */
static int
twe_probe(device_t dev)
{

    debug_called(4);

    if ((pci_get_vendor(dev) == TWE_VENDOR_ID) &&
	((pci_get_device(dev) == TWE_DEVICE_ID) || 
	 (pci_get_device(dev) == TWE_DEVICE_ID_ASIC))) {
	device_set_desc_copy(dev, TWE_DEVICE_NAME ". Driver version " TWE_DRIVER_VERSION_STRING);
	return(BUS_PROBE_DEFAULT);
    }
    return(ENXIO);
}
예제 #17
0
static int
acpi_fujitsu_probe(device_t dev)
{
	char *name;
	char buffer[64];

	name = ACPI_ID_PROBE(device_get_parent(dev), dev, fujitsu_ids);
	if (acpi_disabled("fujitsu") || name == NULL ||
	    device_get_unit(dev) > 1)
		return (ENXIO);

	sprintf(buffer, "Fujitsu Function Hotkeys %s", name);
	device_set_desc_copy(dev, buffer);

	return (0);
}
예제 #18
0
파일: sfxge.c 프로젝트: AhmadTux/freebsd
static int
sfxge_vpd_init(struct sfxge_softc *sc)
{
	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev);
	struct sysctl_oid *vpd_node;
	struct sysctl_oid_list *vpd_list;
	char keyword[3];
	efx_vpd_value_t value;
	int rc;

	if ((rc = efx_vpd_size(sc->enp, &sc->vpd_size)) != 0)
		goto fail;
	sc->vpd_data = malloc(sc->vpd_size, M_SFXGE, M_WAITOK);
	if ((rc = efx_vpd_read(sc->enp, sc->vpd_data, sc->vpd_size)) != 0)
		goto fail2;

	/* Copy ID (product name) into device description, and log it. */
	value.evv_tag = EFX_VPD_ID;
	if (efx_vpd_get(sc->enp, sc->vpd_data, sc->vpd_size, &value) == 0) {
		value.evv_value[value.evv_length] = 0;
		device_set_desc_copy(sc->dev, value.evv_value);
		device_printf(sc->dev, "%s\n", value.evv_value);
	}

	vpd_node = SYSCTL_ADD_NODE(
		ctx, SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)),
		OID_AUTO, "vpd", CTLFLAG_RD, NULL, "Vital Product Data");
	vpd_list = SYSCTL_CHILDREN(vpd_node);

	/* Add sysctls for all expected and any vendor-defined keywords. */
	sfxge_vpd_try_add(sc, vpd_list, EFX_VPD_RO, "PN");
	sfxge_vpd_try_add(sc, vpd_list, EFX_VPD_RO, "EC");
	sfxge_vpd_try_add(sc, vpd_list, EFX_VPD_RO, "SN");
	keyword[0] = 'V';
	keyword[2] = 0;
	for (keyword[1] = '0'; keyword[1] <= '9'; keyword[1]++)
		sfxge_vpd_try_add(sc, vpd_list, EFX_VPD_RO, keyword);
	for (keyword[1] = 'A'; keyword[1] <= 'Z'; keyword[1]++)
		sfxge_vpd_try_add(sc, vpd_list, EFX_VPD_RO, keyword);

	return 0;
	
fail2:
	free(sc->vpd_data, M_SFXGE);
fail:
	return rc;
}
예제 #19
0
static int
ahci_fdt_probe(device_t dev)
{
	struct ahci_controller *ctlr = device_get_softc(dev);
	phandle_t node;

	if (!ofw_bus_status_okay(dev))
		return (ENXIO);

	if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
		return (ENXIO);

	device_set_desc_copy(dev, "AHCI SATA controller");
	node = ofw_bus_get_node(dev);
	ctlr->dma_coherent = OF_hasprop(node, "dma-coherent");
	return (BUS_PROBE_DEFAULT);
}
예제 #20
0
static int
thunder_pem_probe(device_t dev)
{
	uint16_t pci_vendor_id;
	uint16_t pci_device_id;

	pci_vendor_id = pci_get_vendor(dev);
	pci_device_id = pci_get_device(dev);

	if ((pci_vendor_id == THUNDER_PEM_VENDOR_ID) &&
	    (pci_device_id == THUNDER_PEM_DEVICE_ID)) {
		device_set_desc_copy(dev, THUNDER_PEM_DESC);
		return (0);
	}

	return (ENXIO);
}
예제 #21
0
static int
ahci_acpi_probe(device_t dev)
{
	ACPI_HANDLE h;

	if ((h = acpi_get_handle(dev)) == NULL)
		return (ENXIO);

	if (pci_get_class(dev) == PCIC_STORAGE &&
	    pci_get_subclass(dev) == PCIS_STORAGE_SATA &&
	    pci_get_progif(dev) == PCIP_STORAGE_SATA_AHCI_1_0) {
		device_set_desc_copy(dev, "AHCI SATA controller");
		return (BUS_PROBE_DEFAULT);
	}

	return (ENXIO);
}
예제 #22
0
파일: ata-pci.c 프로젝트: coyizumi/cs111
/*
 * generic PCI ATA device probe
 */
int
ata_pci_probe(device_t dev)
{
    struct ata_pci_controller *ctlr = device_get_softc(dev);
    char buffer[64];

    /* is this a storage class device ? */
    if (pci_get_class(dev) != PCIC_STORAGE)
	return (ENXIO);

    /* is this an IDE/ATA type device ? */
    if (pci_get_subclass(dev) != PCIS_STORAGE_IDE)
	return (ENXIO);
    
    sprintf(buffer, "%s ATA controller", ata_pcivendor2str(dev));
    device_set_desc_copy(dev, buffer);
    ctlr->chipinit = ata_generic_chipinit;

    /* we are a low priority handler */
    return (BUS_PROBE_GENERIC);
}
예제 #23
0
static int
acpi_timer_attach(device_t dev)
{
    char desc[40];
    int i, j;

    ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);

    /*
     * If all tests of the counter succeed, use the ACPI-fast method.  If
     * at least one failed, default to using the safe routine, which reads
     * the timer multiple times to get a consistent value before returning.
     */
    j = 0;
    for (i = 0; i < 10; i++)
	j += acpi_timer_test();
    if (j == 10) {
	if (acpi_timer_resolution == 32) {
	    acpi_cputimer.name = "ACPI-fast";
	    acpi_cputimer.count = acpi_timer_get_timecount;
	} else {
	    acpi_cputimer.name = "ACPI-fast24";
	    acpi_cputimer.count = acpi_timer_get_timecount24;
	}
    } else {
	if (acpi_timer_resolution == 32)
	    acpi_cputimer.name = "ACPI-safe";
	else
	    acpi_cputimer.name = "ACPI-safe24";
	acpi_cputimer.count = acpi_timer_get_timecount_safe;
    }

    ksprintf(desc, "%u-bit timer at 3.579545MHz", acpi_timer_resolution);
    device_set_desc_copy(dev, desc);

    cputimer_register(&acpi_cputimer);
    cputimer_select(&acpi_cputimer, 0);

    return (0);
}
예제 #24
0
static int
ixl_probe(device_t dev)
{
	ixl_vendor_info_t *ent;

	u16	pci_vendor_id, pci_device_id;
	u16	pci_subvendor_id, pci_subdevice_id;
	char	device_name[256];

#if 0
	INIT_DEBUGOUT("ixl_probe: begin");
#endif
	pci_vendor_id = pci_get_vendor(dev);
	if (pci_vendor_id != I40E_INTEL_VENDOR_ID)
		return (ENXIO);

	pci_device_id = pci_get_device(dev);
	pci_subvendor_id = pci_get_subvendor(dev);
	pci_subdevice_id = pci_get_subdevice(dev);

	ent = ixl_vendor_info_array;
	while (ent->vendor_id != 0) {
		if ((pci_vendor_id == ent->vendor_id) &&
		    (pci_device_id == ent->device_id) &&

		    ((pci_subvendor_id == ent->subvendor_id) ||
		     (ent->subvendor_id == 0)) &&

		    ((pci_subdevice_id == ent->subdevice_id) ||
		     (ent->subdevice_id == 0))) {
			sprintf(device_name, "%s, Version - %s",
				ixl_strings[ent->index],
				ixl_driver_version);
			device_set_desc_copy(dev, device_name);
			return (BUS_PROBE_DEFAULT);
		}
		ent++;
	}
	return (ENXIO);
}
예제 #25
0
static int
bhnd_pmu_chipc_probe(device_t dev)
{
	struct bhnd_pmu_softc	*sc;
	struct chipc_caps	*ccaps;
	struct chipc_softc	*chipc_sc;
	device_t		 chipc;
	char			 desc[34];
	int			 error;
	uint32_t		 pcaps;
	uint8_t			 rev;

	sc = device_get_softc(dev);

	/* Look for chipc parent */
	chipc = device_get_parent(dev);
	if (device_get_devclass(chipc) != devclass_find("bhnd_chipc"))
		return (ENXIO);

	/* Check the chipc PMU capability flag. */
	ccaps = BHND_CHIPC_GET_CAPS(chipc);
	if (!ccaps->pmu)
		return (ENXIO);

	/* Delegate to common driver implementation */
	if ((error = bhnd_pmu_probe(dev)) > 0)
		return (error);

	/* Fetch PMU capability flags */
	chipc_sc = device_get_softc(chipc);
	pcaps = bhnd_bus_read_4(chipc_sc->core, BHND_PMU_CAP);

	/* Set description */
	rev = BHND_PMU_GET_BITS(pcaps, BHND_PMU_CAP_REV);
	snprintf(desc, sizeof(desc), "Broadcom ChipCommon PMU, rev %hhu", rev);
	device_set_desc_copy(dev, desc);

	return (BUS_PROBE_NOWILDCARD);
}
예제 #26
0
static int
acpi_pci_link_probe(device_t dev)
{
	char descr[28], name[12];

	/*
	 * We explicitly do not check _STA since not all systems set it to
	 * sensible values.
	 */
	if (acpi_disabled("pci_link") ||
	    ACPI_ID_PROBE(device_get_parent(dev), dev, pci_link_ids) == NULL)
		return (ENXIO);

	if (ACPI_SUCCESS(acpi_short_name(acpi_get_handle(dev), name,
	    sizeof(name)))) {
		snprintf(descr, sizeof(descr), "ACPI PCI Link %s", name);
		device_set_desc_copy(dev, descr);
	} else
		device_set_desc(dev, "ACPI PCI Link");
	device_quiet(dev);
	return (0);
}
예제 #27
0
/*
 * HighPoint chipset support functions
 */
static int
ata_highpoint_probe(device_t dev)
{
    struct ata_pci_controller *ctlr = device_get_softc(dev);
    const struct ata_chip_id *idx;
    static const struct ata_chip_id ids[] =
    {{ ATA_HPT374, 0x07, HPT_374, 0,       ATA_UDMA6, "HPT374" },
     { ATA_HPT372, 0x02, HPT_372, 0,       ATA_UDMA6, "HPT372N" },
     { ATA_HPT372, 0x01, HPT_372, 0,       ATA_UDMA6, "HPT372" },
     { ATA_HPT371, 0x01, HPT_372, 0,       ATA_UDMA6, "HPT371" },
     { ATA_HPT366, 0x05, HPT_372, 0,       ATA_UDMA6, "HPT372" },
     { ATA_HPT366, 0x03, HPT_370, 0,       ATA_UDMA5, "HPT370" },
     { ATA_HPT366, 0x02, HPT_366, 0,       ATA_UDMA4, "HPT368" },
     { ATA_HPT366, 0x00, HPT_366, HPT_OLD, ATA_UDMA4, "HPT366" },
     { ATA_HPT302, 0x01, HPT_372, 0,       ATA_UDMA6, "HPT302" },
     { 0, 0, 0, 0, 0, 0}};
    char buffer[64];

    if (pci_get_vendor(dev) != ATA_HIGHPOINT_ID)
        return ENXIO;

    if (!(idx = ata_match_chip(dev, ids)))
	return ENXIO;

    strcpy(buffer, "HighPoint ");
    strcat(buffer, idx->text);
    if (idx->cfg1 == HPT_374) {
	if (pci_get_function(dev) == 0)
	    strcat(buffer, " (channel 0+1)");
	if (pci_get_function(dev) == 1)
	    strcat(buffer, " (channel 2+3)");
    }
    sprintf(buffer, "%s %s controller", buffer, ata_mode2str(idx->max_dma));
    device_set_desc_copy(dev, buffer);
    ctlr->chip = idx;
    ctlr->chipinit = ata_highpoint_chipinit;
    return (BUS_PROBE_LOW_PRIORITY);
}
예제 #28
0
static int
nouveau_probe(device_t kdev)
{
	int vendor;

	if (pci_get_class(kdev) == PCIC_DISPLAY) {
		vendor = pci_get_vendor(kdev);
		if (vendor == 0x10de) {

			const char *ident;
			char model[64];

			if (pci_get_vpd_ident(kdev, &ident) == 0) {
				snprintf(model, 64, "%s", ident);
				device_set_desc_copy(kdev, model);
				DRM_DEBUG("VPD : %s\n", model);
			}

			return drm_probe(kdev, nouveau_pciidlist);
		}
	}
	return ENXIO;
}
예제 #29
0
static int
ata_pcichannel_probe(device_t dev)
{
    struct ata_channel *ch = device_get_softc(dev);
    device_t *children;
    int count, i;
    char buffer[32];

    /* take care of green memory */
    bzero(ch, sizeof(struct ata_channel));

    /* find channel number on this controller */
    device_get_children(device_get_parent(dev), &children, &count);
    for (i = 0; i < count; i++) {
	if (children[i] == dev)
	    ch->unit = i;
    }
    kfree(children, M_TEMP);

    ksprintf(buffer, "ATA channel %d", ch->unit);
    device_set_desc_copy(dev, buffer);

    return ata_probe(dev);
}
예제 #30
0
static int
acpi_timer_probe(device_t dev)
{
    char desc[40];
    int i, j, rid, rtype;

    ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);

    if (dev != acpi_timer_dev)
	return (ENXIO);

    rid = 0;
    rtype = AcpiGbl_FADT.XPmTimerBlock.SpaceId ?
	SYS_RES_IOPORT : SYS_RES_MEMORY;
    acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE);
    if (acpi_timer_reg == NULL) {
	device_printf(dev, "couldn't allocate resource (%s 0x%lx)\n",
	    (rtype == SYS_RES_IOPORT) ? "port" : "mem",
	    (u_long)AcpiGbl_FADT.XPmTimerBlock.Address);
	return (ENXIO);
    }
    acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg);
    acpi_timer_bst = rman_get_bustag(acpi_timer_reg);
    if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) != 0)
	acpi_counter_mask = 0xffffffff;
    else
	acpi_counter_mask = 0x00ffffff;

    /*
     * If all tests of the counter succeed, use the ACPI-fast method.  If
     * at least one failed, default to using the safe routine, which reads
     * the timer multiple times to get a consistent value before returning.
     */
    j = 0;
    for (i = 0; i < 10; i++)
	j += acpi_timer_test();
    if (j == 10) {
	if (acpi_counter_mask == 0xffffffff) {
	    acpi_cputimer.name = "ACPI-fast";
	    acpi_cputimer.count = acpi_timer_get_timecount;
	} else {
	    acpi_cputimer.name = "ACPI-fast24";
	    acpi_cputimer.count = acpi_timer_get_timecount24;
	}
    } else {
	if (acpi_counter_mask == 0xffffffff)
		acpi_cputimer.name = "ACPI-safe";
	else
		acpi_cputimer.name = "ACPI-safe24";
	acpi_cputimer.count = acpi_timer_get_timecount_safe;
    }

    ksprintf(desc, "%d-bit timer at 3.579545MHz",
	    (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) ? 32 : 24);
    device_set_desc_copy(dev, desc);

    cputimer_register(&acpi_cputimer);
    cputimer_select(&acpi_cputimer, 0);
    /* Release the resource, we'll allocate it again during attach. */
    bus_release_resource(dev, rtype, rid, acpi_timer_reg);
    return (0);
}