dumbvm -...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <types.h> #include <kern/errno.h> #include <lib.h> #include <thread.h> #include <curthread.h> #include <addrspace.h> #include <vm.h> #include <machine/spl.h> #include <machine/tlb.h> /* * Dumb MIPS-only "VM system" that is intended to only be just barely * enough to struggle off the ground. You should replace all of this * code while doing the VM assignment. In fact, starting in that * assignment, this file is not included in your kernel! */ /* under dumbvm, always have 48k of user stack */ #define DUMBVM_STACKPAGES 12 void vm_bootstrap(void) { } static paddr_t getppages(unsigned long npages) { int spl; paddr_t addr; spl = splhigh(); addr = ram_stealmem(npages); splx(spl); return addr; } /* Allocate/free some kernel-space virtual pages */ vaddr_t alloc_kpages(int npages) { paddr_t pa; pa = getppages(npages); if (pa==0) { return 0; } return PADDR_TO_KVADDR(pa); } void free_kpages(vaddr_t addr) { /* nothing */ (void)addr;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
} int vm_fault(int faulttype, vaddr_t faultaddress) { vaddr_t vbase1, vtop1, vbase2, vtop2, stackbase, stacktop; paddr_t paddr; int i; u_int32_t ehi, elo; struct addrspace *as; int spl; spl = splhigh(); faultaddress &= PAGE_FRAME; DEBUG(DB_VM, "dumbvm: fault: 0x%x\n", faultaddress); switch (faulttype) { case VM_FAULT_READONLY: /* We always create pages read-write, so we can't get this */ panic("dumbvm: got VM_FAULT_READONLY\n"); case VM_FAULT_READ: case VM_FAULT_WRITE: break; default: splx(spl); return EINVAL;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 6

dumbvm -...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online