In message <[EMAIL PROTECTED]> Doug Rabson
writes:
: I think you are on the right lines here. Where does the resource come
: from? Are you going to support bus_space_map() and if so, how are you
: planning to call BUS_ALLOC_RESOURCE?
In i386/i386/resource.c :-). Here's what is there now. It looks like
it currently bypasses BUS_ALLOC_RESOURCE, going to the resource
manager (rman) directly. Do you have any comments on this code? Or
would you rather I send you a complete patch/diff to comment on?
int
bus_space_alloc(t, rstart, rend, size, alignment, boundary, flags,
bpap, bshp)
bus_space_tag_t t;
bus_addr_t rstart, rend;
bus_size_t size, alignment, boundary;
int flags;
bus_addr_t *bpap;
bus_space_handle_t *bshp;
{
struct resource *rv;
struct rman *ex;
unsigned long bpa;
int error;
/*
* Pick the appropriate resource.
*/
if (t == I386_BUS_SPACE_IO) {
if (flags & BUS_SPACE_MAP_LINEAR)
return EOPNOTSUPP;
ex = &ioport_rman;
} else if (t == I386_BUS_SPACE_MEM)
ex = &iomem_rman;
else
panic("bus_space_alloc: bad bus space tag");
/*
* Sanity check the allocation against the resource's boundaries.
*/
if (rstart < ex->rm_start || rend > ex->rm_end)
panic("bus_space_alloc: bad region start/end");
/*
* Do the requested allocation.
*/
retry:
/*
printf("bus_space_alloc %lx,%lx,%lx,%lx\n",
(u_long)rstart, (u_long)rend, (u_long)size, (u_long)alignment);
*/
rv = rman_reserve_resource(ex, rstart, rend, size, flags, NULL); /* XXX NULL? */
if (!rv) {
return EAGAIN;
}
if ( rv->r_start != EXTENT_ALIGN (rv->r_start, alignment, 0) ) {
rstart = EXTENT_ALIGN (rv->r_start, alignment, 0);
rman_release_resource (rv);
goto retry;
}
bpa = rv->r_start;
rman_activate_resource (rv);
/*
* For I/O space, that's all she wrote.
*/
if (t == I386_BUS_SPACE_IO) {
bshp->addr = *bpap = bpa;
bshp->resource = rv;
return 0;
}
/*
* For memory space, map the bus physical address to
* a kernel virtual address.
*/
if (bpa >= ISA_HOLE_START &&
(bpa + size) <= ISA_HOLE_START + ISA_HOLE_LENGTH) { /* ISA hole */
bshp->addr = (u_int)ISA_HOLE_VADDR(bpa);
} else { /* General */
if((error = i386_mem_alloc_and_map (bpa, size, (vm_offset_t*)(&bshp->addr)))) {
rman_release_resource (rv);
return 1;
}
}
*bpap = bpa;
bshp->resource = rv;
return 0;
}
: I assume that you will update the alpha version of bus.h too.
Of course.
Warner
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message