本文整理汇总了C++中pci_intr_map函数的典型用法代码示例。如果您正苦于以下问题:C++ pci_intr_map函数的具体用法?C++ pci_intr_map怎么用?C++ pci_intr_map使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pci_intr_map函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ral_pci_attach
void
ral_pci_attach(struct device *parent, struct device *self, void *aux)
{
struct ral_pci_softc *psc = (struct ral_pci_softc *)self;
struct rt2560_softc *sc = &psc->sc_sc;
struct pci_attach_args *pa = aux;
const char *intrstr;
pci_intr_handle_t ih;
pcireg_t memtype;
int error;
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_RALINK) {
switch (PCI_PRODUCT(pa->pa_id)) {
case PCI_PRODUCT_RALINK_RT2560:
psc->sc_opns = &ral_rt2560_opns;
break;
case PCI_PRODUCT_RALINK_RT2561:
case PCI_PRODUCT_RALINK_RT2561S:
case PCI_PRODUCT_RALINK_RT2661:
psc->sc_opns = &ral_rt2661_opns;
break;
default:
psc->sc_opns = &ral_rt2860_opns;
break;
}
} else {
/* all other vendors are RT2860 only */
psc->sc_opns = &ral_rt2860_opns;
}
sc->sc_dmat = pa->pa_dmat;
psc->sc_pc = pa->pa_pc;
/* map control/status registers */
memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, RAL_PCI_BAR0);
error = pci_mapreg_map(pa, RAL_PCI_BAR0, memtype, 0, &sc->sc_st,
&sc->sc_sh, NULL, &psc->sc_mapsize, 0);
if (error != 0) {
printf(": can't map mem space\n");
return;
}
if (pci_intr_map(pa, &ih) != 0) {
printf(": can't map interrupt\n");
return;
}
intrstr = pci_intr_string(psc->sc_pc, ih);
psc->sc_ih = pci_intr_establish(psc->sc_pc, ih, IPL_NET,
psc->sc_opns->intr, sc, sc->sc_dev.dv_xname);
if (psc->sc_ih == NULL) {
printf(": can't establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
return;
}
printf(": %s", intrstr);
(*psc->sc_opns->attach)(sc, PCI_PRODUCT(pa->pa_id));
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:60,代码来源:if_ral_pci.c
示例2: amdiic_attach
void
amdiic_attach(struct device *parent, struct device *self, void *aux)
{
struct amdiic_softc *sc = (struct amdiic_softc *)self;
struct pci_attach_args *pa = aux;
struct i2cbus_attach_args iba;
pcireg_t conf;
bus_size_t iosize;
pci_intr_handle_t ih;
const char *intrstr = NULL;
/* Map I/O space */
if (pci_mapreg_map(pa, AMD8111_SMB_BASE, PCI_MAPREG_TYPE_IO, 0,
&sc->sc_iot, &sc->sc_ioh, NULL, &iosize, 0)) {
printf(": can't map i/o space\n");
return;
}
/* Read configuration */
conf = pci_conf_read(pa->pa_pc, pa->pa_tag, AMD8111_SMB_MISC);
DPRINTF((": conf 0x%08x", conf));
sc->sc_poll = 1;
if (conf & AMD8111_SMB_MISC_SCIEN) {
/* No PCI IRQ */
printf(": SCI");
} else if (conf & AMD8111_SMB_MISC_INTEN) {
/* Install interrupt handler */
if (pci_intr_map(pa, &ih) == 0) {
intrstr = pci_intr_string(pa->pa_pc, ih);
sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO,
amdiic_intr, sc, sc->sc_dev.dv_xname);
if (sc->sc_ih != NULL) {
printf(": %s", intrstr);
sc->sc_poll = 0;
}
}
if (sc->sc_poll)
printf(": polling");
}
printf("\n");
/* Attach I2C bus */
rw_init(&sc->sc_i2c_lock, "iiclk");
sc->sc_i2c_tag.ic_cookie = sc;
sc->sc_i2c_tag.ic_acquire_bus = amdiic_i2c_acquire_bus;
sc->sc_i2c_tag.ic_release_bus = amdiic_i2c_release_bus;
sc->sc_i2c_tag.ic_exec = amdiic_i2c_exec;
bzero(&iba, sizeof(iba));
iba.iba_name = "iic";
iba.iba_tag = &sc->sc_i2c_tag;
config_found(self, &iba, iicbus_print);
return;
}
开发者ID:alenichev,项目名称:openbsd-kernel,代码行数:57,代码来源:amdiic.c
示例3: ral_pci_attach
void
ral_pci_attach(device_t parent, device_t self, void *aux)
{
struct ral_pci_softc *psc = device_private(self);
struct rt2560_softc *sc = &psc->sc_sc;
const struct pci_attach_args *pa = aux;
const char *intrstr;
bus_addr_t base;
pci_intr_handle_t ih;
pcireg_t reg;
int error;
pci_aprint_devinfo(pa, NULL);
psc->sc_opns = (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_RALINK_RT2560) ?
&ral_rt2560_opns : &ral_rt2661_opns;
sc->sc_dev = self;
sc->sc_dmat = pa->pa_dmat;
psc->sc_pc = pa->pa_pc;
/* enable the appropriate bits in the PCI CSR */
reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
reg |= PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_MEM_ENABLE;
pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, reg);
/* map control/status registers */
error = pci_mapreg_map(pa, RAL_PCI_BAR0, PCI_MAPREG_TYPE_MEM |
PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_st, &sc->sc_sh, &base,
&psc->sc_mapsize);
if (error != 0) {
aprint_error(": could not map memory space\n");
return;
}
if (pci_intr_map(pa, &ih) != 0) {
aprint_error(": could not map interrupt\n");
return;
}
intrstr = pci_intr_string(psc->sc_pc, ih);
psc->sc_ih = pci_intr_establish(psc->sc_pc, ih, IPL_NET,
psc->sc_opns->intr, sc);
if (psc->sc_ih == NULL) {
aprint_error(": could not establish interrupt");
if (intrstr != NULL)
aprint_error(" at %s", intrstr);
aprint_error("\n");
return;
}
aprint_normal_dev(sc->sc_dev, "interrupting at %s\n", intrstr);
(*psc->sc_opns->attach)(sc, PCI_PRODUCT(pa->pa_id));
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:56,代码来源:if_ral_pci.c
示例4: mfi_pci_attach
void
mfi_pci_attach(struct device *parent, struct device *self, void *aux)
{
struct mfi_softc *sc = (struct mfi_softc *)self;
struct pci_attach_args *pa = aux;
const struct mfi_pci_device *mpd;
pci_intr_handle_t ih;
bus_size_t size;
pcireg_t reg;
int regbar;
mpd = mfi_pci_find_device(pa);
if (mpd == NULL) {
printf(": can't find matching pci device\n");
return;
}
if (mpd->mpd_iop == MFI_IOP_GEN2 || mpd->mpd_iop == MFI_IOP_SKINNY)
regbar = MFI_BAR_GEN2;
else
regbar = MFI_BAR;
reg = pci_mapreg_type(pa->pa_pc, pa->pa_tag, regbar);
if (pci_mapreg_map(pa, regbar, reg, 0,
&sc->sc_iot, &sc->sc_ioh, NULL, &size, MFI_PCI_MEMSIZE)) {
printf(": can't map controller pci space\n");
return;
}
sc->sc_dmat = pa->pa_dmat;
if (pci_intr_map(pa, &ih) != 0) {
printf(": can't map interrupt\n");
goto unmap;
}
printf(": %s\n", pci_intr_string(pa->pa_pc, ih));
sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, mfi_intr, sc,
sc->sc_dev.dv_xname);
if (!sc->sc_ih) {
printf("%s: can't establish interrupt\n", DEVNAME(sc));
goto unmap;
}
if (mfi_attach(sc, mpd->mpd_iop)) {
printf("%s: can't attach\n", DEVNAME(sc));
goto unintr;
}
return;
unintr:
pci_intr_disestablish(pa->pa_pc, sc->sc_ih);
sc->sc_ih = NULL;
unmap:
bus_space_unmap(sc->sc_iot, sc->sc_ioh, size);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:56,代码来源:mfi_pci.c
示例5: pgt_pci_attach
void
pgt_pci_attach(struct device *parent, struct device *self, void *aux)
{
struct pgt_pci_softc *psc = (struct pgt_pci_softc *)self;
struct pgt_softc *sc = &psc->sc_pgt;
struct pci_attach_args *pa = aux;
const char *intrstr = NULL;
pci_intr_handle_t ih;
int error;
sc->sc_dmat = pa->pa_dmat;
psc->sc_pc = pa->pa_pc;
/* remember chipset */
if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTERSIL_ISL3877)
sc->sc_flags |= SC_ISL3877;
/* map control / status registers */
error = pci_mapreg_map(pa, PGT_PCI_BAR0,
PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
&sc->sc_iotag, &sc->sc_iohandle, NULL, &psc->sc_mapsize, 0);
if (error != 0) {
printf(": can't map mem space\n");
return;
}
/* map interrupt */
if (pci_intr_map(pa, &ih) != 0) {
printf(": can't map interrupt\n");
return;
}
/* disable all interrupts */
bus_space_write_4(sc->sc_iotag, sc->sc_iohandle, PGT_REG_INT_EN, 0);
(void)bus_space_read_4(sc->sc_iotag, sc->sc_iohandle, PGT_REG_INT_EN);
DELAY(PGT_WRITEIO_DELAY);
/* establish interrupt */
intrstr = pci_intr_string(psc->sc_pc, ih);
psc->sc_ih = pci_intr_establish(psc->sc_pc, ih, IPL_NET, pgt_intr, sc,
sc->sc_dev.dv_xname);
if (psc->sc_ih == NULL) {
printf(": can't establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
return;
}
printf(": %s\n", intrstr);
if (rootvp == NULL)
mountroothook_establish(pgt_attach, sc);
else
pgt_attach(sc);
}
开发者ID:sofuture,项目名称:bitrig,代码行数:55,代码来源:if_pgt_pci.c
示例6: bwi_pci_attach
void
bwi_pci_attach(struct device *parent, struct device *self, void *aux)
{
struct bwi_pci_softc *psc = (struct bwi_pci_softc *)self;
struct pci_attach_args *pa = aux;
struct bwi_softc *sc = &psc->psc_bwi;
const char *intrstr = NULL;
pci_intr_handle_t ih;
pcireg_t memtype, reg;
sc->sc_dmat = pa->pa_dmat;
psc->psc_pc = pa->pa_pc;
psc->psc_pcitag = pa->pa_tag;
/* map control / status registers */
memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, BWI_PCI_BAR0);
if (pci_mapreg_map(pa, BWI_PCI_BAR0, memtype, 0, &sc->sc_mem_bt,
&sc->sc_mem_bh, NULL, &psc->psc_mapsize, 0)) {
printf(": can't map mem space\n");
return;
}
/* map interrupt */
if (pci_intr_map(pa, &ih) != 0) {
printf(": can't map interrupt\n");
return;
}
/* establish interrupt */
intrstr = pci_intr_string(psc->psc_pc, ih);
psc->psc_ih = pci_intr_establish(psc->psc_pc, ih, IPL_NET, bwi_intr, sc,
sc->sc_dev.dv_xname);
if (psc->psc_ih == NULL) {
printf(": can't establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
return;
}
printf(": %s", intrstr);
/* we need to access PCI config space from the driver */
sc->sc_conf_write = bwi_pci_conf_write;
sc->sc_conf_read = bwi_pci_conf_read;
reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
sc->sc_pci_revid = PCI_REVISION(pa->pa_class);
sc->sc_pci_did = PCI_PRODUCT(pa->pa_id);
sc->sc_pci_subvid = PCI_VENDOR(reg);
sc->sc_pci_subdid = PCI_PRODUCT(reg);
bwi_attach(sc);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:54,代码来源:if_bwi_pci.c
示例7: rtsx_pci_attach
void
rtsx_pci_attach(struct device *parent, struct device *self, void *aux)
{
struct rtsx_pci_softc *sc = (struct rtsx_pci_softc *)self;
struct pci_attach_args *pa = aux;
pci_intr_handle_t ih;
char const *intrstr;
bus_space_tag_t iot;
bus_space_handle_t ioh;
bus_size_t size;
int flags;
if ((pci_conf_read(pa->pa_pc, pa->pa_tag, RTSX_CFG_PCI)
& RTSX_CFG_ASIC) != 0) {
printf("%s: no asic\n", sc->sc.sc_dev.dv_xname);
return;
}
if (pci_intr_map_msi(pa, &ih) && pci_intr_map(pa, &ih)) {
printf(": can't map interrupt\n");
return;
}
intrstr = pci_intr_string(pa->pa_pc, ih);
sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_SDMMC,
rtsx_intr, sc, sc->sc.sc_dev.dv_xname);
if (sc->sc_ih == NULL) {
printf(": can't establish interrupt\n");
return;
}
printf(": %s\n", intrstr);
if (pci_mem_find(pa->pa_pc, pa->pa_tag, RTSX_PCI_BAR,
NULL, NULL, NULL) != 0) {
printf("%s: can't find registers\n", sc->sc.sc_dev.dv_xname);
return;
}
if (pci_mapreg_map(pa, RTSX_PCI_BAR, PCI_MAPREG_TYPE_MEM, 0,
&iot, &ioh, NULL, &size, 0)) {
printf("%s: can't map registers\n", sc->sc.sc_dev.dv_xname);
return;
}
pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_REALTEK_RTS5209)
flags = RTSX_F_5209;
else
flags = RTSX_F_5229;
if (rtsx_attach(&sc->sc, iot, ioh, size, pa->pa_dmat, flags) != 0)
printf("%s: can't initialize chip\n", sc->sc.sc_dev.dv_xname);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:54,代码来源:rtsx_pci.c
示例8: ahci_pci_attach
static void
ahci_pci_attach(device_t parent, device_t self, void *aux)
{
struct pci_attach_args *pa = aux;
struct ahci_pci_softc *psc = device_private(self);
struct ahci_softc *sc = &psc->ah_sc;
bus_size_t size;
char devinfo[256];
const char *intrstr;
pci_intr_handle_t intrhandle;
void *ih;
sc->sc_atac.atac_dev = self;
if (pci_mapreg_map(pa, AHCI_PCI_ABAR,
PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
&sc->sc_ahcit, &sc->sc_ahcih, NULL, &size) != 0) {
aprint_error_dev(self, "can't map ahci registers\n");
return;
}
psc->sc_pc = pa->pa_pc;
psc->sc_pcitag = pa->pa_tag;
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
aprint_naive(": AHCI disk controller\n");
aprint_normal(": %s\n", devinfo);
if (pci_intr_map(pa, &intrhandle) != 0) {
aprint_error("%s: couldn't map interrupt\n", AHCINAME(sc));
return;
}
intrstr = pci_intr_string(pa->pa_pc, intrhandle);
ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_BIO, ahci_intr, sc);
if (ih == NULL) {
aprint_error("%s: couldn't establish interrupt", AHCINAME(sc));
return;
}
aprint_normal("%s: interrupting at %s\n", AHCINAME(sc),
intrstr ? intrstr : "unknown interrupt");
sc->sc_dmat = pa->pa_dmat;
if (PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_RAID) {
AHCIDEBUG_PRINT(("%s: RAID mode\n", AHCINAME(sc)), DEBUG_PROBE);
sc->sc_atac_capflags = ATAC_CAP_RAID;
} else {
AHCIDEBUG_PRINT(("%s: SATA mode\n", AHCINAME(sc)), DEBUG_PROBE);
}
ahci_attach(sc);
if (!pmf_device_register(self, NULL, ahci_pci_resume))
aprint_error_dev(self, "couldn't establish power handler\n");
}
开发者ID:NetBsdDriverProxy,项目名称:NetBsdDriverProxy,代码行数:53,代码来源:ahcisata_pci.c
示例9: ahci_pci_attach
void
ahci_pci_attach(struct device *parent, struct device *self, void *aux)
{
struct ahci_pci_softc *psc = (struct ahci_pci_softc *)self;
struct ahci_softc *sc = &psc->psc_ahci;
struct pci_attach_args *pa = aux;
const struct ahci_device *ad;
pci_intr_handle_t ih;
int mapped = 0;
psc->psc_pc = pa->pa_pc;
psc->psc_tag = pa->pa_tag;
sc->sc_dmat = pa->pa_dmat;
ad = ahci_lookup_device(pa);
if (ad != NULL && ad->ad_attach != NULL) {
if (ad->ad_attach(sc, pa) != 0) {
/* error should be printed by ad_attach */
return;
}
}
if (!(sc->sc_flags & AHCI_F_NO_MSI))
mapped = pci_intr_map_msi(pa, &ih) != 0 ? 0 : 1;
if (!mapped && pci_intr_map(pa, &ih) != 0) {
printf(": unable to map interrupt\n");
return;
}
printf(": %s,", pci_intr_string(pa->pa_pc, ih));
if (ahci_map_regs(psc, pa) != 0) {
/* error already printed by ahci_map_regs */
return;
}
if (ahci_map_intr(psc, pa, ih) != 0) {
/* error already printed by ahci_map_intr */
goto unmap;
}
if (ahci_attach(sc) != 0) {
/* error printed by ahci_attach */
goto unmap;
}
return;
unmap:
ahci_unmap_regs(psc);
return;
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:52,代码来源:ahci_pci.c
示例10: mtd_pci_attach
static void
mtd_pci_attach(device_t parent, device_t self, void *aux)
{
struct pci_attach_args * const pa = aux;
struct mtd_softc * const sc = device_private(self);
pci_intr_handle_t ih;
const char *intrstring = NULL;
bus_space_tag_t iot, memt;
bus_space_handle_t ioh, memh;
int io_valid, mem_valid;
sc->dev = self;
pci_aprint_devinfo(pa, NULL);
io_valid = (pci_mapreg_map(pa, PCI_IO_MAP_REG, PCI_MAPREG_TYPE_IO,
0, &iot, &ioh, NULL, NULL) == 0);
mem_valid = (pci_mapreg_map(pa, PCI_MEM_MAP_REG, PCI_MAPREG_TYPE_MEM
| PCI_MAPREG_MEM_TYPE_32BIT, 0, &memt, &memh,
NULL, NULL) == 0);
if (mem_valid) {
sc->bus_tag = memt;
sc->bus_handle = memh;
} else if (io_valid) {
sc->bus_tag = iot;
sc->bus_handle = ioh;
} else {
aprint_error_dev(sc->dev, "could not map memory or i/o space\n");
return;
}
sc->dma_tag = pa->pa_dmat;
/* Do generic attach. Seems this must be done before setting IRQ */
mtd_config(sc);
if (pci_intr_map(pa, &ih)) {
aprint_error_dev(sc->dev, "could not map interrupt\n");
return;
}
intrstring = pci_intr_string(pa->pa_pc, ih);
if (pci_intr_establish(pa->pa_pc, ih, IPL_NET, mtd_irq_h, sc) == NULL) {
aprint_error_dev(sc->dev, "could not establish interrupt");
if (intrstring != NULL)
aprint_error(" at %s", intrstring);
aprint_error("\n");
return;
} else {
aprint_normal_dev(sc->dev, "using %s for interrupt\n",
intrstring ? intrstring : "unknown interrupt");
}
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:52,代码来源:if_mtd_pci.c
示例11: mtd_pci_attach
static void
mtd_pci_attach(struct device *parent, struct device *self, void *aux)
{
struct mtd_softc *sc = (void *)self;
struct pci_attach_args *pa = aux;
pci_intr_handle_t ih;
const char *intrstr = NULL;
bus_size_t iosize;
#ifndef MTD_USE_IO
if (pci_mapreg_map(pa, MTD_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0,
&sc->bus_tag, &sc->bus_handle, NULL, &iosize, 0)) {
printf(": can't map mem space\n");
return;
}
#else /* MTD_USE_IO */
if (pci_mapreg_map(pa, MTD_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0,
&sc->bus_tag, &sc->bus_handle, NULL, &iosize, 0)) {
printf(": can't map io space\n");
return;
}
#endif /* MTD_USE_IO */
/*
* Allocate our interrupt.
*/
if (pci_intr_map(pa, &ih)) {
printf(": couldn't map interrupt\n");
bus_space_unmap(sc->bus_tag, sc->bus_handle, iosize);
return;
}
intrstr = pci_intr_string(pa->pa_pc, ih);
if (pci_intr_establish(pa->pa_pc, ih, IPL_NET, mtd_irq_h, sc,
self->dv_xname) == NULL) {
printf(": couldn't establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
bus_space_unmap(sc->bus_tag, sc->bus_handle, iosize);
return;
}
printf(": %s", intrstr);
sc->dma_tag = pa->pa_dmat;
mtd_config(sc);
}
开发者ID:MarginC,项目名称:kame,代码行数:47,代码来源:if_mtd_pci.c
示例12: pci_intx_alloc
int
pci_intx_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihpp)
{
pci_intr_handle_t *ihp;
ihp = kmem_alloc(sizeof(*ihp), KM_SLEEP);
if (ihp == NULL)
return ENOMEM;
if (pci_intr_map(pa, ihp)) {
kmem_free(ihp, sizeof(*ihp));
return EINVAL;
}
*ihpp = ihp;
return 0;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:17,代码来源:pci_machdep.c
示例13: an_pci_attach
void
an_pci_attach(struct device *parent, struct device *self, void *aux)
{
struct an_softc *sc = (struct an_softc *)self;
struct pci_attach_args *pa = aux;
pci_intr_handle_t ih;
bus_space_handle_t ioh;
bus_space_tag_t iot = pa->pa_iot;
pci_chipset_tag_t pc = pa->pa_pc;
const char *intrstr;
/* Map the I/O ports. */
if (pci_mapreg_map(pa, AN_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0,
&iot, &ioh, NULL, NULL, 0) != 0) {
printf(": can't map i/o space\n");
return;
}
sc->sc_iot = iot;
sc->sc_ioh = ioh;
/* Map and establish the interrupt. */
if (pci_intr_map(pa, &ih)) {
printf("\n%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
return;
}
intrstr = pci_intr_string(pc, ih);
sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, an_intr, sc,
sc->sc_dev.dv_xname);
if (sc->sc_ih == NULL) {
printf("\n%s: couldn't establish interrupt",
sc->sc_dev.dv_xname);
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
return;
}
printf(": %s", intrstr);
sc->sc_enabled = 1;
an_attach(sc);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:42,代码来源:if_an_pci.c
示例14: genppc_pci_intx_alloc
int
genppc_pci_intx_alloc(const struct pci_attach_args *pa,
pci_intr_handle_t **ihps)
{
pci_intr_handle_t *handle;
int error;
handle = kmem_zalloc(sizeof(*handle), KM_SLEEP);
if (handle == NULL)
return ENOMEM;
error = pci_intr_map(pa, handle);
if (error != 0) {
kmem_free(handle, sizeof(*handle));
return error;
}
*ihps = handle;
return 0;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:20,代码来源:pci_machdep_common.c
示例15: pci_intx_alloc
int
pci_intx_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihp)
{
pci_intr_handle_t *pih;
if (ihp == NULL)
return EINVAL;
pih = kmem_alloc(sizeof(*pih), KM_SLEEP);
if (pih == NULL)
return ENOMEM;
if (pci_intr_map(pa, pih)) {
kmem_free(pih, sizeof(*pih));
return EINVAL;
}
*ihp = pih;
return 0;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:20,代码来源:pci_stub.c
示例16: genppc_pci_intr_alloc
int
genppc_pci_intr_alloc(const struct pci_attach_args *pa,
pci_intr_handle_t **ihps, int *counts, pci_intr_type_t max_type)
{
pci_intr_handle_t *ihp;
if (counts != NULL && counts[PCI_INTR_TYPE_INTX] == 0)
return EINVAL;
ihp = kmem_alloc(sizeof(*ihp), KM_SLEEP);
if (ihp == NULL)
return ENOMEM;
if (pci_intr_map(pa, ihp)) {
kmem_free(ihp, sizeof(*ihp));
return EINVAL;
}
*ihps = ihp;
return 0;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:21,代码来源:pci_machdep_common.c
示例17: pci_intx_alloc
int
pci_intx_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **pih)
{
struct intrsource *isp;
pci_intr_handle_t *handle;
int error;
char intrstr_buf[INTRIDBUF];
const char *intrstr;
handle = kmem_zalloc(sizeof(*handle), KM_SLEEP);
if (handle == NULL) {
aprint_normal("cannot allocate pci_intr_handle_t\n");
return ENOMEM;
}
if (pci_intr_map(pa, handle) != 0) {
aprint_normal("cannot set up pci_intr_handle_t\n");
error = EINVAL;
goto error;
}
intrstr = pci_intr_string(pa->pa_pc, *handle,
intrstr_buf, sizeof(intrstr_buf));
mutex_enter(&cpu_lock);
isp = intr_allocate_io_intrsource(intrstr);
mutex_exit(&cpu_lock);
if (isp == NULL) {
aprint_normal("can't allocate io_intersource\n");
error = ENOMEM;
goto error;
}
*pih = handle;
return 0;
error:
kmem_free(handle, sizeof(*handle));
return error;
}
开发者ID:yazshel,项目名称:netbsd-kernel,代码行数:39,代码来源:pci_intr_machdep.c
示例18: twe_attach
/*
* Attach a supported board.
*
* XXX This doesn't fail gracefully.
*/
static void
twe_attach(device_t parent, device_t self, void *aux)
{
struct pci_attach_args *pa;
struct twe_softc *sc;
pci_chipset_tag_t pc;
pci_intr_handle_t ih;
pcireg_t csr;
const char *intrstr;
int s, size, i, rv, rseg;
size_t max_segs, max_xfer;
bus_dma_segment_t seg;
const struct sysctlnode *node;
struct twe_cmd *tc;
struct twe_ccb *ccb;
sc = device_private(self);
sc->sc_dev = self;
pa = aux;
pc = pa->pa_pc;
sc->sc_dmat = pa->pa_dmat;
SIMPLEQ_INIT(&sc->sc_ccb_queue);
SLIST_INIT(&sc->sc_ccb_freelist);
aprint_naive(": RAID controller\n");
aprint_normal(": 3ware Escalade\n");
if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0,
&sc->sc_iot, &sc->sc_ioh, NULL, NULL)) {
aprint_error_dev(self, "can't map i/o space\n");
return;
}
/* Enable the device. */
csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
csr | PCI_COMMAND_MASTER_ENABLE);
/* Map and establish the interrupt. */
if (pci_intr_map(pa, &ih)) {
aprint_error_dev(self, "can't map interrupt\n");
return;
}
intrstr = pci_intr_string(pc, ih);
sc->sc_ih = pci_intr_establish(pc, ih, IPL_BIO, twe_intr, sc);
if (sc->sc_ih == NULL) {
aprint_error_dev(self, "can't establish interrupt%s%s\n",
(intrstr) ? " at " : "",
(intrstr) ? intrstr : "");
return;
}
if (intrstr != NULL)
aprint_normal_dev(self, "interrupting at %s\n",
intrstr);
/*
* Allocate and initialise the command blocks and CCBs.
*/
size = sizeof(struct twe_cmd) * TWE_MAX_QUEUECNT;
if ((rv = bus_dmamem_alloc(sc->sc_dmat, size, PAGE_SIZE, 0, &seg, 1,
&rseg, BUS_DMA_NOWAIT)) != 0) {
aprint_error_dev(self, "unable to allocate commands, rv = %d\n", rv);
return;
}
if ((rv = bus_dmamem_map(sc->sc_dmat, &seg, rseg, size,
(void **)&sc->sc_cmds,
BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
aprint_error_dev(self, "unable to map commands, rv = %d\n", rv);
return;
}
if ((rv = bus_dmamap_create(sc->sc_dmat, size, size, 1, 0,
BUS_DMA_NOWAIT, &sc->sc_dmamap)) != 0) {
aprint_error_dev(self, "unable to create command DMA map, rv = %d\n", rv);
return;
}
if ((rv = bus_dmamap_load(sc->sc_dmat, sc->sc_dmamap, sc->sc_cmds,
size, NULL, BUS_DMA_NOWAIT)) != 0) {
aprint_error_dev(self, "unable to load command DMA map, rv = %d\n", rv);
return;
}
ccb = malloc(sizeof(*ccb) * TWE_MAX_QUEUECNT, M_DEVBUF, M_NOWAIT);
if (ccb == NULL) {
aprint_error_dev(self, "unable to allocate memory for ccbs\n");
return;
}
sc->sc_cmds_paddr = sc->sc_dmamap->dm_segs[0].ds_addr;
//.........这里部分代码省略.........
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:101,代码来源:twe.c
示例19: nfe_attach
void
nfe_attach(struct device *parent, struct device *self, void *aux)
{
struct nfe_softc *sc = (struct nfe_softc *)self;
struct pci_attach_args *pa = aux;
pci_chipset_tag_t pc = pa->pa_pc;
pci_intr_handle_t ih;
const char *intrstr;
struct ifnet *ifp;
bus_size_t memsize;
pcireg_t memtype;
memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, NFE_PCI_BA);
if (pci_mapreg_map(pa, NFE_PCI_BA, memtype, 0, &sc->sc_memt,
&sc->sc_memh, NULL, &memsize, 0)) {
printf(": can't map mem space\n");
return;
}
if (pci_intr_map(pa, &ih) != 0) {
printf(": can't map interrupt\n");
return;
}
intrstr = pci_intr_string(pc, ih);
sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, nfe_intr, sc,
sc->sc_dev.dv_xname);
if (sc->sc_ih == NULL) {
printf(": could not establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
return;
}
printf(": %s", intrstr);
sc->sc_dmat = pa->pa_dmat;
sc->sc_flags = 0;
switch (PCI_PRODUCT(pa->pa_id)) {
case PCI_PRODUCT_NVIDIA_NFORCE3_LAN2:
case PCI_PRODUCT_NVIDIA_NFORCE3_LAN3:
case PCI_PRODUCT_NVIDIA_NFORCE3_LAN4:
case PCI_PRODUCT_NVIDIA_NFORCE3_LAN5:
sc->sc_flags |= NFE_JUMBO_SUP | NFE_HW_CSUM;
break;
case PCI_PRODUCT_NVIDIA_MCP51_LAN1:
case PCI_PRODUCT_NVIDIA_MCP51_LAN2:
sc->sc_flags |= NFE_40BIT_ADDR | NFE_PWR_MGMT;
break;
case PCI_PRODUCT_NVIDIA_MCP61_LAN1:
case PCI_PRODUCT_NVIDIA_MCP61_LAN2:
case PCI_PRODUCT_NVIDIA_MCP61_LAN3:
case PCI_PRODUCT_NVIDIA_MCP61_LAN4:
case PCI_PRODUCT_NVIDIA_MCP67_LAN1:
case PCI_PRODUCT_NVIDIA_MCP67_LAN2:
case PCI_PRODUCT_NVIDIA_MCP67_LAN3:
case PCI_PRODUCT_NVIDIA_MCP67_LAN4:
case PCI_PRODUCT_NVIDIA_MCP73_LAN1:
case PCI_PRODUCT_NVIDIA_MCP73_LAN2:
case PCI_PRODUCT_NVIDIA_MCP73_LAN3:
case PCI_PRODUCT_NVIDIA_MCP73_LAN4:
sc->sc_flags |= NFE_40BIT_ADDR | NFE_CORRECT_MACADDR |
NFE_PWR_MGMT;
break;
case PCI_PRODUCT_NVIDIA_MCP77_LAN1:
case PCI_PRODUCT_NVIDIA_MCP77_LAN2:
case PCI_PRODUCT_NVIDIA_MCP77_LAN3:
case PCI_PRODUCT_NVIDIA_MCP77_LAN4:
sc->sc_flags |= NFE_40BIT_ADDR | NFE_HW_CSUM |
NFE_CORRECT_MACADDR | NFE_PWR_MGMT;
break;
case PCI_PRODUCT_NVIDIA_MCP79_LAN1:
case PCI_PRODUCT_NVIDIA_MCP79_LAN2:
case PCI_PRODUCT_NVIDIA_MCP79_LAN3:
case PCI_PRODUCT_NVIDIA_MCP79_LAN4:
case PCI_PRODUCT_NVIDIA_MCP89_LAN:
sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM |
NFE_CORRECT_MACADDR | NFE_PWR_MGMT;
break;
case PCI_PRODUCT_NVIDIA_CK804_LAN1:
case PCI_PRODUCT_NVIDIA_CK804_LAN2:
case PCI_PRODUCT_NVIDIA_MCP04_LAN1:
case PCI_PRODUCT_NVIDIA_MCP04_LAN2:
sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM;
break;
case PCI_PRODUCT_NVIDIA_MCP65_LAN1:
case PCI_PRODUCT_NVIDIA_MCP65_LAN2:
case PCI_PRODUCT_NVIDIA_MCP65_LAN3:
case PCI_PRODUCT_NVIDIA_MCP65_LAN4:
sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR |
NFE_CORRECT_MACADDR | NFE_PWR_MGMT;
break;
case PCI_PRODUCT_NVIDIA_MCP55_LAN1:
case PCI_PRODUCT_NVIDIA_MCP55_LAN2:
sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM |
NFE_HW_VLAN | NFE_PWR_MGMT;
break;
}
//.........这里部分代码省略.........
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:101,代码来源:if_nfe.c
示例20: iavc_pci_attach
static void
iavc_pci_attach(device_t parent, device_t self, void *aux)
{
struct iavc_pci_softc *psc = device_private(self);
struct iavc_softc *sc = &psc->sc_iavc;
struct pci_attach_args *pa = aux;
pci_chipset_tag_t pc = pa->pa_pc;
const struct iavc_pci_product *pp;
pci_intr_handle_t ih;
const char *intrstr;
int ret;
char intrbuf[PCI_INTRSTR_LEN];
pp = find_cardname(pa);
if (pp == NULL)
return;
sc->sc_dev = self;
sc->sc_t1 = 0;
sc->sc_dma = 0;
sc->dmat = pa->pa_dmat;
if (pci_mapreg_map(pa, IAVC_PCI_IOBA, PCI_MAPREG_TYPE_IO, 0,
&sc->sc_io_bt, &sc->sc_io_bh, &psc->io_base, &psc->io_size)) {
aprint_error(": unable to map i/o registers\n");
return;
}
if (pci_mapreg_map(pa, IAVC_PCI_MMBA, PCI_MAPREG_TYPE_MEM, 0,
&sc->sc_mem_bt, &sc->sc_mem_bh, &psc->mem_base, &psc->mem_size)) {
aprint_error(": unable to map mem registers\n");
return;
}
aprint_normal(": %s\n", pp->name);
iavc_b1dma_reset(sc);
if (pp->npp_product == PCI_PRODUCT_AVM_T1) {
aprint_error_dev(sc->sc_dev, "sorry, PRI not yet supported\n");
return;
#if 0
sc->sc_capi.card_type = CARD_TYPEC_AVM_T1_PCI;
sc->sc_capi.sc_nbch = NBCH_PRI;
ret = iavc_t1_detect(sc);
if (ret) {
if (ret < 6) {
aprint_error_dev(sc->sc_dev, "no card detected?\n");
} else {
aprint_error_dev(sc->sc_dev, "black box not on\n");
}
return;
} else {
sc->sc_dma = 1;
sc->sc_t1 = 1;
}
#endif
} else if (pp->npp_product == PCI_PRODUCT_AVM_B1) {
sc->sc_capi.card_type = CARD_TYPEC_AVM_B1_PCI;
sc->sc_capi.sc_nbch = NBCH_BRI;
ret = iavc_b1dma_detect(sc);
if (ret) {
ret = iavc_b1_detect(sc);
if (ret) {
aprint_error_dev(sc->sc_dev, "no card detected?\n");
return;
}
} else {
sc->sc_dma = 1;
}
}
if (sc->sc_dma)
iavc_b1dma_reset(sc);
#if 0
/*
* XXX: should really be done this way, but this freezes the card
*/
if (sc->sc_t1)
iavc_t1_reset(sc);
else
iavc_b1_reset(sc);
#endif
if (pci_intr_map(pa, &ih)) {
aprint_error_dev(sc->sc_dev, "couldn't map interrupt\n");
return;
}
intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf));
psc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, iavc_pci_intr, psc);
if (psc->sc_ih == NULL) {
aprint_error_dev(sc->sc_dev, "couldn't establish interrupt");
if (intrstr != NULL)
aprint_error(" at %s", intrstr);
aprint_error("\n");
return;
}
psc->sc_pc = pc;
//.........这里部分代码省略.........
开发者ID:eyberg,项目名称:rumpkernel-netbsd-src,代码行数:101,代码来源:iavc_pci.c
注:本文中的pci_intr_map函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论