summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>1999-02-26 04:41:14 +0000
committerArtur Grabowski <art@cvs.openbsd.org>1999-02-26 04:41:14 +0000
commit6bbe8bb03eac297fcaa07763b0d6f8472c578643 (patch)
treec35b5b7ddcb0b332c2d6db6f2f8db4febb0e4138 /sys/arch
parent645bb583e37de40b7c4a8b194509cd11927e6eb2 (diff)
some allocation changes, name changes, etc for uvm
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/i386/i386/machdep.c90
-rw-r--r--sys/arch/i386/i386/mem.c16
-rw-r--r--sys/arch/i386/i386/sys_machdep.c17
3 files changed, 121 insertions, 2 deletions
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 1fb3137a8e0..d5f41799ee4 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.101 1999/02/25 21:17:22 mickey Exp $ */
+/* $OpenBSD: machdep.c,v 1.102 1999/02/26 04:41:13 art Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -117,6 +117,10 @@
#include <vm/vm_kern.h>
#include <vm/vm_page.h>
+#if defined(UVM)
+#include <uvm/uvm_extern.h>
+#endif
+
#include <sys/sysctl.h>
#define _I386_BUS_DMA_PRIVATE
@@ -193,7 +197,14 @@ struct msgbuf *msgbufp;
int msgbufmapped;
bootarg_t *bootargp;
+
+#if defined(UVM)
+vm_map_t exec_map = NULL;
+vm_map_t mb_map = NULL;
+vm_map_t phys_map = NULL;
+#else
vm_map_t buffer_map;
+#endif
extern vm_offset_t avail_start, avail_end;
vm_offset_t hole_start, hole_end;
@@ -306,7 +317,11 @@ cpu_startup()
* and then give everything true virtual addresses.
*/
sz = (int)allocsys((caddr_t)0);
+#if defined(UVM)
+ if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
+#else
if ((v = (caddr_t)kmem_alloc(kernel_map, round_page(sz))) == 0)
+#endif
panic("startup: no room for tables");
if (allocsys(v) - v != sz)
panic("startup: table size inconsistency");
@@ -321,14 +336,24 @@ cpu_startup()
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
*/
+#if defined(UVM)
+ exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
+ 16*NCARGS, TRUE, FALSE, NULL);
+#else
exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, 16*NCARGS,
TRUE);
+#endif
/*
* Allocate a submap for physio
*/
+#if defined(UVM)
+ phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
+ VM_PHYS_SIZE, TRUE, FALSE, NULL);
+#else
phys_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE,
TRUE);
+#endif
/*
* Finally, allocate mbuf pool. Since mclrefcnt is an off-size
@@ -337,8 +362,13 @@ cpu_startup()
mclrefcnt = (char *)malloc(NMBCLUSTERS+CLBYTES/MCLBYTES, M_MBUF,
M_NOWAIT);
bzero(mclrefcnt, NMBCLUSTERS+CLBYTES/MCLBYTES);
+#if defined(UVM)
+ mb_map = uvm_km_suballoc(kernel_map, (vm_offset_t *)&mbutl, &maxaddr,
+ VM_MBUF_SIZE, FALSE, FALSE, NULL);
+#else
mb_map = kmem_suballoc(kernel_map, (vm_offset_t *)&mbutl, &maxaddr,
VM_MBUF_SIZE, FALSE);
+#endif
/*
* Initialize callouts
@@ -347,7 +377,11 @@ cpu_startup()
for (i = 1; i < ncallout; i++)
callout[i-1].c_next = &callout[i];
+#if defined(UVM)
+ printf("avail mem = %ld\n", ptoa(uvmexp.free));
+#else
printf("avail mem = %ld\n", ptoa(cnt.v_free_count));
+#endif
printf("using %d buffers containing %d bytes of memory\n",
nbuf, bufpages * CLBYTES);
@@ -465,7 +499,9 @@ allocsys(v)
if (nswbuf > 256)
nswbuf = 256; /* sanity */
}
+#if !defined(UVM)
valloc(swbuf, struct buf, nswbuf);
+#endif
valloc(buf, struct buf, nbuf);
return v;
}
@@ -481,12 +517,21 @@ setup_buffers(maxaddr)
vm_page_t pg, *last, *last2;
size = MAXBSIZE * nbuf;
+#if defined(UVM)
+ if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size),
+ NULL, UVM_UNKNOWN_OFFSET,
+ UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
+ UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
+ panic("cpu_startup: cannot allocate VM for buffers");
+ addr = (vaddr_t)buffers;
+#else
buffer_map = kmem_suballoc(kernel_map, (vm_offset_t *)&buffers,
maxaddr, size, TRUE);
addr = (vm_offset_t)buffers;
if (vm_map_find(buffer_map, vm_object_allocate(size), (vm_offset_t)0,
&addr, size, FALSE) != KERN_SUCCESS)
panic("startup: cannot allocate buffers");
+#endif
base = bufpages / nbuf;
residual = bufpages % nbuf;
@@ -514,8 +559,13 @@ setup_buffers(maxaddr)
addr = 0;
for (left = bufpages; left > 2 * 1024 * 1024 / CLBYTES;
left -= 2 * 1024 * 1024 / CLBYTES) {
+#if defined(UVM)
+ if (uvm_pglistalloc(2 * 1024 * 1024, 0, 16 * 1024 * 1024,
+ CLBYTES, 0, &pgs, 1, 0)) {
+#else
if (vm_page_alloc_memory(2 * 1024 * 1024, 0, 16 * 1024 * 1024,
CLBYTES, 0, &pgs, 1, 0)) {
+#endif
if (last2) {
TAILQ_INIT(&freepgs);
freepgs.tqh_first = *last2;
@@ -523,7 +573,11 @@ setup_buffers(maxaddr)
(*last2)->pageq.tqe_prev = &freepgs.tqh_first;
pgs.tqh_last = last2;
*last2 = NULL;
+#if defined(UVM)
+ uvm_pglistfree(&freepgs);
+#else
vm_page_free_memory(&freepgs);
+#endif
left += 2 * 1024 * 1024 / CLBYTES;
addr = 16 * 1024 * 1024;
}
@@ -533,8 +587,13 @@ setup_buffers(maxaddr)
last = pgs.tqh_last;
}
if (left > 0)
+#if defined(UVM)
+ if (uvm_pglistalloc(left * CLBYTES, addr, avail_end,
+ CLBYTES, 0, &pgs, 1, 0))
+#else
if (vm_page_alloc_memory(left * CLBYTES, addr, avail_end,
CLBYTES, 0, &pgs, 1, 0))
+#endif
panic("cannot get physical memory for buffer cache");
pg = pgs.tqh_first;
@@ -1580,7 +1639,11 @@ fix_f00f()
void *p;
/* Allocate two new pages */
+#if defined(UVM)
+ va = uvm_km_zalloc(kernel_map, NBPG*2);
+#else
va = kmem_alloc(kernel_map, NBPG*2);
+#endif
p = (void *)(va + NBPG - 7*sizeof(*idt));
/* Copy over old IDT */
@@ -2150,7 +2213,11 @@ bus_mem_add_mapping(bpa, size, cacheable, bshp)
panic("bus_mem_add_mapping: overflow");
#endif
+#if defined(UVM)
+ va = uvm_km_valloc(kernel_map, endpa - pa);
+#else
va = kmem_alloc_pageable(kernel_map, endpa - pa);
+#endif
if (va == 0)
return (ENOMEM);
@@ -2202,7 +2269,11 @@ bus_space_unmap(t, bsh, size)
/*
* Free the kernel virtual mapping.
*/
+#if defined(UVM)
+ uvm_km_free(kernel_map, va, endva - va);
+#else
kmem_free(kernel_map, va, endva - va);
+#endif
break;
default:
@@ -2519,7 +2590,11 @@ _bus_dmamem_free(t, segs, nsegs)
}
}
+#if defined(UVM)
+ uvm_pglistfree(&mlist);
+#else
vm_page_free_memory(&mlist);
+#endif
}
/*
@@ -2540,7 +2615,11 @@ _bus_dmamem_map(t, segs, nsegs, size, kvap, flags)
int curseg;
size = round_page(size);
+#if defined(UVM)
+ va = uvm_km_valloc(kmem_map, size);
+#else
va = kmem_alloc_pageable(kmem_map, size);
+#endif
if (va == 0)
return (ENOMEM);
@@ -2583,7 +2662,11 @@ _bus_dmamem_unmap(t, kva, size)
#endif
size = round_page(size);
+#if defined(UVM)
+ uvm_km_free(kmem_map, (vm_offset_t)kva, size);
+#else
kmem_free(kmem_map, (vm_offset_t)kva, size);
+#endif
}
/*
@@ -2652,8 +2735,13 @@ _bus_dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs,
* Allocate pages from the VM system.
*/
TAILQ_INIT(&mlist);
+#if defined(UVM)
+ error = uvm_pglistalloc(size, low, high,
+ alignment, boundary, &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0);
+#else
error = vm_page_alloc_memory(size, low, high,
alignment, boundary, &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0);
+#endif
if (error)
return (error);
diff --git a/sys/arch/i386/i386/mem.c b/sys/arch/i386/i386/mem.c
index 9704aa82728..c98ddeeb517 100644
--- a/sys/arch/i386/i386/mem.c
+++ b/sys/arch/i386/i386/mem.c
@@ -1,5 +1,5 @@
/* $NetBSD: mem.c,v 1.31 1996/05/03 19:42:19 christos Exp $ */
-/* $OpenBSD: mem.c,v 1.10 1998/11/20 15:57:24 deraadt Exp $ */
+/* $OpenBSD: mem.c,v 1.11 1999/02/26 04:41:13 art Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990, 1993
@@ -57,6 +57,10 @@
#include <vm/vm.h>
+#if defined(UVM)
+#include <uvm/uvm_extern.h>
+#endif
+
extern char *vmmap; /* poor name! */
caddr_t zeropage;
@@ -176,9 +180,15 @@ mmrw(dev, uio, flags)
case 1:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
+#if defined(UVM)
+ if (!uvm_kernacc((caddr_t)v, c,
+ uio->uio_rw == UIO_READ ? B_READ : B_WRITE))
+ return (EFAULT);
+#else
if (!kernacc((caddr_t)v, c,
uio->uio_rw == UIO_READ ? B_READ : B_WRITE))
return (EFAULT);
+#endif
error = uiomove((caddr_t)v, c, uio);
continue;
@@ -239,7 +249,11 @@ mmmmap(dev, off, prot)
/* minor device 1 is kernel memory */
case 1:
/* XXX - writability, executability checks? */
+#if defined(UVM)
+ if (!uvm_kernacc((caddr_t)off, NBPG, B_READ))
+#else
if (!kernacc((caddr_t)off, NBPG, B_READ))
+#endif
return -1;
return i386_btop(vtophys(off));
#ifdef APERTURE
diff --git a/sys/arch/i386/i386/sys_machdep.c b/sys/arch/i386/i386/sys_machdep.c
index 0d0539eea76..4e580beb53c 100644
--- a/sys/arch/i386/i386/sys_machdep.c
+++ b/sys/arch/i386/i386/sys_machdep.c
@@ -59,6 +59,10 @@
#include <vm/vm.h>
#include <vm/vm_kern.h>
+#if defined(UVM)
+#include <uvm/uvm_extern.h>
+#endif
+
#include <machine/cpu.h>
#include <machine/cpufunc.h>
#include <machine/gdt.h>
@@ -152,8 +156,13 @@ i386_user_cleanup(pcb)
pcb->pcb_ldt_sel = GSEL(GLDT_SEL, SEL_KPL);
if (pcb == curpcb)
lldt(pcb->pcb_ldt_sel);
+#if defined(UVM)
+ uvm_km_free(kernel_map, (vaddr_t)pcb->pcb_ldt,
+ (pcb->pcb_ldt_len * sizeof(union descriptor)));
+#else
kmem_free(kernel_map, (vm_offset_t)pcb->pcb_ldt,
(pcb->pcb_ldt_len * sizeof(union descriptor)));
+#endif
pcb->pcb_ldt = 0;
}
@@ -244,7 +253,11 @@ i386_set_ldt(p, args, retval)
while ((ua.start + ua.num) > pcb->pcb_ldt_len)
pcb->pcb_ldt_len *= 2;
new_len = pcb->pcb_ldt_len * sizeof(union descriptor);
+#if defined(UVM)
+ new_ldt = (union descriptor *)uvm_km_alloc(kernel_map, new_len);
+#else
new_ldt = (union descriptor *)kmem_alloc(kernel_map, new_len);
+#endif
bcopy(old_ldt, new_ldt, old_len);
bzero((caddr_t)new_ldt + old_len, new_len - old_len);
pcb->pcb_ldt = new_ldt;
@@ -258,7 +271,11 @@ i386_set_ldt(p, args, retval)
lldt(pcb->pcb_ldt_sel);
if (old_ldt != ldt)
+#if defined(UVM)
+ uvm_km_free(kernel_map, (vaddr_t)old_ldt, old_len);
+#else
kmem_free(kernel_map, (vm_offset_t)old_ldt, old_len);
+#endif
#ifdef DEBUG
printf("i386_set_ldt(%d): new_ldt=%x\n", p->p_pid, new_ldt);
#endif