Ejemplo n.º 1
0
static int
bt_pci_probe(device_t dev)
{
	switch (pci_get_devid(dev)) {
		case PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER:
		case PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC:
		{
			struct bt_softc   *bt = device_get_softc(dev);
			pci_info_data_t pci_info;
			int error;

			error = bt_pci_alloc_resources(dev);
			if (error)
				return (error);

			/*
			 * Determine if an ISA compatible I/O port has been
			 * enabled.  If so, record the port so it will not
			 * be probed by our ISA probe.  If the PCI I/O port
			 * was not set to the compatibility port, disable it.
			 */
			error = bt_cmd(bt, BOP_INQUIRE_PCI_INFO,
				       /*param*/NULL, /*paramlen*/0,
				       (u_int8_t*)&pci_info, sizeof(pci_info),
				       DEFAULT_CMD_TIMEOUT);
			if (error == 0
			 && pci_info.io_port < BIO_DISABLED) {
				bt_mark_probed_bio(pci_info.io_port);
				if (rman_get_start(bt->port) !=
				    bt_iop_from_bio(pci_info.io_port)) {
					u_int8_t new_addr;

					new_addr = BIO_DISABLED;
					bt_cmd(bt, BOP_MODIFY_IO_ADDR,
					       /*param*/&new_addr,
					       /*paramlen*/1, /*reply_buf*/NULL,
					       /*reply_len*/0,
					       DEFAULT_CMD_TIMEOUT);
				}
			}
			bt_pci_release_resources(dev);
			device_set_desc(dev, "Buslogic Multi-Master SCSI Host Adapter");
			return (0);
		}
		default:
			break;
	}

	return (ENXIO);
}
Ejemplo n.º 2
0
/*
 * Check if the device can be found at the port given
 * and if so, set it up ready for further work
 * as an argument, takes the isa_device structure from
 * autoconf.c
 */
static int
bt_isa_probe(device_t dev)
{
	/*
	 * find unit and check we have that many defined
	 */
	int	port_index;
        int	max_port_index;

	/* No pnp support */
	if (isa_get_vendorid(dev))
		return (ENXIO);

	port_index = 0;
	max_port_index = BT_NUM_ISAPORTS - 1;
	/*
	 * Bound our board search if the user has
	 * specified an exact port.
	 */
	bt_find_probe_range(isa_get_port(dev), &port_index, &max_port_index);

	if (port_index < 0)
		return (ENXIO);

	/* Attempt to find an adapter */
	for (;port_index <= max_port_index; port_index++) {
		struct bt_probe_info info;
		u_int ioport;

		ioport = bt_iop_from_bio(port_index);

		/*
		 * Ensure this port has not already been claimed already
		 * by a PCI, EISA or ISA adapter.
		 */
		if (bt_check_probed_iop(ioport) != 0)
			continue;

		/* Initialise the softc for use during probing */
		if (bt_isa_alloc_resources(dev, ioport,
					   ioport + BT_NREGS -1) != 0)
			continue;

		/* We're going to attempt to probe it now, so mark it probed */
		bt_mark_probed_bio(port_index);

		if (bt_port_probe(dev, &info) != 0) {
			if (bootverbose)
				kprintf("bt_isa_probe: Probe failed at 0x%x\n",
				       ioport);
			bt_isa_release_resources(dev);
			continue;
		}

		bt_isa_release_resources(dev);

		bus_set_resource(dev, SYS_RES_DRQ, 0, info.drq, 1, -1);
		bus_set_resource(dev, SYS_RES_IRQ, 0, info.irq, 1,
		    machintr_legacy_intr_cpuid(info.irq));

		return (0);
	}

	return (ENXIO);
}