当前位置: 首页>>代码示例>>C++>>正文


C++ rman_get_virtual函数代码示例

本文整理汇总了C++中rman_get_virtual函数的典型用法代码示例。如果您正苦于以下问题:C++ rman_get_virtual函数的具体用法?C++ rman_get_virtual怎么用?C++ rman_get_virtual使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rman_get_virtual函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: c4iw_mmap

static int c4iw_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
{
	int len = vma->vm_end - vma->vm_start;
	u32 key = vma->vm_pgoff << PAGE_SHIFT;
	struct c4iw_rdev *rdev;
	int ret = 0;
	struct c4iw_mm_entry *mm;
	struct c4iw_ucontext *ucontext;
	u64 addr, paddr;

	u64 va_regs_res = 0, va_udbs_res = 0;
	u64 len_regs_res = 0, len_udbs_res = 0;

	CTR3(KTR_IW_CXGBE, "%s:1 ctx %p vma %p", __func__, context, vma);

	CTR4(KTR_IW_CXGBE, "%s:1a pgoff 0x%lx key 0x%x len %d", __func__,
	    vma->vm_pgoff, key, len);

	if (vma->vm_start & (PAGE_SIZE-1)) {
		CTR3(KTR_IW_CXGBE, "%s:2 unaligned vm_start %u vma %p",
		    __func__, vma->vm_start, vma);
		return -EINVAL;
	}

	rdev = &(to_c4iw_dev(context->device)->rdev);
	ucontext = to_c4iw_ucontext(context);

	mm = remove_mmap(ucontext, key, len);
	if (!mm) {
		CTR4(KTR_IW_CXGBE, "%s:3 ucontext %p key %u len %u", __func__,
		    ucontext, key, len);
		return -EINVAL;
	}
	addr = mm->addr;
	kfree(mm);

	va_regs_res = (u64)rman_get_virtual(rdev->adap->regs_res);
	len_regs_res = (u64)rman_get_size(rdev->adap->regs_res);
	va_udbs_res = (u64)rman_get_virtual(rdev->adap->udbs_res);
	len_udbs_res = (u64)rman_get_size(rdev->adap->udbs_res);

	CTR6(KTR_IW_CXGBE,
	    "%s:4 addr %p, masync region %p:%p, udb region %p:%p", __func__,
	    addr, va_regs_res, va_regs_res+len_regs_res, va_udbs_res,
	    va_udbs_res+len_udbs_res);

	if (addr >= va_regs_res && addr < va_regs_res + len_regs_res) {
		CTR4(KTR_IW_CXGBE, "%s:5 MA_SYNC addr %p region %p, reglen %u",
		    __func__, addr, va_regs_res, len_regs_res);
		/*
		 * MA_SYNC register...
		 */
		paddr = vtophys(addr);
		vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
		ret = io_remap_pfn_range(vma, vma->vm_start,
				paddr >> PAGE_SHIFT,
				len, vma->vm_page_prot);
	} else {
开发者ID:Digital-Chaos,项目名称:freebsd,代码行数:58,代码来源:provider.c

示例2: bcma_nexus_attach

static int
bcma_nexus_attach(device_t dev)
{
	int 		 erom_rid;
	int 		 error;
	struct resource	*erom_res;
	const struct bhnd_chipid *cid = BHND_BUS_GET_CHIPID(device_get_parent(dev), dev);

  	erom_rid = BCMA_NEXUS_EROM_RID;
 	error = bus_set_resource(dev, SYS_RES_MEMORY, erom_rid, cid->enum_addr, BCMA_EROM_TABLE_SIZE);
 	if (error != 0) {
 		BHND_ERROR_DEV(dev, "failed to set EROM resource");
 		return (error);
 	}

 	/* Map the EROM resource and enumerate our children. */
 	BHND_DEBUG_DEV(dev, "erom enum address: %jx", cid->enum_addr);
 	erom_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &erom_rid, RF_ACTIVE);
 	if (erom_res == NULL) {
 		BHND_ERROR_DEV(dev, "failed to allocate EROM resource");
 		return (ENXIO);
 	}

 	BHND_DEBUG_DEV(dev, "erom scanning start address: %p", rman_get_virtual(erom_res));
 	error = bcma_add_children(dev, erom_res, BCMA_EROM_TABLE_START);

 	/* Clean up */
 	bus_release_resource(dev, SYS_RES_MEMORY, erom_rid, erom_res);
 	if (error)
 		return (error);

 	/* Call our superclass' implementation */
 	return (bcma_attach(dev));
}
开发者ID:tomtor,项目名称:freebsd,代码行数:34,代码来源:bcma_nexus.c

示例3: xrpu_attach

static int
xrpu_attach(device_t self)
{
	struct softc *sc;
	struct resource *res;
	int rid, unit;

	unit = device_get_unit(self);
	sc = device_get_softc(self);
	sc->mode = NORMAL;
	rid = PCI_MAP_REG_START;
	res = bus_alloc_resource(self, SYS_RES_MEMORY, &rid,
				 0, ~0, 1, RF_ACTIVE);
	if (res == NULL) {
		device_printf(self, "Could not map memory\n");
		return ENXIO;
	}
	sc->virbase = (vm_offset_t)rman_get_virtual(res);
	sc->physbase = rman_get_start(res);
	sc->virbase62 = (u_int *)(sc->virbase + 0x800000);

	if (bootverbose)
		printf("Mapped physbase %#lx to virbase %#lx\n",
		    (u_long)sc->physbase, (u_long)sc->virbase);

	make_dev(&xrpu_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "xrpu%d", unit);
	return 0;
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:28,代码来源:xrpu.c

示例4: ata_siiprb_softreset

static u_int32_t
ata_siiprb_softreset(device_t dev, int port)
{
    struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
    struct ata_channel *ch = device_get_softc(dev);
    struct ata_siiprb_command *prb = (struct ata_siiprb_command *)ch->dma.work;
    u_int32_t signature;
    int offset = ch->unit * 0x2000;

    /* setup the workspace for a soft reset command */
    bzero(prb, sizeof(struct ata_siiprb_command));
    prb->control = htole16(0x0080);
    prb->fis[1] = port & 0x0f;

    /* issue soft reset */
    if (ata_siiprb_issue_cmd(dev))
	return -1;

    ata_udelay(150000);

    /* get possible signature */
    prb = (struct ata_siiprb_command *)
	((u_int8_t *)rman_get_virtual(ctlr->r_res2) + offset);
    signature=prb->fis[12]|(prb->fis[4]<<8)|(prb->fis[5]<<16)|(prb->fis[6]<<24);

    /* clear error bits/interrupt */
    ATA_IDX_OUTL(ch, ATA_SERROR, 0xffffffff);

    return signature;
}
开发者ID:ppaeps,项目名称:freebsd-head,代码行数:30,代码来源:ata-siliconimage.c

示例5: iop_pci_attach

static int
iop_pci_attach(device_t dev)
{
    struct iop_softc *sc = device_get_softc(dev);
    int rid;

    bzero(sc, sizeof(struct iop_softc));

    /* get resources */
    rid = 0x10;
    sc->r_mem = 
	bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);

    if (!sc->r_mem)
	return 0;

    rid = 0x00;
    sc->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
				       RF_SHAREABLE | RF_ACTIVE);

    /* now setup the infrastructure to talk to the device */
    pci_enable_busmaster(dev);

    sc->ibase = rman_get_virtual(sc->r_mem);
    sc->reg = (struct i2o_registers *)sc->ibase;
    sc->dev = dev;
    mtx_init(&sc->mtx, "pst lock", NULL, MTX_DEF);

    if (!iop_init(sc))
	return 0;
    return bus_generic_attach(dev);
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:32,代码来源:pst-pci.c

示例6: cy_isa_probe

static int
cy_isa_probe(device_t dev)
{
	struct resource *mem_res;
	cy_addr iobase;
	int mem_rid;

	if (isa_get_logicalid(dev) != 0)	/* skip PnP probes */
		return (ENXIO);

	mem_rid = 0;
	mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
	    0ul, ~0ul, 0ul, RF_ACTIVE);
	if (mem_res == NULL) {
		device_printf(dev, "ioport resource allocation failed\n");
		return (ENXIO);
	}
	iobase = rman_get_virtual(mem_res);

	/* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
	cy_inb(iobase, CY16_RESET, 0);	/* XXX? */
	DELAY(500);		/* wait for the board to get its act together */

	/* this is needed to get the board out of reset */
	cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
	DELAY(500);

	bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
	return (cy_units(iobase, 0) == 0 ? ENXIO : 0);
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:30,代码来源:cy_isa.c

示例7: vga_pci_unmap_bios

void
vga_pci_unmap_bios(device_t dev, void *bios)
{
	struct vga_resource *vr;

	if (bios == NULL) {
		return;
	}

#if defined(__amd64__) || defined(__i386__) || defined(__ia64__)
	if (vga_pci_is_boot_display(dev)) {
		/* We mapped the BIOS shadow copy located at 0xC0000. */
		pmap_unmapdev((vm_offset_t)bios, VGA_PCI_BIOS_SHADOW_SIZE);

		return;
	}
#endif

	/*
	 * Look up the PCIR_BIOS resource in our softc.  It should match
	 * the address we returned previously.
	 */
	vr = lookup_res(device_get_softc(dev), PCIR_BIOS);
	KASSERT(vr->vr_res != NULL, ("vga_pci_unmap_bios: bios not mapped"));
	KASSERT(rman_get_virtual(vr->vr_res) == bios,
	    ("vga_pci_unmap_bios: mismatch"));
	vga_pci_release_resource(dev, NULL, SYS_RES_MEMORY, PCIR_BIOS,
	    vr->vr_res);
}
开发者ID:ChristosKa,项目名称:freebsd,代码行数:29,代码来源:vga_pci.c

示例8: vga_pci_map_bios

void *
vga_pci_map_bios(device_t dev, size_t *size)
{
	int rid;
	struct resource *res;

#if defined(__amd64__) || defined(__i386__) || defined(__ia64__)
	if (vga_pci_is_boot_display(dev)) {
		/*
		 * On x86, the System BIOS copy the default display
		 * device's Video BIOS at a fixed location in system
		 * memory (0xC0000, 128 kBytes long) at boot time.
		 *
		 * We use this copy for the default boot device, because
		 * the original ROM may not be valid after boot.
		 */

		*size = VGA_PCI_BIOS_SHADOW_SIZE;
		return (pmap_mapbios(VGA_PCI_BIOS_SHADOW_ADDR, *size));
	}
#endif

	rid = PCIR_BIOS;
	res = vga_pci_alloc_resource(dev, NULL, SYS_RES_MEMORY, &rid, 0ul,
	    ~0ul, 1, RF_ACTIVE);
	if (res == NULL) {
		return (NULL);
	}

	*size = rman_get_size(res);
	return (rman_get_virtual(res));
}
开发者ID:ChristosKa,项目名称:freebsd,代码行数:32,代码来源:vga_pci.c

示例9: pci_read_config

void *os_map_pci_bar(
    void *osext, 
    int index,   
    HPT_U32 offset,
    HPT_U32 length
)
{
	PHBA hba = (PHBA)osext;
	HPT_U32 base;

	hba->pcibar[index].rid = 0x10 + index * 4;
	base = pci_read_config(hba->pcidev, hba->pcibar[index].rid, 4);

	if (base & 1) {
		hba->pcibar[index].type = SYS_RES_IOPORT;
		hba->pcibar[index].res = bus_alloc_resource_any(hba->pcidev,
			hba->pcibar[index].type, &hba->pcibar[index].rid, RF_ACTIVE);
		hba->pcibar[index].base = (void *)(unsigned long)(base & ~0x1);
	} else {
		hba->pcibar[index].type = SYS_RES_MEMORY;
		hba->pcibar[index].res = bus_alloc_resource_any(hba->pcidev,
			hba->pcibar[index].type, &hba->pcibar[index].rid, RF_ACTIVE);
		hba->pcibar[index].base = (char *)rman_get_virtual(hba->pcibar[index].res) + offset;
	}

	return hba->pcibar[index].base;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:27,代码来源:hptnr_os_bsd.c

示例10: nexus_deactivate_resource

static int
nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
			  struct resource *r)
{
	/*
	 * If this is a memory resource, unmap it.
	 */
	if (type == SYS_RES_MEMORY) {
		pmap_unmapdev((vm_offset_t)rman_get_virtual(r),
		    rman_get_size(r));
	}
		
	return (rman_deactivate_resource(r));
}
开发者ID:oza,项目名称:FreeBSD-7.3-dyntick,代码行数:14,代码来源:nexus.c

示例11: zbpci_deactivate_resource

static int
zbpci_deactivate_resource(device_t bus, device_t child, int type, int rid,
			  struct resource *r)
{
	vm_offset_t va;

	if (type != SYS_RES_IOPORT) {
		return (bus_generic_deactivate_resource(bus, child, type,
							rid, r));
	}
	
	va = (vm_offset_t)rman_get_virtual(r);
	pmap_unmapdev(va, rman_get_size(r));

	return (rman_deactivate_resource(r));
}
开发者ID:2asoft,项目名称:freebsd,代码行数:16,代码来源:sb_zbpci.c

示例12: ofw_pci_deactivate_resource

static int
ofw_pci_deactivate_resource(device_t bus, device_t child, int type, int rid,
    struct resource *res)
{
	/*
	 * If this is a memory resource, unmap it.
	 */
	if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) {
		u_int32_t psize;

		psize = rman_get_size(res);
		pmap_unmapdev((vm_offset_t)rman_get_virtual(res), psize);
	}

	return (rman_deactivate_resource(res));
}
开发者ID:ngkaho1234,项目名称:freebsd,代码行数:16,代码来源:ofw_pci.c

