• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ rman_reserve_resource函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: omap_alloc_resource

/**
 *	omap_alloc_resource
 *
 *	This function will be called when bus_alloc_resource(...) if the memory
 *	region requested is in the range of the managed values set by
 *	rman_manage_region(...) above.
 *
 *	For SYS_RES_MEMORY resource types the omap_attach() calls rman_manage_region
 *	with the list of pyshical mappings defined in the omap_devmap region map.
 *	However because we are working with physical addresses, we need to convert
 *	the physical to virtual within this function and return the virtual address
 *	in the bus tag field.
 *
 */
static struct resource *
omap_alloc_resource(device_t dev, device_t child, int type, int *rid,
                     u_long start, u_long end, u_long count, u_int flags)
{
	struct omap_softc *sc = device_get_softc(dev);
	struct resource_list_entry *rle;
	struct omap_ivar *ivar = device_get_ivars(child);
	struct resource_list *rl = &ivar->resources;

	/* If we aren't the parent pass it onto the actual parent */
	if (device_get_parent(child) != dev) {
		return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
		    type, rid, start, end, count, flags));
	}
	
	/* Find the resource in the list */
	rle = resource_list_find(rl, type, *rid);
	if (rle == NULL)
		return (NULL);
	if (rle->res)
		panic("Resource rid %d type %d already in use", *rid, type);

	if (start == 0UL && end == ~0UL) {
		start = rle->start;
		count = ulmax(count, rle->count);
		end = ulmax(rle->end, start + count - 1);
	}

	switch (type)
	{
	case SYS_RES_IRQ:
		rle->res = rman_reserve_resource(&sc->sc_irq_rman,
		    start, end, count, flags, child);
		break;
	case SYS_RES_MEMORY:
		rle->res = rman_reserve_resource(&sc->sc_mem_rman,
		    start, end, count, flags, child);
		if (rle->res != NULL) {
			rman_set_bustag(rle->res, &omap_bs_tag);
			rman_set_bushandle(rle->res, omap_devmap_phys2virt(start));
		}
		break;
	}

	if (rle->res) {
		rle->start = rman_get_start(rle->res);
		rle->end = rman_get_end(rle->res);
		rle->count = count;
		rman_set_rid(rle->res, *rid);
	}
	return (rle->res);
}
开发者ID:christianrodher,项目名称:freebsd-armv6,代码行数:66,代码来源:omap.c


示例2: ixp425_alloc_resource

static struct resource *
ixp425_alloc_resource(device_t dev, device_t child, int type, int *rid,
    u_long start, u_long end, u_long count, u_int flags)
{
	struct ixp425_softc *sc = device_get_softc(dev);
	struct rman *rmanp;
	struct resource *rv;
	uint32_t vbase, addr;
	int irq;

	switch (type) {
	case SYS_RES_IRQ:
		rmanp = &sc->sc_irq_rman;
		/* override per hints */
		if (BUS_READ_IVAR(dev, child, IXP425_IVAR_IRQ, &irq) == 0)
			start = end = irq;
		rv = rman_reserve_resource(rmanp, start, end, count,
			flags, child);
		if (rv != NULL)
			rman_set_rid(rv, *rid);
		break;

	case SYS_RES_MEMORY:
		rmanp = &sc->sc_mem_rman;
		/* override per hints */
		if (BUS_READ_IVAR(dev, child, IXP425_IVAR_ADDR, &addr) == 0) {
			start = addr;
			end = start + 0x1000;	/* XXX */
		}
		if (getvbase(start, end - start, &vbase) != 0) {
			/* likely means above table needs to be updated */
			device_printf(dev, "%s: no mapping for 0x%lx:0x%lx\n",
			    __func__, start, end-start);
			return NULL;
		}
		rv = rman_reserve_resource(rmanp, start, end, count,
			flags, child);
		if (rv != NULL) {
			rman_set_rid(rv, *rid);
			if (strcmp(device_get_name(child), "uart") == 0)
				rman_set_bustag(rv, &ixp425_a4x_bs_tag);
			else
				rman_set_bustag(rv, sc->sc_iot);
			rman_set_bushandle(rv, vbase);
		}
		break;
	default:
		rv = NULL;
		break;
	}
	return rv;
}
开发者ID:coolgoose85,项目名称:FreeBSD,代码行数:52,代码来源:ixp425.c


