tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bus_space_physload(9)
On Wed, Mar 24, 2010 at 05:09:23PM +0900, Masao Uebayashi wrote:
> On Wed, Mar 24, 2010 at 03:06:08PM +0900, Masao Uebayashi wrote:
> > void *bus_space_physload(bus_space_tag_t space, bus_addr_t addr,
> > bus_size_t size);
>
> This function should take the same arguments as bus_space_mmap(9). I've
> added "int prot" and "int flags":
>
> void *bus_space_physload(bus_space_tag_t space, bus_addr_t addr,
> bus_size_t size, int prot, int flags);
>
> "int prot" is the device's characteristic. Audio mic devices would use
> VM_PROT_READ. Framebuffers would use VM_PROT_WRITE. We need to introduce
> BUS_SPACE_PROT_* symbols too.
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;
}
--
David Young OJC Technologies
dyoung%ojctech.com@localhost Urbana, IL * (217) 278-3933
Home |
Main Index |
Thread Index |
Old Index