-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResponseRange.cpp
43 lines (32 loc) · 1.05 KB
/
ResponseRange.cpp
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
#include "ResponseRange.h"
ResponseRange::ResponseRange(word32 start, word32 end, byte rw_mask) : ResponseRange::ResponseRange(start, end, rw_mask, 0, 0) {}
ResponseRange::ResponseRange(word32 start, word32 end, byte rw_mask, ResponseRange::ReadCallback read_callback, ResponseRange::WriteCallback write_callback) {
this->_Start = start & 0xFFFFFF;
this->_End = end & 0xFFFFFF;
this->_RWMask = rw_mask & RW_VALID_MASKS;
this->_ReadCallback = read_callback;
this->_WriteCallback = write_callback;
}
bool ResponseRange::RespondsToAddress(word32 address, bool write) {
return (
(
((!write) && ((this->_RWMask & RW_MASK_R) != 0)) ||
((write) && ((this->_RWMask & RW_MASK_W) != 0))
) && (
this->_Start <= address &&
this->_End >= address
)
);
}
word32 ResponseRange::Start() {
return this->_Start;
}
word32 ResponseRange::End() {
return this->_End;
}
ResponseRange::ReadCallback ResponseRange::GetReadCallback() {
return this->_ReadCallback;
}
ResponseRange::WriteCallback ResponseRange::GetWriteCallback() {
return this->_WriteCallback;
}