protos.h
2.07 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* 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.
*
*/
#ifndef _PROTOS_H_
#define _PROTOS_H_
/*
* Prototype declarations and inlined functions used in several source files
*/
#include <malloc.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <standards.h>
#include "globals.h"
#include "sim.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);
/*
* A direct mapped TLB of size TB_SIZE is being simulated here. So, the TLB
* lookup is very fast. If we miss in the TLB, a tlb_miss handler is
* invoked.
*/
#ifdef __GNUC__
inline
#else
# pragma inline(addr2phys)
#endif
ulong static
addr2phys (thread_ptr pthread, long addr)
{
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) {
return ((ulong) pg->lookaside->page + TB_OFFSET (addr));
}
}
return (tlb_miss (pthread, addr, vpage, tbkey, tbtag, 0));
}
#ifdef SOLO
#ifdef __GNUC__
inline
#else
# pragma inline(text_addr2phys)
#endif
ulong static
text_addr2phys (thread_ptr pthread, long addr)
{
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) {
return ((ulong) pg->lookaside->page + TB_OFFSET (addr));
}
}
return (text_tlb_miss (pthread, addr, vpage, tbkey, tbtag, 0));
}
#endif
#endif /* _PROTOS_H */