2018-08-13 13:41:23 +00:00
|
|
|
#include <stdint.h>
|
2014-10-18 11:33:48 +00:00
|
|
|
#include "memory.h"
|
|
|
|
|
|
|
|
void Memory::put (Device &dev, address b) {
|
2014-10-21 18:41:44 +00:00
|
|
|
Device **d = _pages + b/page_size;
|
2014-10-18 11:33:48 +00:00
|
|
|
|
2014-10-21 18:41:44 +00:00
|
|
|
int size = dev.pages();
|
|
|
|
while (size--)
|
|
|
|
*d++ = &dev;
|
2014-10-18 11:33:48 +00:00
|
|
|
|
2014-10-21 18:41:44 +00:00
|
|
|
dev.base(b);
|
2014-10-18 11:33:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class NullDevice: public Memory::Device {
|
2014-10-21 18:41:44 +00:00
|
|
|
public:
|
|
|
|
NullDevice(): Memory::Device(65536) {}
|
2018-08-13 13:41:23 +00:00
|
|
|
void operator= (uint8_t b) {}
|
|
|
|
operator uint8_t() { return 0; }
|
2014-10-18 11:33:48 +00:00
|
|
|
} nd;
|
|
|
|
|
2014-10-31 08:44:57 +00:00
|
|
|
void Memory::begin() {
|
2014-10-21 18:41:44 +00:00
|
|
|
put(nd, 0);
|
2014-10-31 17:44:37 +00:00
|
|
|
nd._pages = 1; // hack for checkpointing
|
2014-10-18 11:33:48 +00:00
|
|
|
}
|