Exemple #1
0
static int
bt_mca_probe (device_t dev)
{
	const char *		desc;
	mca_id_t		id = mca_get_id(dev);
	struct bt_probe_info	info;
	u_int32_t		iobase = 0;
	u_int32_t		iosize = 0;
	u_int8_t		drq = 0;
	u_int8_t		irq = 0;
	u_int8_t		pos;
	int			result;

	desc = mca_match_id(id, bt_mca_devs);
	if (!desc)
		return (ENXIO);
	device_set_desc(dev, desc);

	pos = (mca_pos_read(dev, BT_MCA_IOPORT_POS1) & BT_MCA_IOPORT_MASK1) |
	      (mca_pos_read(dev, BT_MCA_IOPORT_POS2) & BT_MCA_IOPORT_MASK2);
	iobase = BT_MCA_IOPORT(pos);
	iosize = BT_MCA_IOPORT_SIZE;

	pos = mca_pos_read(dev, BT_MCA_DRQ_POS);
	drq = BT_MCA_DRQ(pos);

	pos = mca_pos_read(dev, BT_MCA_IRQ_POS);
	irq = BT_MCA_IRQ(pos);

	bt_mark_probed_iop(iobase);

	mca_add_iospace(dev, iobase, iosize);

	/* And allocate them */
	bt_mca_alloc_resources(dev, BT_MCA_PROBE);
			
	if (bt_port_probe(dev, &info) != 0) {
		printf("bt_mca_probe: Probe failed for "
		       "card at slot %d\n", mca_get_slot(dev) + 1);
		result = ENXIO;
	} else {	       
		mca_add_drq(dev, drq);
		mca_add_irq(dev, irq);
		result = BUS_PROBE_DEFAULT;    
	}	       
	bt_mca_release_resources(dev);

	return (result);
}
Exemple #2
0
static int
bt_eisa_probe(device_t dev)
{
	const char *desc;
	u_long iobase;
	struct bt_probe_info info;
	u_long port;
	u_long iosize;
	u_int  ioconf;
	int    result;
	int    shared;

	desc = bt_match(eisa_get_id(dev));
	if (!desc)
		return (ENXIO);
	device_set_desc(dev, desc);

	iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE); 
	if (eisa_get_id(dev) == EISA_DEVICE_ID_AMI_4801) {
		u_int ioconf1;

		iobase += AMI_EISA_SLOT_OFFSET;
		iosize = AMI_EISA_IOSIZE;
		ioconf1 = inb(iobase + AMI_EISA_IOCONF1);
		/* Determine "ISA" I/O port */
		switch (ioconf1 & AMI_PORTADDR) {
		case AMI_PORT_330:
			port = 0x330;
			break;
		case AMI_PORT_334:
			port = 0x334;
			break;
		case AMI_PORT_230:
			port = 0x230;
			break;
		case AMI_PORT_234:
			port = 0x234;
			break;
		case AMI_PORT_134:
			port = 0x134;
			break;
		case AMI_PORT_130:
			port = 0x130;
			break;
		default:
			/* Disabled */
			printf("bt: AMI EISA Adapter at "
			       "slot %d has a disabled I/O "
			       "port.  Cannot attach.\n",
			       eisa_get_slot(dev));
			return (ENXIO);
		}
		shared = (inb(iobase + AMI_EISA_IOCONF1) & AMI_IRQ_LEVEL) ?
				EISA_TRIGGER_LEVEL : EISA_TRIGGER_EDGE;
	} else {
		iobase += BT_EISA_SLOT_OFFSET;
		iosize = BT_EISA_IOSIZE;

		ioconf = inb(iobase + EISA_IOCONF);
		/* Determine "ISA" I/O port */
		switch (ioconf & PORTADDR) {
		case PORT_330:
			port = 0x330;
			break;
		case PORT_334:
			port = 0x334;
			break;
		case PORT_230:
			port = 0x230;
			break;
		case PORT_234:
			port = 0x234;
			break;
		case PORT_130:
			port = 0x130;
			break;
		case PORT_134:
			port = 0x134;
			break;
		default:
			/* Disabled */
			printf("bt: Buslogic EISA Adapter at "
			       "slot %d has a disabled I/O "
			       "port.  Cannot attach.\n",
			       eisa_get_slot(dev));
			return (ENXIO);
		}
		shared = (inb(iobase + EISA_IRQ_TYPE) & LEVEL) ?
				EISA_TRIGGER_LEVEL : EISA_TRIGGER_EDGE;
	}
	bt_mark_probed_iop(port);

	/* Tell parent where our resources are going to be */
	eisa_add_iospace(dev, iobase, iosize, RESVADDR_NONE);
	eisa_add_iospace(dev, port, BT_IOSIZE, RESVADDR_NONE);

	/* And allocate them */
	bt_eisa_alloc_resources(dev);

	if (bt_port_probe(dev, &info) != 0) {
		printf("bt_eisa_probe: Probe failed for "
		       "card at slot 0x%x\n", eisa_get_slot(dev));
		result = ENXIO;
	} else {
		eisa_add_intr(dev, info.irq, shared);
		result = 0;
	}
	bt_eisa_release_resources(dev);

	return (result);
}