mmu.c
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* 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;
}