示例3: at91_alloc_resource

static struct resource *
at91_alloc_resource(device_t dev, device_t child, int type, int *rid,
    u_long start, u_long end, u_long count, u_int flags)
{
	struct at91_softc *sc = device_get_softc(dev);
	struct resource_list_entry *rle;
	struct at91_ivar *ivar = device_get_ivars(child);
	struct resource_list *rl = &ivar->resources;

	if (device_get_parent(child) != dev)
		return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
		    type, rid, start, end, count, flags));
	
	rle = resource_list_find(rl, type, *rid);
	if (rle == NULL)
		return (NULL);
	if (rle->res)
		panic("Resource rid %d type %d already in use", *rid, type);
	if (start == 0UL && end == ~0UL) {
		start = rle->start;
		count = ulmax(count, rle->count);
		end = ulmax(rle->end, start + count - 1);
	}
	switch (type)
	{
	case SYS_RES_IRQ:
		rle->res = rman_reserve_resource(&sc->sc_irq_rman,
		    start, end, count, flags, child);
		break;
	case SYS_RES_MEMORY:
#if 0
		if (start >= 0x00300000 && start <= 0x003fffff)
			rle->res = rman_reserve_resource(&sc->sc_usbmem_rman,
			    start, end, count, flags, child);
		else
#endif
			rle->res = rman_reserve_resource(&sc->sc_mem_rman,
			    start, end, count, flags, child);
		if (rle->res != NULL) {
			rman_set_bustag(rle->res, &at91_bs_tag);
			rman_set_bushandle(rle->res, start);
		}
		break;
	}
	if (rle->res) {
		rle->start = rman_get_start(rle->res);
		rle->end = rman_get_end(rle->res);
		rle->count = count;
		rman_set_rid(rle->res, *rid);
	}
	return (rle->res);
}
开发者ID:oza,项目名称:FreeBSD-7.3-dyntick,代码行数:52,代码来源:at91.c


示例4: ocpbus_alloc_resource

