Pull all the code to deal with bus space methods into a shared set of

routines.
This commit is contained in:
Kevin Lo 2008-06-10 03:44:14 +00:00
parent 49d3c1f416
commit 43d8707e0f
2 changed files with 7 additions and 102 deletions

View File

@ -1,5 +1,6 @@
# $FreeBSD$
arm/arm/bus_space_generic.c standard
arm/arm/cpufunc_asm_xscale.S standard
arm/arm/irq_dispatch.S standard

View File

@ -48,13 +48,6 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <machine/pcb.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_kern.h>
#include <vm/vm_extern.h>
#include <machine/bus.h>
#include <arm/xscale/pxa/pxareg.h>
@ -63,7 +56,6 @@ __FBSDID("$FreeBSD$");
MALLOC_DEFINE(M_PXATAG, "PXA bus_space tags", "Bus_space tags for PXA");
/* Prototypes for all the bus_space structure functions */
bs_protos(obio);
bs_protos(generic);
bs_protos(generic_armv4);
bs_protos(pxa);
@ -77,16 +69,16 @@ struct bus_space _base_tag = {
(void *) 0,
/* mapping/unmapping */
obio_bs_map,
obio_bs_unmap,
obio_bs_subregion,
generic_bs_map,
generic_bs_unmap,
generic_bs_subregion,
/* allocation/deallocation */
obio_bs_alloc,
obio_bs_free,
generic_bs_alloc,
generic_bs_free,
/* barrier */
obio_bs_barrier,
generic_bs_barrier,
/* read (single) */
pxa_bs_r_1,
@ -174,94 +166,6 @@ pxa_bus_tag_alloc(bus_addr_t offset)
return ((bus_space_tag_t)tag);
}
int
obio_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
bus_space_handle_t *bshp)
{
const struct pmap_devmap *pd;
vm_paddr_t startpa, endpa, pa, offset;
vm_offset_t va;
pt_entry_t *pte;
if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) {
/* Device was statically mapped. */
*bshp = pd->pd_va + (bpa - pd->pd_pa);
return (0);
}
endpa = round_page(bpa + size);
offset = bpa & PAGE_MASK;
startpa = trunc_page(bpa);
va = kmem_alloc(kernel_map, endpa - startpa);
if (va == 0)
return (ENOMEM);
*bshp = va + offset;
for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
pmap_kenter(va, pa);
pte = vtopte(va);
*pte &= ~L2_S_CACHE_MASK;
PTE_SYNC(pte);
}
return (0);
}
int
obio_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size,
bus_size_t alignment, bus_size_t boundary, int flags, bus_addr_t *bpap,
bus_space_handle_t *bshp)
{
panic("obio_bs_alloc(): not implemented");
}
void
obio_bs_unmap(void *t, bus_space_handle_t h, bus_size_t size)
{
vm_offset_t va, endva;
if (pmap_devmap_find_va((vm_offset_t)t, size) != NULL) {
/* Device was statically mapped; nothing to do. */
return;
}
endva = round_page((vm_offset_t)t + size);
va = trunc_page((vm_offset_t)t);
while (va < endva) {
pmap_kremove(va);
va += PAGE_SIZE;
}
kmem_free(kernel_map, va, endva - va);
}
void
obio_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size)
{
panic("obio_bs_free(): not implemented");
}
int
obio_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
bus_size_t size, bus_space_handle_t *nbshp)
{
*nbshp = bsh + offset;
return (0);
}
void
obio_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
bus_size_t len, int flags)
{
/* Nothing to do. */
}
#define READ_SINGLE(type, proto, base) \
type \