Add UVM support to amiga

This commit is contained in:
mhitch 1998-07-10 20:23:24 +00:00
parent 6e2d9eae80
commit dc9188e3e1
7 changed files with 223 additions and 47 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.5 1998/01/06 08:46:11 thorpej Exp $
# $NetBSD: genassym.cf,v 1.6 1998/07/10 20:23:46 mhitch Exp $
#
# Copyright (c) 1982, 1990, 1993
@ -45,6 +45,10 @@ include <sys/user.h>
include <vm/vm.h>
ifdef UVM
include <uvm/uvm_extern.h>
endif
include <machine/cpu.h>
include <machine/psl.h>
include <machine/reg.h>
@ -106,7 +110,11 @@ define MD_REGS offsetof(struct mdproc, md_regs)
define SRUN SRUN
# interrupt/fault metering
ifdef UVM
define UVMEXP_INTRS offsetof(struct uvmexp, intrs)
else
define V_INTR offsetof(struct vmmeter, v_intr)
endif
# general constants
define UPAGES UPAGES

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.97 1998/05/24 19:32:36 is Exp $ */
/* $NetBSD: locore.s,v 1.98 1998/07/10 20:24:05 mhitch Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -46,6 +46,8 @@
* Other contributors: Bryan Ford (kernel reload stuff)
*/
#include "opt_uvm.h"
#include "assym.h"
#include <machine/asm.h>
#include <machine/trap.h>
@ -463,7 +465,11 @@ _trace:
_spurintr:
addql #1,_intrcnt+0
addql #1,_cnt+V_INTR
#if defined(UVM)
addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS
#else
addql #1,_C_LABEL(cnt)+V_INTR
#endif
jra rei
_lev5intr:
@ -477,7 +483,11 @@ _lev5intr:
#endif
moveml sp@+,d0/d1/a0/a1
addql #1,_intrcnt+20
addql #1,_cnt+V_INTR
#if defined(UVM)
addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS
#else
addql #1,_C_LABEL(cnt)+V_INTR
#endif
jra rei
#ifdef DRACO
@ -505,7 +515,11 @@ _DraCoLev2intr:
Ldraciaend:
moveml sp@+,d0/d1/a0/d1
addql #1,_cnt+V_INTR
#if defined(UVM)
addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS
#else
addql #1,_C_LABEL(cnt)+V_INTR
#endif
jra rei
/* XXX on the DraCo rev. 4 or later, lev 1 is vectored here. */
@ -539,7 +553,11 @@ Ldrclockretry:
clrb a0@(9) | reset timer irq
moveml sp@+,d0/d1/a0/a1
addql #1,_cnt+V_INTR
#if defined(UVM)
addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS
#else
addql #1,_C_LABEL(cnt)+V_INTR
#endif
jra rei
/* XXX on the DraCo, lev 1, 3, 4, 5 and 6 are vectored here by initcpu() */
@ -556,7 +574,11 @@ Ldrintrcommon:
jbsr _intrhand | handle interrupt
addql #4,sp | pop SR
moveml sp@+,d0/d1/a0/a1
addql #1,_cnt+V_INTR
#if defined(UVM)
addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS
#else
addql #1,_C_LABEL(cnt)+V_INTR
#endif
jra rei
#endif
@ -578,7 +600,11 @@ Lintrcommon:
jbsr _intrhand | handle interrupt
addql #4,sp | pop SR
moveml sp@+,d0/d1/a0/a1
addql #1,_cnt+V_INTR
#if defined(UVM)
addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS
#else
addql #1,_C_LABEL(cnt)+V_INTR
#endif
jra rei
/* XXX used to be ifndef DRACO; vector will be overwritten by initcpu() */
@ -652,7 +678,11 @@ Lskipciab:
| other ciab interrupts?
Llev6done:
moveml sp@+,d0/d1/a0/a1 | restore scratch regs
addql #1,_cnt+V_INTR | chalk up another interrupt
#if defined(UVM)
addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS
#else
addql #1,_C_LABEL(cnt)+V_INTR | chalk up another interrupt
#endif
jra rei | all done [can we do rte here?]
Lchkexter:
| check to see if EXTER request is really set?
@ -1095,7 +1125,7 @@ ENTRY(qsetjmp)
moveq #0,d0 | return 0
rts
.globl _whichqs,_qs,_cnt,_panic
.globl _whichqs,_qs,_panic
.globl _curproc
.comm _want_resched,4
@ -1133,7 +1163,11 @@ ENTRY(switch_exit)
movl #USPACE,sp@- | size of u-area
movl a0@(P_ADDR),sp@- | address u-area of process
movl _kernel_map,sp@- | map it was allocated in
jbsr _kmem_free | deallocate it
#if defined(UVM)
jbsr _C_LABEL(uvm_km_free) | deallocate it
#else
jbsr _C_LABEL(kmem_free) | deallocate it
#endif
lea sp@(12),sp | pop args
jra _cpu_switch

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.120 1998/07/05 08:49:37 jonathan Exp $ */
/* $NetBSD: machdep.c,v 1.121 1998/07/10 20:24:33 mhitch Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -48,6 +48,7 @@
#include "opt_iso.h"
#include "opt_ns.h"
#include "opt_compat_netbsd.h"
#include <opt_uvm.h>
#include <sys/param.h>
#include <sys/systm.h>
@ -91,6 +92,10 @@
#include <vm/vm_kern.h>
#include <vm/vm_page.h>
#if defined(UVM)
#include <uvm/uvm_extern.h>
#endif
#include <sys/sysctl.h>
#include <machine/db_machdep.h>
@ -164,6 +169,12 @@ void fdintr __P((int));
*/
u_int16_t amiga_serialspl = PSL_S|PSL_IPL4;
#if defined(UVM)
vm_map_t exec_map = NULL;
vm_map_t mb_map = NULL;
vm_map_t phys_map = NULL;
#endif
/*
* Declare these as initialized data so we can patch them.
*/
@ -344,14 +355,21 @@ again:
if (nswbuf > 256)
nswbuf = 256; /* sanity */
}
#if !defined(UVM)
valloc(swbuf, struct buf, nswbuf);
#endif
valloc(buf, struct buf, nbuf);
/*
* End of first pass, size has been calculated so allocate memory
*/
if (firstaddr == 0) {
size = (vm_size_t)(v - firstaddr);
#if defined(UVM)
firstaddr = (caddr_t)uvm_km_zalloc(kernel_map,
round_page(size));
#else
firstaddr = (caddr_t) kmem_alloc(kernel_map, round_page(size));
#endif
if (firstaddr == 0)
panic("startup: no room for tables");
goto again;
@ -367,12 +385,21 @@ again:
* in that they usually occupy more virtual memory than physical.
*/
size = MAXBSIZE * nbuf;
#if defined(UVM)
if (uvm_map(kernel_map, (vm_offset_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("startup: cannot allocate VM for buffers");
minaddr = (vm_offset_t) buffers;
#else
buffer_map = kmem_suballoc(kernel_map, (vm_offset_t *)&buffers,
&maxaddr, size, TRUE);
minaddr = (vm_offset_t)buffers;
if (vm_map_find(buffer_map, vm_object_allocate(size), (vm_offset_t)0,
&minaddr, size, FALSE) != KERN_SUCCESS)
panic("startup: cannot allocate buffers");
#endif
if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
/* don't want to alloc more physical mem than needed */
bufpages = btoc(MAXBSIZE) * nbuf;
@ -380,6 +407,35 @@ again:
base = bufpages / nbuf;
residual = bufpages % nbuf;
for (i = 0; i < nbuf; i++) {
#if defined(UVM)
vm_size_t curbufsize;
vm_offset_t curbuf;
struct vm_page *pg;
/*
* Each buffer has MAXBSIZE bytes of VM space allocated. Of
* that MAXBSIZE space, we allocate and map (base+1) pages
* for the first "residual" buffers, and then we allocate
* "base" pages for the rest.
*/
curbuf = (vm_offset_t) buffers + (i * MAXBSIZE);
curbufsize = CLBYTES * ((i < residual) ? (base+1) : base);
while (curbufsize) {
pg = uvm_pagealloc(NULL, 0, NULL);
if (pg == NULL)
panic("cpu_startup: not enough memory for "
"buffer cache");
#if defined(PMAP_NEW)
pmap_kenter_pgs(curbuf, &pg, 1);
#else
pmap_enter(kernel_map->pmap, curbuf,
VM_PAGE_TO_PHYS(pg), VM_PROT_ALL, TRUE);
#endif
curbuf += PAGE_SIZE;
curbufsize -= PAGE_SIZE;
}
#else /* ! UVM */
vm_size_t curbufsize;
vm_offset_t curbuf;
@ -394,26 +450,42 @@ again:
curbufsize = CLBYTES * (i < residual ? base+1 : base);
vm_map_pageable(buffer_map, curbuf, curbuf+curbufsize, FALSE);
vm_map_simplify(buffer_map, curbuf);
#endif /* UVM */
}
/*
* 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 cluster submap.
*/
#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
@ -425,8 +497,13 @@ again:
#ifdef DEBUG
pmapdebug = opmapdebug;
#endif
#if defined(UVM)
printf("avail mem = %ld (%ld pages)\n", ptoa(uvmexp.free),
ptoa(uvmexp.free)/NBPG);
#else
printf("avail mem = %ld (%ld pages)\n", ptoa(cnt.v_free_count),
ptoa(cnt.v_free_count)/NBPG);
#endif
printf("using %d buffers containing %d bytes of memory\n",
nbuf, bufpages * CLBYTES);
@ -634,38 +711,8 @@ void
bootsync(void)
{
if (waittime < 0) {
register struct buf *bp;
int iter, nbusy;
waittime = 0;
(void) spl0();
printf("syncing disks... ");
/*
* Release vnodes held by texts before sync.
*/
if (panicstr == 0)
vnode_pager_umount(NULL);
sys_sync(&proc0, (void *)NULL, (int *)NULL);
/*
* unmount filesystems
*/
if (panicstr == 0)
vfs_unmountall();
for (iter = 0; iter < 20; iter++) {
nbusy = 0;
for (bp = &buf[nbuf]; --bp >= buf; )
if ((bp->b_flags & (B_BUSY|B_INVAL)) == B_BUSY)
nbusy++;
if (nbusy == 0)
break;
printf("%d ", nbusy);
delay(40000 * iter);
}
if (nbusy)
printf("giving up\n");
else
printf("done\n");
vfs_shutdown();
/*
* If we've been adjusting the clock, the todr
* will be out of synch; adjust it now.
@ -1568,14 +1615,22 @@ intrhand(sr)
#ifdef REALLYDEBUG
printf("calling netintr\n");
#endif
#if defined(UVM)
uvmexp.softs++;
#else
cnt.v_soft++;
#endif
netintr();
}
if (ssir_active & SIR_CLOCK) {
#ifdef REALLYDEBUG
printf("calling softclock\n");
#endif
#if defined(UVM)
uvmexp.softs++;
#else
cnt.v_soft++;
#endif
/* XXXX softclock(&frame.f_stackadj); */
softclock();
}
@ -1583,7 +1638,11 @@ intrhand(sr)
#ifdef REALLYDEBUG
printf("calling softcallbacks\n");
#endif
#if defined(UVM)
uvmexp.softs++;
#else
cnt.v_soft++;
#endif
call_sicallbacks();
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.19 1998/05/07 21:01:41 kleink Exp $ */
/* $NetBSD: mem.c,v 1.20 1998/07/10 20:24:34 mhitch Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -44,6 +44,8 @@
* Memory special file
*/
#include "opt_uvm.h"
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/buf.h>
@ -55,6 +57,9 @@
#include <machine/cpu.h>
#include <vm/vm.h>
#if defined(UVM)
#include <uvm/uvm_extern.h>
#endif
extern int kernel_reload_write(struct uio *uio);
extern u_int lowram;
@ -147,9 +152,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
if (v < NBPG) {
#ifdef DEBUG
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.63 1998/07/04 22:18:15 jonathan Exp $ */
/* $NetBSD: trap.c,v 1.64 1998/07/10 20:24:34 mhitch Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -44,6 +44,7 @@
#include "opt_ddb.h"
#include "opt_ktrace.h"
#include "opt_uvm.h"
#include "opt_compat_sunos.h"
#include <sys/param.h>
@ -63,6 +64,10 @@
#include <sys/user.h>
#include <vm/pmap.h>
#if defined(UVM)
#include <uvm/uvm_extern.h>
#endif
#include <machine/psl.h>
#include <machine/trap.h>
#include <machine/cpu.h>
@ -402,7 +407,11 @@ trapmmufault(type, code, v, fp, p, sticks)
printf("vm_fault(%p,%lx,%d,0)\n", map, va, ftype);
#endif
#if defined(UVM)
rv = uvm_fault(map, va, 0, ftype);
#else
rv = vm_fault(map, va, ftype, FALSE);
#endif
#ifdef DEBUG
if (mmudebug)
@ -511,8 +520,13 @@ nogo:
trapcpfault(p, fp);
return;
}
#if defined(UVM)
printf("uvm_fault(%p, 0x%lx, 0, 0x%x) -> 0x%x\n",
map, va, ftype, rv);
#else
printf("vm_fault(%p, %lx, %x, 0) -> %x\n",
map, va, ftype, rv);
#endif
printf(" type %x, code [mmu,,ssw]: %x\n",
type, code);
panictrap(type, code, v, fp);
@ -541,7 +555,11 @@ trap(type, code, v, frame)
p = curproc;
ucode = 0;
#if defined(UVM)
uvmexp.traps++;
#else
cnt.v_trap++;
#endif
if (USERMODE(frame.f_sr)) {
type |= T_USER;
@ -753,7 +771,11 @@ syscall(code, frame)
register_t args[8], rval[2];
u_quad_t sticks;
#if defined(UVM)
uvmexp.syscalls++;
#else
cnt.v_syscall++;
#endif
if (!USERMODE(frame.f_sr))
panic("syscall");
p = curproc;
@ -953,9 +975,15 @@ _write_back (wb, wb_sts, wb_data, wb_addr, wb_map)
if (mmudebug)
printf("wb3: need to bring in first page\n");
#endif
#if defined(UVM)
wb_rc = uvm_fault(wb_map,
trunc_page((vm_offset_t)wb_addr),
0, VM_PROT_READ | VM_PROT_WRITE);
#else
wb_rc = vm_fault(wb_map,
trunc_page((vm_offset_t)wb_addr),
VM_PROT_READ | VM_PROT_WRITE, FALSE);
#endif
if(wb_rc != KERN_SUCCESS)
return (wb_rc);
@ -986,9 +1014,15 @@ _write_back (wb, wb_sts, wb_data, wb_addr, wb_map)
" Bringing in extra page.\n",wb);
#endif
#if defined(UVM)
wb_rc = uvm_fault(wb_map,
trunc_page((vm_offset_t)wb_addr + wb_extra_page),
0, VM_PROT_READ | VM_PROT_WRITE);
#else
wb_rc = vm_fault(wb_map,
trunc_page((vm_offset_t)wb_addr + wb_extra_page),
VM_PROT_READ | VM_PROT_WRITE,FALSE);
#endif
if(wb_rc != KERN_SUCCESS)
return (wb_rc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.35 1998/04/17 17:39:23 veego Exp $ */
/* $NetBSD: vm_machdep.c,v 1.36 1998/07/10 20:24:35 mhitch Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -42,6 +42,8 @@
* @(#)vm_machdep.c 7.10 (Berkeley) 5/7/91
*/
#include "opt_uvm.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
@ -57,6 +59,11 @@
#include <vm/vm.h>
#include <sys/user.h>
#include <vm/vm_kern.h>
#if defined(UVM)
#include <uvm/uvm_extern.h>
#endif
#include <machine/pte.h>
/* XXX - Put this in some header file? */
@ -137,10 +144,18 @@ void
cpu_exit(p)
struct proc *p;
{
#if defined(UVM)
uvmspace_free(p->p_vmspace);
#else
vmspace_free(p->p_vmspace);
#endif
(void)splhigh();
#if defined(UVM)
uvmexp.swtch++;
#else
cnt.v_swtch++;
#endif
switch_exit(p);
/* NOTREACHED */
}
@ -355,7 +370,11 @@ vmapbuf(bp, len)
uva = m68k_trunc_page(bp->b_saveaddr = bp->b_data);
off = (vm_offset_t)bp->b_data - uva;
len = m68k_round_page(off + len);
#if defined(UVM)
kva = uvm_km_valloc_wait(phys_map, len);
#else
kva = kmem_alloc_wait(phys_map, len);
#endif
bp->b_data = (caddr_t)(kva + off);
upmap = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map);
@ -393,7 +412,11 @@ vunmapbuf(bp, len)
* pmap_remove() is unnecessary here, as kmem_free_wakeup()
* will do it for us.
*/
#if defined(UVM)
uvm_km_free_wakeup(phys_map, kva, len);
#else
kmem_free_wakeup(phys_map, kva, len);
#endif
bp->b_data = bp->b_saveaddr;
bp->b_saveaddr = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: grf_cc.c,v 1.24 1998/01/12 10:39:30 thorpej Exp $ */
/* $NetBSD: grf_cc.c,v 1.25 1998/07/10 20:23:24 mhitch Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@ -36,6 +36,8 @@
* view.c
*/
#include "opt_uvm.h"
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/errno.h>
@ -58,6 +60,11 @@
#include <sys/conf.h>
#include <machine/conf.h>
#if defined(UVM)
#include <vm/vm.h>
#include <uvm/uvm_extern.h>
#endif
#include "view.h"
int grfccmatch __P((struct device *, struct cfdata *, void *));