示例13: nexus_deactivate_resource

static int
nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
			  struct resource *r)
{
	/*
	 * If this is a memory resource, unmap it.
	 */
	if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (r->r_end >= 1024 * 1024)) {
		u_int32_t psize;

		psize = r->r_end - r->r_start;
		pmap_unmapdev((vm_offset_t)rman_get_virtual(r), psize);
	}
		
	return (rman_deactivate_resource(r));
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:16,代码来源:nexus.c

示例14: cy_isa_attach

static int
cy_isa_attach(device_t dev)
{
	struct resource *irq_res, *mem_res;
	void *irq_cookie, *vaddr, *vsc;
	int irq_rid, mem_rid;

	irq_res = NULL;
	mem_res = NULL;

	mem_rid = 0;
	mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &mem_rid,
	    0ul, ~0ul, 0ul, RF_ACTIVE);
	if (mem_res == NULL) {
		device_printf(dev, "memory resource allocation failed\n");
		goto fail;
	}
	vaddr = rman_get_virtual(mem_res);

	vsc = cyattach_common(vaddr, 0);
	if (vsc == NULL) {
		device_printf(dev, "no ports found!\n");
		goto fail;
	}

	irq_rid = 0;
	irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0ul, ~0ul, 0ul,
	    RF_SHAREABLE | RF_ACTIVE);
	if (irq_res == NULL) {
		device_printf(dev, "interrupt resource allocation failed\n");
		goto fail;
	}
	if (bus_setup_intr(dev, irq_res, INTR_TYPE_TTY | INTR_FAST, cyintr,
	    vsc, &irq_cookie) != 0) {
		device_printf(dev, "interrupt setup failed\n");
		goto fail;
	}

	return (0);

fail:
	if (irq_res != NULL)
		bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
	if (mem_res != NULL)
		bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
	return (ENXIO);
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:47,代码来源:cy_isa.c

示例15: nexus_deactivate_resource

static int
nexus_deactivate_resource(device_t bus __unused, device_t child __unused,
    int type __unused, int rid __unused, struct resource *r)
{

	/*
	 * If this is a memory resource, unmap it.
	 */
	if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) {
		bus_size_t psize;

		psize = rman_get_size(r);
		pmap_unmapdev((vm_offset_t)rman_get_virtual(r), psize);
	}

	return (rman_deactivate_resource(r));
}
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:17,代码来源:nexus.c


注:本文中的rman_get_virtual函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。