static struct resource *
ocpbus_alloc_resource(device_t dev, device_t child, int type, int *rid,
    u_long start, u_long end, u_long count, u_int flags)
{
	struct ocpbus_softc *sc;
	struct resource *rv;
	int error;

	sc = device_get_softc(dev);

	switch (type) {
	case SYS_RES_IRQ:
		if (start == 0ul && end == ~0ul) {
			error = ocpbus_get_resource(dev, child, type, *rid,
			    &start, &count);
			if (error)
				return (NULL);
		}

		rv = rman_reserve_resource(&sc->sc_irq, start,
		    start + count - 1, count, flags, child);
		if (rv == NULL)
			return (NULL);
		break;

	case SYS_RES_MEMORY:
		if (start != 0ul || end != ~0ul)
			return (NULL);

		error = ocpbus_get_resource(dev, child, type, *rid, &start,
		    &count);
		if (error)
			return (NULL);

		rv = rman_reserve_resource(&sc->sc_mem, start,
		    start + count - 1, count, flags, child);
		if (rv == NULL)
			return (NULL);

		rman_set_bustag(rv, &bs_be_tag);
		rman_set_bushandle(rv, rman_get_start(rv));
		break;

	default:
		return (NULL);
	}

	rman_set_rid(rv, *rid);
	return (rv);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:50,代码来源:ocpbus.c


示例5: at91_alloc_resource

static struct resource *
at91_alloc_resource(device_t dev, device_t child, int type, int *rid,
    rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
	struct at91_softc *sc = device_get_softc(dev);
	struct resource_list_entry *rle;
	struct at91_ivar *ivar = device_get_ivars(child);
	struct resource_list *rl = &ivar->resources;
	bus_space_handle_t bsh;

	if (device_get_parent(child) != dev)
		return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
		    type, rid, start, end, count, flags));
	
	rle = resource_list_find(rl, type, *rid);
	if (rle == NULL)
		return (NULL);
	if (rle->res)
		panic("Resource rid %d type %d already in use", *rid, type);
	if (start == 0UL && end == ~0UL) {
		start = rle->start;
		count = ulmax(count, rle->count);
		end = ulmax(rle->end, start + count - 1);
	}
	switch (type)
	{
	case SYS_RES_IRQ:
		rle->res = rman_reserve_resource(&sc->sc_irq_rman,
		    start, end, count, flags, child);
		break;
	case SYS_RES_MEMORY:
		rle->res = rman_reserve_resource(&sc->sc_mem_rman,
		    start, end, count, flags, child);
		if (rle->res != NULL) {
			bus_space_map(arm_base_bs_tag, start,
			    rman_get_size(rle->res), 0, &bsh);
			rman_set_bustag(rle->res, arm_base_bs_tag);
			rman_set_bushandle(rle->res, bsh);
		}
		break;
	}
	if (rle->res) {
		rle->start = rman_get_start(rle->res);
		rle->end = rman_get_end(rle->res);
		rle->count = count;
		rman_set_rid(rle->res, *rid);
	}
	return (rle->res);
}
开发者ID:embedclub,项目名称:freebsd,代码行数:49,代码来源:at91.c


示例6: sgmap_alloc_region

/*
 * Map a range of virtual addresses using the sgmap and return the bus 
 * address of the mapped region. An opaque handle for the mapped
 * region is also returned in *mhp. This handle should be passed to
 * sgmap_free_region() when the mapping is no longer required.
 */
