/* ARGSUSED */ int osiop_pcctwo_match(device_t parent, cfdata_t cf, void *args) { struct pcctwo_attach_args *pa; bus_space_handle_t bsh; int rv; pa = args; if (strcmp(pa->pa_name, osiop_cd.cd_name)) return (0); /* * See if the SCSI controller is responding. */ if (bus_space_map(pa->pa_bust, pa->pa_offset, OSIOP_NREGS, 0, &bsh)) return (0); rv = bus_space_peek_1(pa->pa_bust, bsh, OSIOP_CTEST8, NULL); bus_space_unmap(pa->pa_bust, bsh, OSIOP_NREGS); if (rv) return (0); pa->pa_ipl = cf->pcctwocf_ipl; return (1); }
static int bwtwomatch_any(struct device *parent, struct cfdata *cf, void *aux) { struct mainbus_attach_args *ma = aux; bus_space_handle_t bh; int matched; /* Make sure there is something there... */ if (bus_space_map(ma->ma_bustag, ma->ma_paddr + BWREG_REG, sizeof(struct bwtworeg), 0, &bh)) return (0); matched = (bus_space_peek_1(ma->ma_bustag, bh, 0, NULL) == 0); bus_space_unmap(ma->ma_bustag, bh, sizeof(struct bwtworeg)); return (matched); }
uint32_t ofw_pci_read_config_common(device_t dev, u_int regmax, u_long offset, u_int bus, u_int slot, u_int func, u_int reg, int width) { struct ofw_pci_softc *sc; bus_space_handle_t bh; uint32_t r, wrd; int i; uint16_t shrt; uint8_t byte; sc = device_get_softc(dev); if (bus < sc->sc_pci_secbus || bus > sc->sc_pci_subbus || slot > PCI_SLOTMAX || func > PCI_FUNCMAX || reg > regmax) return (-1); bh = sc->sc_pci_bh[OFW_PCI_CS_CONFIG]; switch (width) { case 1: i = bus_space_peek_1(sc->sc_pci_cfgt, bh, offset, &byte); r = byte; break; case 2: i = bus_space_peek_2(sc->sc_pci_cfgt, bh, offset, &shrt); r = shrt; break; case 4: i = bus_space_peek_4(sc->sc_pci_cfgt, bh, offset, &wrd); r = wrd; break; default: panic("%s: bad width %d", __func__, width); /* NOTREACHED */ } if (i) { #ifdef OFW_PCI_DEBUG printf("%s: read data error reading: %d.%d.%d: 0x%x\n", __func__, bus, slot, func, reg); #endif r = -1; } return (r); }
static int tod_obio_match(device_t parent, cfdata_t cf, void *args) { struct obio_attach_args *oba = args; bus_space_handle_t bh; int matched; /* This driver only supports one unit. */ if (tod_attached) return 0; /* Make sure there is something there... */ if (bus_space_map(oba->oba_bustag, oba->oba_paddr, MM58167REG_BANK_SZ, 0, &bh)) return 0; matched = (bus_space_peek_1(oba->oba_bustag, bh, 0, NULL) == 0); bus_space_unmap(oba->oba_bustag, bh, MM58167REG_BANK_SZ); return matched; }