Skip to content
Snippets Groups Projects
Commit bbcfaf03 authored by Oscar Widjaja's avatar Oscar Widjaja
Browse files

a3.7: unfinished code, stub for putppages

commit to save work in progress
only up to first task in a3.7

have not implemented bitmap
parent 967942a1
No related branches found
No related tags found
No related merge requests found
#include "opt-A3.h"
/*
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
* The President and Fellows of Harvard College.
......@@ -67,6 +68,11 @@
*/
#define PADDR_TO_KVADDR(paddr) ((paddr)+MIPS_KSEG0)
#if OPT_A3
// opposite of PADDR_TO_KVADDR, for use in freekpages(kvaddr) into putppages(paddr)
#define KVADDR_TO_PADDR(kvaddr) ((kvaddr)-MIPS_KSEG0)
#endif
/*
* The top of user space. (Actually, the address immediately above the
* last valid user address.)
......
......@@ -39,8 +39,10 @@
#include <addrspace.h>
#include <vm.h>
#if OPT_A3 // 6: for ability to call sys__exit() directly
#include <syscall.h>
#if OPT_A3 // 6
#include <syscall.h> // for ability to call sys__exit() directly
#define ALLOC_POISON -1
#endif
/*
......@@ -59,7 +61,15 @@ static struct spinlock stealmem_lock = SPINLOCK_INITIALIZER;
void
vm_bootstrap(void)
{
#if OPT_A3
kprintf("[a3] in vm_bootstrap\n");
paddr_t lo, hi;
ram_getsize(&lo, &hi);
kprintf("[a3] lo=%d, hi=%d\n", lo, hi);
#else
/* Do nothing. */
#endif
}
static
......@@ -88,6 +98,18 @@ alloc_kpages(int npages)
return PADDR_TO_KVADDR(pa);
}
#if OPT_A3 // 7: physical page allocater, to handle memory once proc terminates
static void
putppages(paddr_t paddr){
(void) paddr;
}
void
free_kpages(vaddr_t addr){
putppages(KVADDR_TO_PADDR(addr));
}
#else
void
free_kpages(vaddr_t addr)
{
......@@ -95,6 +117,7 @@ free_kpages(vaddr_t addr)
(void)addr;
}
#endif
void
vm_tlbshootdown_all(void)
......@@ -243,7 +266,7 @@ vm_fault(int faulttype, vaddr_t faultaddress)
continue;
}
ehi = faultaddress;
elo = paddr | TLBLO_DIRTY | TLBLO_VALID;
elo = paddr | TLBLO_DIRTY | TLBLO_VALIDall;
DEBUG(DB_VM, "dumbvm: 0x%x -> 0x%x\n", faultaddress, paddr);
tlb_write(ehi, elo, i);
splx(spl);
......@@ -281,6 +304,12 @@ as_create(void)
void
as_destroy(struct addrspace *as)
{
#if OPT_A3
putppages(as->as_pbase1);
putppages(as->as_pbase2);
putppages(as->as_stackpbase);
#endif
kfree(as);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment