siop_pci_attach_common(sc, pa) struct siop_pci_softc *sc;
siop_pci_attach_common(pci_sc, siop_sc, pa, intr) struct siop_pci_common_softc *pci_sc; struct siop_common_softc *siop_sc;
siop_pci_attach_common(sc, pa)	struct siop_pci_softc *sc;	struct pci_attach_args *pa;{	pci_chipset_tag_t pc = pa->pa_pc;	pcitag_t tag = pa->pa_tag;    	const char *intrstr;	pci_intr_handle_t intrhandle;	bus_space_tag_t iot, memt;	bus_space_handle_t ioh, memh;	pcireg_t memtype;	int memh_valid, ioh_valid;	bus_addr_t ioaddr, memaddr;	sc->sc_pp = siop_lookup_product(pa->pa_id, PCI_REVISION(pa->pa_class));	if (sc->sc_pp == NULL) {		printf("siop: broken match/attach!\n");		return 0;	}	/* copy interesting infos about the chip */	sc->siop.features = sc->sc_pp->features;	sc->siop.maxburst = sc->sc_pp->maxburst;	sc->siop.maxoff = sc->sc_pp->maxoff;	sc->siop.clock_div = sc->sc_pp->clock_div;	sc->siop.scf_index = sc->sc_pp->scf_index;	sc->siop.ram_size = sc->sc_pp->ram_size;	sc->siop.sc_reset = siop_pci_reset;	sc->sc_pc = pc;	sc->sc_tag = tag;	sc->siop.sc_dmat = pa->pa_dmat;	memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, 0x14);	switch (memtype) {	case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:	case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:		memh_valid = (pci_mapreg_map(pa, 0x14, memtype, 0,		    &memt, &memh, &memaddr, NULL, 0) == 0);		break;	default:		memh_valid = 0;	}	ioh_valid = (pci_mapreg_map(pa, 0x10, PCI_MAPREG_TYPE_IO, 0,	    &iot, &ioh, &ioaddr, NULL, 0) == 0);	if (memh_valid) {		sc->siop.sc_rt = memt;		sc->siop.sc_rh = memh;		sc->siop.sc_raddr = memaddr;	} else if (ioh_valid) {		sc->siop.sc_rt = iot;		sc->siop.sc_rh = ioh;		sc->siop.sc_raddr = ioaddr;	} else {		printf("\n%s: unable to map device registers\n",		    sc->siop.sc_dev.dv_xname);		return 0;	}	if (sc->siop.features & SF_CHIP_RAM) {		int bar;		switch (memtype) {		case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:			bar = 0x18;			break;		case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:			bar = 0x1c;			break;		}		if (pci_mapreg_map(pa, bar, memtype, 0,                    &sc->siop.sc_ramt, &sc->siop.sc_ramh,		    &sc->siop.sc_scriptaddr, NULL, 0) != 0)			sc->siop.features &= ~SF_CHIP_RAM;	}	if (pci_intr_map(pa, &intrhandle)) {		printf("\n%s: couldn't map interrupt\n",		    sc->siop.sc_dev.dv_xname);		return 0;	}	intrstr = pci_intr_string(pa->pa_pc, intrhandle);	sc->sc_ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_BIO,	    siop_intr, &sc->siop, sc->siop.sc_dev.dv_xname);	if (sc->sc_ih == NULL) {		printf("\n%s: couldn't establish interrupt",		    sc->siop.sc_dev.dv_xname);		if (intrstr != NULL)			printf(" at %s", intrstr);		printf("\n");		return 0;	}	printf(": %s", (intrstr != NULL) ? intrstr : "irq ?");	if (sc->siop.features & SF_CHIP_RAM)		printf(", has RAM");	printf("\n");	return 1;}