Beispiel #1
0
int
isa_release_resource(device_t bus, device_t child, int type, int rid,
		     struct resource *r)
{
	struct isa_device* idev = DEVTOISA(child);
	struct resource_list *rl = &idev->id_resources;
#ifdef PC98
	/*
	 * Indirection support.  The type of bus_space_handle_t is
	 * defined in sys/i386/include/bus_pc98.h.
	 */
	int	i;
	bus_space_handle_t bh;

	if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) {
		bh = rman_get_bushandle(r);
		if (bh != NULL) {
			for (i = 1; i < bh->bsh_ressz; i++)
				resource_list_release(rl, bus, child, type,
						      rid + i, bh->bsh_res[i]);
			if (bh->bsh_res != NULL)
				free(bh->bsh_res, M_DEVBUF);
		}
	}
#endif
	return resource_list_release(rl, bus, child, type, rid, r);
}
static int
ebus_release_resource(device_t bus, device_t child, int type, int rid,
    struct resource *res)
{
	struct resource_list *rl;
	struct resource_list_entry *rle;
	int passthrough = (device_get_parent(child) != bus);
	int rv;

	rl = BUS_GET_RESOURCE_LIST(bus, child);
	switch (type) {
	case SYS_RES_MEMORY:
		if ((rv = rman_release_resource(res)) != 0)
			return (rv);
		if (!passthrough) {
			rle = resource_list_find(rl, type, rid);
			KASSERT(rle != NULL, ("ebus_release_resource: "
			    "resource entry not found!"));
			KASSERT(rle->res != NULL, ("ebus_alloc_resource: "
			    "resource entry is not busy"));
			rle->res = NULL;
		}
		break;
	case SYS_RES_IRQ:
		return (resource_list_release(rl, bus, child, type, rid, res));
	default:
		panic("ebus_release_resource: unsupported resource type %d",
		    type);
	}
	return (0);
}
Beispiel #3
0
int
isa_release_resource(device_t bus, device_t child, int type, int rid,
		     struct resource *res)
{
	int passthrough = (device_get_parent(child) != bus);
	struct isa_device* idev = DEVTOISA(child);
	struct resource_list *rl = &idev->id_resources;
	struct resource_list_entry *rle;
	int error;

	if (type != SYS_RES_IRQ)
		return resource_list_release(rl, bus, child, type, rid, res);

	error = rman_release_resource(res);

	if (!passthrough && !error) {
		rle = resource_list_find(rl, SYS_RES_IRQ, rid);
		if (rle)
			rle->res = NULL;
		else
			error = ENOENT;
	}

	return error;
}
Beispiel #4
0
static int
sbus_release_resource(device_t bus, device_t child, int type, int rid,
                      struct resource *r)
{
    struct resource_list *rl;
    struct resource_list_entry *rle;
    int error, passthrough;

    passthrough = (device_get_parent(child) != bus);
    rl = BUS_GET_RESOURCE_LIST(bus, child);
    if (type == SYS_RES_MEMORY) {
        if ((rman_get_flags(r) & RF_ACTIVE) != 0) {
            error = bus_deactivate_resource(child, type, rid, r);
            if (error)
                return (error);
        }
        error = rman_release_resource(r);
        if (error != 0)
            return (error);
        if (!passthrough) {
            rle = resource_list_find(rl, type, rid);
            KASSERT(rle != NULL,
                    ("%s: resource entry not found!", __func__));
            KASSERT(rle->res != NULL,
                    ("%s: resource entry is not busy", __func__));
            rle->res = NULL;
        }
        return (0);
    }
    return (resource_list_release(rl, bus, child, type, rid, r));
}
Beispiel #5
0
static int
sbus_release_resource(device_t bus, device_t child, int type, int rid,
    struct resource *r)
{
	struct resource_list *rl;
	struct resource_list_entry *rle;
	int error, passthrough;

	passthrough = (device_get_parent(child) != bus);
	rl = BUS_GET_RESOURCE_LIST(bus, child);
	if (type == SYS_RES_IRQ)
		return (resource_list_release(rl, bus, child, type, rid, r));
	if ((rman_get_flags(r) & RF_ACTIVE) != 0) {
		error = bus_deactivate_resource(child, type, rid, r);
		if (error != 0)
			return (error);
	}
	error = rman_release_resource(r);
	if (error != 0 || passthrough)
		return (error);
	rle = resource_list_find(rl, type, rid);
	if (rle == NULL)
		panic("%s: cannot find resource", __func__);
	if (rle->res == NULL)
		panic("%s: resource entry is not busy", __func__);
	rle->res = NULL;
	return (0);
}
Beispiel #6
0
int
isa_release_resource(device_t bus, device_t child, int type, int rid,
		     struct resource *r)
{
	struct isa_device* idev = DEVTOISA(child);
	struct resource_list *rl = &idev->id_resources;
	return resource_list_release(rl, bus, child, type, rid, r);
}
Beispiel #7
0
static int
pccard_release_resource(device_t bus, device_t child, int type, int rid,
		     struct resource *r)
{
	struct pccard_devinfo *devi = PCCARD_DEVINFO(child);
	struct resource_list *rl = &devi->resources;
	return resource_list_release(rl, bus, child, type, rid, r);
}
Beispiel #8
0
/*
 * Indirection support.  The type of bus_space_handle_t is
 * defined in sys/i386/include/bus_pc98.h.
 */
struct resource *
isa_alloc_resourcev(device_t child, int type, int *rid,
		    bus_addr_t *res, bus_size_t count, u_int flags)
{
	struct isa_device* idev = DEVTOISA(child);
	struct resource_list *rl = &idev->id_resources;

	device_t	bus = device_get_parent(child);
	bus_addr_t	start;
	bus_space_handle_t bh;
	struct resource *re;
	struct resource	**bsre;
	int		i, j, k, linear_cnt, ressz, bsrid;

	start = bus_get_resource_start(child, type, *rid);

	linear_cnt = count;
	ressz = 1;
	for (i = 1; i < count; ++i) {
		if (res[i] != res[i - 1] + 1) {
			if (i < linear_cnt)
				linear_cnt = i;
			++ressz;
		}
	}

	re = isa_alloc_resource(bus, child, type, rid,
				start + res[0], start + res[linear_cnt - 1],
				linear_cnt, flags);
	if (re == NULL)
		return NULL;

	bsre = malloc(sizeof (struct resource *) * ressz, M_DEVBUF, M_NOWAIT);
	if (bsre == NULL) {
		resource_list_release(rl, bus, child, type, *rid, re);
		return NULL;
	}
	bsre[0] = re;

	for (i = linear_cnt, k = 1; i < count; i = j, k++) {
		for (j = i + 1; j < count; j++) {
			if (res[j] != res[j - 1] + 1)
				break;
		}
		bsrid = *rid + k;
		bsre[k] = isa_alloc_resource(bus, child, type, &bsrid,
			start + res[i], start + res[j - 1], j - i, flags);
		if (bsre[k] == NULL) {
			for (k--; k >= 0; k--)
				resource_list_release(rl, bus, child, type,
						      *rid + k, bsre[k]);
			free(bsre, M_DEVBUF);
			return NULL;
		}
	}

	bh = rman_get_bushandle(re);
	bh->bsh_res = bsre;
	bh->bsh_ressz = ressz;

	return re;
}