static int
ncvprobe(DEVPORT_PDEVICE devi)
{
	int rv;
	struct ncv_softc *sc = device_get_softc(devi);
	u_int32_t flags = DEVPORT_PDEVFLAGS(devi);

#if defined(__FreeBSD__) && __FreeBSD_version >= 400001
	rv = ncvprobesubr(rman_get_bustag(sc->port_res),
			  rman_get_bushandle(sc->port_res),
			  flags, NCV_HOSTID);
#else
	bus_addr_t offset = 0;
	u_int iobase = DEVPORT_PDEVIOBASE(devi);

	if(flags & KME_KXLC004_01)
		offset = OFFSET_KME_KXLC004_01;

	rv = ncvprobesubr(I386_BUS_SPACE_IO,
			  iobase + offset,
			  flags, NCV_HOSTID);
#endif

	return rv;
}
static int
ncvattach(DEVPORT_PDEVICE devi)
{
	struct ncv_softc *sc;
	struct scsi_low_softc *slp;
	u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
#if defined(__FreeBSD__) && __FreeBSD_version < 400001
	int unit = DEVPORT_PDEVUNIT(devi);
	bus_addr_t offset = 0;
	u_int iobase = DEVPORT_PDEVIOBASE(devi);
#endif
	char dvname[16]; /* SCSI_LOW_DVNAME_LEN */

	strcpy(dvname, "ncv");

#if defined(__FreeBSD__) && __FreeBSD_version < 400001
	if (unit >= NNCV)
	{
		printf("%s: unit number too high\n", dvname);
		return (0);
	}

	if (iobase == 0)
	{
		printf("%s: no ioaddr is given\n", dvname);
		return (0);
	}

	if(flags & KME_KXLC004_01)
		offset = OFFSET_KME_KXLC004_01;
#endif

	sc = DEVPORT_PDEVALLOC_SOFTC(devi);
	if (sc == NULL) {
		return(0);
	}

	slp = &sc->sc_sclow;
#if defined(__FreeBSD__) && __FreeBSD_version >= 400001
	slp->sl_dev = devi;
	sc->sc_iot = rman_get_bustag(sc->port_res);
	sc->sc_ioh = rman_get_bushandle(sc->port_res);
#else
	bzero(sc, sizeof(struct ncv_softc));
	strcpy(slp->sl_dev.dv_xname, dvname);
	slp->sl_dev.dv_unit = unit;
	sc->sc_iot = I386_BUS_SPACE_IO;
	sc->sc_ioh = iobase + offset;
#endif

	slp->sl_hostid = NCV_HOSTID;
	slp->sl_cfgflags = flags;

	ncvattachsubr(sc);

	sc->sc_ih = ncvintr;

	return(NCVIOSZ);
}
static	int
nspattach(DEVPORT_PDEVICE devi)
{
    struct nsp_softc *sc;
    struct scsi_low_softc *slp;
    u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
    u_int	iobase = DEVPORT_PDEVIOBASE(devi);
    intrmask_t s;
    char	dvname[16];

    strcpy(dvname,"nsp");

    if (iobase == 0) {
        printf("%s: no ioaddr is given\n", dvname);
        return (0);
    }

    sc = DEVPORT_PDEVALLOC_SOFTC(devi);
    if (sc == NULL)
        return (0);

    slp = &sc->sc_sclow;
    slp->sl_dev = devi;
    sc->sc_iot = rman_get_bustag(sc->port_res);
    sc->sc_ioh = rman_get_bushandle(sc->port_res);

    if (sc->mem_res == NULL) {
        printf("WARNING: CANNOT GET Memory RESOURCE going PIO mode");
        flags |= PIO_MODE;
    }

    if ((flags & PIO_MODE) == 0) {
        sc->sc_memt = rman_get_bustag(sc->mem_res);
        sc->sc_memh = rman_get_bushandle(sc->mem_res);
    } else {
        sc->sc_memh = 0;
    }
    /* slp->sl_irq = devi->pd_irq; */
    sc->sc_iclkdiv = CLKDIVR_20M;
    sc->sc_clkdiv = CLKDIVR_40M;

    slp->sl_hostid = NSP_HOSTID;
    slp->sl_cfgflags = flags;

    s = splcam();
    nspattachsubr(sc);
    splx(s);

    return(NSP_IOSIZE);
}
static int
ncv_alloc_resource(DEVPORT_PDEVICE dev)
{
	struct ncv_softc	*sc = device_get_softc(dev);
	u_int32_t		flags = DEVPORT_PDEVFLAGS(dev);
	u_int			iobase = DEVPORT_PDEVIOBASE(dev);
	u_long			maddr, msize;
	int			error;
	bus_addr_t		offset = 0;

	if(flags & KME_KXLC004_01)
		offset = OFFSET_KME_KXLC004_01;

	sc->port_rid = 0;
	sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
					  iobase+offset, ~0, NCVIOSZ, RF_ACTIVE);
	if (sc->port_res == NULL) {
		ncv_release_resource(dev);
		return(ENOMEM);
	}

	sc->irq_rid = 0;
	sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
					 0, ~0, 1, RF_ACTIVE);
	if (sc->irq_res == NULL) {
		ncv_release_resource(dev);
		return(ENOMEM);
	}

	error = bus_get_resource(dev, SYS_RES_MEMORY, 0, &maddr, &msize);
	if (error) {
		return(0);	/* XXX */
	}

	/* no need to allocate memory if not configured */
	if (maddr == 0 || msize == 0) {
		return(0);
	}

	sc->mem_rid = 0;
	sc->mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->mem_rid,
					 0, ~0, msize, RF_ACTIVE);
	if (sc->mem_res == NULL) {
		ncv_release_resource(dev);
		return(ENOMEM);
	}

	return(0);
}
static	int
nspattach(DEVPORT_PDEVICE devi)
{
	struct nsp_softc *sc;
	struct scsi_low_softc *slp;
	u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
	u_int	iobase = DEVPORT_PDEVIOBASE(devi);
	char	dvname[16];

	strcpy(dvname,"nsp");

	if (iobase == 0)
	{
		kprintf("%s: no ioaddr is given\n", dvname);
		return (0);
	}

	sc = DEVPORT_PDEVALLOC_SOFTC(devi);
	if (sc == NULL) {
		return (0);
	}

	slp = &sc->sc_sclow;
	slp->sl_dev = devi;
	sc->sc_iot = rman_get_bustag(sc->port_res);
	sc->sc_ioh = rman_get_bushandle(sc->port_res);

	if((flags & PIO_MODE) == 0) {
		sc->sc_memt = rman_get_bustag(sc->mem_res);
		sc->sc_memh = rman_get_bushandle(sc->mem_res);
	} else {
		sc->sc_memh = 0;
	}
	/* slp->sl_irq = devi->pd_irq; */
	sc->sc_iclkdiv = CLKDIVR_20M;
	sc->sc_clkdiv = CLKDIVR_40M;

	slp->sl_hostid = NSP_HOSTID;
	slp->sl_cfgflags = flags;

	crit_enter();
	nspattachsubr(sc);
	crit_exit();

	return(NSP_IOSIZE);
}
Beispiel #6
0
static	int
stgattach(DEVPORT_PDEVICE devi)
{
	struct stg_softc *sc;
	struct scsi_low_softc *slp;
	u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
	u_int iobase = DEVPORT_PDEVIOBASE(devi);
	char	dvname[16];

	strcpy(dvname,"stg");

	if (iobase == 0)
	{
		kprintf("%s: no ioaddr is given\n", dvname);
		return (0);
	}

	sc = DEVPORT_PDEVALLOC_SOFTC(devi);
	if (sc == NULL) {
		return(0);
	}

	slp = &sc->sc_sclow;
	slp->sl_dev = devi;
	sc->sc_iot = rman_get_bustag(sc->port_res);
	sc->sc_ioh = rman_get_bushandle(sc->port_res);

	slp->sl_hostid = STG_HOSTID;
	slp->sl_cfgflags = flags;

	crit_enter();
	stgattachsubr(sc);
	crit_exit();

	return(STGIOSZ);
}