diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 1999-11-05 18:07:12 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 1999-11-05 18:07:12 +0000 |
commit | 3a1888d7e16d100d3d2ef6a1d6293afc14bb39fa (patch) | |
tree | da7eaf3b8ba6f60d6ae6f6be13146e7e204901eb /sys | |
parent | 2c5505dbf5abe059b149d7a319cb7542bce1ff84 (diff) |
Move the allocation of iomme ptes to iommuattach (where it belongs).
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sparc/sparc/iommu.c | 54 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/pmap.c | 24 |
2 files changed, 50 insertions, 28 deletions
diff --git a/sys/arch/sparc/sparc/iommu.c b/sys/arch/sparc/sparc/iommu.c index a817c531d58..de3202f3aaa 100644 --- a/sys/arch/sparc/sparc/iommu.c +++ b/sys/arch/sparc/sparc/iommu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iommu.c,v 1.4 1999/01/11 05:11:58 millert Exp $ */ +/* $OpenBSD: iommu.c,v 1.5 1999/11/05 18:07:11 art Exp $ */ /* $NetBSD: iommu.c,v 1.13 1997/07/29 09:42:04 fair Exp $ */ /* @@ -41,6 +41,10 @@ #include <sys/systm.h> #include <sys/device.h> #include <vm/vm.h> +#include <vm/vm_kern.h> +#if defined(UVM) +#include <uvm/uvm.h> +#endif #include <machine/autoconf.h> #include <machine/ctlreg.h> @@ -125,8 +129,10 @@ iommu_attach(parent, self, aux) register u_int pbase, pa; register int i, mmupcrsave, s; register iopte_t *tpte_p; - extern u_int *kernel_iopte_table; - extern u_int kernel_iopte_table_pa; + struct pglist mlist; + struct vm_page *m; + vaddr_t iopte_va; + paddr_t iopte_pa; /*XXX-GCC!*/mmupcrsave=0; iommu_sc = sc; @@ -171,6 +177,44 @@ iommu_attach(parent, self, aux) (14 - IOMMU_BAR_IBASHFT); /* + * Allocate memory for I/O pagetables. This takes 64k of memory + * since we want to have 64M of dvma space (this actually depends + * on the definition of DVMA4M_BASE...we may drop it back to 32M). + * The table must be aligned on a (-DVMA4M_BASE/NBPG) boundary + * (i.e. 64K for 64M of dvma space). + */ + TAILQ_INIT(&mlist); +#define DVMA_PTESIZE ((0 - DVMA4M_BASE) / 1024) +#if defined(UVM) + if (uvm_pglistalloc(DVMA_PTESIZE, 0, 0xffffffff, DVMA_PTESIZE, + 0, &mlist, 1, 0) || + (iopte_va = uvm_km_valloc(kernel_map, DVMA_PTESIZE)) == 0) + panic("iommu_attach: can't allocate memory for pagetables"); +#else + if (vm_page_alloc_memory(DVMA_PTESIZE, 0, 0xffffffff, DVMA_PTESIZE, + 0, &mlist, 1, 0) || + (iopte_va = kmem_alloc_pageable(kernel_map, DVMA_PTESIZE)) == 0) + panic("iommu_attach: can't allocate memory for pagetables"); +#endif +#undef DVMA_PTESIZE + m = TAILQ_FIRST(&mlist); + iopte_pa = VM_PAGE_TO_PHYS(m); + sc->sc_ptes = (iopte_t *) iopte_va; + + while (m) { +#if defined(UVM) + uvm_pagewire(m); +#else + vm_page_wire(m); +#endif + pmap_enter(pmap_kernel(), iopte_va, VM_PAGE_TO_PHYS(m), + VM_PROT_READ|VM_PROT_WRITE, 1, + VM_PROT_READ|VM_PROT_WRITE); + iopte_va += NBPG; + m = TAILQ_NEXT(m, pageq); + } + + /* * Now we build our own copy of the IOMMU page tables. We need to * do this since we're going to change the range to give us 64M of * mappings, and thus we can move DVMA space down to 0xfd000000 to @@ -178,7 +222,7 @@ iommu_attach(parent, self, aux) * * XXX Note that this is rather messy. */ - sc->sc_ptes = (iopte_t *) kernel_iopte_table; + /* * Now discache the page tables so that the IOMMU sees our @@ -232,7 +276,7 @@ iommu_attach(parent, self, aux) sc->sc_reg->io_cr = (sc->sc_reg->io_cr & ~IOMMU_CTL_RANGE) | (i << IOMMU_CTL_RANGESHFT) | IOMMU_CTL_ME; - sc->sc_reg->io_bar = (kernel_iopte_table_pa >> 4) & IOMMU_BAR_IBA; + sc->sc_reg->io_bar = (iopte_pa >> 4) & IOMMU_BAR_IBA; IOMMU_FLUSHALL(sc); splx(s); diff --git a/sys/arch/sparc/sparc/pmap.c b/sys/arch/sparc/sparc/pmap.c index a769db2948d..8da637d1ada 100644 --- a/sys/arch/sparc/sparc/pmap.c +++ b/sys/arch/sparc/sparc/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.37 1999/11/05 16:22:08 art Exp $ */ +/* $OpenBSD: pmap.c,v 1.38 1999/11/05 18:07:10 art Exp $ */ /* $NetBSD: pmap.c,v 1.118 1998/05/19 19:00:18 thorpej Exp $ */ /* @@ -339,9 +339,6 @@ struct segmap kernel_segmap_store[NKREG*NSEGRG];/* the kernel's segmaps */ u_int *kernel_regtable_store; /* 1k of storage to map the kernel */ u_int *kernel_segtable_store; /* 2k of storage to map the kernel */ u_int *kernel_pagtable_store; /* 128k of storage to map the kernel */ - -u_int *kernel_iopte_table; /* 64k of storage for iommu */ -u_int kernel_iopte_table_pa; #endif #define MA_SIZE 32 /* size of memory descriptor arrays */ @@ -3204,26 +3201,7 @@ pmap_bootstrap4m(void) * The amount of physical memory that becomes unavailable for * general VM use is marked by [unavail_start, unavail_end>. */ - - /* - * Reserve memory for I/O pagetables. This takes 64k of memory - * since we want to have 64M of dvma space (this actually depends - * on the definition of DVMA4M_BASE...we may drop it back to 32M). - * The table must be aligned on a (-DVMA4M_BASE/NBPG) boundary - * (i.e. 64K for 64M of dvma space). - */ -#ifdef DEBUG - if ((0 - DVMA4M_BASE) % (16*1024*1024)) - panic("pmap_bootstrap4m: invalid DVMA4M_BASE of 0x%x", DVMA4M_BASE); -#endif - - p = (caddr_t) roundup((u_int)p, (0 - DVMA4M_BASE) / 1024); unavail_start = (paddr_t)p - KERNBASE; - - kernel_iopte_table = (u_int *)p; - kernel_iopte_table_pa = VA2PA((caddr_t)kernel_iopte_table); - p += (0 - DVMA4M_BASE) / 1024; - pagetables_start = p; /* * Allocate context table. |