-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathram_device.cpp
More file actions
38 lines (26 loc) · 824 Bytes
/
ram_device.cpp
File metadata and controls
38 lines (26 loc) · 824 Bytes
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
#include <stdlib.h>
#include "ram_device.h"
RAMDevice::RAMDevice(word32 base, word32 size) {
this->_StorageArea = (byte*)malloc(size);
this->AddResponseRange(base, base + size - 1, RW_MASK_R | RW_MASK_W);
this->_InitOk = this->_StorageArea != NULL;
}
RAMDevice::~RAMDevice() {
if(this->_InitOk)
free(this->_StorageArea);
}
bool RAMDevice::_InternalReadByte(word32 address, word32 timestamp, word32 emulFlags, ResponseRange* range, byte &b) {
b = this->_InitOk ?
this->_StorageArea[address - range->Start()] :
0xFF;
return true;
}
bool RAMDevice::_InternalWriteByte(word32 address, word32 timestamp, ResponseRange* range, byte b) {
if(this->_InitOk)
this->_StorageArea[address - range->Start()] = b;
return true;
}
bool RAMDevice::Refresh(word32 timestamp) {
//Nothing to refresh
return false;
}