Copy bus_space_map() function from arm/mainbus/mainbus_io.c.

This commit is contained in:
toshii 2001-03-10 13:27:53 +00:00
parent c62849a451
commit 4333644371
1 changed files with 39 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sa11x0_io.c,v 1.1 2001/02/23 03:48:21 ichiro Exp $ */
/* $NetBSD: sa11x0_io.c,v 1.2 2001/03/10 13:27:53 toshii Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe.
@ -42,7 +42,13 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/queue.h>
#include <uvm/uvm.h>
#include <machine/bus.h>
#include <machine/pmap.h>
#include <machine/pte.h>
/* Proto types for all the bus_space structure functions */
@ -135,15 +141,39 @@ sa11x0_bs_map(t, bpa, size, cacheable, bshp)
int cacheable;
bus_space_handle_t *bshp;
{
/*
* Temporary implementation as all I/O is already mapped etc.
*
* Eventually this function will do the mapping check for multiple maps
*/
*bshp = bpa;
return(0);
u_long startpa, endpa, pa;
vaddr_t va;
pt_entry_t *pte;
if ((u_long)bpa > (u_long)KERNEL_SPACE_START) {
/* XXX This is a temporary hack to aid transition. */
*bshp = bpa;
return(0);
}
startpa = trunc_page(bpa);
endpa = round_page(bpa + size);
/* XXX use extent manager to check duplicate mapping */
va = uvm_km_valloc(kernel_map, endpa - startpa);
if (! va)
return(ENOMEM);
*bshp = (bus_space_handle_t)(va + (bpa - startpa));
for(pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
pte = pmap_pte(kernel_pmap, va);
if (cacheable)
*pte |= PT_CACHEABLE;
else
*pte &= ~PT_CACHEABLE;
}
return(0);
}
int
sa11x0_bs_alloc(t, rstart, rend, size, alignment, boundary, cacheable,
bpap, bshp)
@ -189,7 +219,7 @@ sa11x0_bs_subregion(t, bsh, offset, size, nbshp)
bus_space_handle_t *nbshp;
{
*nbshp = bsh + (offset << ((int)t));
*nbshp = bsh + offset;
return (0);
}