tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bus_space_physload(9)



On Thu, Mar 25, 2010 at 11:43:52AM +0900, Masao Uebayashi wrote:
> On Wed, Mar 24, 2010 at 01:07:15PM -0500, David Young wrote:
> > Can it be implemented like this?
> > 
> > void *
> > bus_space_physload(bus_space_tag_t bst, bus_addr_t addr, bus_size_t size,
> >     vm_prot_t prot, int flags)
> > {
> >     bus_space_handle_t bsh;
> >     void *p;
> >     int rc;
> > 
> >     rc = bus_space_map(bst, addr, size, flags | BUS_SPACE_MAP_LINEAR, &bsh);
> >     if (rc != 0)
> >             return NULL;
> > 
> >     p = bus_space_vaddr(bst, bsh);
> > 
> >     if (p == NULL) {
> >             bus_space_unmap(bst, bsh, size);
> >             return NULL;
> >     }
> > 
> >     rc = vm_map_protect(kernel_map, (vaddr_t)p, (vaddr_t)p + size, prot,
> >         true);
> > 
> >     if (rc != 0) {
> >             bus_space_unmap(bst, bsh, size);
> >             return NULL;
> >     }
> > 
> >     return p;
> > }
> 
> No, like this:
> 
>       void *
>       bus_space_physload(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
>           int prot, int flags)
>       {
>               const bus_addr_t busp = addr;
>               const bus_addr_t busq = addr + size;
>               const paddr_t physp = bus_space_mmap(t, busp, 0, prot, flags);
>               const paddr_t physq = bus_space_mmap(t, busq, 0, prot, flags);

You haven't mmap()'d the entire range.  Shouldn't that be:

                const bus_addr_t busp = addr;
                const bus_addr_t busq = addr + size;
                off_t i;
                const paddr_t physp = bus_space_mmap(t, busp, 0, prot, flags);
                const paddr_t physq = bus_space_mmap(t, busq, 0, prot, flags);

                for (i = PAGE_SIZE; i < busq - busp; i += PAGE_SIZE)
                        (void)bus_space_mmap(t, busp, i, prot, flags);

Dave

-- 
David Young             OJC Technologies
dyoung%ojctech.com@localhost      Urbana, IL * (217) 278-3933


Home | Main Index | Thread Index | Old Index