From owner-freebsd-hackers Sun Jul 4 13: 5:33 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (Postfix) with ESMTP id 1DE5014E18 for ; Sun, 4 Jul 1999 13:05:29 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.9.3/8.9.3) with ESMTP id OAA16184; Sun, 4 Jul 1999 14:05:28 -0600 (MDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.9.3/8.8.3) with ESMTP id OAA43735; Sun, 4 Jul 1999 14:03:29 -0600 (MDT) Message-Id: <199907042003.OAA43735@harmony.village.org> To: Doug Rabson Subject: Re: The busspace modernization initiative. Cc: hackers@freebsd.org In-reply-to: Your message of "Sun, 04 Jul 1999 11:05:14 BST." References: Date: Sun, 04 Jul 1999 14:03:29 -0600 From: Warner Losh Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message 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 majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message