mmu.c 1.36 KB
/*
 * Copyright (C) 1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * Copyright (C) 1998 Digital Equipment Corporation
 *
 * This file is part of the SimOS distribution.
 * See LICENSE file for terms of the license.
 *
 */




#include <malloc.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <standards.h>

#include "sim_error.h"
#include "gamma.h"
#include "thread.h"
#include "globals.h"
#include "sim.h"
#include "mmu.h"


extern void fatal __ ((char *,...));
extern void warning __ ((char *,...));
static ulong map_shared (thread_ptr, long);
extern void wakeup_thr (thread_ptr pthread);
extern void sleep_thr (thread_ptr pthread);
extern void aint_cvt_fp_mem (int opnum, double fpreg, long *memloc);
ulong tlb_miss (thread_ptr pthread, long addr,
		long vpage, long tbkey, long tbtag, int mmap);

MMUStatus
TranslateVirtual (AlphaState * P, VA addr, MA *mAddr)
{
   thread_ptr pthread = P->aintThread;
    long vpage, tbkey, tbtag;
    struct page_table_entry *pg;

    vpage = TB_VPAGE (addr);
    tbkey = TB_KEY (vpage);
    tbtag = TB_TAG (vpage);

    pg = pthread->page_bucket[tbkey];
    if (pg) {
	    if (pg->lookaside->tag == tbtag) {
		*mAddr =((ulong) pg->lookaside->page + TB_OFFSET (addr));
		return MMU_SUCCESS;
	    }
    }
    *mAddr =  (tlb_miss (pthread, addr, vpage, tbkey, tbtag, 0));
    return MMU_SUCCESS;
}