addrspace - #include #include #include #include #include...

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> #define DUMBVM_STACKPAGES 12 /* Inner Page */ struct page { paddr_t pa; vaddr_t va; unsigned frame : 28; // This gives us the offset unsigned dirty : 1; unsigned swap : 1; unsigned kpage : 1; unsigned inuse : 1; } __attribute__((__packed__)); 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); } int vm_fault(int faulttype, vaddr_t faultaddress) { vaddr_t vbase1, vtop1, vbase2, vtop2, stackbase, stacktop; paddr_t paddr; int i;
Background image of page 1

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

View Full DocumentRight Arrow Icon
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; } as = curthread->t_vmspace; if (as == NULL) { /* * No address space set up. This is probably a kernel * fault early in boot. Return EFAULT so as to panic * instead of getting into an infinite faulting loop.
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.

This note was uploaded on 11/10/2009 for the course CS 536 taught by Professor Lums during the Spring '09 term at Indiana.

Page1 / 6

addrspace - #include #include #include #include #include...

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