bus_addr_t
sgmap_alloc_region(struct sgmap *sgmap,
		   bus_size_t size,
		   bus_size_t boundary,
		   void **mhp)
{
	struct resource *res;
	bus_addr_t ba, nba;

	/*
	 * This ensures allocations are on page boundaries. The extra
	 * page is used as a guard page since dma prefetching can
	 * generate accesses to addresses outside the transfer range.
	 */
	size = round_page(size);

	/*
	 * Attempt to allocate within each boundary delimited region.
	 */
	res = 0;
	for (ba = sgmap->sba; ba < sgmap->eba; ba = nba) {
		nba = (ba + boundary) & ~(boundary - 1);
		res = rman_reserve_resource(&sgmap->rm,
					    ba, nba - 1, size + PAGE_SIZE,
					    RF_ACTIVE, 0);
		if (res)
			break;
	}

	if (res == 0)
		return 0;

	*mhp = (void *) res;
	return rman_get_start(res);
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:41,代码来源:sgmap.c


示例7: zbpci_alloc_resource

static struct resource *
zbpci_alloc_resource(device_t bus, device_t child, int type, int *rid,
		     rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
	struct resource *res;

	/*
	 * Handle PCI I/O port resources here and pass everything else to nexus.
	 */
	if (type != SYS_RES_IOPORT) {
		res = bus_generic_alloc_resource(bus, child, type, rid,
						 start, end, count, flags);
		return (res);
	}

	res = rman_reserve_resource(&port_rman, start, end, count,
				    flags, child);
	if (res == NULL)
		return (NULL);

	rman_set_rid(res, *rid);

	/* Activate the resource is requested */
	if (flags & RF_ACTIVE) {
		if (bus_activate_resource(child, type, *rid, res) != 0) {
			rman_release_resource(res);
			return (NULL);
		}
	}

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


示例8: mvs_alloc_resource

static struct resource *
mvs_alloc_resource(device_t dev, device_t child, int type, int *rid,
		       u_long start, u_long end, u_long count, u_int flags)
{
	struct mvs_controller *ctlr = device_get_softc(dev);
	int unit = ((struct mvs_channel *)device_get_softc(child))->unit;
	struct resource *res = NULL;
	int offset = PORT_BASE(unit & 0x03);
	long st;

	switch (type) {
	case SYS_RES_MEMORY:
		st = rman_get_start(ctlr->r_mem);
		res = rman_reserve_resource(&ctlr->sc_iomem, st + offset,
		    st + offset + PORT_SIZE - 1, PORT_SIZE, RF_ACTIVE, child);
		if (res) {
			bus_space_handle_t bsh;
			bus_space_tag_t bst;
			bsh = rman_get_bushandle(ctlr->r_mem);
			bst = rman_get_bustag(ctlr->r_mem);
			bus_space_subregion(bst, bsh, offset, PORT_SIZE, &bsh);
			rman_set_bushandle(res, bsh);
			rman_set_bustag(res, bst);
		}
		break;
	case SYS_RES_IRQ:
		if (*rid == ATA_IRQ_RID)
			res = ctlr->irq.r_irq;
		break;
	}
	return (res);
}
开发者ID:ChristosKa,项目名称:freebsd,代码行数:32,代码来源:mvs_soc.c


示例9: ciu_alloc_resource

static struct resource *
ciu_alloc_resource(device_t bus, device_t child, int type, int *rid,
		   u_long start, u_long end, u_long count, u_int flags)
{
	struct resource *res;
	struct ciu_softc *sc;
	
	sc = device_get_softc(bus);

	switch (type) {
	case SYS_RES_IRQ:
		break;
	default:
		return (bus_alloc_resource(device_get_parent(bus), type, rid,
					   start, end, count, flags));
	}

	/*
	 * One interrupt at a time for now.
	 */
	if (start != end)
		return (NULL);

	res = rman_reserve_resource(&sc->irq_rman, start, end, count, flags,
				    child);
	if (res != NULL)
		return (res);

	return (NULL);
}
开发者ID:coyizumi,项目名称:cs111,代码行数:30,代码来源:ciu.c


示例10: pci_alloc_resource

/*
 * Allocate a resource on behalf of child.  NB: child is usually going to be a
 * child of one of our descendants, not a direct child of the pci chipset.
 */
struct resource *
pci_alloc_resource(device_t bus, device_t child, int type, int *rid,
		   u_long start, u_long end, u_long count, u_int flags)
{
	struct	rman *rm;

	switch (type) {
	case SYS_RES_IRQ:
		rm = &irq_rman;
		break;

	case SYS_RES_IOPORT:
		rm = &port_rman;
		break;

	case SYS_RES_MEMORY:
		rm = &mem_rman;
		break;

	default:
		return 0;
	}

	return rman_reserve_resource(rm, start, end, count, flags, child);
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:29,代码来源:pcibus.c


示例11: nexus_alloc_resource

/*
 * Allocate a resource on behalf of child.  NB: child is usually going to be a
 * child of one of our descendants, not a direct child of nexus0.
 * (Exceptions include footbridge.)
 */
static struct resource *
nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
    u_long start, u_long end, u_long count, u_int flags)
{
	struct resource *rv;
	struct rman *rm;
	int needactivate = flags & RF_ACTIVE;

	switch (type) {
	case SYS_RES_MEMORY:
	case SYS_RES_IOPORT:
		rm = &mem_rman;
		break;

	default:
		return (0);
	}

	rv = rman_reserve_resource(rm, start, end, count, flags, child);
	if (rv == 0)
		return (0);

	rman_set_rid(rv, *rid);
	rman_set_bushandle(rv, rman_get_start(rv));

	if (needactivate) {
		if (bus_activate_resource(child, type, *rid, rv)) {
			rman_release_resource(rv);
			return (0);
		}
	}

	return (rv);
}
开发者ID:amir-partovi,项目名称:Taha,代码行数:39,代码来源:nexus.c


示例12: nexus_alloc_resource

/*
 * Allocate resources at the behest of a child.  This only handles interrupts,
 * since I/O resources are handled by child busses.
 */
static struct resource *
nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
    u_long start, u_long end, u_long count, u_int flags)
{
	struct nexus_softc *sc;
	struct resource *rv;

	if (type != SYS_RES_IRQ) {
		device_printf(bus, "unknown resource request from %s\n",
		    device_get_nameunit(child));
		return (NULL);
	}

	if (count == 0 || start + count - 1 != end) {
		device_printf(bus, "invalid IRQ allocation from %s\n",
		    device_get_nameunit(child));
		return (NULL);
	}

	sc = device_get_softc(bus);

	rv = rman_reserve_resource(&sc->sc_rman, start, end, count,
	    flags, child);
	if (rv == NULL) {
		device_printf(bus, "IRQ allocation failed for %s\n",
		    device_get_nameunit(child));
	} else
		rman_set_rid(rv, *rid);

	return (rv);
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:35,代码来源:nexus.c


示例13: ofwbus_alloc_resource

static struct resource *
ofwbus_alloc_resource(device_t bus, device_t child, int type, int *rid,
    u_long start, u_long end, u_long count, u_int flags)
{
	struct ofwbus_softc *sc;
	struct rman *rm;
	struct resource *rv;
	struct resource_list_entry *rle;
	int isdefault, passthrough;

	isdefault = (start == 0UL && end == ~0UL);
	passthrough = (device_get_parent(child) != bus);
	sc = device_get_softc(bus);
	rle = NULL;

	if (!passthrough && isdefault) {
		rle = resource_list_find(BUS_GET_RESOURCE_LIST(bus, child),
		    type, *rid);
		if (rle == NULL)
			return (NULL);
		if (rle->res != NULL)
			panic("%s: resource entry is busy", __func__);
		start = rle->start;
		count = ulmax(count, rle->count);
		end = ulmax(rle->end, start + count - 1);
	}

	switch (type) {
	case SYS_RES_IRQ:
		rm = &sc->sc_intr_rman;
		break;
	case SYS_RES_MEMORY:
		rm = &sc->sc_mem_rman;
		break;
	default:
		return (NULL);
	}

	rv = rman_reserve_resource(rm, start, end, count, flags & ~RF_ACTIVE,
	    child);
	if (rv == NULL)
		return (NULL);
	rman_set_rid(rv, *rid);

	if ((flags & RF_ACTIVE) != 0 && bus_activate_resource(child, type,
	    *rid, rv) != 0) {
		rman_release_resource(rv);
		return (NULL);
	}

	if (!passthrough && rle != NULL) {
		rle->res = rv;
		rle->start = rman_get_start(rv);
		rle->end = rman_get_end(rv);
		rle->count = rle->end - rle->start + 1;
	}

	return (rv);
}
开发者ID:ChristosKa,项目名称:freebsd,代码行数:59,代码来源:ofwbus.c


示例14: thunder_pem_alloc_resource

static struct resource *
thunder_pem_alloc_resource(device_t dev, device_t child, int type, int *rid,
    rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
	struct thunder_pem_softc *sc = device_get_softc(dev);
	struct rman *rm = NULL;
	struct resource *res;
	device_t parent_dev;

	rm = thunder_pem_rman(sc, type);
	if (rm == NULL) {
		/* Find parent device. On ThunderX we know an exact path. */
		parent_dev = device_get_parent(device_get_parent(dev));
		return (BUS_ALLOC_RESOURCE(parent_dev, dev, type, rid, start,
		    end, count, flags));
	}


	if (!RMAN_IS_DEFAULT_RANGE(start, end)) {
		/*
		 * We might get PHYS addresses here inherited from EFI.
		 * Convert to PCI if necessary.
		 */
		if (range_addr_is_phys(sc->ranges, start, count)) {
			start = range_addr_phys_to_pci(sc->ranges, start);
			end = start + count - 1;
		}

	}

	if (bootverbose) {
		device_printf(dev,
		    "thunder_pem_alloc_resource: start=%#lx, end=%#lx, count=%#lx\n",
		    start, end, count);
	}

	res = rman_reserve_resource(rm, start, end, count, flags, child);
	if (res == NULL)
		goto fail;

	rman_set_rid(res, *rid);

	if (flags & RF_ACTIVE)
		if (bus_activate_resource(child, type, *rid, res)) {
			rman_release_resource(res);
			goto fail;
		}

	return (res);

fail:
	if (bootverbose) {
		device_printf(dev, "%s FAIL: type=%d, rid=%d, "
		    "start=%016lx, end=%016lx, count=%016lx, flags=%x\n",
		    __func__, type, *rid, start, end, count, flags);
	}

	return (NULL);
}
开发者ID:Digital-Chaos,项目名称:freebsd,代码行数:59,代码来源:thunder_pcie_pem.c


示例15: nexus_alloc_resource

/*
 * Allocate a resource on behalf of child.  NB: child is usually going to be a
 * child of one of our descendants, not a direct child of nexus0.
 * (Exceptions include footbridge.)
 */
static struct resource *
nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
    rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
	struct nexus_device *ndev = DEVTONX(child);
	struct resource *rv;
	struct resource_list_entry *rle;
	struct rman *rm;
	int needactivate = flags & RF_ACTIVE;

	/*
	 * If this is an allocation of the "default" range for a given
	 * RID, and we know what the resources for this device are
	 * (ie. they aren't maintained by a child bus), then work out
	 * the start/end values.
	 */
	if (RMAN_IS_DEFAULT_RANGE(start, end) && (count == 1)) {
		if (device_get_parent(child) != bus || ndev == NULL)
			return(NULL);
		rle = resource_list_find(&ndev->nx_resources, type, *rid);
		if (rle == NULL)
			return(NULL);
		start = rle->start;
		end = rle->end;
		count = rle->count;
	}

	switch (type) {
	case SYS_RES_IRQ:
		rm = &irq_rman;
		break;

	case SYS_RES_MEMORY:
	case SYS_RES_IOPORT:
		rm = &mem_rman;
		break;

	default:
		return (NULL);
	}

	rv = rman_reserve_resource(rm, start, end, count, flags, child);
	if (rv == NULL)
		return (NULL);

	rman_set_rid(rv, *rid);
	rman_set_bushandle(rv, rman_get_start(rv));

	if (needactivate) {
		if (bus_activate_resource(child, type, *rid, rv)) {
			rman_release_resource(rv);
			return (NULL);
		}
	}

	return (rv);
}
开发者ID:nomadlogic,项目名称:freebsd-base-graphics,代码行数:62,代码来源:nexus.c


示例16: wiibus_alloc_resource

static struct resource *
wiibus_alloc_resource(device_t bus, device_t child, int type,
    int *rid, unsigned long start, unsigned long end,
    unsigned long count, unsigned int flags)
{
	struct wiibus_softc *sc;
	struct wiibus_devinfo *dinfo;
	struct resource_list_entry *rle;
	struct resource *rv;
	int needactivate;

	sc = device_get_softc(bus);
	dinfo = device_get_ivars(child);
	needactivate = flags & RF_ACTIVE;
	flags &= ~RF_ACTIVE;

	switch (type) {
	case SYS_RES_MEMORY:
		rle = resource_list_find(&dinfo->di_resources, SYS_RES_MEMORY,
		    *rid);
		if (rle == NULL) {
			device_printf(bus, "no res entry for %s memory 0x%x\n",
			    device_get_nameunit(child), *rid);
			return (NULL);
		}
		rv = rman_reserve_resource(&sc->sc_rman, rle->start, rle->end,
		    rle->count, flags, child);
		if (rv == NULL) {
			device_printf(bus,
			    "failed to reserve resource for %s\n",
			    device_get_nameunit(child));
			return (NULL);
		}
		rman_set_rid(rv, *rid);
		break;
	case SYS_RES_IRQ:
		return (resource_list_alloc(&dinfo->di_resources, bus, child,
		    type, rid, start, end, count, flags));
	default:
		device_printf(bus, "unknown resource request from %s\n",
		    device_get_nameunit(child));
		return (NULL);
	}

	if (needactivate) {
		if (bus_activate_resource(child, type, *rid, rv) != 0) {
			device_printf(bus,
			    "failed to activate resource for %s\n",
			    device_get_nameunit(child));
			return (NULL);
		}
	}
	
	return (rv);
}
开发者ID:coyizumi,项目名称:cs111,代码行数:55,代码来源:wii_bus.c


示例17: ofw_pci_alloc_resource

static struct resource *
ofw_pci_alloc_resource(device_t bus, device_t child, int type, int *rid,
    u_long start, u_long end, u_long count, u_int flags)
{
	struct			ofw_pci_softc *sc;
	struct			resource *rv;
	struct			rman *rm;
	int			needactivate;

	needactivate = flags & RF_ACTIVE;
	flags &= ~RF_ACTIVE;

	sc = device_get_softc(bus);

	switch (type) {
	case SYS_RES_MEMORY:
		rm = &sc->sc_mem_rman;
		break;

	case SYS_RES_IOPORT:
		rm = &sc->sc_io_rman;
		break;

	case SYS_RES_IRQ:
		return (bus_alloc_resource(bus, type, rid, start, end, count,
		    flags));

	default:
		device_printf(bus, "unknown resource request from %s\n",
		    device_get_nameunit(child));
		return (NULL);
	}

	rv = rman_reserve_resource(rm, start, end, count, flags, child);
	if (rv == NULL) {
		device_printf(bus, "failed to reserve resource for %s\n",
		    device_get_nameunit(child));
		return (NULL);
	}

	rman_set_rid(rv, *rid);

	if (needactivate) {
		if (bus_activate_resource(child, type, *rid, rv) != 0) {
			device_printf(bus,
			    "failed to activate resource for %s\n",
			    device_get_nameunit(child));
			rman_release_resource(rv);
			return (NULL);
		}
	}

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


示例18: uninorth_alloc_resource

static struct resource *
uninorth_alloc_resource(device_t bus, device_t child, int type, int *rid,
    u_long start, u_long end, u_long count, u_int flags)
{
	struct			uninorth_softc *sc;
	struct			resource *rv;
	struct			rman *rm;
	bus_space_tag_t		bt;
	int			needactivate;

	needactivate = flags & RF_ACTIVE;
	flags &= ~RF_ACTIVE;

	sc = device_get_softc(bus);

	switch (type) {
	case SYS_RES_MEMORY:
		rm = &sc->sc_mem_rman;
		bt = PPC_BUS_SPACE_MEM;
                if (flags & PPC_BUS_SPARSE4)
			bt |= 4;		
		break;
	case SYS_RES_IRQ:
		return (bus_alloc_resource(bus, type, rid, start, end, count,
		    flags));
		break;
	default:
		device_printf(bus, "unknown resource request from %s\n",
		    device_get_nameunit(child));
		return (NULL);
	}

	rv = rman_reserve_resource(rm, start, end, count, flags, child);
	if (rv == NULL) {
		device_printf(bus, "failed to reserve resource for %s\n",
		    device_get_nameunit(child));
		return (NULL);
	}

	rman_set_bustag(rv, bt);
	rman_set_bushandle(rv, rman_get_start(rv));

	if (needactivate) {
		if (bus_activate_resource(child, type, *rid, rv) != 0) {
			device_printf(bus,
			    "failed to activate resource for %s\n",
			    device_get_nameunit(child));
			rman_release_resource(rv);
			return (NULL);
		}
	}

	return (rv);
}
开发者ID:MarginC,项目名称:kame,代码行数:54,代码来源:uninorth.c


示例19: alpha_pci_alloc_resource

/*
 * Allocate a resource on behalf of child.  NB: child is usually going to be a
 * child of one of our descendants, not a direct child of the pci chipset.
 */
struct resource *
alpha_pci_alloc_resource(device_t bus, device_t child, int type, int *rid,
		   u_long start, u_long end, u_long count, u_int flags)
{
	struct	rman *rm;
	struct	resource *rv;
	void *va;

	switch (type) {
	case SYS_RES_IRQ:
#ifdef DEV_ISA
		if((start >= ISA_IRQ_OFFSET) &&
		   (end < ISA_IRQ_OFFSET + ISA_IRQ_LEN)) {
		  	return isa_alloc_intrs(bus, child,
					       start - ISA_IRQ_OFFSET,
					       end - ISA_IRQ_OFFSET);
		}
		else
#endif
			rm = &irq_rman;
		break;

	case SYS_RES_IOPORT:
	case SYS_RES_MEMORY:
		rm = ALPHAPCI_GET_RMAN(bus, type);
		break;

	default:
		return 0;
	}

	rv = rman_reserve_resource(rm, start, end, count, flags, child);
	if (rv == 0)
		return 0;

	rman_set_bustag(rv, ALPHAPCI_GET_BUSTAG(bus, type));
	rman_set_bushandle(rv, rv->r_start);
	switch (type) {
	case SYS_RES_MEMORY:
		va = 0;
		if (flags & PCI_RF_DENSE)
			va = ALPHAPCI_CVT_DENSE(bus, rv->r_start);
		else if (flags & PCI_RF_BWX)
			va = ALPHAPCI_CVT_BWX(bus, rv->r_start);
		else
			va = (void *) rv->r_start; /* maybe NULL? */
		rman_set_virtual(rv, va);

		break;
	}

	return rv;
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:57,代码来源:pcibus.c


示例20: i80321_pci_alloc_resource

static struct resource *
i80321_pci_alloc_resource(device_t bus, device_t child, int type, int *rid,
    u_long start, u_long end, u_long count, u_int flags)
{
	struct i80321_pci_softc *sc = device_get_softc(bus);	
	struct resource *rv;
	struct rman *rm;
	bus_space_tag_t bt = NULL;
	bus_space_handle_t bh = 0;

	switch (type) {
	case SYS_RES_IRQ:
		rm = &sc->sc_irq_rman;
		break;
	case SYS_RES_MEMORY:
		rm = &sc->sc_mem_rman;
		bt = sc->sc_pcimem;
		bh = (start >= 0x80000000 && start < 0x84000000) ? 0x80000000 :
		    sc->sc_mem;
		start &= (0x1000000 - 1);
		end &= (0x1000000 - 1);
		break;
	case SYS_RES_IOPORT:
		rm = &sc->sc_io_rman;
		bt = sc->sc_pciio;
		bh = sc->sc_io;
		if (start < sc->sc_io) {
			start = start - 0x90000000 + sc->sc_io;
			end = end - 0x90000000 + sc->sc_io;
		}
		break;
	default:
		return (NULL);
	}

	rv = rman_reserve_resource(rm, start, end, count, flags, child);
	if (rv == NULL)
		return (NULL);
	rman_set_rid(rv, *rid);
	if (type != SYS_RES_IRQ) {
		if (type == SYS_RES_MEMORY)
			bh += (rman_get_start(rv));
		rman_set_bustag(rv, bt);
		rman_set_bushandle(rv, bh);
		if (flags & RF_ACTIVE) {
			if (bus_activate_resource(child, type, *rid, rv)) {
				rman_release_resource(rv);
				return (NULL);
			}
		} 
	}
	return (rv);
}
开发者ID:coolgoose85,项目名称:FreeBSD,代码行数:53,代码来源:i80321_pci.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rman_set_bustag函数代码示例发布时间:2022-05-30
下一篇:
C++ rman_release_resource函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap