-
Notifications
You must be signed in to change notification settings - Fork 8
/
tlbprotocol.go
211 lines (177 loc) · 4.59 KB
/
tlbprotocol.go
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package tlb
import (
"github.com/sarchlab/akita/v3/mem/vm"
"github.com/sarchlab/akita/v3/sim"
)
// A FlushReq asks the TLB to invalidate certain entries. It will also not block all incoming and outgoing ports
type FlushReq struct {
sim.MsgMeta
VAddr []uint64
PID vm.PID
}
// Meta returns the meta data associated with the message.
func (r *FlushReq) Meta() *sim.MsgMeta {
return &r.MsgMeta
}
// FlushReqBuilder can build AT flush requests
type FlushReqBuilder struct {
sendTime sim.VTimeInSec
src, dst sim.Port
vAddrs []uint64
pid vm.PID
}
// WithSendTime sets the send time of the request to build.:w
func (b FlushReqBuilder) WithSendTime(
t sim.VTimeInSec,
) FlushReqBuilder {
b.sendTime = t
return b
}
// WithSrc sets the source of the request to build.
func (b FlushReqBuilder) WithSrc(src sim.Port) FlushReqBuilder {
b.src = src
return b
}
// WithDst sets the destination of the request to build.
func (b FlushReqBuilder) WithDst(dst sim.Port) FlushReqBuilder {
b.dst = dst
return b
}
// WithVAddrs sets the Vaddr of the pages to be flushed
func (b FlushReqBuilder) WithVAddrs(vAddrs []uint64) FlushReqBuilder {
b.vAddrs = vAddrs
return b
}
// WithPID sets the pid whose entries are to be flushed
func (b FlushReqBuilder) WithPID(pid vm.PID) FlushReqBuilder {
b.pid = pid
return b
}
// Build creates a new TLBFlushReq
func (b FlushReqBuilder) Build() *FlushReq {
r := &FlushReq{}
r.ID = sim.GetIDGenerator().Generate()
r.Src = b.src
r.Dst = b.dst
r.SendTime = b.sendTime
r.VAddr = b.vAddrs
r.PID = b.pid
return r
}
// A FlushRsp is a response from AT indicating flush is complete
type FlushRsp struct {
sim.MsgMeta
}
// Meta returns the meta data associated with the message.
func (r *FlushRsp) Meta() *sim.MsgMeta {
return &r.MsgMeta
}
// FlushRspBuilder can build AT flush rsp
type FlushRspBuilder struct {
sendTime sim.VTimeInSec
src, dst sim.Port
}
// WithSendTime sets the send time of the request to build.:w
func (b FlushRspBuilder) WithSendTime(
t sim.VTimeInSec,
) FlushRspBuilder {
b.sendTime = t
return b
}
// WithSrc sets the source of the request to build.
func (b FlushRspBuilder) WithSrc(src sim.Port) FlushRspBuilder {
b.src = src
return b
}
// WithDst sets the destination of the request to build.
func (b FlushRspBuilder) WithDst(dst sim.Port) FlushRspBuilder {
b.dst = dst
return b
}
// Build creates a new TLBFlushRsps.
func (b FlushRspBuilder) Build() *FlushRsp {
r := &FlushRsp{}
r.ID = sim.GetIDGenerator().Generate()
r.Src = b.src
r.Dst = b.dst
r.SendTime = b.sendTime
return r
}
// A RestartReq is a request to TLB to start accepting requests and resume operations
type RestartReq struct {
sim.MsgMeta
}
// Meta returns the meta data associated with the message.
func (r *RestartReq) Meta() *sim.MsgMeta {
return &r.MsgMeta
}
// RestartReqBuilder can build TLB restart requests.
type RestartReqBuilder struct {
sendTime sim.VTimeInSec
src, dst sim.Port
}
// WithSendTime sets the send time of the request to build.
func (b RestartReqBuilder) WithSendTime(
t sim.VTimeInSec,
) RestartReqBuilder {
b.sendTime = t
return b
}
// WithSrc sets the source of the request to build.
func (b RestartReqBuilder) WithSrc(src sim.Port) RestartReqBuilder {
b.src = src
return b
}
// WithDst sets the destination of the request to build.
func (b RestartReqBuilder) WithDst(dst sim.Port) RestartReqBuilder {
b.dst = dst
return b
}
// Build creates a new TLBRestartReq.
func (b RestartReqBuilder) Build() *RestartReq {
r := &RestartReq{}
r.ID = sim.GetIDGenerator().Generate()
r.Src = b.src
r.Dst = b.dst
r.SendTime = b.sendTime
return r
}
// A RestartRsp is a response from AT indicating it has resumed working
type RestartRsp struct {
sim.MsgMeta
}
// Meta returns the meta data associated with the message.
func (r *RestartRsp) Meta() *sim.MsgMeta {
return &r.MsgMeta
}
// RestartRspBuilder can build AT flush rsp
type RestartRspBuilder struct {
sendTime sim.VTimeInSec
src, dst sim.Port
}
// WithSendTime sets the send time of the request to build.:w
func (b RestartRspBuilder) WithSendTime(
t sim.VTimeInSec,
) RestartRspBuilder {
b.sendTime = t
return b
}
// WithSrc sets the source of the request to build.
func (b RestartRspBuilder) WithSrc(src sim.Port) RestartRspBuilder {
b.src = src
return b
}
// WithDst sets the destination of the request to build.
func (b RestartRspBuilder) WithDst(dst sim.Port) RestartRspBuilder {
b.dst = dst
return b
}
// Build creates a new TLBRestartRsp
func (b RestartRspBuilder) Build() *RestartRsp {
r := &RestartRsp{}
r.ID = sim.GetIDGenerator().Generate()
r.Src = b.src
r.Dst = b.dst
r.SendTime = b.sendTime
return r
}