annotations.h
3.47 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
* Copyright (C) 1996-1998 by the Board of Trustees
* of Leland Stanford Junior University.
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
/*****************************************************************
* annotations.h
*
*
* Author: $Author: blythe $
* Date: $Date: 2002/05/29 01:09:10 $
****************************************************************/
#ifndef ANNOTATIONS_H
#define ANNOTATIONS_H
#include "simtypes.h"
/*****************************************************************
* Annotation Public Declarations
****************************************************************/
typedef struct AnnRec *AnnPtr;
extern AnnPtr *annExcTable;
extern AnnPtr annRFE;
extern AnnPtr annUTLB;
extern int annExcNum, annInstNum;
extern bool annLoads;
extern bool annStores;
extern bool annPCs;
extern bool annWatchpoints;
/*
* Setup routines common to all simulators
*/
void AnnCommonSetup(void);
/*
* Annotation naming
*/
AnnPtr AnnFind(char *typeName, char *argStr);
AnnPtr AnnFindInt(char *typeName, uint64 arg);
/*
* interation. Use as follows:
*
* AnnPtr iter;
* int subtype;
* for (subtype = AnnFirst(type, &iter);
* iter;
* subtype = AnnNext(&iter)) { ...
*
*/
uint64 AnnFirst(char *typeName, AnnPtr *iter);
uint64 AnnNext(AnnPtr *iter);
/*
* return the maximum number of builtin args
*
* allows cpus simulators to make optimizations
* like building tables for exceptions etc.
*
* -1 means infinite number of args
*/
int AnnNumArg(char *typeName);
/*
* Annotation execution
*/
void AnnExec(AnnPtr ann);
/*
* Check for and execute a pre- or post-PC annotation
*/
#define ANN_TAG_SHIFT_SIZE 7
#define ANN_CACHE_SIZE (1 << ANN_TAG_SHIFT_SIZE)
#define ANN_INDEX_MASK (ANN_CACHE_SIZE - 1)
#define ANN_TAG(_pc) ((_pc) >> ANN_TAG_SHIFT_SIZE)
#define ANN_INDEX(_tag) ((_tag) & ANN_INDEX_MASK)
typedef struct AnnCache {
VA postAnnTag;
uint postAnnBitVec;
VA preAnnTag;
uint preAnnBitVec;
} AnnCache;
extern AnnCache annCache[ANN_CACHE_SIZE];
bool RunPCAnnotations(VA pc, VA nPC);
#define RUN_PC_ANNOTATIONS(_pc,_npc) \
if (ANN_TAG(_pc) != annCache[ANN_INDEX(ANN_TAG(_pc))].postAnnTag || \
ANN_TAG(_npc) != annCache[ANN_INDEX(ANN_TAG(_npc))].preAnnTag) { \
RunPCAnnotations(_pc,_npc); \
}
/*****************************************************************
* Fast Memory (FM) Annotation Lookup
*
* This module provides a mechanism for cpu simulators
* to quickly determine if there is a memory annotation
* on a range of addresses.
*
****************************************************************/
#define ANNFM_PC_TYPE 0x0001
#define ANNFM_PRE_PC_TYPE 0x0002
#define ANNFM_LD_TYPE 0x0004
#define ANNFM_ST_TYPE 0x0008
#define ANNFM_ALL_TYPES (ANNFM_PC_TYPE|ANNFM_PRE_PC_TYPE|ANNFM_LD_TYPE|ANNFM_ST_TYPE)
void AnnFMInit(uint rangeSize);
int AnnFMRangeCheck(VA addr, int types);
uint AnnFMRangeVector(VA addr, int types);
AnnPtr AnnFMLookup(VA addr, int type);
void AnnFMExec(VA addr, int type);
int AnnFMTypesExist(int type);
/*****************************************************************
*
* Random Annotations that don't fit anywhere else
*
****************************************************************/
extern uint scacheAnnotation;
extern void ScacheAnnotation(VA _vAddr, PA _pAddr, uint type, uint cpu);
#endif /* ANNOTATIONS_H */