本文整理汇总了C++中rman_release_resource函数的典型用法代码示例。如果您正苦于以下问题:C++ rman_release_resource函数的具体用法?C++ rman_release_resource怎么用?C++ rman_release_resource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rman_release_resource函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: obio_release_resource
static int
obio_release_resource(device_t dev, device_t child, int type,
int rid, struct resource *r)
{
struct resource_list *rl;
struct resource_list_entry *rle;
rl = obio_get_resource_list(dev, child);
if (rl == NULL)
return (EINVAL);
rle = resource_list_find(rl, type, rid);
if (rle == NULL)
return (EINVAL);
rman_release_resource(r);
rle->res = NULL;
return (0);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:18,代码来源:obio.c
示例2: chipc_release_resource
static int
chipc_release_resource(device_t dev, device_t child, int type, int rid,
struct resource *r)
{
struct chipc_softc *sc;
struct chipc_region *cr;
struct rman *rm;
struct resource_list_entry *rle;
int error;
sc = device_get_softc(dev);
/* Handled by parent bus? */
rm = chipc_get_rman(sc, type);
if (rm == NULL || !rman_is_region_manager(r, rm)) {
return (bus_generic_rl_release_resource(dev, child, type, rid,
r));
}
/* Locate the mapping region */
cr = chipc_find_region(sc, rman_get_start(r), rman_get_end(r));
if (cr == NULL)
return (EINVAL);
/* Deactivate resources */
if (rman_get_flags(r) & RF_ACTIVE) {
error = BUS_DEACTIVATE_RESOURCE(dev, child, type, rid, r);
if (error)
return (error);
}
if ((error = rman_release_resource(r)))
return (error);
/* Drop allocation reference */
chipc_release_region(sc, cr, RF_ALLOCATED);
/* Clear reference from the resource list entry if exists */
rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child), type, rid);
if (rle != NULL)
rle->res = NULL;
return (0);
}
开发者ID:wulf7,项目名称:freebsd,代码行数:44,代码来源:chipc.c
示例3: obio_alloc_resource
static struct resource *
obio_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;
bus_space_handle_t bh = 0;
struct obio_softc *sc = device_get_softc(bus);
switch (type) {
case SYS_RES_IRQ:
rm = &sc->oba_irq_rman;
break;
case SYS_RES_MEMORY:
return (NULL);
case SYS_RES_IOPORT:
rm = &sc->oba_rman;
bh = sc->oba_addr;
start = bh;
break;
default:
return (NULL);
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
if (rv == NULL)
return (NULL);
if (type == SYS_RES_IRQ)
return (rv);
rman_set_rid(rv, *rid);
rman_set_bustag(rv, mips_bus_space_generic);
rman_set_bushandle(rv, bh);
if (0) {
if (bus_activate_resource(child, type, *rid, rv)) {
rman_release_resource(rv);
return (NULL);
}
}
return (rv);
}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:43,代码来源:obio.c
示例4: ofwbus_release_resource
static int
ofwbus_release_resource(device_t bus, device_t child, int type,
int rid, struct resource *r)
{
struct resource_list_entry *rle;
int error;
/* Clean resource list entry */
rle = resource_list_find(BUS_GET_RESOURCE_LIST(bus, child), type, rid);
if (rle != NULL)
rle->res = NULL;
if ((rman_get_flags(r) & RF_ACTIVE) != 0) {
error = bus_deactivate_resource(child, type, rid, r);
if (error)
return (error);
}
return (rman_release_resource(r));
}
开发者ID:embedclub,项目名称:freebsd,代码行数:19,代码来源:ofwbus.c
示例5: cbb_pci_release_resource
static int
cbb_pci_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
struct cbb_softc *sc;
int error;
sc = device_get_softc(bus);
if (type == PCI_RES_BUS) {
if (!rman_is_region_manager(r, &sc->bus.rman))
return (EINVAL);
if (rman_get_flags(r) & RF_ACTIVE) {
error = bus_deactivate_resource(child, type, rid, r);
if (error)
return (error);
}
return (rman_release_resource(r));
}
return (cbb_release_resource(bus, child, type, rid, r));
}
开发者ID:embedclub,项目名称:freebsd,代码行数:20,代码来源:pccbb_pci.c
示例6: thunder_pem_release_resource
static int
thunder_pem_release_resource(device_t dev, device_t child, int type, int rid,
struct resource *res)
{
device_t parent_dev;
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
struct thunder_pem_softc *sc = device_get_softc(dev);
if (type == PCI_RES_BUS)
return (pci_domain_release_bus(sc->id, child, rid, res));
#endif
/* Find parent device. On ThunderX we know an exact path. */
parent_dev = device_get_parent(device_get_parent(dev));
if ((type != SYS_RES_MEMORY) && (type != SYS_RES_IOPORT))
return (BUS_RELEASE_RESOURCE(parent_dev, child,
type, rid, res));
return (rman_release_resource(res));
}
开发者ID:tomtor,项目名称:freebsd,代码行数:20,代码来源:thunder_pcie_pem.c
示例7: gpiobus_alloc_resource
static struct resource *
gpiobus_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 gpiobus_softc *sc;
struct resource *rv;
struct resource_list *rl;
struct resource_list_entry *rle;
int isdefault;
if (type != SYS_RES_IRQ)
return (NULL);
isdefault = (start == 0UL && end == ~0UL && count == 1);
rle = NULL;
if (isdefault) {
rl = BUS_GET_RESOURCE_LIST(bus, child);
if (rl == NULL)
return (NULL);
rle = resource_list_find(rl, type, *rid);
if (rle == NULL)
return (NULL);
if (rle->res != NULL)
panic("%s: resource entry is busy", __func__);
start = rle->start;
count = rle->count;
end = rle->end;
}
sc = device_get_softc(bus);
rv = rman_reserve_resource(&sc->sc_intr_rman, start, end, count, flags,
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);
}
return (rv);
}
开发者ID:fengsi,项目名称:freebsd,代码行数:41,代码来源:gpiobus.c
示例8: nexus_alloc_resource
/*
* Allocate resources at the behalf of a child. This only handles interrupts,
* since i/o resources are usually set up by the firmware, and thus need not
* be handled here.
*/
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 = device_get_softc(bus);
struct resource *rv;
struct rman *rm;
int needactivate = flags & RF_ACTIVE;
flags &= ~RF_ACTIVE;
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, child);
if (rv == NULL)
return (NULL);
if (type == SYS_RES_MEMORY) {
rman_set_bustag(rv, &nexus_bustag);
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:MarginC,项目名称:kame,代码行数:44,代码来源:nexus.c
示例9: pci_host_generic_core_release_resource
int
pci_host_generic_core_release_resource(device_t dev, device_t child, int type,
int rid, struct resource *res)
{
struct generic_pcie_core_softc *sc;
struct rman *rm;
sc = device_get_softc(dev);
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
if (type == PCI_RES_BUS) {
return (pci_domain_release_bus(sc->ecam, child, rid, res));
}
#endif
rm = generic_pcie_rman(sc, type);
if (rm != NULL) {
KASSERT(rman_is_region_manager(res, rm), ("rman mismatch"));
rman_release_resource(res);
}
return (bus_generic_release_resource(dev, child, type, rid, res));
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:23,代码来源:pci_host_generic.c
示例10: apb_alloc_resource
static struct resource *
apb_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 apb_softc *sc = device_get_softc(bus);
struct apb_ivar *ivar = device_get_ivars(child);
struct resource *rv;
struct resource_list_entry *rle;
struct rman *rm;
int isdefault, needactivate, passthrough;
isdefault = (RMAN_IS_DEFAULT_RANGE(start, end));
needactivate = flags & RF_ACTIVE;
/*
* Pass memory requests to nexus device
*/
passthrough = (device_get_parent(child) != bus);
rle = NULL;
dprintf("%s: entry (%p, %p, %d, %d, %p, %p, %jd, %d)\n",
__func__, bus, child, type, *rid, (void *)(intptr_t)start,
(void *)(intptr_t)end, count, flags);
if (passthrough)
return (BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type,
rid, start, end, count, flags));
/*
* 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 (isdefault) {
rle = resource_list_find(&ivar->resources, type, *rid);
if (rle == NULL) {
return (NULL);
}
if (rle->res != NULL) {
panic("%s: resource entry is busy", __func__);
}
start = rle->start;
end = rle->end;
count = rle->count;
dprintf("%s: default resource (%p, %p, %ld)\n",
__func__, (void *)(intptr_t)start,
(void *)(intptr_t)end, count);
}
switch (type) {
case SYS_RES_IRQ:
rm = &sc->apb_irq_rman;
break;
case SYS_RES_MEMORY:
rm = &sc->apb_mem_rman;
break;
default:
printf("%s: unknown resource type %d\n", __func__, type);
return (0);
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
if (rv == 0) {
printf("%s: could not reserve resource\n", __func__);
return (0);
}
rman_set_rid(rv, *rid);
if (needactivate) {
if (bus_activate_resource(child, type, *rid, rv)) {
printf("%s: could not activate resource\n", __func__);
rman_release_resource(rv);
return (0);
}
}
return (rv);
}
开发者ID:vocho,项目名称:freebsd-base-graphics,代码行数:81,代码来源:apb.c
示例11: 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;
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
if (type == PCI_RES_BUS)
return (pci_domain_alloc_bus(sc->id, child, rid, start, end,
count, flags));
#endif
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:tomtor,项目名称:freebsd,代码行数:64,代码来源:thunder_pcie_pem.c
示例12: fdtbus_alloc_resource
static struct resource *
fdtbus_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 fdtbus_softc *sc;
struct resource *res;
struct rman *rm;
struct fdtbus_devinfo *di;
struct resource_list_entry *rle;
int needactivate;
/*
* Request for the default allocation with a given rid: use resource
* list stored in the local device info.
*/
if ((start == 0UL) && (end == ~0UL)) {
if ((di = device_get_ivars(child)) == NULL)
return (NULL);
if (type == SYS_RES_IOPORT)
type = SYS_RES_MEMORY;
rle = resource_list_find(&di->di_res, type, *rid);
if (rle == NULL) {
device_printf(bus, "no default resources for "
"rid = %d, type = %d\n", *rid, type);
return (NULL);
}
start = rle->start;
end = rle->end;
count = rle->count;
}
sc = device_get_softc(bus);
needactivate = flags & RF_ACTIVE;
flags &= ~RF_ACTIVE;
switch (type) {
case SYS_RES_IRQ:
rm = &sc->sc_irq;
break;
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
rm = &sc->sc_mem;
break;
default:
return (NULL);
}
res = rman_reserve_resource(rm, start, end, count, flags, child);
if (res == NULL) {
device_printf(bus, "failed to reserve resource %#lx - %#lx "
"(%#lx)\n", start, end, count);
return (NULL);
}
rman_set_rid(res, *rid);
if (type == SYS_RES_IOPORT || type == SYS_RES_MEMORY) {
/* XXX endianess should be set based on SOC node */
rman_set_bustag(res, fdtbus_bs_tag);
rman_set_bushandle(res, rman_get_start(res));
}
if (needactivate)
if (bus_activate_resource(child, type, *rid, res)) {
device_printf(child, "resource activation failed\n");
rman_release_resource(res);
return (NULL);
}
return (res);
}
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:76,代码来源:fdtbus.c
示例13: pci_release_resource
int
pci_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
return (rman_release_resource(r));
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:6,代码来源:pcibus.c
示例14: obio_alloc_resource
static struct resource *
obio_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 obio_softc *sc = device_get_softc(bus);
struct obio_ivar *ivar = device_get_ivars(child);
struct resource *rv;
struct resource_list_entry *rle;
struct rman *rm;
int isdefault, needactivate, passthrough;
isdefault = (start == 0UL && end == ~0UL);
needactivate = flags & RF_ACTIVE;
passthrough = (device_get_parent(child) != bus);
rle = NULL;
if (passthrough)
return (BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type,
rid, start, end, count, flags));
/*
* 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 (isdefault) {
rle = resource_list_find(&ivar->resources, type, *rid);
if (rle == NULL)
return (NULL);
if (rle->res != NULL) {
panic("%s: resource entry is busy", __func__);
}
start = rle->start;
end = rle->end;
count = rle->count;
}
switch (type) {
case SYS_RES_IRQ:
rm = &sc->oba_irq_rman;
break;
case SYS_RES_MEMORY:
rm = &sc->oba_mem_rman;
break;
default:
printf("%s: unknown resource type %d\n", __func__, type);
return (0);
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
if (rv == 0) {
printf("%s: could not reserve resource\n", __func__);
return (0);
}
rman_set_rid(rv, *rid);
if (needactivate) {
if (bus_activate_resource(child, type, *rid, rv)) {
printf("%s: could not activate resource\n", __func__);
rman_release_resource(rv);
return (0);
}
}
return (rv);
}
开发者ID:JabirTech,项目名称:Source,代码行数:67,代码来源:obio.c
示例15: unin_chip_alloc_resource
//.........这里部分代码省略.........
struct rman *rm;
u_long adjstart, adjend, adjcount;
struct unin_chip_devinfo *dinfo;
struct resource_list_entry *rle;
sc = device_get_softc(bus);
dinfo = device_get_ivars(child);
needactivate = flags & RF_ACTIVE;
flags &= ~RF_ACTIVE;
switch (type) {
case SYS_RES_MEMORY:
case SYS_RES_IOPORT:
rle = resource_list_find(&dinfo->udi_resources, SYS_RES_MEMORY,
*rid);
if (rle == NULL) {
device_printf(bus, "no rle for %s memory %d\n",
device_get_nameunit(child), *rid);
return (NULL);
}
rle->end = rle->end - 1; /* Hack? */
if (start < rle->start)
adjstart = rle->start;
else if (start > rle->end)
adjstart = rle->end;
else
adjstart = start;
if (end < rle->start)
adjend = rle->start;
else if (end > rle->end)
adjend = rle->end;
else
adjend = end;
adjcount = adjend - adjstart;
rm = &sc->sc_mem_rman;
break;
case SYS_RES_IRQ:
/* Check for passthrough from subattachments. */
if (device_get_parent(child) != bus)
return BUS_ALLOC_RESOURCE(device_get_parent(bus), child,
type, rid, start, end, count,
flags);
rle = resource_list_find(&dinfo->udi_resources, SYS_RES_IRQ,
*rid);
if (rle == NULL) {
if (dinfo->udi_ninterrupts >= 6) {
device_printf(bus,
"%s has more than 6 interrupts\n",
device_get_nameunit(child));
return (NULL);
}
resource_list_add(&dinfo->udi_resources, SYS_RES_IRQ,
dinfo->udi_ninterrupts, start, start,
1);
dinfo->udi_interrupts[dinfo->udi_ninterrupts] = start;
dinfo->udi_ninterrupts++;
}
return (resource_list_alloc(&dinfo->udi_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);
}
rv = rman_reserve_resource(rm, adjstart, adjend, adjcount, flags,
child);
if (rv == NULL) {
device_printf(bus,
"failed to reserve resource %#lx - %#lx (%#lx)"
" for %s\n", adjstart, adjend, adjcount,
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:coyizumi,项目名称:cs111,代码行数:101,代码来源:uninorth.c
示例16: sgmap_free_region
/*
* Free a region allocated using sgmap_alloc_region().
*/
void
sgmap_free_region(struct sgmap *sgmap, void *mh)
{
struct resource *res = mh;
rman_release_resource(res);
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:9,代码来源:sgmap.c
示例17: pxa_alloc_resource
static struct resource *
pxa_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 obio_softc *sc;
struct obio_device *od;
struct resource *rv;
struct resource_list *rl;
struct resource_list_entry *rle;
struct rman *rm;
int needactivate;
sc = (struct obio_softc *)device_get_softc(dev);
od = (struct obio_device *)device_get_ivars(child);
rl = &od->od_resources;
rle = resource_list_find(rl, type, *rid);
if (rle == NULL) {
/* We can allocate GPIO-based IRQs lazily. */
if (type == SYS_RES_IRQ)
return (pxa_alloc_gpio_irq(dev, child, type, rid,
start, end, count, flags));
return (NULL);
}
if (rle->res != NULL)
panic("pxa_alloc_resource: resource is busy");
switch (type) {
case SYS_RES_IRQ:
rm = &sc->obio_irq;
break;
case SYS_RES_MEMORY:
rm = &sc->obio_mem;
break;
default:
return (NULL);
}
needactivate = flags & RF_ACTIVE;
flags &= ~RF_ACTIVE;
rv = rman_reserve_resource(rm, rle->start, rle->end, rle->count, flags,
child);
if (rv == NULL)
return (NULL);
rle->res = rv;
rman_set_rid(rv, *rid);
if (type == SYS_RES_MEMORY) {
rman_set_bustag(rv, sc->obio_bst);
rman_set_bushandle(rv, rle->start);
}
if (needactivate) {
if (bus_activate_resource(child, type, *rid, rv)) {
rman_release_resource(rv);
return (NULL);
}
}
return (rv);
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:62,代码来源:pxa_obio.c
示例18: 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 npx.)
*/
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_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 ((start == 0UL) && (end == ~0UL) && (count == 1)) {
if (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;
}
flags &= ~RF_ACTIVE;
switch (type) {
case SYS_RES_IRQ:
rm = &irq_rman;
break;
case SYS_RES_DRQ:
rm = &drq_rman;
break;
case SYS_RES_IOPORT:
rm = &port_rman;
break;
case SYS_RES_MEMORY:
rm = &mem_rman;
break;
default:
return 0;
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
if (rv == 0)
return 0;
if (type == SYS_RES_MEMORY) {
rman_set_bustag(rv, I386_BUS_SPACE_MEM);
} else if (type == SYS_RES_IOPORT) {
rman_set_bustag(rv, I386_BUS_SPACE_IO);
#ifndef PC98
rman_set_bushandle(rv, rv->r_start);
#endif
}
#ifdef PC98
if ((type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) &&
i386_bus_space_handle_alloc(rv->r_bustag, rv->r_start, count,
&rv->r_bushandle) != 0) {
rman_release_resource(rv);
return 0;
}
#endif
if (needactivate) {
if (bus_activate_resource(child, type, *rid, rv)) {
#ifdef PC98
if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) {
i386_bus_space_handle_free(rv->r_bustag,
rv->r_bushandle, rv->r_bushandle->bsh_sz);
}
#endif
rman_release_resource(rv);
return 0;
}
}
return rv;
}
开发者ID:MarginC,项目名称:kame,代码行数:91,代码来源:nexus.c
示例19: pxa_smi_alloc_resource
static struct resource *
pxa_smi_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 pxa_smi_softc *sc;
struct smi_ivars *smid;
struct resource *rv;
struct resource_list *rl;
struct resource_list_entry *rle;
int needactivate;
sc = (struct pxa_smi_softc *)device_get_softc(dev);
smid = (struct smi_ivars *)device_get_ivars(child);
rl = &smid->smid_resources;
if (type == SYS_RES_IOPORT)
type = SYS_RES_MEMORY;
rle = resource_list_find(rl, type, *rid);
if (rle == NULL)
return (NULL);
if (rle->res != NULL)
panic("pxa_smi_alloc_resource: resource is busy");
needactivate = flags & RF_ACTIVE;
flags &= ~RF_ACTIVE;
switch (type) {
case SYS_RES_MEMORY:
rv = rman_reserve_resource(&sc->ps_mem, rle->start, rle->end,
rle->count, flags, child);
if (rv == NULL)
return (NULL);
rle->res = rv;
rman_set_rid(rv, *rid);
rman_set_bustag(rv, sc->ps_bst);
rman_set_bushandle(rv, rle->start);
if (needactivate) {
if (bus_activate_resource(child, type, *rid, rv) != 0) {
rman_release_resource(rv);
return (NULL);
}
}
break;
case SYS_RES_IRQ:
rv = bus_alloc_resource(dev, type, rid, rle->start, rle->end,
rle->count, flags);
if (rv == NULL)
return (NULL);
if (needactivate) {
if (bus_activate_resource(child, type, *rid, rv) != 0) {
bus_release_resource(dev, type, *rid, rv);
return (NULL);
}
}
break;
default:
return (NULL);
}
return (rv);
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:66,代码来源:pxa_smi.c
示例20: ebus_alloc_resource
static struct resource *
ebus_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 ebus_softc *sc;
struct resource_list *rl;
struct resource_list_entry *rle = NULL;
struct resource *res;
struct ebus_rinfo *eri;
struct ebus_nexus_ranges *enr;
uint64_t cend, cstart, offset;
int i, isdefault, passthrough, ridx;
isdefault = (start == 0UL && end == ~0UL);
passthrough = (device_get_parent(child) != bus);
sc = device_get_softc(bus);
rl = BUS_GET_RESOURCE_LIST(bus, child);
switch (type) {
case SYS_RES_MEMORY:
KASSERT(!(isdefault && passthrough),
("%s: passthrough of default allocation", __func__));
if (!passthrough) {
rle = resource_list_find(rl, type, *rid);
if (rle == NULL)
return (NULL);
KASSERT(rle->res == NULL,
("%s: resource entry is busy", __func__));
if (isdefault) {
start = rle->start;
count = ulmax(count, rle->count);
end = ulmax(rle->end, start + count - 1);
}
}
res = NULL;
if ((sc->sc_flags & EBUS_PCI) != 0) {
/*
* Map EBus ranges to PCI ranges. This may include
* changing the allocation type.
*/
(void)ofw_isa_range_map(sc->sc_range, sc->sc_nrange,
&start, &end, &ridx);
eri = &sc->sc_rinfo[ridx];
res = rman_reserve_resource(&eri->eri_rman, start,
end, count, flags & ~RF_ACTIVE, child);
if (res == NULL)
return (NULL);
rman_set_rid(res, *rid);
if ((flags & RF_ACTIVE) != 0 && bus_activate_resource(
child, type, *rid, res) != 0) {
rman_release_resource(res);
return (NULL);
}
} else {
/* Map EBus ranges to nexus ranges. */
for (i = 0; i < sc->sc_nrange; i++) {
enr = &((struct ebus_nexus_ranges *)
sc->sc_range)[i];
cstart = (((uint64_t)enr->child_hi) << 32) |
enr->child_lo;
cend = cstart + enr->size - 1;
if (start >= cstart && end <= cend) {
offset =
(((uint64_t)enr->phys_hi) << 32) |
enr->phys_lo;
start += offset - cstart;
end += offset - cstart;
res = bus_generic_alloc_resource(bus,
child, type, rid, start, end,
count, flags);
break;
}
}
}
if (!passthrough)
rle->res = res;
return (res);
case SYS_RES_IRQ:
return (resource_list_alloc(rl, bus, child, type, rid, start,
end, count, flags));
}
return (NULL);
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:83,代码来源:ebus.c
注:本文中的rman_release_resource函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论