Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hpcarm/mainbus Implement bus_space_map().



details:   https://anonhg.NetBSD.org/src/rev/e23968466505
branches:  trunk
changeset: 504179:e23968466505
user:      toshii <toshii%NetBSD.org@localhost>
date:      Sat Feb 24 12:41:20 2001 +0000

description:
Implement bus_space_map().

diffstat:

 sys/arch/hpcarm/mainbus/mainbus_io.c |  48 ++++++++++++++++++++++++++++++------
 1 files changed, 40 insertions(+), 8 deletions(-)

diffs (71 lines):

diff -r bed78c9f3dcc -r e23968466505 sys/arch/hpcarm/mainbus/mainbus_io.c
--- a/sys/arch/hpcarm/mainbus/mainbus_io.c      Sat Feb 24 11:11:36 2001 +0000
+++ b/sys/arch/hpcarm/mainbus/mainbus_io.c      Sat Feb 24 12:41:20 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mainbus_io.c,v 1.1 2001/02/23 03:48:20 ichiro Exp $    */
+/*     $NetBSD: mainbus_io.c,v 1.2 2001/02/24 12:41:20 toshii Exp $    */
 
 /*
  * Copyright (c) 1997 Mark Brinicombe.
@@ -38,7 +38,15 @@
 
 #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>
+
+pt_entry_t *pmap_pte(pmap_t, vm_offset_t);
 
 /* Proto types for all the bus_space structure functions */
 
@@ -130,14 +138,38 @@
        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;
+       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
 mainbus_bs_alloc(t, rstart, rend, size, alignment, boundary, cacheable,



Home | Main Index | Thread Index | Old Index